PINE64
Booting - User device selection in U-Boot? - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: Pinebook Pro (https://forum.pine64.org/forumdisplay.php?fid=111)
+--- Forum: General Discussion on Pinebook Pro (https://forum.pine64.org/forumdisplay.php?fid=112)
+--- Thread: Booting - User device selection in U-Boot? (/showthread.php?tid=9872)

Pages: 1 2


Booting - User device selection in U-Boot? - Arwen - 05-16-2020

One of the issues that comes up is that we can't easily select what device to boot during startup.
U-Boot does not have that option for us, yet. During testing, I've had to remove and insert the
MicroSD card far too many times. It would be nice if I could leave it installed and force booting
something else.


So, how about something like this?

U-Boot selectable device target:
        - Pause & blink LED, (which one?), for a short time, (5 seconds?)
        - During this time, accept keyboard input
        - Select boot device of:
                - eMMC, (number 1?)
                - MicroSD card, (number 2?)
        - Timeout default using current scheme, MicroSD if installed, eMMC otherwise.

The exact keys for which devices are not really important. And if NVMe or USB booting works fine
then those could be added as well. Plus, allow changing the default boot order at install time, (so
people with NVMes could be a priority over eMMC).

Plus, perhaps having the ESC and Enter keys immediately jump to the default action. So a way to
skip the pause.

As time goes one, perhaps we can add a primitive text menu on the screen.


At present, this idea does not care where U-Boot is installed, (SPI, eMMC, MicroSD card). For
testing, it probably easiest to have it on a eMMC or MicroSD card. This idea is to address which
device we use for "/boot".

So, what does anyone else think?

Perhaps someone has a better idea?

Does using Grub as a target allow boot chaining?
(Meaning a grub menu entry can say go to another device.)


RE: Booting - User device selection in U-Boot? - shawnanastasio - 05-16-2020

I think the petitboot bootloader (also used on some POWER systems) would be a good fit here: https://github.com/open-power/petitboot.

It's a small linux program that scans all connected drives for grub, syslinux, etc. boot configurations and presents them in an ncurses TUI. It uses the kernel's kexec facility to boot the selected OS, so it should work OOTB on arm64.


RE: Booting - User device selection in U-Boot? - khanku - 06-08-2020

(05-16-2020, 01:44 PM)Arwen Wrote: U-Boot selectable device target:
        - Pause & blink LED, (which one?), for a short time, (5 seconds?)
        - During this time, accept keyboard input
        - Select boot device of:
                - eMMC, (number 1?)
                - MicroSD card, (number 2?)
        - Timeout default using current scheme, MicroSD if installed, eMMC otherwise.

This reminds me of how Qi used to work on OpenMoko phones. While not quite convenient it was functional and would certainly be an improvement on the current u-boot situation on the pinebook pro.


RE: Booting - User device selection in U-Boot? - xmixahlx - 06-08-2020

using the uboot priority mapped to numbers would be great. usb, sd, nvme, emmc = 1 2 3 4 etc.

selectable ala grub would be useful for multiple installed kernels on a single device. most usable for testing.

either would be a huge improvement.


RE: Booting - User device selection in U-Boot? - Arwen - 06-08-2020

Yes, either Grub with menu, or the simple U-Boot device selection would work.
People doing testing could then select which OS to boot. If it fails, no problem,
just reboot and select the working OS and make a change to the one under
test. Then try again.

At present, I don't see Grub getting both text menu, (on the LCD), and keyboard
support, (also the PBP keyboard, not serial console), any time soon. Grub seems
to support such for x86/x64, but that is likely through BIOS calls that don't exist
for any ARM computer.

Thinking about it, I've added ESC & Return keys to the original post, to do the
obvious thing.


RE: Booting - User device selection in U-Boot? - amiraeva - 06-08-2020

(06-08-2020, 09:55 AM)Arwen Wrote: Yes, either Grub with menu, or the simple U-Boot device selection would work.
People doing testing could then select which OS to boot. If it fails, no problem,
just reboot and select the working OS and make a change to the one under
test. Then try again.

At present, I don't see Grub getting both text menu, (on the LCD), and keyboard
support, (also the PBP keyboard, not serial console), any time soon. Grub seems
to support such for x86/x64, but that is likely through BIOS calls that don't exist
for any ARM computer.

Thinking about it, I've added ESC & Return keys to the original post, to do the
obvious thing.

I got the PBP keyboard to work with u-boot and grub (using the arm64-efi target). It's as simple as adding a few flags when compiling u-boot to instruct it to enable the necessary USB support, and having "usb start" as part of the boot script (note this does slow down the boot by a second or two). Unfortunately the menu only displays over a serial console since u-boot doesn't know how to initialize LCD.

If anyone has any pointers on how to port the LCD/eDP drivers that linux uses to u-boot I'd love to hear it. The code for both are sooo similar, and unfortunately I wasn't smart enough to figure out the right combination of edits to the u-boot code to make it work (can only make the screen briefly flicker).


RE: Booting - User device selection in U-Boot? - xyzzy - 11-18-2020

All these things you propose can and have be done with u-boot.  For some reason the pinebook pro has an barely functional u-boot with no features.

U-boot has a console, where it's possible to boot specific kernels with custom command lines, mount file systems, copy files between devices, do basic networking like DHCP, ping, tftp load files and mount network drives with NFS.

It can use USB device mode to make the eMMC appear as a flash drive to a host computer connected to the USB port.  Really handy way to repair an eMMC that won't boot, compared to needing to open the pbp up and remove the eMMC module!

You can create scripts to do certain things, e.g. "boot-emmc", "boot-sd", "boot-sdkernel-emmcroot".

There is a menu system that can list boot options and allows selecting one.

It's possible to create an automatic fallback system.  If a kernel fails to boot a certain number of times in a row, then an alternate kernel will be used.  Something run in Linux marks a boot as good when it's reached some point considered good enough, like systemd has finished entering multi-user.target.  Every embedded Linux product I've designed has had something like this.

But the u-boot on the PBP doesn't even have keyboard or fb support, so one can't even seen an error message if it doesn't boot, much less any of the above.


RE: Booting - User device selection in U-Boot? - ALBNC1974 - 11-19-2020

https://forum.pine64.org/showthread.php?tid=10694


RE: Booting - User device selection in U-Boot? - Arwen - 11-20-2020

I am going to mark this as solved,. Not that all, (or most), distro use U-Boot with the enhancements of display, keyboard and NVMe support. But, it's in progress in the thread that @ALBNC1974 referenced.


RE: Booting - User device selection in U-Boot? - xyzzy - 11-20-2020

Doesn't seem like much has been done yet to improve the u-boot boot scripts. Being able to use the u-boot console without a serial adapter is a good start. Still lacking stuff like the ability to automatically recover after installing a kernel that doesn't boot or select from usb, sd, emmc, nvme for the OS to boot.