22 May 2019, 00:00

Arch on Rock64 with USB boot

Share

Here are my notes to install Arch on a Rock64 and boot on USB first.

Warning, you can brick your device (but can unbrick it), you are on your own.

  • Follow Arch Instructions to Install on an SD Card
  • Boot on it
  • Insert your USB device and follow the exact same installation but this time to the /dev/sdadevice
    At the end
    Mount / into root again Run blkid to grab the UUID of your /
  /dev/sda1: UUID="a3490212-03b6-46a6-9e6b-7733513a3efa" TYPE="ext4"  

Add the file root/boot/boot.txt as follow and recopy your own UUID

              # MAC address (use spaces instead of colons)
              setenv macaddr da 19 c8 7b 6d bd

              part uuid ${devtype} ${devnum}:${bootpart} uuid
              setenv bootargs console=ttyS2,1500000 root=UUID=a3490212-03b6-46a6-9e6b-7733513a3efa rw rootwait earlycon=uart8250,mmio32,0xff130000
              setenv fdtfile rockchip/rk3328-rock64.dtb

              if load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /boot/Image; then
                if load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then
                  fdt addr ${fdt_addr_r}
                  fdt resize
                  fdt set /ethernet@ff540000 local-mac-address "[${macaddr}]"
                  if load ${devtype} ${devnum}:${bootpart} ${ramdisk_addr_r} /boot/initramfs-linux.img; then
                    booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
                  else
                    booti ${kernel_addr_r} - ${fdt_addr_r};
                  fi;
                fi;
              fi

Then write it to the scr

  cd root/boot
  pacman -S uboot-tools
  mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d boot.txt boot.scr

Reboot and remove the USB device

  • Download a dedicated image labelled u-boot-flash-spi-rock64.img.xz from ayufan’s github
  • Burn it to an SD Card, turn on your Rock64, wait for the white LED to flash several at 1 second frequency
  • Turn it off, remove the SC Card, insert the USB device, it should now boot on your USB device

BTRFS

Here is a config for a ext4 /boot and / btrfs.

mount -o noatime,ssd,compress=lzo,subvol=@root /dev/sda2 root
mount /dev/sda1 root/boot
cd root/boot
mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d boot.txt boot.scr

And the matching boot.txt

# After modifying, run ./mkscr
# MAC address (use spaces instead of colons)
setenv macaddr da 19 c8 7a 6d f4
part uuid ${devtype} ${devnum}:${bootpart} uuid
setenv bootargs console=ttyS2,1500000 rootfstype=btrfs root=UUID=7ba94ef7-a453-495a-a93c-a6cdb875b28e rootflags=subvol=@root rw rootwait earlycon=uart8250,mmio32,0xff130000
setenv fdtfile rockchip/rk3328-rock64.dtb
if load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /Image; then
  if load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /dtbs/${fdtfile}; then
    fdt addr ${fdt_addr_r}
    fdt resize
    fdt set /ethernet@ff540000 local-mac-address "[${macaddr}]"
    if load ${devtype} ${devnum}:${bootpart} ${ramdisk_addr_r} /initramfs-linux.img; then
      booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
    else
      booti ${kernel_addr_r} - ${fdt_addr_r};
    fi;
  fi;

Do not used zstd compression for now since it was not available in 4.4 ayufan kernel you may find yourself stuck with a filesystem you cannot read back in older kernel (been there).

Kernel

I’ve tried mainline 5.1 kernel for days, with a lot of instabilities, memory corruption, compilator crashed.
It looked like cpu overheating problems but was not, simply downgraded to 4.4 ayufan kernel and everything went back to normal.

You can install linux-aarch64-rock64-bin from AUR or used mine more recent AUR packages.

Stability

USB 3 port is unstable with ayufan kernel, hopefully it may be fixed in mainline.

Disabling uas for your usb key seems to improve a lot.

Identify your USB storage with lsusb -v

Add usb-storage module loading options identifying your device on your bootargs in /boot/boot.txt

setenv bootargs console=ttyS2,1500000 rootfstype=btrfs root=UUID=c9136915-614c-4203-ba8d-5f2f202ffbcd rootflags=subvol=@root usb-storage.quirks=0x078
1:0x5588:u rw rootwait earlycon=uart8250,mmio32,0xff130000