Thursday, 13 July 2017

u-boot on RPi3

1) Get the latest u-boot from git
$ git clone git@github.com:u-boot/u-boot.git

2) Build the u-boot for RPi3 as follows
$ export ARCH=arm
$ export CROSS_COMPILE=arm-linux-gnueabihf-
$ make rpi_3_32b_defconfig

Please note that above step will config u-boot for 32-bit.

$ make -j4

copy u-boot.bin to boot partition of SD card.

3) you need to modify config.txt in order to boot u-boot.

kernel=u-boot.bin

Also, if you want serial console then it is required to enable serial.

enable_uart=1

4) In order to boot kernel from u-boot create boot.scr.uimg file. u-boot reads the file and executes the commands written in the file.
4.1) Create boot.scr
$ cat boot.scr
setenv fdtfile bcm2710-rpi-3-b.dtb
mmc dev 0
fatload mmc 0:1 ${kernel_addr_r} kernel7.img
fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}
setenv bootargs earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait noinitrd
bootz ${kernel_addr_r} - ${fdt_addr_r}

I am assuming name of the kernel file is kernel7.img.
4.2) create  boot.scr.uimg from boot.scr
$ mkimage -A arm -O linux -T script -C none -n boot.scr -d boot.scr boot.scr.uimg
4.3) copy boot.scr.uimg to boot partition of SD-card and you are done