help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Grub2 UEFI boot and serial console output


From: Matwey V. Kornilov
Subject: Re: Grub2 UEFI boot and serial console output
Date: Mon, 16 Jan 2017 11:36:29 +0300

2017-01-16 11:29 GMT+03:00 Matwey V. Kornilov <address@hidden>:
> 2017-01-14 10:55 GMT+03:00 Andrei Borzenkov <address@hidden>:
>> 13.01.2017 19:40, Matwey V. Kornilov пишет:
>>> 2017-01-13 16:44 GMT+03:00 Andrei Borzenkov <address@hidden>:
>>>> 13.01.2017 12:03, Matwey V. Kornilov пишет:
>>>>> 2017-01-11 20:16 GMT+03:00 Andrei Borzenkov <address@hidden>:
>>>>>> 11.01.2017 19:55, Matwey V. Kornilov пишет:
>>>>>>> 2017-01-11 19:45 GMT+03:00 Andrei Borzenkov <address@hidden>:
>>>>>>>> 11.01.2017 16:27, Matwey V. Kornilov пишет:
>>>>>>>>> Hello,
>>>>>>>>>
>>>>>>>>> What is the proper way to output GRUB2 menu to serial rs232 console 
>>>>>>>>> when
>>>>>>>>> UEFI boot is used? I've copy-pasted GRUB_SERIAL_COMMAND="serial 
>>>>>>>>> --unit=0
>>>>>>>>> --speed=115200" from Google because I didn't find anything else. It
>>>>>>>>> doesn't work.
>>>>>>>>> Now, reading grub sources, I see that the proper way should probably 
>>>>>>>>> be
>>>>>>>>> something like GRUB_SERIAL_COMMAND="serial efi0".
>>>>>>>>>
>>>>>>>>
>>>>>>>> This is platform dependent. --unit=0 refers to COM1 on PC BIOS 
>>>>>>>> platform.
>>>>>>>> On EFI grub is using EFI Serial I/O Protocol and enumerates all handles
>>>>>>>> with this protocol using efiXX names. Then there is USB serial driver,
>>>>>>>> ARC and IEEE1275 where names are provided by firmware etc.
>>>>>>>
>>>>>>> I just can't understand, term/serial.c: grub_cmd_serial() sets name to
>>>>>>> "com%ld" using --unit=value on any platform.
>>>>>>>
>>>>>>>   if (state[OPTION_UNIT].set)
>>>>>>>     {
>>>>>>>       grub_snprintf (pname, sizeof (pname), "com%ld",
>>>>>>>                      grub_strtoul (state[0].arg, 0, 0));
>>>>>>>       name = pname;
>>>>>>>    }
>>>>>>>
>>>>>>> Then this "com0" is put to grub_serial_find(name) call. The question
>>>>>>> is how this is going to match with "efi0"?
>>>>>>
>>>>>> It is not.
>>>>>>
>>>>>>> Please correct me, if I am wrong.
>>>>>>>
>>>>>>
>>>>>> Again - "--unit=0" is simply alias for "com0". Whether device with name
>>>>>> "com0" actually exists depends on platform and loaded drivers.
>>>>>>
>>>>>> This alias makes no sense on platform that does not include ns8250
>>>>>> driver that provides access to device with name "com0". You can check
>>>>>> grub-core/Makefile.core.def which platforms include this driver.
>>>>>>
>>>>>> So on EFI you are not going to use --unit=0 (or you need to add some
>>>>>> platform-dependent magic to translate --unit=0 into platform device).
>>>>>>
>>>>>> And yes, this could use better documentation, both for "serial" command
>>>>>> and "Serial terminal" section.
>>>>>
>>>>> Thank you.
>>>>> "serial --speed=115200 efi0" also doesn't work.
>>>>
>>>> Please define "does not work". What you expect it to do and how you
>>>> verify it?
>>>>
>>>
>>> I expect that it will show grub menu on serial port where I wait for
>>> it. I believe that the port itself is working because I see linux
>>> kernel console output redirected to serial after grub timeout.
>>>
>>>>> It seems that there is no Serial IO protocol in my Insyde UEFI.
>>>>>
>>
>> You can verify it by loading EFI Shell, and looking in devtree output
>
> It says
>
> Ctrl[186] PciRoot(0x0)/Pci(0x1F,0x0)/Serial(0x0)/Uart(115200,8,N,1)
>   Ctrl[187] PC-ANSI Serial Console
>
>> for something like "ISA Serial Port" or similar. You can also list all
>> handles with bound Serial IO protocol using
>>
>> dh -p SerialIO
>>
>
> Handle dump by protocol 'SerialIO'
>  186: DevPath (..rial(0x0)/Uart(115200,8,N,1))SerialIO
>  188: DevPath (..rial(0x0)/Uart(115200,8,N,1))SerialIO
>
>>
>>>>
>>>> What is output of "terminal_input" and "terminal_output"?
>>>>
>>>>
>>>
>>> serial --speed=115200 efi0
>>> terminal_input serial
>>> terminal_output serial
>>>
>>
>> Well, it is messy indeed. First, I was wrong, and ns8250 driver is
>> compiled on EFI x86 platforms. Do you have x86 or ARM system?
>>
>> Second, terminal names to use with "terminal_input" and
>> "terminal_output" are "serial_efi0" for port "efi0". Do you get any
>> error from the commands you listed?
>>
>> Third, "serial" is alias to the first used ns8250 port. So
>>
>> serial --unit=0
>> terminal_input serial
>>
>> *will* work because the first command makes "serial" alias for
>> "serial_com0". But your commands will *not* work because they configure
>> port "efi0" but attempt to use port "com0" instead. May be we should
>> extend handling and make "serial" consistently to be alias for the first
>> used port, so the above sequence would work on each platform.
>>
>> Finally I am not whether we should support direct hardware access with
>> ns8250 on EFI at all.
>>
>> Here is what I get on x86 OVMF.
>>
>>
>> grub> lsmod
>> Name    Ref Count       Dependencies
>> minicmd 1
>> normal  1               gettext,boot,extcmd,bufio,crypto,terminal
>> gzio    0
>> gettext 2
>> extcmd  2
>> crypto  2
>> terminal        2
>> tar     1               archelp
>> archelp 2
>> memdisk 1
>> efinet  1               net
>> net     2               boot,datetime,bufio,priority_queue
>> priority_queue  3
>> bufio   5
>> datetime        3
>> boot    5
>> grub> terminal_input
>> Active input terminals:
>> console
>> Available input terminals:
>> serial_* serial at_keyboard
>> grub> serial --speed=115200 efi0
>> grub> lsmod
>> Name    Ref Count       Dependencies
>> serial  1               terminfo,extcmd
>> terminfo        2               extcmd
>> minicmd 1
>> normal  1               gettext,boot,extcmd,bufio,crypto,terminal
>> gzio    0
>> gettext 2
>> extcmd  7
>> crypto  2
>> terminal        2
>> tar     1               archelp
>> archelp 2
>> memdisk 1
>> efinet  1               net
>> net     2               boot,datetime,bufio,priority_queue
>> priority_queue  3
>> bufio   5
>> datetime        3
>> boot    5
>> grub> terminal_input
>> Active input terminals:
>> console
>> Available input terminals:
>> serial_efi0 serial_com0 serial at_keyboard
>> grub> terminal_output
>> Active output terminals:
>> console
>> Available output terminals:
>> serial_efi0 serial_com0 spkmodem serial gfxterm cbmemc audio
>> grub> serial --unit=0 --speed=115200
>> grub> serial --unit=1 --speed=115200
>> error: serial port `com1' isn't found.
>>
>> Note, I am not sure whether use "serial_com0" will actually work, as it
>> obviously competes with EFI for hardware access so result may be
>> unpredictable.
>
> I think here is my issue:
>
> terminal_input says that 'console' is active terminal and no other
> terminals available.
>
> serial --speed=115200 efi0 says "can't find command `serial'"
>

Ok, now I see! There is file /boot/grub2/x86_64-efi/serial.mod but
isnmod serial says that there is no such file.



-- 
With best regards,
Matwey V. Kornilov
http://blog.matwey.name
xmpp://address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]