MichaIng / DietPi

Lightweight justice for your single-board computer!
https://dietpi.com/
GNU General Public License v2.0
4.9k stars 499 forks source link

New kernel for Nanopi R5S makes SD-card not bootable - SOLVED #7229

Open Cabletwister opened 1 month ago

Cabletwister commented 1 month ago

Creating a bug report/issue

Required Information

Additional Information (if applicable)

Steps to reproduce

Expected behaviour

DietPi with new kernel is starting from SD card

Actual behaviour

SD Card is not discovered as bootable, NanoPi starts from MMC or any other system, cannot use SD

Extra details

I have first experienced this when updating a DietPi installation that was some 3-4 months old. As the youngest working DietPi image I had on my machine was March 2023 I had to use this one. I installed it to several SD cards and did an install & update. => Whenever I went for the new R5S kernel, I was unable to start from SD afterwards => Whenever I kept the old version (selected "Cancel" when asked to switch to new kernel) it works like a charm, boots from SD => Whenever I download the latest image and flash to card, it will not start from SD

MichaIng commented 1 month ago

Can you try to keep pressing the MASK key before powering on, until you see some LEDs blinking? The bootloader changed the boot order, AFAIK, so I guess it just boots the eMMC with priority, at least if it contains an image with the original FriendlyELEC bootloader (which was the case with our older images).

Cabletwister commented 1 month ago

SOLVED So with the old images, if you want to boot them from SD card, just put in the SD card and power With this image (the new one), if you want to boot from SD-card, you have to press MASK while powering it and keep MASK pressed until the red LED blinks. This does NOT harm your MMC, so if you start it the next time, it simply boots from MMC.

The bis drawback of this version is: Now it is not possible to reboot into DietPi. So if there is just one second of Power-Loss, it will boot to the MMC.

Anyway, this clarified and solved the issue!

Cabletwister commented 1 month ago

SOLVED the problem by

MichaIng commented 1 month ago

So the default boot order is bad. IMO it makes sense to boot from movable boot devices with priority, internal ones with less priority, i.e. from SD card, if it is bootable, from eMMC only if no bootable SD card (or USB drive) is present.

I remember there even was an Armbian patch touching this. Maybe we can either remove, change or add a patch to adjust the boot order.

MichaIng commented 1 month ago

Testing this: https://github.com/MichaIng/build/commit/5b888ee Build is running: https://github.com/MichaIng/DietPi/actions/runs/11059240281

MichaIng commented 1 month ago

Okay in my case it does actually boot from SD card first, without above patch.

@Cabletwister what image is on your eMMC? Those FriendlyELEC R5/R6 SBCs have this weird behaviour, that their boot order depends on whether an image contains a FriendlyELEC vendor bootloader, or mainline U-Boot. So my guess is that the image on your eMMC is an older one, or an official FriendlyELEC image, and is then booted from eMMC with higher priority, than an SD card image with mainline U-Boot. In this case, there is nothing we can change about this, but you could flash mainline U-Boot to the eMMC or a DietPi image.

Cabletwister commented 1 month ago

Yes, the image on the MMC is a vendor-provided image, to be precise it is an SD-to-MMC-FriendlyWRT image.

Yes, it would be great to either have something like the oldfashioned BIOS boot-priority-setting or something like the GRUB we used in the ancient first years of Linux. Or just the plain "removable drives have priority" if this is possible.

As I am very happy with DietPi and more and more unhappy with FriendlyWRT, I am considering to flash DietPi to the MMC, hopefully this would also solve the issue for my case.

If I can help with any R5S related topic, please drop me a note, I can test whatever should be tested.

MichaIng commented 1 month ago

The problem is we have no real effect on this: the hardware/ROM decides about which boot device to use first. And obviously it decides to use the eMMC in this case, loading the bootloader shipped with the FriendlyELEC image. It would need to pick the SD card before our bootloader even had a chance to do further decisions, show a selection menu or such 🤔.

Other SBCs have a jumper to set the boot priority hardware-wise, but the NanoPi R5/R6 ones have a MASK button only, to disable the eMMC temporarily.

Cabletwister commented 1 month ago

The strange thing for me is: This depends on the image loaded to the SD card:

MichaIng commented 1 month ago

As said, essentially it is prioritising to boot a vendor bootloader, if present on and boot device. There was actually a table somewhere on FriendlyELEC wiki, but I cannot find it anymore. However, should be like this:

eMMC SD card
vendor !vendor!
!vendor! mainline
mainline !vendor!
mainline !mainline!

And the 2nd is sadly the default case, with some vendor image pre-installed on eMMC and DietPi now using mainline U-Boot.