Skip to content

Instantly share code, notes, and snippets.

@apritzel
Created May 11, 2025 18:19
Show Gist options
  • Save apritzel/22d5d2a8f87625e477a9b2a3209c0381 to your computer and use it in GitHub Desktop.
Save apritzel/22d5d2a8f87625e477a9b2a3209c0381 to your computer and use it in GitHub Desktop.
Shell script to boot a 64-bit Allwinner SoC with a given kernel and initrd via FEL
#!/bin/sh
# ADJUST to match your setup
INITRD=/srv/tftp/busybox.initrd.gz
UBOOT_DIR=/src/u-boot.git
if [ $# -eq 0 -o "$1" = "-h" ]
then
echo "usage: %0 <kernel.img> [<cmdline>]"
exit 0
fi
kernel="$1"
shift
if [ $# -lt 1 ]
then
cmdline="console=ttyS0,115200n8 earlycon"
else
cmdline="$1"
shift
fi
ramdisk_size=$(stat -c %s "$INITRD" | rax2 -)
tmpf="/tmp/bootscript.$$"
echo "setenv bootargs \"$cmdline\"" > $tmpf
echo "booti \$kernel_addr_r \$ramdisk_addr_r:$ramdisk_size \$fdtcontroladdr" >> $tmpf
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "boot script" -d $tmpf ${tmpf}.img > /dev/null
$ECHO sunxi-fel -v -p uboot $UBOOT_DIR/u-boot-sunxi-with-spl.bin write 0x40080000 "$kernel" write 0x4ff00000 "$INITRD" write 0x4fe00000 ${tmpf}.img
rm -f $tmpf ${tmpf}.img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment