2

I want to interact with GRUB through a usb-to-serial converter.

I was able to achieve this on my laptop by using this list of commands in grub's cli:

insmod nativedisk #to not loose drive information after insmod *hci
nativedisk ahci
insmod ehci
insmod ohci
insmod uhci
insmod usbserial_ftdi # I use an ftdi usb to serial adapter
terminal_output --append serial_usb0
terminal_input --append serial_usb0

The same procedure did not work on my desktop pc, the problem being that grub looses drives information after doing insmod ehci, meaning that an ls after that returns no disk, and thus all the next commands fail, nothing can be done anymore and I have to reboot.

This problem was fixed on my SATA-based laptop as shown above by using nativedisk ahci, this command doesn't work on the desktop pc because it uses NVMe (pcie) drives, and the ahci module is for SATA drives.

The GRUB's docs page of nativedisk doesn't list any parameter that can be used, and looking in the source code I see a few parameters for nativedisk, which unfortunately don't fix my problem.

So my question is, why does GRUB loose drives information when insmoding the various *hci modules? How do I prevent/work around this?

1 Answer 1

2
+50

Without nativedisk, GRUB will be relying on the firmware's list of disks. A system that supports booting from NVMe most likely has UEFI firmware, and that means it has built-in support for USB.

When GRUB loads its USB drivers, it will be taking over control of the USB from the firmware - and the firmware might be smart enough to realize it means its list of storage devices might become invalid as a result. So it's a firmware implementation trait, which makes it tricky to work around.

The UEFI shell has a map -r command, which indicates UEFI understands the concept of "re-scan the storage devices using the drivers you currently have active", but apparently GRUB does not currently invoke that after taking over the USB bus access. If you are using a UEFI version of GRUB, it might be relatively easy to add support for that by adding one more UEFI service call; but if you are using the classic i386-pc version, I'm not sure a suitable BIOS call exists.

I'm actually rather surprised that the ehci USB driver works for you; I'd expected systems with NVMe boot support to have a XHCI USB controller.

2
  • Do I understand you correctly that it is impossible without changing Grub since it can neither access the NVMe with nativedisk, nor it has proper xhci support?
    – koalo
    Commented Jun 22, 2023 at 7:27
  • @koalo Yes, best case. Worst case would be if a UEFI firmware bugfix is also needed. (GRUB is open source, so you can change it yourself, or find someone to change it for you. Firmware is proprietary, so you'd have to convince the appropriate vendor that your issue is important enough to fix - and they can just say "no, the issue is not important enough to spend time on".)
    – telcoM
    Commented Jun 22, 2023 at 12:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .