NanoPi M6 - Boot from SD Card with DietPi on NVMe

Creating this topic to not pollute anymore the R5S one as the SBCs can have some minor differences.

My Setup
Nanopi M6 + SD Card + NVMe + Ethernet
NO emmc
NO wifi

These are the tests I already made based on the comments in the above post

Scenario 1 - DietPi Only
This would ideally be the preferred method as it would not go out of the DietPi ecosystem

Flashed DietPi on SD Card and booted the system

Completed the first time setup (including the system update and the password setting) and my M6 now starts perfectly from the SD Card (I’m able to login with ssh etc …)

This is the starting disk status, mmcblk1 being the SD Card

root@DietPi:/tmp# lsblk 
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
mmcblk1     179:0    0   7.4G  0 disk 
└─mmcblk1p1 179:1    0   7.4G  0 part /
nvme0n1     259:0    0 931.5G  0 disk 

I followed the instructions posted by @MichaIng

cd /tmp
wget https://dietpi.com/downloads/images/DietPi_NanoPiM6-ARMv8-Bookworm.img.xz
apt install xz-utils
xz -d DietPi_NanoPiM6-ARMv8-Bookworm.img.xz
dd if=DietPi_NanoPiM6-ARMv8-Bookworm.img of=/dev/nvme0n1 bs=1M status=progress

This is the disk status after the commands, now system is still booting and running from SD card but the nvme is partitioned as the dietpi image before the first setup

root@DietPi:/tmp# lsblk 
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
mmcblk1     179:0    0   7.4G  0 disk 
└─mmcblk1p1 179:1    0   7.4G  0 part /
nvme0n1     259:0    0 931.5G  0 disk 
├─nvme0n1p1 259:1    0   1.1G  0 part 
└─nvme0n1p2 259:2    0     1M  0 part 

finally applying the last suggested operation to maintain only the basic bootloader on sdcard

parted /dev/mmcblk1 rm 1
<selected 'Ignore'>
reboot

Nanopi is unfortunately stuck with fixed red led, doesn’t boot

Scenario 2 - Start from Armbian
Armbian provides a Nanopi M6 image that allows, using armbian-install, to move the system to nvme maintaining only the bootloader on the SD Card
This are the disks after this setup:

root@nanopi-m6:~# lsblk 
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
mmcblk1     179:0    0    30G  0 disk 
└─mmcblk1p1 179:1    0  29,7G  0 part /boot
                                      /media/mmcboot
zram0       252:0    0  15,5G  0 disk [SWAP]
zram1       252:1    0    50M  0 disk /var/log
zram2       252:2    0     0B  0 disk 
nvme0n1     259:0    0 931,5G  0 disk 
└─nvme0n1p1 259:1    0 931,5G  0 part /var/log.hdd
                                      /

I then launched the following commands (needed because armbian uses a nested /boot folder)

umount /boot
mv /media/mmcboot/boot/{,.??,.[^.]}* /media/mmcboot/
rmdir /media/mmcboot/boot
umount /media/mmcboot
sed -i '/[[:blank:]]\/boot[[:blank:]]/d' /etc/fstab
sed -i 's|/media/mmcboot|/boot|' /etc/fstab
systemctl daemon-reload
mount /boot
reboot

When it restarted I launched the DietPi conversion script

bash -c "$(curl -sSfL 'https://raw.githubusercontent.com/MichaIng/DietPi/master/.build/images/dietpi-installer')"

filled up the requested fields selecting Nanopi M6 as target and master as the branch.
The script proceeded without issues, but on reboot, as the other users pointed out, there is no way to reach through ssh the nanopi m6 (it waits at the dietpi login on hdmi, but ssh and ping shows unreachable)

Logging in will start the DietPi first setup that will immediately fail as the network is not reachable.
These are the data I managed to obtain

Oh, the image changes the network interface names:

rm /etc/udev/rules.d/70-persistent-net.rules

Though, as I wanted to implement this into our installer, it is done already :thinking:.

However, while it would be good to find out about this, better is to get method 1 working. So it seems like parted removes not only the partition, but also the bootloader :thinking:. Hence try to not remove the whole partition, but just the boot script:

mv /boot/boot.scr{,_bak}

Thanks for the info @MichaIng, but unfortunately the nanopi still hang at boot with fixed red light

root@DietPi:~# cd /tmp
root@DietPi:/tmp# wget https://dietpi.com/downloads/images/DietPi_NanoPiM6-ARMv8-Bookworm.img.xz
--2025-01-14 10:32:03--  https://dietpi.com/downloads/images/DietPi_NanoPiM6-ARMv8-Bookworm.img.xz
Resolving dietpi.com (dietpi.com)... 188.114.97.7, 188.114.96.7, 2a06:98c1:3121::7, ...
Connecting to dietpi.com (dietpi.com)|188.114.97.7|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 200332640 (191M) [application/x-xz]
Saving to: ‘DietPi_NanoPiM6-ARMv8-Bookworm.img.xz’

DietPi_NanoPiM6-ARMv8-Bookworm.img.xz                     100%[=====================================================================================================================================>] 191.05M  80.1MB/s    in 2.4s    

2025-01-14 10:32:06 (80.1 MB/s) - ‘DietPi_NanoPiM6-ARMv8-Bookworm.img.xz’ saved [200332640/200332640]

root@DietPi:/tmp# apt install xz-utils
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
xz-utils is already the newest version (5.4.1-0.2).
0 upgraded, 0 newly installed, 0 to remove and 18 not upgraded.
root@DietPi:/tmp# xz -d DietPi_NanoPiM6-ARMv8-Bookworm.img.xz
root@DietPi:/tmp# dd if=DietPi_NanoPiM6-ARMv8-Bookworm.img of=/dev/nvme0n1 bs=1M status=progress
1116+1 records in
1116+1 records out
1170227712 bytes (1.2 GB, 1.1 GiB) copied, 4.05965 s, 288 MB/s
root@DietPi:/tmp# lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
mmcblk1     179:0    0   7.4G  0 disk 
└─mmcblk1p1 179:1    0   7.4G  0 part /
nvme0n1     259:0    0 931.5G  0 disk 
├─nvme0n1p1 259:2    0   1.1G  0 part 
└─nvme0n1p2 259:3    0     1M  0 part 
root@DietPi:/tmp# mv /boot/boot.scr{,_bak}
root@DietPi:/tmp# ls /boot/
Image				 boot.cmd      config-6.1.84-vendor-rk35xx  dietpi-LICENSE.txt	dietpi-wifi.txt  dietpiEnv.txt	dtb-6.1.84-vendor-rk35xx	 uInitrd		       vmlinuz-6.1.84-vendor-rk35xx
System.map-6.1.84-vendor-rk35xx  boot.scr_bak  dietpi			    dietpi-README.md	dietpi.txt	 dtb		initrd.img-6.1.84-vendor-rk35xx  uInitrd-6.1.84-vendor-rk35xx
root@DietPi:/tmp# reboot

Hmm then I guess we need serial console output. Probably this vendor U-Boot build cannot detect the NVMe or so.

I’m sorry but I don’t have a serial cable to connect.
If you have any other idea to test I’m available, it will only take me the time to reflash my sd card to the “initial” state with dietpi initial setup done entirely on the sd card

Thanks!!

Regarding the “armbian” step, I tried

 rm /etc/udev/rules.d/70-persistent-net.rules

after a dietpi conversion script and reboot, but in /etc/udev/rules.d there are only
80-net-setup-link.rules
90-naming-audios.rules

so nothing changed and no network connection is available

there you go :smiley:

DDR 9fffbe1e78 cym 24/02/04-10:09:20,fwver: v1.16
LPDDR5, 2400MHz
channel[0] BW=16 Col=10 Bk=16 CS0 Row=16 CS1 Row=16 CS=2 Die BW=16 Size=4096MB
channel[1] BW=16 Col=10 Bk=16 CS0 Row=16 CS1 Row=16 CS=2 Die BW=16 Size=4096MB
channel[2] BW=16 Col=10 Bk=16 CS0 Row=16 CS1 Row=16 CS=2 Die BW=16 Size=4096MB
channel[3] BW=16 Col=10 Bk=16 CS0 Row=16 CS1 Row=16 CS=2 Die BW=16 Size=4096MB
Manufacturer ID:0xff
CH0 RX Vref:27.1%, TX Vref:21.0%,21.0%
CH1 RX Vref:26.3%, TX Vref:20.0%,20.0%
CH2 RX Vref:27.9%, TX Vref:20.0%,19.0%
CH3 RX Vref:29.7%, TX Vref:21.0%,20.0%
change to F1: 534MHz
change to F2: 1320MHz
change to F3: 1968MHz
change to F0: 2400MHz
out
U-Boot SPL board init
U-Boot SPL 2017.09-armbian-2017.09-S303f-P2429-H8c72-Vef2b-Bda0a-R448a (Oct 17 2024 - 04:04:17)
Trying to boot from MMC2
MMC: no card present
mmc_init: -123, time 0
spl: mmc init failed with error: -123
Trying to boot from MMC1
spl: partition error
Trying fit image at 0x4000 sector
## Verified-boot: 0
## Checking atf-1 0x00040000 ... sha256(a7d1d8d191...) + OK
## Checking uboot 0x00200000 ... sha256(0f51416869...) + OK
## Checking fdt 0x00316a60 ... sha256(f59dd3d6b9...) + OK
## Checking atf-2 0xff100000 ... sha256(4b2065349b...) + OK
## Checking atf-3 0x000f0000 ... sha256(aa71013e72...) + OK
Jumping to U-Boot(0x00200000) via ARM Trusted Firmware(0x00040000)
Total: 82.392/341.636 ms

INFO:    Preloader serial: 2
NOTICE:  BL31: v2.3():v2.3-682-g4ca8a8422:derrick.huang, fwver: v1.45
NOTICE:  BL31: Built : 10:11:21, Dec 27 2023
INFO:    spec: 0x13
INFO:    code: 0x88
INFO:    ext 32k is valid
INFO:    ddr: stride-en 4CH
INFO:    GICv3 without legacy support detected.
INFO:    ARM GICv3 driver initialized in EL3
INFO:    valid_cpu_msk=0xff bcore0_rst = 0x0, bcore1_rst = 0x0
INFO:    l3 cache partition cfg-0
INFO:    system boots from cpu-hwid-0
INFO:    disable memory repair
INFO:    idle_st=0x21fff, pd_st=0x11fff9, repair_st=0xfff70001
INFO:    dfs DDR fsp_params[0].freq_mhz= 2400MHz
INFO:    dfs DDR fsp_params[1].freq_mhz= 534MHz
INFO:    dfs DDR fsp_params[2].freq_mhz= 1320MHz
INFO:    dfs DDR fsp_params[3].freq_mhz= 1968MHz
INFO:    BL31: Initialising Exception Handling Framework
INFO:    BL31: Initializing runtime services
WARNING: No OPTEE provided by BL2 boot loader, Booting device without OPTEE initialization. SMC`s destined for OPTEE will return SMC_UNK
ERROR:   Error initializing runtime service opteed_fast
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x200000
INFO:    SPSR = 0x3c9


U-Boot 2017.09-armbian-2017.09-S303f-P2429-H8c72-Vef2b-Bda0a-R448a (Oct 17 2024 - 04:04:17 +0000)

Model: NanoPi M6
MPIDR: 0x81000000
PreSerial: 2, raw, 0xfeb50000
DRAM:  16 GiB
Sysmem: init
Relocation Offset: eda48000
Relocation fdt: eb9f8740 - eb9fece0
CR: M/C/I
Using default environment

DM: v2
mmc@fe2c0000: 1, mmc@fe2e0000: 0
Bootdev(atags): mmc 0
MMC0: HS400 Enhanced Strobe, 200Mhz
PartType: EFI
No misc partition
boot mode: None
FIT: No boot partition
Failed to load DTB, ret=-2
No valid DTB, ret=-22
Failed to get kernel dtb, ret=-22
Model: NanoPi M6
MPIDR: 0x81000000
starting USB...
Bus usb@fc800000: USB EHCI 1.00
Bus usb@fc840000: USB OHCI 1.0
Bus usb@fc880000: USB EHCI 1.00
Bus usb@fc8c0000: USB OHCI 1.0
scanning bus usb@fc800000 for devices... 1 USB Device(s) found
scanning bus usb@fc840000 for devices... 1 USB Device(s) found
scanning bus usb@fc880000 for devices... 2 USB Device(s) found
scanning bus usb@fc8c0000 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
No usb mass storage found
CLK: (sync kernel. arm: enter 1008000 KHz, init 1008000 KHz, kernel 0N/A)
  b0pll 24000 KHz
  b1pll 24000 KHz
  lpll 24000 KHz
  v0pll 24000 KHz
  aupll 24000 KHz
  cpll 1500000 KHz
  gpll 1188000 KHz
  npll 24000 KHz
  ppll 1100000 KHz
  aclk_center_root 702000 KHz
  pclk_center_root 100000 KHz
  hclk_center_root 396000 KHz
  aclk_center_low_root 500000 KHz
  aclk_top_root 750000 KHz
  pclk_top_root 100000 KHz
  aclk_low_top_root 396000 KHz
Net:   No ethernet found.
Hit key to stop autoboot('CTRL+C'):  0

Device 0: unknown device
MMC: no card present
mmc_init: -123, time 0
pcie@fe190000: failed to get pcie phy (ret=-19)

Device 0: unknown device
pcie@fe190000: failed to find reset-gpios property

Device 1: unknown device
scanning bus for devices...

Device 0: unknown device
switch to partitions #0, OK
mmc0(part 0) is current device
** Invalid partition 1 **

Device 2: unknown device

Device 1: unknown device

Device 0: unknown device
pcie@fe190000: failed to find reset-gpios property
No ethernet found.
missing environment variable: pxeuuid
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm-rockchip
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default
No ethernet found.
Config file not found
pcie@fe190000: failed to find reset-gpios property
No ethernet found.
Could not find misc partition
ANDROID: reboot reason: "(none)"
Not AVB images, AVB skip
android_image_load_by_partname: Can't find part: boot
Android image load failed
Android boot failed, error -1.
## Booting FIT Image FIT: No boot partition
FIT: No fit blob
FIT: No FIT image
Unknown command 'bootrkp' - try 'help'
=>

Doesn’t seems to see NVMe an boot