January 25, 2017

Orange Pi Plus - U-boot on the eMMC to network boot Kyu

This is a quick "cookbook" style description of how to put U-boot onto the onboard eMMC on an Orange Pi PC Plus and have it do a network boot via DHCP and TFTP. If you want more details, you can find them on two other writeups.

I do all this using the serial console.

Build U-boot

In case you don't want to do this yourself, I offer you the binary file I use: To build this, I obtained recent U-boot sources (v2016.11) and applied the Armbian patches. Then I did this:
cd u-boot
export CROSS_COMPILE=arm-linux-gnu-
make distclean
make orangepi_pc_plus_defconfig
make all
This runs quickly, giving me the necessary binary file.

Copy U-boot to eMMC

To do this you will need an SD card that will boot and run Armbian linux on the PC Plus. Boot this and use scp to copy the U-boot image to the Armbian system. Then do this:
dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk1 bs=1024 seek=8
447+1 records in
447+1 records out
458738 bytes (459 kB) copied, 0.0609168 s, 7.5 MB/s
After this, shutdown Armbian, remove the SD card and reapply power.

Configure U-boot

Interrupt U-boot by typing any character as suggested. This will give the U-boot interactive prompt. Then the version command should give this:
=> version
U-Boot 2016.11-g29e0cfb-dirty (Jan 09 2017 - 11:19:55 -0700) Allwinner Technology
arm-linux-gnu-gcc (GCC) 6.1.1 20160621 (Red Hat Cross 6.1.1-2)
GNU ld version 2.27-3.fc24
Then issue the following commands (you may as well cut and paste them from here):
setenv bootaddr 0x42000000
setenv boot_kyu echo Booting Kyu via dhcp/tftp\; dhcp\; go \${bootaddr}
setenv bootcmd run boot_kyu
saveenv
Before you hit reset, use the following command to get the MAC address.
=> env print ethaddr
ethaddr=02:20:7f:9b:xx:yy

Set up your DHCP (and TFTP) servers

I already have these set up on my system, so I just need to add an entry for this new board (and this is why we fetched the MAC address) On my Fedora 24 system, I add the following to /etc/dhcpd/dhcpd.conf
    host orangepiplus2 {
	hardware ethernet 02:20:7f:9b:xx:yy;
	fixed-address 192.168.0.61;
	option host-name "orangepiplus2";
	server-name "trona";
	filename "orange.bin";
    }
Then I do this:
systemctl restart  dhcpd.service
After this type "boot" to the U-boot prompt (or else hit reset or power cycle). It will boot the file "orange.bin" from your tftp directory (in my case /var/lib/tftpboot).

Works great. Being able to save the U-boot environment on MMC is fantastic!


Have any comments? Questions? Drop me a line!

Tom's electronics pages / [email protected]