armembeddedstm32f4bsprtems

RTEMS STM32F4 how to use BSP


I’m very new to RTEMS. I think to have successfully built RTEMS to run on the STM32F4. I’ve tried the LED blinking example (trough timer) contained in the examples folder (here: https://github.com/RTEMS/examples-v2/tree/master/led).

I have compiled and flashed it on my board and the led blinked, so I think to have a good setup. Unfortunatly there not exist so much examples about "how to use Board Support Packages (BSP)" in order to program hardware related features.

I want to go further and I would like to use USART in order to have a console useful for debugging and learning. I really have no clues on how to use the BSP (at code level) to implement USART or more in general, implementing hardware drivers. What should I define? What I need to call? I can imagine that with RTEMS and the BSP I shouldn’t write code at “registers level”. Am I right? Can someone provide me a simple example about it? Can you give me some clarifications on the argument?

Thanks in advance for your help. Lorenzo


Solution

  • On most BSPs, one of the serial ports is used for standard input and standard output. So you should be able to use normal POSIX functions (like printf) for printing text to that console.

    By default, only USART3 is active on this BSP. So if you didn't use any special options, I would assume that one to be stdout. Default baudrate is 115200. The pins should be TX on PD8 and RX on PD9.

    From the examples-v2 repository the hello_world_c should do some basic output: https://github.com/RTEMS/examples-v2/tree/master/hello/hello_world_c

    If you want to use another USART or UART, you should enable it during configuring your BSP with options like: STM32F4_ENABLE_USART_1=1 (Note that 4 and 5 are UART instead of USART)

    You should then be able to open all other USARTS and UARTS by just opening for example the /dev/ttyS1 devices with open(...) and using the same read(...) or write(...) calls like you would on Linux.