RTEMS | bsps/arm/stm32f4: Make printk() independent of the console driver. (!1518)
Catalin Miron (@catalin)
gitlab at rtems.org
Wed Sep 30 16:25:38 UTC 2026
Catalin Miron created a merge request: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1518
Project:Branches: catalin/rtems:stm32f4_bsp_fix to rtems/rtos/rtems:main
Author: Catalin Miron
## Summary
BSP_output_char used Console_Port_Tbl, which is only allocated by the legacy console_initialization(). With the simple console driver (e.g testsuites/samples/hello) or for any printk() before device driver initialization this resulted in a NULL pointer dereference. The USART was also never initialized in this case.
Fall back to Console_Configuration_Ports while Console_Port_Tbl is not yet set up. Initialize the console USART in a BSP_START system initialization handler and laizly on the first character. Provide BSP_poll_char for getchark().
Disabled STM32F4_ENABLE_USART_3 by default because not all stm32f4 boards have this port. Added PORT_COUNT \> 0 guards in case no USART is configured in config.ini.
Tested on STM32F411RE Nucleo board by running hello.exe
## AI Details
<!--Make sure you have read our statement at https://www.rtems.org/generative-ai/-->
### Prompt used
Not a single prompt, it was an iterative process.
### AI model used
Claude Opus 5.5
### How AI was used for the contribution
- [x] Formatting
- [ ] Test creation.
- [x] Code comments.
- [ ] The entire contribution was generated using AI
- [ ] AI code completion such as Copilot in VSCode.
If others were used please add below
The source of the crash was found by me with gdb, then I asked Calude for a fix, then I suggested changes to that solution.
### Access
I have not used a product which claims copyright in its output, and I have legitimate access to the one I used.
<!--Default settings, if it is a dropdown it will set after submission-->
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1518
You're receiving this email because of your account on gitlab.rtems.org. Unsubscribe from this thread: https://gitlab.rtems.org/-/namespace/49/sent_notifications/5-54u2fn4i6yhth0t34u8tnzggc-1d/unsubscribe | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | Help: https://gitlab.rtems.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260930/405fb8dc/attachment-0001.htm>
More information about the bugs
mailing list