com(4) and UEFI bootloader

NetBSD has an option to redirect console to the serial device in the boot(8) selector program and it works pretty well with the BIOS bootloader. After switching to interactive mode, one can simply type consdev com0 and console immediately switches to serial output (with default config of 9600 8N1). It is possible to change the speed by adding one after comma, for example, consdev com0,115200. Same command can be added to boot.cfg, if permanent serial output is required.

uefiboot, however, has some peculiarities. First of all, using device index doesn’t seem to work, thus specifying com0 or com1 doesn’t end up in serial output. The second issue is related to the fact that even if configuration is correct, console is not redirected immediately at boot selector application. Additionally, consdev command still reprints the banner in the screen contributing to more confusion and gives initial impression of broken functionality, especially if being used to BIOS bootloader functionality. I believe second issue is a bug, unless there are some technical limitations. Nevertheless, the console redirection to serial device still works right after the boot process starts, if serial device address is used instead of index in consdev command. Format is consdev com,addr,speed (please, take attention to no specific index while writing com). There are several ways to find the address of the serial device. I am usually retrieving it from dmesg(8) messages, for example dmesg |grep com0 should show something like com0 at acpi0 (UAR1, PNP0501-0): io 0x3f8-0x3ff irq 4 where 0x3f8 is the address required. This info quite often can be found in some BIOS options too. Typically com0 is a 0x3f8, thus consdev com,0x3f8,115200 command would properly redirect console to serial device as soon as boot starts.

It took me a bit of time to figure that out by reading documentation and some experimentation, later I also found the same recommendation in the mailing lists, but since UEFI boot is common these days, hopefully this info can save someones time and it is a good reminder for myself.