Booting the Quartz64 from NVMe

November 18, 2023

The Quartz64 has a M.2 PCIe slot, and it works with NVMe drives. However, you have to do some configuration to get the RK3566 to actually boot from this source.

The steps here assume that you already have a Quartz64 with a functional Plebian root filesystem on an SD card or eMMC drive. I also just blindly copy the rootfs onto the NVMe drive, so the first drive has to be smaller than the NVMe. If you're running another distro, things might be different!

Step 1: Building U-Boot

You can do this from another computer and it'll be faster, but I did this from the Quartz. As mentioned, I am running Plebian on a Quartz64 Model B, so if you're doing anything different, you should definitely check the real instructions.

$ sudo apt install device-tree-compiler build-essential gcc-aarch64-linux-gnu \
	binutils-aarch64-linux-gnu make python3 python3-dev libssl-dev python3-pyelftools python3-setuptools \
	swig git bison flex mtd-utils
$ git clone https://source.denx.de/u-boot/u-boot.git
$ git clone https://github.com/rockchip-linux/rkbin.git
$ cd u-boot
$ export ROCKCHIP_TPL="$(ls ../rkbin/bin/rk35/rk3566_ddr_1056MHz_v*.bin | sort | tail -n1)"   
$ export BL31="$(ls ../rkbin/bin/rk35/rk3568_bl31_v*.elf | sort | tail -n1)"
$ make quartz64-b-rk3566_defconfig
$ make -j4

Step 2: Flashing the SPI flash

The U-Boot build produces several files, but the one we're interested in is u-boot-rockchip-spi.bin. Kwiboo's U-Boot build instructions describe how to flash this to locations: for the SPI flash run

$ sudo flashcp -v -p u-boot-rockchip-spi.bin /dev/mtd0

flashcp is found in the mtd-utils package (on Debian) installed earlier.

Step 3: Copying the rootfs

Boot the Quartz64 from the SD or eMMC with the NVMe drive inserted. Modify the partition table to whatever you want, and make a partition of the type Linux filesystem (fdisk name). Copy your entire rootfs with

$ sudo dd if=/dev/mmcblk0p2 of=/dev/nvme0n1p1 bs=4M status=progress

There's probably a smarter way to do this! Also note that your partition numbers might be different. Once the copy finishes, run:

$ sudo e2fsck -f /dev/nvme0n1p1
$ sudo resize2fs /dev/nvme0n1p1

to resize the filesystem to fill the partition.

Step 4: Reboot

Shut down the Quartz and remove all storage devices except for the NVMe drive. Power it on again and U-Boot should detect the drive, then boot from it!