NanoPi R5S - Boot from NVMe

:smiley:
@MichaIng: You are awesome !
@Joulinar: It’s working headless perfectly finally !
I’m sure it would help to have this incorporated in dietpi-install script, and/or have this properly documented somewhere on Nanopi R5S download/install page, but’s working and the solution is so simple at the end.
Thank you so much for the time you spent supporting me! Long live to dietpi !

 ─────────────────────────────────────────────────────
 DietPi v9.8.0 : 09:40 - Sat 10/19/24
 ─────────────────────────────────────────────────────
 - Device model : NanoPi R5S/R5C (aarch64)
 - CPU temp : 38 Β°C / 100 Β°F : Cool runnings
 - LAN IP : 192.168.1.39 (eth2)
 - MOTD : DietPi v9.8 is here. Check out all changes:
          https://dietpi.com/docs/releases/v9_8/
 ─────────────────────────────────────────────────────

 DietPi Team     : https://github.com/MichaIng/DietPi#the-dietpi-project-team
 Patreon Legends : Chris Gelatt, ADSB.im
 Website         : https://dietpi.com/ | https://twitter.com/DietPi_
 Contribute      : https://dietpi.com/contribute.html
 Web Hosting by  : https://myvirtualserver.com

 dietpi-launcher : All the DietPi programs in one place
 dietpi-config   : Feature rich configuration tool for your device
 dietpi-software : Select optimised software for installation
 htop            : Resource monitor
 cpu             : Shows CPU information and stats

root@DietPi:~# lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
mmcblk1      179:0    0  14.6G  0 disk 
└─mmcblk1p1  179:1    0  14.4G  0 part 
mmcblk1boot0 179:32   0     4M  1 disk 
mmcblk1boot1 179:64   0     4M  1 disk 
nvme0n1      259:0    0 465.8G  0 disk 
└─nvme0n1p1  259:1    0 465.7G  0 part /
root@DietPi:~# 

Great. My idea in general it to provide bootloader-only images for all SBCs, or at least all without SPI flash. So they can be flashed to an SD card or eMMC to boot images on USB or NVMe.

1 Like

yes I can confirm this, not sure if this is the NVMe? At least mine stays at CPU temp : 44 Β°C / 111 Β°F and case feels quite warm.

Hmm, the β€œlegacy” kernel is still in the repository, can you test whether it is the same with it?

sure, can you share command to switch kernel to legacy?

apt install linux-{image,dtb}-legacy-rk35xx

you are sure it’s still there?

root@DietPi:~# apt install linux-{image,dtb}-legacy-rk35xx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package linux-image-legacy-rk35xx
E: Unable to locate package linux-dtb-legacy-rk35xx
root@DietPi:~#

Nope. I tested without NVMe and it is still warm.

Regarding R5S getting warmer than usual while completely idle, I have an hypothesis. Doing some research, I discovered that some embedded CLI only distros are building the kernel with the following options:

CONFIG_PREEMPT_VOLUNTARY=y
CONFIG_PREEMPT_VOLUNTARY_BUILD=y

I have DietPi 9.9 running both on an OrangePi5 and on a NanoPi R5S. While idle, OrangePi5 is at room temperature, and R5S is always warm, almost hot, usually 10C above room temperature.

Checking CONFIG_PREEMPT on both, I noticed that Kernel in OrangePi5 is compiled with the options I mentioned above, while R5S has kernel preemption enabled, see below:

DietPi 9.9 on OrangePi5:

root@opi5:~# uname -a
Linux opi5.home 6.1.84-vendor-rk35xx #1 SMP Tue Dec 24 13:36:04 UTC 2024 aarch64 GNU/Linux
root@opi5:~# gzip -cd /proc/config.gz | grep PREEMPT
CONFIG_PREEMPT_VOLUNTARY_BUILD=y
# CONFIG_PREEMPT_NONE is not set
CONFIG_PREEMPT_VOLUNTARY=y
# CONFIG_PREEMPT is not set
# CONFIG_PREEMPT_DYNAMIC is not set
CONFIG_HAVE_PREEMPT_DYNAMIC=y
CONFIG_HAVE_PREEMPT_DYNAMIC_KEY=y
CONFIG_PREEMPT_NOTIFIERS=y
# CONFIG_PREEMPTIRQ_DELAY_TEST is not set
root@opi5:~# 

DietPi 9.9 on R5S:

root@DietPi:~# uname -a
Linux r5s 6.6.56-current-rockchip64 #1 SMP PREEMPT Thu Oct 10 10:50:06 UTC 2024 aarch64 GNU/Linux
root@DietPi:~# gzip -cd /proc/config.gz | grep PREEMPT
CONFIG_PREEMPT_BUILD=y
# CONFIG_PREEMPT_NONE is not set
# CONFIG_PREEMPT_VOLUNTARY is not set
CONFIG_PREEMPT=y
CONFIG_PREEMPT_COUNT=y
CONFIG_PREEMPTION=y
# CONFIG_PREEMPT_DYNAMIC is not set
CONFIG_PREEMPT_RCU=y
CONFIG_HAVE_PREEMPT_DYNAMIC=y
CONFIG_HAVE_PREEMPT_DYNAMIC_KEY=y
CONFIG_PREEMPT_NOTIFIERS=y
# CONFIG_DEBUG_PREEMPT is not set
# CONFIG_PREEMPT_TRACER is not set
# CONFIG_PREEMPTIRQ_DELAY_TEST is not set
root@DietPi:~# 

Perhaps I will open a separate thread to further evolve this hypothesis.

vs

So the 1st is more preemption points, while the 2nd is making all kernel code preemptible, even outside of preemption points. And it states in addition to β€œslightly lower throughput” also β€œslight runtime overhead to kernel code.”

Generally, as far as I understood, β€œpreemption” means to interrupt a process/thread to do other things in between. Usually, this can be done only at defined parts in kernel code, the preemption points. So the first options adds more of those points, so that processes/threads can be interrupted more quickly/at more stages, for other applications to run more quickly/smoothly under loader, while the 2nd option is much more consequent, allowing them to be interrupted anywhere.

This however should not add idle load, only changing behaviour under load :thinking:. But can still be tested, of course.

Hello @MichaIng and thanks for your work!

I recently acquired a Nanopi M6 that should have the same β€œissue” as the R5S in needing the SD Card/Emmc with the bootloader, so I think the answer would be generic for all the more recent Nanopi boards.

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

Now: I put an nvme inside the M6, and I’d like to run only the bare minimum from the SD Card while all the system should go in the nvme.
I don’t have the emmc on board, so SD card is the only boot option for me

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 (using the correct image for the M6) stopping before the last line

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

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 

Is it not clear how to proceed from here, as applying the last operation

parted /dev/mmcblk0 rm 1

changing mmcblk0 β†’ mmcblk1 will delete the sd card partition, including the bootloader

Tried it and upon a reboot Nanopi is stuck with fixed red light, nothing happening (so I suspect that removing the sd card partition wasn’t a good idea)

Any help is really appreciated, Thanks!!!

Thanks. I just created a new topic for this and replied there.

@MichaIng Please, if you think this should have its own topic let me know. I used this topic as I think the information would benefit all modern nanopi sbc.

To give more info, I also tried the conversion script starting from Armbian install on nvme

This is the partition snapshot after armbian-install having the β€œboot” on SD and the system on nvme

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 launched from Armbian

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

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 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 login on hdmi, but ssh and ping shows unreachable

Can you show the output of these?

ip l
ip a
ip r
journalctl -u ifup@eth0

assuming you have an Ethernet cable attached. If you tried to use WiFi, check ifup@wlan0 instead.

And Yes, please open a new topic, as this one filled in the meantime with a number of side topics, not related to NVMe boot at all (which obviously works well in your case). Network is a different topic, and very individual for every SBC, as in this case even different kernel builds are in use.

@MichaIng I am having issues using ``dietpi-config``` to install bootloader in eMMC to boot from NVMe (Advanced Options β†’ Update MMC bootloader).

I just booted from SD card with a clean image of DietPi 9.9.0. My plan was to do a fresh install of DietPi on NVMe and update eMMC with DietPi bootloader.

However it seems thad dietpi-config is incorrectly identifying eMMC device as mmcblk0 which is incorrect. eMMC is at mmcblk1, see details below.

Two questions:

  1. Is there any dietpi-configconfiguration file I can use to fix this?
  2. If not, where can I find the bootloader image file I can use to flash directly in eMMC using dd?
    EDITED: I am testing using
    /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc /dev/mmcblk1, I will update if it works.

Thanks!

oot@DietPi:~# echo $G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB.$G_DIETPI_VERSION_RC
9.9.0
root@DietPi:~# lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
mmcblk1      179:0    0  14.6G  0 disk 
└─mmcblk1p1  179:1    0  14.4G  0 part 
mmcblk1boot0 179:32   0     4M  1 disk 
mmcblk1boot1 179:64   0     4M  1 disk 
mmcblk0      179:96   0  29.7G  0 disk 
└─mmcblk0p1  179:97   0  29.7G  0 part /
nvme0n1      259:0    0 232.9G  0 disk 
└─nvme0n1p1  259:1    0 232.9G  0 part 
root@DietPi:~# dietpi-config

eMMC is at /dev/mmcblk1 (not /dev/mmcblk0):