Printf UART usage issues

Joel Sherrill joel at
Tue Apr 25 23:25:16 UTC 2017

As you suspect, you should not use printf() before the open on /dev/console
that actually opens stdin, out, and error. Before that point, you can use
printk() but on some BSPs, that doesn't work until the console
method is invoked. I suspect it will work on the Leon2 if you have grmon
since you can rely on that initialization.

You also should not invoke printf() from interrupt handlers.

If the console device is polled on this BSP (and in this configuration since
it is often a BSP option), then it could be periodically filling out the
TX buffer on the UART and then hanging until all the output is gone.
I don't know the buffer depth on the UART. But short prints at the
right rate could go into the TX buffer and out without  you


On Tue, Apr 25, 2017 at 2:34 AM, Chris Coppens <
Chris.Coppens at> wrote:

> Hello,
> I am developing an RTEMS 4.11 driver. The environment we are using is a
> LEON2 CPU with GRMON debug tool connected to UART debug link.
> We load the driver, by defining it in a “system.h” file that includes
> “confdefs.h”. System configuration looks like this:
>> // our driver:
> #define CONFIGURE_EXECUTIVE_RAM_SIZE    (64*1024*1024)
> #define CONFIGURE_STACK_SPACE_SIZE      (1024*1024)
> #define CONFIGURE_MAXIMUM_TASKS             5
> #include <rtems/confdefs.h>
> We do many printf’s, both in Driver initialize context(thread), but also
> in Application tasks. We did not change the console driver configuration,
> so I’m guessing the console driver in “Polled mode” (correct me if I'm
> wrong).  The printf’s we are doing during driver initialization we are not
> seeing. Probably because I read that the /dev/console file is created after
> loading all drivers (post_bsp hook).
> The problem we are encountering is that sometimes during printf the UART
> (debug) communication link seems to fail and the application does not
> respond anymore. Has someone else had issues using printf from different
> contexts? Are there any guidelines for the point in time when we can
> actually start using printf? Any idea what may be the issue with the UART
> stability using printfs?
> Thanks for any help.
> Kind regards,
> Chris
> Kind regards,
> Chris Coppens
> Software Designer
> TOPIC Products
> Materiaalweg 4, NL-5681 RJ Best
> Postbus 440, NL-5680 AK Best
> Telefoon: +31 (0) 499 33 69 79
> E-mail: Chris.Coppens at
> Website:
> Please consider the environment before printing this e-mail
> _______________________________________________
> users mailing list
> users at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the users mailing list