How early can I send data to a serial port on Linux boot?

530 views Asked by At

I have an external serial peripheral that needs to be setup on Linux boot, on an embedded system. What I need is sending a short configuration string as early as possible during system boot, so my procedure is simply

  • Set port to 115200 bps
  • Send a string, like "ABCDE\r\n"

I see that recent kernels support an early-on serial console, but what I need is not a console (my peripheral can also send meaningless data in that phase, plus I'll be showing a splash screen in graphic mode), just a fast initialization for the the peripheral.

How can it be done?

1

There are 1 answers

1
BalaC On

The answer to this will be subjective depending on what you mean by as early as possible. I will provide few possibilities I am aware of which might help you

  • In case your embedded platform uses any form of bootloader (ex: U-Boot) then you can do the serial(UART) initialization as part of the bootloader (Usually this will be done for the target platform alone so that we can see how far the boot is happening). You can try initializing your external serial peripheral in bootloader itself. As bootloader will execute before the linux kernel gets loaded you can achieve this easily.

  • If your platform doesn't use any form of bootloader then the possibility of initializing the external serial peripheral is via kernel driver (or) system init process.

I have been using PSplash program which uses the basic frame buffer driver for the boot progress. If interested check the following repo

PSplash