&sectl;2023-08-22

After you cross-compiled the u-boot,

(chroot) hc4Bookworm /usr/src/u-boot-odroid-hc4/sd_fuse # scp  alexlai@192.168.48.131:/home/alexlai/build/src/u-boot/sd_fuse/*.* ./
(chroot) hc4Bookworm /usr/src/u-boot-odroid-hc4/sd_fuse # ./sd_fusing.sh /dev/sdb
1710+1 records in
1710+1 records out
875888 bytes (876 kB, 855 KiB) copied, 0.324882 s, 2.7 MB/s
Finished.
(chroot) hc4Bookworm /usr/src/linux-6.1.41-gentoo # lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 223.6G  0 disk 
├─sda1   8:1    0 457.8M  0 part 
├─sda2   8:2    0 215.1G  0 part /etc/resolv.conf
└─sda3   8:3    0     8G  0 part [SWAP]
sdb      8:16   1  14.9G  0 disk 
├─sdb1   8:17   1   512M  0 part /mnt
└─sdb2   8:18   1  14.4G  0 part /

(chroot) hc4Bookworm /usr/src/linux-6.1.41-gentoo # ls -l arch/arm64/boot/
total 33752
-rw-r--r--  1 root root 25586176 Aug 22 15:18 Image
-rw-r--r--  1 root root  9093343 Aug 22 15:19 Image.gz
-rw-r--r--  1 root root     1198 Aug 22 12:32 Makefile
drwxr-xr-x 35 root root     4096 Aug 22 12:43 dts
-rwxr-xr-x  1 root root      962 Aug 22 12:32 install.sh
(chroot) hc4Bookworm /usr/src/linux-6.1.41-gentoo # cp  -v arch/arm64/boot/Image*  /mnt
'arch/arm64/boot/Image' -> '/mnt/Image'
'arch/arm64/boot/Image.gz' -> '/mnt/Image.gz'

(chroot) hc4Bookworm /mnt # mkdir -p dtbs/amlogic
(chroot) hc4Bookworm /mnt # cd dtbs/amlogic/

(chroot) hc4Bookworm /mnt/dtbs/amlogic # scp alexlai@n2mnjaro.yushei.net:/boot/dtbs/amlogic/* ./

(chroot) hc4Bookworm /mnt # cat boot.ini 
ODROIDHC$-UBOOT-CONFIG

# Default Console Device Setting
setenv condev "console=ttyAML0,115200n8"   # on both
# set bootlabel
setenv bootlabel "odroid-hc4 Gentoo 2023-08-23"

# Boot Args
# setenv bootargs "root=PARTUUID=0930d220-02 rootwait rw ${condev} ${amlogic} no_console_suspend fsck.repair=yes net.ifnames=0 clk_ignore_unused quiet splash plymouth.ignore-serial-consoles"
setenv bootargs "root=PARTUUID=8336949-02 rootwait rw ${condev} ${amlogic} no_console_suspend fsck.repair=yes net.ifnames=0 clk_ignore_unused plymouth.ignore-serial-consoles"
# /dev/sdb2: UUID="d0b3fbd0-04a8-4132-ba90-429e2b8f5a82" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="a8336949-02"

# Set load addresses
setenv dtb_loadaddr "0x20000000"
setenv loadaddr "0x1080000"
setenv initrd_loadaddr "0x4080000"

# Load kernel, dtb and initrd
load mmc ${devno}:1 ${loadaddr} /Image
load mmc ${devno}:1 ${dtb_loadaddr} /dtbs/amlogic/meson-g12b-odroid-n2.dtb
load mmc ${devno}:1 ${initrd_loadaddr} /initramfs-linux.uimg
#fdt addr ${dtb_loadaddr}

# boot
booti ${loadaddr} ${initrd_loadaddr} ${dtb_loadaddr}


You have to cross compile it on a x86_64 machine.

¶Toolchain

Click one of the site to download toolchain to build U-boot.

Once the download is done, extract one of the tarball to /opt/toolchains/.

$ sudo mkdir -p /opt/toolchains
$ sudo tar xvf gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz -C /opt/toolchains/
$ sudo tar xvf gcc-linaro-arm-none-eabi-4.8-2014.04_linux.tar.xz -C /opt/toolchains/
export ARCH=arm64
export CROSS_COMPILE=aarch64-none-elf-
export PATH=/opt/toolchains/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:/opt/toolchains/gcc-linaro-arm-none-eabi-4.8-2014.04_linux/bin:$PATH
alexlai@SurfacePro:~/build/src$ aarch64-none-elf-gcc -v
組み込み spec を使用しています。
COLLECT_GCC=aarch64-none-elf-gcc
COLLECT_LTO_WRAPPER=/opt/toolchains/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin/../libexec/gcc/aarch64-none-elf/4.8.3/lto-wrapper
ターゲット: aarch64-none-elf
configure 設定: /cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/src/gcc-linaro-4.8-2013.11/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=aarch64-none-elf --prefix=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/install --with-local-prefix=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/install/aarch64-none-elf --without-headers --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG linaro-1.13.1-4.8-2013.11 - Linaro GCC 2013.10' --with-bugurl=https://bugs.launchpad.net/gcc-linaro --with-arch=armv8-a --disable-__cxa_atexit --with-gmp=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/aarch64-none-elf/build/static --with-mpfr=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/aarch64-none-elf/build/static --with-mpc=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/aarch64-none-elf/build/static --with-isl=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/aarch64-none-elf/build/static --with-cloog=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/aarch64-none-elf/build/static --with-libelf=/cbuild/slaves/oorts/crosstool-ng/builds/aarch64-none-elf-linux/.build/aarch64-none-elf/build/static --enable-lto --enable-linker-build-id --disable-libmudflap --disable-libgomp --disable-libssp --disable-libstdcxx-pch --enable-multiarch --disable-multilib --enable-languages=c,c++,fortran
スレッドモデル: single
gcc バージョン 4.8.3 20131111 (prerelease) (crosstool-NG linaro-1.13.1-4.8-2013.11 - Linaro GCC 2013.10) 

¶Step 1.

$ git clone https://github.com/hardkernel/u-boot.git -b odroidg12-v2015.01
(chroot) hc4Bookworm /usr/src # cd u-boot/
(chroot) hc4Bookworm /usr/src/u-boot # make odroidc4_defconfig
  HOSTCC  scripts/basic/fixdep
  GEN     ./Makefile
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
(chroot) hc4Bookworm /usr/src/u-boot # find ./ -name .config
./build/.config

---------------------------
- SCP Firmware BL3-0: offset=0x4000, size=0xD400
- EL3 Runtime Firmware BL3-1: offset=0x14000, size=0x2B000
- Non-Trusted Firmware BL3-3: offset=0x40000, size=0xB4C60
---------------------------
# build final bootloader
Building /home/alexlai/build/src/u-boot/sd_fuse/u-boot.bin...
/home/alexlai/build/src/u-boot/sd_fuse/u-boot.bin is updated.

real	0m32.809s
user	0m29.602s
sys	0m4.024s

alexlai@SurfacePro:~/build/src/u-boot$ ls sd_fuse/
sd_fusing.sh  u-boot.bin  u-boot.bin.sd.bin  u-boot.bin.usb.bl2  u-boot.bin.usb.tpl

alexlai@SurfacePro:~/build/src/u-boot$ cat sd_fuse/sd_fusing.sh 
#!/bin/sh
#
# Copyright (C) 2018 Hardkernel Co,. Ltd
# Dongjin Kim <tobetter@gmail.com>
#
# SPDX-License-Identifier:      GPL-2.0+
#

abort() {
	echo "$1"
	exit 1
}

[ -z "$1" ] && abort "usage: $0 <your/memory/card/device>"
[ -z "$UBOOT" ] && UBOOT="${PWD}/u-boot.bin"
if [ ! -f "$UBOOT" ] ; then
	UBOOT="$(echo "$0" | perl -pe 's/[^\/]*$//g')u-boot.bin"
fi
[ ! -f "$UBOOT" ] && abort "error: $UBOOT is not exist"

sudo dd if="$UBOOT" of="$1" conv=fsync,notrunc bs=512 seek=1

sync

sudo eject "$1"
echo "Finished."

¶Installation to memory card directly

We provide the script, sd_fuse/sd_fusing.sh, this helps you to install the bootloader into your blank card MicroSD.

Insert your card to USB card reader and attach to USB host port of your desktop. Check the device path of your USB card reader.

Install the bootloader binaries using sd_fuse/sd_fusing.sh.

$ cd sd_fuse
$ ./sd_fusing.sh <device/path/of/your/card>