Booting - User device selection in U-Boot?
#1
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.)
--
Arwen Evenstar
Princess of Rivendale
#2
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.
#3
(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.
#4
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.
#5
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.
--
Arwen Evenstar
Princess of Rivendale
#6
(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).
#7
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.
#8
https://forum.pine64.org/showthread.php?tid=10694
#9
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.
--
Arwen Evenstar
Princess of Rivendale
#10
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.


Possibly Related Threads…
Thread Author Replies Views Last Post
  Manjaro KDE dolphin not showing usb device straightwalker 0 53 07-30-2021, 09:51 AM
Last Post: straightwalker
  U-Boot, video console, and visual artifacts dsimic 15 1,356 07-28-2021, 09:37 AM
Last Post: dsimic
  boot order straightwalker 6 356 07-22-2021, 12:31 AM
Last Post: wdt
  My pbp is a sleek, black, flat brick, and won't boot from any kind of media rotwang 14 1,471 07-19-2021, 06:30 PM
Last Post: rotwang
Tongue Hello my frend. How to fix my boot problem? carinosa 6 445 07-04-2021, 04:01 AM
Last Post: jiyong
  U-Boot with direct NVMe boot support for eMMC/SPI Flash pcm720 119 103,912 06-24-2021, 11:59 AM
Last Post: sepp
  cannot boot SD card : "unable to select a mode" alchemist 0 215 06-18-2021, 02:03 AM
Last Post: alchemist
  Pinebook Boot CharlesBunders 14 2,435 06-15-2021, 07:40 PM
Last Post: James Good
  PBP won't boot alchemist 5 718 06-07-2021, 09:31 AM
Last Post: alchemist
Video Problem Booting from SD card ezryder324r 0 247 05-19-2021, 02:42 PM
Last Post: ezryder324r

Forum Jump:


Users browsing this thread: 1 Guest(s)