Re: different console settings for loader[.efi] and kernel

From: Andriy Gapon <avg_at_FreeBSD.org>
Date: Wed, 17 Aug 2022 13:59:25 UTC
On 2022-08-16 19:52, Warner Losh wrote:
> 
> 
> On Tue, Aug 16, 2022 at 12:52 AM Andriy Gapon <avg@freebsd.org 
> <mailto:avg@freebsd.org>> wrote:
> 
> 
>     It seems that console variable in loader.conf affects both the
>     OS/kernel
>     and the loader itself.  Is there a way to have different console
>     settings between those?
> 
> 
> Yes.
> 
>     Let me explain.  I have a system that I access in several different
>     ways: via its physical serial console, via IPMI / iKVM, and sometimes
>     via its physical video console.
>     console is set to "comconsole, efi".
>     The system uses EFI boot.
>     The BIOS is configured to "redirect" video console to serial and to
>     stop
>     the redirection once an OS starts.
> 
>     The setup works fine before the loader (e.g., for entering BIOS
>     settings) and it works fine once the kernel starts.
>     But while in the loader, every character printed gets doubled on the
>     serial console.  I guess that this is because the loader prints it to
>     both the serial output and the EFI output while the BIOS still
>     redirects
>     the EFI output to the serial.
> 
> 
> Yes. You've told it to have two consoles, and when they are the same 
> hardware
> you'll get that doubling.

Yup.

> 
>     I would like to solve that double printing while keeping both the
>     serial
>     console and the video / EFI console usable.
> 
> 
> Double printing is trivial to fix: Don't add 'comconsole' to the 
> consoles. EFI loader
> uses the generic console facilities. So when it's doing redirect, just 
> set it to EFI.

The reason I added comconsole was that I did not know of any other way 
to instruct the kernel to use the serial console.

> 
>     So, one way would be for the loader to use only the EFI console and let
>     the BIOS redirect take care of the serial.
> 
> 
> console=efi does exactly that on my systems.
> 
>     I guess that another way would be for the loader to announce itself as
>     an "OS" (whatever that technically means), so that the BIOS stops its
>     redirection.
> 
> 
> Now, having said that, there's one issue with EFI. EFI specifies the UID
> which the boot loader can't decode into an address, and the current kernel
> doesn't verify the address is correct, nor can it use this UID to do cninit
> (because ACPI isn't brought up enough to find the address yet). In those 
> cases,
> you'll need to use an additional environment variable from the loader:
> 
> hw.uart.console="io:1016,br:115200"
> 
> this sets the port to 0x3f8 for the kernel, but the loader won't do 
> anything with it.
> The kernel will.

Thank you very much!  This is exactly what I was looking for.


-- 
Andriy Gapon


https://standforukraine.com
https://razomforukraine.org