Nanopi R5C seems to ignore SD Card in boot order

I’m a programmer who uses Linux on a daily basis. But the NanoPi R5C is my first SBC and I’m trying to get DietPi onto it for the first time.

So sorry I’m a bit lost on this very simple issue.

My problem is that the R5C seems to ignore the mini sd card in the boot sequence.

I’ve read the documentation for DietPi, googled, searched through Github issues and forum posts to try to find an answer as I know it will be simple, but I can’t find anything.

The sd card is brand new, I have flashed the sd card with DietPi according to the DietPi instructions, but when I insert the card the R5C simply boots straight into the default OS which is Friendly WRT.

The Friendly Elec docs seem to say that in order to flash the eMMC, you need to use their special tool - NanoPi R5C - FriendlyELEC WiKi

But the R5C is supported by DietPi, and the DietPi docs doesn’t mention that, the dietpi docs just say flash the image to the sd card, insert and boot.

Yes you can try the way describe on FriendlyELEC WiKi, section 4.4.3.1.2 Flash third party OS (Image file) to eMMC

The procedure described in our online documents is quite general and may not work with every SBC available on the market. In your case, it seems that eMMC is preferred over TF card. I know this behaviour from the past, where it was necessary to erase the eMMC on the NanoPi before booting from the TF card. Looks like this has changed according to FriendlyELEC WiKi.

Actually,i only done the same operation like dietpi install tutorial showed.i use win32disklmager to flash img in SD card. When insert card to r5c,it can automatically boot from card,not eMMC. :upside_down_face:

I have managed to complete the following 2 tasks:

  1. Get the R5C to boot from the sd card
  2. Copy the R5C DietPi installation from the sd card to the emmc

(1) How to get the NanoPi R5C to boot from the sd card.

In order to do this I executed the following command:

dd if=/dev/zero of=/dev/mmcblk1 bs=8M count=1

Or it was this (or very similar, I can’t quite recall):

dd if=/dev/zero of=/dev/mmcblk1p1 bs=8M count=1

This approach was obtained from Can't boot DietPi on the NanoPi R4SE - #2 by Jappe

Basically the objective is to break the default installed FriendlyElec OS, because the firmware will ignore the sdcard if it finds a working OS on the emmc.

Therefore, break the OS on the emmc so the firmware looks for a working OS on the sd card :slightly_smiling_face:

(2) How to get DietPi booting from the eMMC on the Nano Pi R5C.

After getting DietPi to boot I could run it on the sd card, but I wanted to run DietPi on the emmc. In order to achieve this I approximately followed this: Moving a running DietPi system to a USB stick/disk or an onboard eMMC – DietPi Blog

Noting that initially I spent a day trying to get that article work with an sd card that was larger than the emmc (the emmc is 32gb and the sd card i first tried was 64 gb). No matter what I tried I couldn’t get it to work.

So I just went out and purchased a 16GB sd card and then the following worked:

Step 1: Mark the / as readonly and reboot

mount -o remount,ro /
sed -i '\|[[:blank:]]/[[:blank:]]|s|,rw|,ro|' /etc/fstab
shutdown -r now

Step 2: Copy the sd card (mmcblk0) to the emmc (mmcblk1)

dietpi-services stop
swapoff -a
dd if=/dev/mmcblk0 of=/dev/mmcblk1 bs=1M status=progress
shutdown -h now

Then remove the sd card, and pull out the power and back in again to boot, and it should boot from the emmc.

Step 3: Return the / to read-write, and reboot and you are finished.

mount -o remount,rw /
sed -i '\|[[:blank:]]/[[:blank:]]|s|,ro|,rw|' /etc/fstab
shutdown -r now

(3) Further notes

During this work I found that Armbian works out of the box to install directly and automatically onto the sd card. It has a script build/packages/bsp/common/usr/sbin/armbian-install at 0a18ec690e423ffb25f66d39c09c0618f768e82d · armbian/build · GitHub

The script was useful to help me understand why Armbian worked and DietPi didn’t.