How to do it:
My CM4 has an onboard emmc module, so that’s trickier then with one without emmc. I assume you know how to access remotely to your zynthian and have a basic knowledge of some bash command line tool.
Write Zynthian image to emmc
- Disable emmc boot on the cm4-IO board by placing a jumper on the header close to the CM4.
- Connect a micro usb to USB cable between the cm4-IO board and your computer.
- Power the cm4-IO board. The emmc drive will appear as an external USB drive.
- Burn the Zynthain image to that drive using your favorite tool. Mine’s USBimager, wich is lightweight, FOSS, and it runs on Win, Mac, Linux.
- Remove the drive (unmount it)
- Power off the cm4-IO board
- Remove jumper
Setup Zynthian / Update kernel version
- plug all your hardware to the cm4-IO board
- Power on and wait until the Zynthian setup process finish
- Enable USB host:
nano /boot/config.txt
and be sure you have:
dtoverlay=dwc2,dr_mode=host
- Using webconf, setup your hardware. Reboot, you should have hopefully a working Zynthian running from the emmc.
- Update kernel to 5.10:
rpi-update
- Reboot. Verify: uname -r => 5.10.39-v7l+ You can now access to your nvme drive: use lsblk command to identify it.
nvme drive setup
- create with fdisk command a 256Mb partition of type FAT32 and a second one big enough for housing the zynthian root file system (30Gb is ok) of type ext4. Save your changes, then exit fdisk.
lsblk:
mmcblk0 179:0 0 14.6G 0 disk
|-mmcblk0p1 179:1 0 256M 0 part /boot
|-mmcblk0p2 179:2 0 14.3G 0 part /
mmcblk0boot0 179:32 0 4M 1 disk
mmcblk0boot1 179:64 0 4M 1 disk
nvme0n1 259:0 0 238.5G 0 disk
|-nvme0n1p1 259:1 0 256M 0 part
|-nvme0n1p2 259:2 0 238.2G 0 part
- Format the partitions:
mkfs -f vfat /dev/nvme0n1p1
mkfs -f ext4 /dev/nvme0n1p2
- Create mount points:
mkdir /mnt/boot
mkdir /mnt/root
- Mount nvme partitions:
mount /dev/nvme0n1p1 /mnt/boot
mount /dev/nvme0n1p2 /mnt/root
- Copy filesystem:
rsync -avx / /mnt/root
rm -r /mnt/root/boot
Customize startup
- nvme module has to be loaded on an early stage to mount the root file system, so we use intramfs:
nano /etc/initramfs-tools/modules
add
nvme
at the end of the file.
- create initramfs:
update-initramfs -c -k
uname -r
Be carefull, they are backticks around uname -r
- Update config.txt:
nano /boot/config.txt
add at the end
initramfs initrd.img-5.10.39-v7l+
- copy /boot partition on the nvme drive:
rsync -avx /boot /mnt/boot
- identify nvme partitions UUID with blkid commad.
blkid
/dev/nvme0n1p1: SEC_TYPE=“msdos” UUID=“5E2E-A6ED” TYPE=“vfat” PARTUUID=“da93a86c-01”
/dev/nvme0n1p2: UUID=“8369e8b4-5f56-4285-97a0-d67c93cb52cf” TYPE=“ext4” PARTUUID=“da93a86c-02”
/dev/mmcblk0p1: LABEL_FATBOOT=“boot” LABEL=“boot” UUID=“592B-C92C” TYPE=“vfat” PARTUUID=“2fed7fee-01”
/dev/mmcblk0p2: LABEL=“rootfs” UUID=“706944a6-7d0f-4a45-9f8c-7fb07375e9f7” TYPE=“ext4” PARTUUID=“2fed7fee-02”
/dev/nvme0n1: PTUUID=“da93a86c” PTTYPE=“dos”
/dev/mmcblk0: PTUUID=“2fed7fee” PTTYPE=“dos”
so on my nvme drive, boot partition is da93a86c-01 and root partition is da93a86c-02
- Modify kernel command line parameter:
nano /mnt/boot/cmdline.txt
modify the root= argument:
root=PARTUUID=da93a86c-02
- To ensure this modification persist if ever you change your hardware configuration or switch from stable to testing branc or vice versa:
Create scripts directory
mkdir /mnt/root/var/zynthian/zynthian-my-data/scripts
create post install script:
nano /mnt/root//var/zynthian/zynthian-my-data/scripts/update_zynthian_sys.sh
and add the following:
#!/bin/bash
echo “initramfs initrd.img-5.10.39-v7l+” >> /boot/config.txt
echo “dtoverlay=dwc2,dr_mode=host” >> /boot/config.txt
echo “dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=da93a86c-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait” > /boot/cmdline.txt
Make it executable
chmod a+x /mnt/root/var/zynthian/zynthian-my-data/scripts/update_zynthian_sys.sh
- Modify fstab:
nano /mnt/root/etc/fstab
set the right PARTUUID:
PARTUUID=da93a86c-01 /boot vfat defaults 0 2
PARTUUID=da93a86c-02 / ext4 defaults,noatime 0 1
- Umount mount points:
umount /mnt/boot
umount /mnt/root
- Power off zynthian
Tell the bootloader to boot on the nvme drive
You will need the usbboot utility (Github link) installed on an another computer.
- Once installed you have to told the bootloader to modify the boot order. In usbbot/nvme/boot.conf change:
BOOT_ORDER=0xf25461
to
BOOT_ORDER=0xf25416
- From usbboot/nvme directory create a new eeprom:
./update-pieeprom.sh
- Write eeprom on cm4:
repeat step 1. 2. 3. go in usbboot directory and run:
./rpiboot -d nvme
- repeat step 6. 7. reboot, cross fingers
root@zynthian:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk0 179:0 0 14.6G 0 disk
|-mmcblk0p1 179:1 0 256M 0 part
|-mmcblk0p2 179:2 0 14.3G 0 part
mmcblk0boot0 179:32 0 4M 1 disk
mmcblk0boot1 179:64 0 4M 1 disk
nvme0n1 259:0 0 238.5G 0 disk
|-nvme0n1p1 259:1 0 256M 0 part /boot
|-nvme0n1p2 259:2 0 238.2G 0 part /
with the help of
RBPI nvme documentation
RBPI forum post