[riot-notifications] [RIOT-OS/RIOT] boot: Moved stdio_init() into periph_init() (#10806)

Marian Buschsieweke notifications at github.com
Tue Mar 26 11:47:11 CET 2019


maribu commented on this pull request.



>  void periph_init(void)
 {
+    /* initialize stdio first to allow DEBUG() during later stages */
+#ifdef CPU_NATIVE

One general remark: It is very rarely seen that someone jumps in at the very end of a process and after a lot of work has been done and asks for dropping core concepts of this process. For good reason. Also a lot of people [tend to get very upset](https://mailarchive.ietf.org/arch/msg/tls/CzjJB1g0uFypY8UDdr6P9SCQBqA) about such things.

That said, the idea of this PR is to assure that stdio is available when the periphs are initialized, so that using `DEBUG()` there is a save thing to do. This solves a real [issue](https://github.com/RIOT-OS/RIOT/issues/10645), as people starting to `ENABLE_DEBUG` in periph initialization would like to debug that periph code and don't want to think about why the debug output does not appear in the console or even crashes the board.

By having the stdio initialization here centralized, it is enforced that `DEBUG()` is safe to do in periph initialization. If it is up to the board/cpu, inconsistent behavior can easily sneak back it. So this idea about making RIOT *less* hardware dependent.

How about this instead:

``` C
#ifndef HAVE_ARCH_STDIO_INIT
static inline void arch_stdio_init(void)
{
    stdio_init();
}
#endif

void periph_init(void)
{
#if defined(MODULE_STDIO_UART) || defined(MODULE_STDIO_RTT)
    arch_stdio_init();
#endif
    ....
}
```

This would allow to provide a architecture specific `void arch_stdio_init()` if needed and handle the hardware specific stuff there.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10806#discussion_r269039729
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190326/38044636/attachment.html>


More information about the notifications mailing list