Mainline U-Boot on Odroid C2

Booting mainline u-boot on the Odroid C2 is fairly trivial, but unfortunately, we still require the binary blobs provided by hardkernel. This short guide should list all the steps needed in one place, for easy future reference.

With Linux 4.14, USB support seems broken, Gbit ethernet is okay.

ARM64 Toolchain

I used a linaro aarch64 toolchain found at https://releases.linaro.org/components/toolchain/binaries/latest/aarch64-linux-gnu/.

Download it, extract it, and export $PATH and $compiler for easy use later on.

# mkdir odroidc2 && cd odroidc2
# wget ...
# tar xf ...
# export PATH="/path/to/toolchain/bin:$PATH"
# export compiler="aarch64-linux-gnu-"

Compiling mainline u-boot

After extracting and preparing the env, we need to compile mainline u-boot. We can grab the official git repo:

# git clone git://git.denx.de/u-boot

Go inside the repo, and compile it.

# make ARCH=arm CROSS_COMPILE=$compiler odroid-c2_defconfig
# make ARCH=arm CROSS_COMPILE=$compiler -j4
# mv u-boot.bin ../ && cd ..

This will provide us with u-boot.bin we'll use later on.

Providing hardkernel's binary blobs

Let's grab a tarball of hardkernel's u-boot repository. A tested revision is 205c7b3259559283161703a1a200b787c2c445a5. We will also need meson-tools - where we find amlbootsig.

# wget -O hardkernel-uboot.tgz https://github.com/hardkernel/u-boot/archive/205c7b3259559283161703a1a200b787c2c445a5.tar.gz
# tar xf hardkernel-uboot.tgz
# mv u-boot-205c7b3259559283161703a1a200b787c2c445a5 hardkernel-uboot
# git clone https://github.com/afaerber/meson-tools
# cd meson-tools
# make
# cd ../hardkernel-uboot

Now we have to compile and use the fip_create program to prepare our .bin files.

# make -C tools/fip_create
# tools/fip_create/fip_create --bl30 fip/gxb/bl30.bin --bl301 fip/gxb/bl301.bin --bl31 fip/gxb/bl31.bin --bl33 ../u-boot.bin fip.bin
# cat fip/gxb/bl2.package fip.bin > boot_new.bin
# ../meson-tools/amlbootsig boot_new.bin u-boot.img
# dd if=u-boot.img of=../u-boot.gxbb bs=512 skip=96
# cp sd_fuse/bl1.bin.hardkernel ../
# cd ..

Now we have it ready, and we can proceed with the final step:

Flashing this stuff to a microsd card

We should be in the directory where bl1.bin.hardkernel and u-boot.gxbb are. To "flash" this on our microsd card we will simply use dd, like always.

# dd if=bl1.bin.hardkernel of=/dev/mmcblk0 conv=fsync bs=1 count=422
# dd if=bl1.bin.hardkernel of=/dev/mmcblk0 conv=fsync bs=512 skip=1 seek=1
# dd if=u-boot.gxbb of=/dev/mmcblk0 conv=fsync bs=512 seek=97
# sync; sync; sync

If this went well, all that is left is providing a boot.scr

boot.scr

boot.cmd:

setenv bootargs console=ttyAML0,115200n8 root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait
#setenv initrd_high "0xffffffff"
#setenv fdt_high "0xffffffff"
load mmc 0 0x43000000 ${fdtfile} || load mmc 0 0x43000000 boot/${fdtfile}
load mmc 0 0x41000000 Image || load mmc  0 0x41000000 boot/Image
#load mmc 0 0x50000000 uInitrd
#booti 0x41000000 0x50000000 0x43000000
booti 0x41000000 - 0x43000000

Create boot.scr out of it:

# mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d boot.cmd boot.scr

Copy the .dtb from your linux sources. It's found in arch/arm64/boot/dts: meson-gxbb-odroidc2.dtb. The u-boot looks for it in a directory called amlogic on the first partition. Of course, remember to copy your Image as well.