Re: More serial ports in EFI bootstrap?

Emmanuel Dreyfus <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
On Fri, May 16, 2025 at 07:39:31AM +0000, Emmanuel Dreyfus wrote:
> I have a Dell server with no serial port, and a serial console is highly
> desirable for system administration. I wonder if EFI bootstrap could
> be modified to use a serial port from a PCIe to serial card, or from a
> USB to serial adapter.

Replying to myself to tell some succes.

The UEFI bootstrap uses UEFI for serial I/O, hence we need UEFI to 
have a driver for the serial port in order to use it in NetBSD EFI
bootstrap.

There is such a driver for a unique USB-to-serial chip (VendorID
0x0403, productId 0x6001). The FtdiUsbSerialDxe driver can be (painfully)
built from Tianocore/EDK2. The instruction are here. I only built
OvmfPkg:
https://github.com/tianocore/edk2-platforms

Once done, I have:
Build/OvmfX64/DEBUG_GCC/X64/Shell.efi
Build/OptionRomPkg/DEBUG_GCC/X64/FtdiUsbSerialDxe.efi

Shell.efi goes in EFI/boot on the EFI partition. FtdiUsbSerialDxe.efi
goes wherever you want, for instance in EFI/EDK2
Next, I tell the machine to boot from file using EFI/boot/Shell.efi
In the UEFI shell I type:
FS0:
load \EFI\EDK2\FtdiUsbSerialDxe.efi

That causes a new serial port to be reported by the sermode command
in the UEFI shell. I should be able to connect it to the UEFI console, 
but I got no success here. By typing bootx64.efi I exit the UEFI
shell and load the NetBSD EFI bootstrap (the setps in UEFI shell 
can be made automatic using /EFI/boot/startup.nsh)

The NetBSD EFI bootstrap looks up devices implementing the SerialIO
protocol, and then filters out anything not on an EISA bus. I removed
that filtering:
--- eficons.c   14 Sep 2023 03:05:15 -0000      1.14
+++ eficons.c   4 Jun 2025 06:59:24 -0000
@@ -819,9 +819,13 @@

                        if (DevicePathType(dp) == ACPI_DEVICE_PATH &&
                            DevicePathSubType(dp) == ACPI_DP) {
                                dpp = (EFI_DEV_PATH_PTR)dp;
+#if 0
                                if (dpp.Acpi->HID == EISA_PNP_ID(0x0501)) {
+#else
+                               {
+#endif
                                        uid = dpp.Acpi->UID;
                                        break;
                                }
                        }

consdev now show only "pc com0" while the unpatched boostrap
did show "pc com0 com1". But this single com0 is the right one. 
If I type consdev com0, I get a working serial console at 9600 bps.

This is great, but the next step is booting the kernel. It does not
support the console on the USB-to-serial adapter and I boot to 
multiuser without a console.

Hence the new question is: do we have any hope of using a USB-to-serial
adapter for kernel console? I have not looked at it yet, but I understand
there will be the issue that the USB-to-serial adapter cannot work 
before a lot of devices initialization. It would be nice to have it 
working for single-user mode, and that should be possible.

-- 
Emmanuel Dreyfus
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.