Assuming you already downloaded Android 9 Pie source code and the device configuration files from https://github.com/brobwind/pie-device-brobwind-rpi3.
And already built the whole project.
- Download the source code from https://github.com/brobwind/pie-device-brobwind-rpi3-u-boot/
$ git clone https://github.com/brobwind/pie-device-brobwind-rpi3-u-boot/ device/brobwind/rpi3/u-boot
- Download mkknlimg from https://github.com/raspberrypi/linux/blob/rpi-4.14.y/scripts/mkknlimg
$ curl https://raw.githubusercontent.com/raspberrypi/linux/rpi-4.14.y/scripts/mkknlimg > device/brobwind/rpi3/u-boot/mkknlimg
$ chmod +x device/brobwind/rpi3/u-boot/mkknlimg
Assuming current path is device/brobwind/rpi3/u-boot, execute following commands will build a 64-bit u-boot.
- Run configuration
$ ARCH=arm64 CROSS_COMPILE=../../../../prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-androidkernel- make rpi_3_defconfig
- Make
$ ARCH=arm64 CROSS_COMPILE=../../../../prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-androidkernel- make
- Add a trailer
$ ./mkknlimg --dtok --ddtk --270x u-boot.bin u-boot-dtok.bin
Uses a USB-to-TTL serial cable to connect the Raspberry Pi to PC and uses minicom to interactive with the bootloader. https://developer.android.com/things/hardware/raspberrypi#serial-console
The serial port setup parameter is 115200,8n1:
$ sudo minicom -b 115200 -D /dev/ttyUSB0
Also connect to a wired Ethernet network and the IP address can obtain from DHCP
- Print environment information
U-Boot> printenv
It will show information like this:
android_rootdev="/dev/mmcblk${android_root_devnum}p${android_root_partnum}"
autoload=no
board=rpi3
board_name=3 Model B+
board_rev=0xD
board_rev_scheme=1
board_revision=0xA020D3
bootcmd=\
fdt addr "${fdt_addr}"; \
fdt resize "${oem_overlay_max_size}"; \
android_ab_select "android_slot" mmc "0;misc" || run fastbootcmd || reset; \
test "${android_slot}" = "a" && env set oem_part "${oem_bootloader_a}"; \
test "${android_slot}" = "b" && env set oem_part "${oem_bootloader_b}"; \
ext2load mmc "0:${oem_part}" "${fdt_high}" /kernel.dtbo && \
fdt apply "${fdt_high}"; \\
fdt get value bootargs /chosen bootargs; \
setenv bootargs "${bootargs} androidboot.serialno=${serial#}"; \
boot_android mmc "0;misc" "${android_slot}" "${kernel_addr_r}"; \
reset
ethaddr=b8:27:eb:3a:df:1c
fastbootcmd=\
usb start && \
dhcp && \
fastboot udp
fdt_addr=2eff9400
fdt_high=2e000000
- Run in fastboot mode
U-Boot> run fastbootcmd
It will show information:
starting USB...
USB0: scanning bus 0 for devices... 5 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
lan78xx_eth Waiting for PHY auto negotiation to complete..... done
BOOTP broadcast 1
DHCP client bound to address 192.168.5.211 (6 ms)
lan78xx_eth Waiting for PHY auto negotiation to complete...... done
Using lan78xx_eth device
Listening for fastboot command on 192.168.5.211
- Flash images
Once the bootloader run in fastboot mode, you can use fastboot command to download images:
$ fastboot -s udp:192.168.5.211 flash rpiboot out/target/product/rpi3/rpiboot.img
$ fastboot -s udp:192.168.5.211 flash boot_a out/target/product/rpi3/boot.img
$ fastboot -s udp:192.168.5.211 flash system_a out/target/product/rpi3/system.img
$ fastboot -s udp:192.168.5.211 flash vendor_a out/target/product/rpi3/vendor.img
- Erase userdata partition
$ fastboot -s udp:192.168.5.211 erase userdata
- Run boot command
U-Boot> run bootcmd
- Show flat device tree
U-Boot> fdt addr ${fdt_addr}
U-Boot> fdt print