[U-Boot] [PATCH 5/6] serial: ns16550: fix debug uart putc called before init

Marek Vasut marex at denx.de
Tue Oct 23 09:00:50 UTC 2018


On 10/19/2018 05:25 AM, Simon Glass wrote:
> On 9 August 2018 at 13:04, Simon Goldschmidt
> <simon.k.r.goldschmidt at gmail.com> wrote:
>> If _debug_uart_putc() is called before _debug_uart_init(), the
>> ns16550 debug uart driver hangs in a tight loop waiting for the
>> tx FIFO to get empty.
>>
>> As this can happen via a printf sneaking in before the port calls
>> debug_uart_init(), let's rather ignore characters before the debug
>> uart is initialized.
>>
>> This is done by reading the baudrate divisor and aborting if is zero.
>>
>> Tested on socfpga_cyclone5_socrates.
>>
>> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>
>> ---
>> v2:
>>  - this patch is new in v2 of the series. It replaces the printf/debug
>>   change in reset_manager_gen5.c from v1
>>
>>  drivers/serial/ns16550.c | 18 ++++++++++++++++--
>>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> We cannot use global_data before it is set up, so I think this is the
> best solution.
> 
> Acked-by: Simon Glass <sjg at chromium.org>

So there's no GD available when using debug uart ? Hum.

btw. Does the NS16550_read_baud_divisor() need to be called within the
while loop ?

-- 
Best regards,
Marek Vasut


More information about the U-Boot mailing list