===== Compile Driver for Android (Raspberry Pi) ===== The following instructions cover the driver compiling process for RED bean on devices running Linux. We recommend using Debian or Ubuntu. It also might be possible to compile on OSX. Compiling directly on a Windows platform is not supported. However, if all you have available is a windows machine then we would recommend to set up a linux based virtual machine. ---- === Android Nougat === 1. Prepare build environment by official [[https://source.android.com/setup/build/initializing|Android guide]] sudo apt-get update sudo apt-get install openjdk-8-jdk sudo apt-get install dosfstools genisoimage bc libssl-dev python2.7 python-mako git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip 2. Install Repo: mkdir ~/bin PATH=~/bin:$PATH curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo 3. Checkout Android Sources mkdir android-raspberry; cd android-raspberry repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.2_r36 git clone https://github.com/android-rpi/local_manifests .repo/local_manifests repo sync -j$(nproc) 4. Setup environment variables sudo ln -s /sbin/mkdosfs /home/${USER}/bin/ source build/envsetup.sh lunch rpi3-eng 5. Build Kernel cd kernel/rpi ARCH=arm scripts/kconfig/merge_config.sh arch/arm/configs/bcm2709_defconfig android/configs/android-base.cfg android/configs/android-recommended.cfg PATH=$ANDROID_BUILD_PATHS$PATH ARCH=arm CROSS_COMPILE=arm-linux-androideabi- make zImage dtbs -j$(nproc) 6. Get the latest qcacld-2.0 sources from 8devices: cd ~ git clone https://github.com/8devices/qcacld-2.0.git -b caf-wlan/LNX.LEH.4.2.2.2 cd qcacld-2.0 7. Build qcacld-driver module PATH=$ANDROID_BUILD_PATHS$PATH KERNEL_SRC=$ANDROID_BUILD_TOP/kernel/rpi/ ARCH=arm CROSS_COMPILE=arm-linux-androideabi- make wlan-sdio -j$(nproc) 8. Include driver into Android build system mkdir $ANDROID_BUILD_TOP/device/brcm/rpi3/firmware/qcacld-2.0 ln -s $PWD/firmware/{usb,sdio} $ANDROID_BUILD_TOP/device/brcm/rpi3/firmware/qcacld-2.0 ln -s $PWD/wlan-{usb,sdio}.ko $ANDROID_BUILD_TOP/device/brcm/rpi3/firmware/qcacld-2.0 9. Patch for auto-loading patch -p1 -d $ANDROID_BUILD_TOP/device/brcm/rpi3/ < android-patches/0001-load-usb-driver.patch patch -p1 -d $ANDROID_BUILD_TOP/device/brcm/rpi3/ < android-patches/0002-add-usb-blobs.patch 10. Build Android source cd ~/android-raspberry make ramdisk systemimage -j$(nproc) 11. Prepare SD card Partitions of the card should be set-up like followings. p1 512MB for BOOT : Do fdisk : W95 FAT32(LBA) & Bootable, mkfs.vfat p2 512MB for /system : Do fdisk, new primary partition p3 512MB for /cache : Do fdisk, mkfs.ext4 p4 remainings for /data : Do fdisk, mkfs.ext4 12. Mount ''BOOT'' partition as ''/mnt/p1'' then copy files cp $ANDROID_BUILD_TOP/device/brcm/rpi3/boot/* /mnt/p1/ cp $ANDROID_BUILD_TOP/kernel/rpi/arch/arm/boot/zImage /mnt/p1/ cp $ANDROID_BUILD_TOP/kernel/rpi/arch/arm/boot/dts/bcm2710-rpi-3-b.dtb /mnt/p1/ cp $ANDROID_BUILD_TOP/kernel/rpi/arch/arm/boot/dts/overlays/vc4-kms-v3d.dtbo /mnt/p1/overlays/vc4-kms-v3d.dtbo cp $ANDROID_BUILD_TOP/out/target/product/rpi3/ramdisk.img /mnt/p1/ 13. Write system partition sudo dd if=$ANDROID_BUILD_TOP/out/target/product/rpi3/system.img of=/dev/ bs=1M 14. Once you have android up and runnning, insert the module with: insmod /lib/modules/wlan-sdio.ko