November 7, 2018

Orange Pi PC 2 - network booting - Build U-Boot from recent sources

By recent sources, I mean u-boot-2018.09 from here: The usual drill builds from source:
untar the snapshot
cd u-boot-2018.09
edit Makefile and add CROSS_COMPILE=aarch64-linux-gnu-
make orangepi_pc2_defconfig
cp ../arm-trusted-firmware/bl31.bin .
make
Note that I already had bl31.bin built as per the notes in u-boot-2018.09/board/sunxi/README.sunxi64

I place this onto a blank SD card (16G, but a smaller card will certainly do).

dd if=../U-Boot/u-boot-2018.09/u-boot-sunxi-with-spl.bin of=/dev/sdf bs=8k seek=1
This boots and runs with network commands already configured!

A place to save the U-Boot environment settings

When I type "saveenv" in U-Boot, it fails with the following message:
Saving Environment to FAT... Unable to use mmc 0:1... Failed (1)
Apparently it wants a FAT partition on the SD card and I simply deposited U-Boot onto a blank card using dd with no partitions. We can fix this in any number of ways. The laziest way is to put one of the Xenial distribution onto the card first. These have a partition layout like this:
Device     Boot  Start     End Sectors  Size Id Type
/dev/sdf1        40960  143359  102400   50M  c W95 FAT32 (LBA)
/dev/sdf2       143360 7395327 7251968  3.5G 83 Linux
It is simply laziness to copy an existing partition setup. I could run fdisk, then figure out how to generate a FAT partition using linux, but why bother.
dd if=../Linux/Ubuntu_Desktop_Xenial_xfce4_PC2_V1_0_0.img of=/dev/sdf bs=64k
dd if=../U-Boot/u-boot-2018.09/u-boot-sunxi-with-spl.bin of=/dev/sdf bs=8k seek=1
After doing this, booting the card, typing to get to the U-Boot prompt, we see this:
saveenv
Saving Environment to FAT... writing uboot.env
OK
Typing "printenv" shows (among lots of other things), the following:
bootcmd=run distro_bootcmd
ethaddr=02:01:05:d4:18:d4
We do the following:
setenv bootaddr 0x40000000
setenv boot_kyu "echo Booting Kyu via dhcp ; dhcp ${bootaddr}; go ${bootaddr}"
setenv bootcmd "run boot_kyu"
saveenv
Before we type "boot", we take note of the ethernet address, and we edit the /etc/dhcpd/dhcpd.conf file on our server and add an entry for that MAC address. We remember to do "service dhcpd restart", then type "boot" to the U-Boot prompt and see:
Hit any key to stop autoboot:  0
Booting Kyu via dhcp
ethernet@1c30000 Waiting for PHY auto negotiation to complete........ done
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.0.68 (255 ms)
Using ethernet@1c30000 device
TFTP from server 192.168.0.5; our IP address is 192.168.0.68
Filename 'h5.bin'.
Load address: 0x40000000
Loading: ############
	 7.4 MiB/s
done
Bytes transferred = 170672 (29ab0 hex)
## Starting application at 0x40000000 ...


Have any comments? Questions? Drop me a line!

Tom's electronics pages / tom@mmto.org