-
-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Odroid N2/HC4 | Add support for petitboot>USB boot #5634
Comments
I need to play around with this. Best IMO would be if the U-Boot from the image itself would allow booting from SSD. Otherwise, if I'm not mistaken, our U-Boot config should work with latest petitboot when leaving out one of the variables. I'll have a look when I find time. |
Thanks for the reply and support. If I modify the boot.cmd in /boot
and save the file. And then run the command
In this case, it can boot up directly from SSD using petitboot. This is for your information. Hope it will be helpful. Additional information: |
So |
@Power-onoff However, it sets the And we can test to link the Guys, can you please try this: sed -i '/^setenv overlay_prefix/a\if test "${variant}" = "n2_plus"; then setenv fdtfile "amlogic/meson-g12b-odroid-n2-plus.dtb"; fi' /boot/boot.cmd
sed -i '/^setenv overlay_prefix/a\if test "${variant}" = "n2-plus"; then setenv fdtfile "amlogic/meson-g12b-odroid-n2-plus.dtb"; fi' /boot/boot.cmd
sed -i '/^setenv overlay_prefix/a\if test "${variant}" = "n2"; then setenv fdtfile "amlogic/meson-g12b-odroid-n2.dtb"; fi' /boot/boot.cmd
sed -i '/^setenv overlay_prefix/a\setenv fdtfile_orig "${fdtfile}"' /boot/boot.cmd
sed -i '/^setenv bootargs/s/"$/ fdtfile_orig=${fdtfile_orig}"/' /boot/boot.cmd
mkimage -C none -A arm64 -T script -d /boot/boot.cmd /boot/boot.scr If it boots: cat /proc/cmdline |
Executing this command
I am noob at linux so please advise how to solve the error? |
Mistake my end, please use: sed -i '/^setenv bootargs/s/"$/ fdtfile_orig=${fdtfile_orig}"/' /boot/boot.cmd |
I don't quite understand your answer What I'm trying to do is not a USB boot It's just booting with a MicroSD card If you connect an external HDD after booting with a MicroSD card, it can recognize and mount normally However, if an external HDD is connected while booting with a MicroSD card, the following error occurs The board is Odroid N2 |
I don't know why, but I failed to boot directly from an external HDD without a MicroSD card or eMMC It also failed to change the root file system to an external HDD after booting to a MicroSD card or eMMC (I copied the image after fdisk operations to avoid duplicate UUIDs) Therefore, an attempt was made to boot from an external HDD using petitboot from SPI flash As a result, I succeeded I don't know why, but it took nearly a minute for petitboot to recognize the external HDD After recognition, there was a symptom of a momentary USB power-off during boot (probably a USB driver initialization), so it took another minute to recognize during boot, and the phrase "Begin: running /script/local-block ... done" was repeated and stopped as shown in the picture I added "rootdelay=120" to "bootargs" and it successfully booted |
Ah okay, then it's a different issue. |
I found time to play around with this. First I updated petitboot to latest version (if it wasn't already):
Adding the above U-Boot settings at least does not break boot with MMC switch, so it's generally valid and correct. However, I'm unable to really test this with SPI switch. Not sure why, but it doesn't read from the USB stick I use for testing (it has an LED which flashes in I/O) until reaching a state where it waits for wake-on-lan. The USB stick LED flashes after this:
Is this kernel and initrd an internal fallback one? And when trying to boot from SD card via SPI/petitboot, it seems to look for
|
It boots again with recovery petitboot, but isn't able to self-update v2022-03-17 even when putting the |
Back on track with latest functioning petitboot. However finally failing on getting the |
Great to hear these news @MichaIng! It would be great to see those steps to modify our running system in order to avoid install all again. Other thing, instead of USB can be used and SSD?, and is going to come back to us the "Move rootfs"? Thank you as always! |
I guess a reinstall is needed as a migration of existing system will not work. |
Migration is possible as mentioned 🙂: G_EXEC cp -a /boot/boot.scr{,.bak}
G_EXEC curl -sSf 'https://raw.githubusercontent.com/MichaIng/DietPi/master/.build/images/U-Boot/boot.cmd' -o /boot/boot.cmd
G_EXEC sed -i '1i[main]' /boot/dietpiEnv.txt
(( $G_HW_MODEL == 15 )) && G_EXEC sed -i '/^setenv overlay_error/a\
\n# petitboot workarounds\
if test "${variant}" = "n2_plus"; then setenv variant "n2-plus"; fi\
setenv fdtfile "amlogic/meson-g12b-odroid-${variant}.dtb"\
setenv rootuuid "true"' /boot/boot.cmd
(( $G_HW_MODEL == 16 )) && G_EXEC sed -i '/^setenv overlay_error/a\
\n# petitboot workarounds\
setenv fdtfile "amlogic/meson-sm1-odroid-${variant}.dtb"\
setenv rootuuid "true"' /boot/boot.cmd
G_EXEC sed -i '/env import/c\\tini main ${scriptaddr} || env import -t ${scriptaddr} ${filesize}' /boot/boot.cmd
G_EXEC sed -i '/test -e/s/fixup.scr;/fixup.scr || test "${petitboot_active}" = "1";/' /boot/boot.cmd
G_EXEC mkimage -C none -A arm64 -T script -d /boot/boot.cmd /boot/boot.scr Paste this as one code block. It does the adjustments depending on whether it is an N2 or C4/HC4 image. Alternative, if you prefer doing it manually:
|
@MichaIng can you explain a bit more the process? Thank you! |
You can copy&paste the code block into your console and hit ENTER. A bit more save is to copy it into a script file indeed, so you can better review that everything was pasted correctly. But then "source" it instead of executing it, since it uses our error handler: source script.sh
No, this won't copy the image to USB drive, it just enables it to be generally bootable from a USB drive. You'd still need to clone/dd it over. We have some guide here to cover that topic, if needed: https://dietpi.com/blog/?p=1236
Since the script does not do the actual copy, the question is obsolete? The SPI bootloader by default loops through all attached USB drives and boots from the first bootable system it finds. So not need to define the USB port, at least if there is only one bootable system attached (including eMMC/SD which take priority). If you have multiple OS drives attached, it can be selected from the petitboot GUI. It shows up on the attached screen and would automatically boot from the first bootable drive after 10 seconds (by default), but you can also select a specific drives, which are listed in the GUI as well. |
@MichaIng just the last doubt, when I installed latest image for HC4 I had to delete petitboot, now with the new image do i have to restore it in order to achieve usb boot, or it is not mandatory? |
Yes petitboot has to be restored, or you can also flash mainline U-Boot to SPI, which was another way already to enable USB boot: apt install linux-u-boot-odroidhc4-current
source /usr/lib/u-boot/platform_install.sh
write_uboot_platform_mtd "$DIR" By default the C4 U-Boot package is installed which does not ship the SPI bootloader binary, hence the package install/replacement needed first. Generally the goal of petitboot support that one can boot DietPi from USB directly without the need to first hold the MASK key, erase or replace the bootloader and all such 🙂. So if you tested either our new image or your running image cloned to USB with petitboot restored, that would be best, since I have no HC4 to test with. |
@MichaIng I did this steps: I cannot do it with cloning the SSD? |
Cloning the drive should work.
The boot script is obviously loaded, but it fails to read the device tree directory it seems. This should be a symbolic link to |
What do you need to see? dtb folder has content I am thinking, if I don't know if I flash the image on the ssd before applied the script.... 🤦 UPDATE: Same error @MichaIng after flashing again. NEW UPDATE: |
The UUID is also used, that is good as intended. Can you check whether it is correct? In petitboot menu I think it shows the UUID of all detected drives/filesystems as well. |
Yes, I check it in dietpi drive manager on the old dietpi installation, and the uuid it's the same.. UPDATE: I've tried flashing the new test image you linked, directly into the SSD, and the error stills the same. So maybe is something about petitboot? For restoring Petitboot I follow this thread: https://forum.odroid.com/viewtopic.php?f=207&t=40906 and this steps: "In order to restore the SPI flash memory, flash the image in the link using Balena Etcher to SD card and insert to SD card slot. Before connecting power adapter to HC4, keep pressing the black button on the bottom until the blue LED turns on. This image will start to flash SPI flash memory with Petitboot firmware, remove SD card once it's done." Is it true that after the flashing finish, a message appear quickly that the installation has finieshed and there is goint to reboot, and that I have to select something on boot to SPI. That part I don't know where I have to set it up, if I have to... Another thing, I have tried flashing the image on an usb drive, not on and ssd through a cable usb3->sata, and petitboot does not recognize it... |
It shouldn't be needed to select or change anything. By default, all drive types is looped through (eMMC > SD > USB) and the first valid one picked for autoboot after 10 seconds. This seems to work correctly since your output shows that the adjusted Also the kernel and initramfs has been loaded successfully, so U-Boot (the one invoked by petitboot) found the filesystem. Now with everything loaded, it is on the initramfs to actually mount the root filesystem, and this seems to fail. There is this USB "connect-debounce failed" error which seems to be related. I wanted to ask whether you could try another USB port, but the HC4 has one only 😄. Could you try booting from SD card again, connect the USB drive (no need to mount), and run Also the kernel is on latest version, right? Should be uname -r |
Ah "edge" kernel package then. However, should work regardless. From the initramfs prompt, can you show the output of these commands: cat /proc/cmdline
ls /dev/disk/by-uuid/
Indeed I also expected that. Instead of the USB error, now there is one related to SD card:
Then I guess something with the boot config is the problem. Probably the setenv bootargs "root=${rootdev} rootfstype=${rootfstype} rootwait ${consoleargs} loglevel=${verbosity} consoleblank=0 coherent_pool=2M usb-storage.quirks=${usbstoragequirks} ${extraargs} ${variant}" and compile it again: mkimage -C none -A arm64 -T script -d /boot/boot.cmd /boot/boot.scr and from initramfs or also when it boots from SD card: cat /proc/cmdline |
You did run the |
Did, input works on petitboot shell but not in initramfs shell. Strange, and bad. Okay this was only to fine out whether the In fdtfile=amlogic/meson-sm1-odroid-hc4.dtb If this does not work I think we need to wait for some more feedback to know whether this affects all HC4 systems. I hope the HC4 petitboot is not somehow very different from the N2 one. EDIT: Just in case: With MASKROM button and SD card it does boot, right? |
Nothing same output, after making those changes I made:
Yes, if I press the button at the botom it does boot PD.: Is it safe is I update to 8.14.2? |
Only needed when doing changes to
We wouldn't have released it if we wouldn't think that 😃. Okay I'm sadly out of ideas for now what the problem is. It is as if some kernel driver is missing to allow the initramfs detecting the SSD (via UUID), but the same for SD card (when booting via petitboot). But since the same kernel, initramfs and device tree are loaded for sure, I've not idea what is different. Sadly we cannot check the cmdline, as long as input at the initramfs console does not work. And since petitboot is suppressing any U-Boot output we can also not just echo it to the console. Ah, but what may fix it in your case, if using UUIDs here is the problem, not the device drivers themselves:
|
At least we see again that the script and config is used and respected, as now it shows |
@colafloat25 Also assure to have latest petitboot, and while obviously first boot stages work, please loop through petitboot settings, assure that "any device" is enabled as boot device. And test with all USB ports and a different PSU and/or cable if you have them. Since it works very well here on my Odroid N2+, the only other left difference I can think of is the PCB version. Mine is |
I used the fresh one and I just install the image directly to external SSD ( No Micro-SD or eMMC ) and I did pb-update before I plugin the external ssd and I got the screen like @amibumping |
It seems to mostly work now, with some more changes done (incorporated above). It is not 100% reliable, even normal MMC mode boot from some SD card variants, but it's best we can currently do and definitely an improvement to before. Marking this as closed. Individual problems can be tracked in dedicated issues. |
Creating a bug report/issue
Required Information
G_DIETPI_VERSION_CORE=8
G_DIETPI_VERSION_SUB=6
G_DIETPI_VERSION_RC=1
G_GITBRANCH='master'
G_GITOWNER='MichaIng'
G_LIVE_PATCH_STATUS[0]='applied'
G_LIVE_PATCH_STATUS[1]='applied'
Linux DietPi 5.10.123-meson64 #22.05.3 SMP PREEMPT Wed Jun 22 07:23:04 utc 2022 aarch64 GNU/Linux
Additional Information (if applicable)
<-- If you sent a "dietpi-bugreport", please paste the ID here -->
echo $G_HW_UUID
Steps to reproduce
I just bought Odroid N2+ and I am trying all kinds of way to try to boot dietpi from SSD only without SD or eMMC. I managed to boot from SSD when in Petitboot editor by editing the following boot options for the SSD partition:
The problem is these parameters can only work one time. I have to modify the Petitboot every time when it boot up. Is there any way or option to get the correct parameters from the boot.scr or save these options in Petitboot without using SD or eMMC?
Thank
I read that dietpi does not support direct booting from SSD for Odroid N2+ but i hope this issue can be resolved easily.
Actual behaviour
Extra details
The text was updated successfully, but these errors were encountered: