I'm not able to print hello world in RTOS console
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-05 8:58 PM - last edited on ‎2024-02-07 7:31 AM by mƎALLEm
void StartDefaultTask(void const * argument)
{
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
printf("Hello world!");
//HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
//HAL_Delay(1000);
//osDelay(1);
}
/* USER CODE END 5 */
}
Greetings! this is the code for printing hello world on the console of RTOS in stm32 cube IDE but I'm not able to see the results on the console is anything wrong here??
I have created a task to print hello world on the console
Solved! Go to Solution.
- Labels:
-
STM32CubeIDE
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-08 2:43 AM - edited ‎2024-02-08 2:44 AM
Hello @Akshay_ & @Andrew Neil,
Q : Are you sure it'll work with an (unknown) RTOS ?
A : It will work with FreeRTOS.
You need to configure at least :
- UART as asynchronous under CubeMX and make sure that pins selected match with hardware. Which STM32 are you using ? with a nucleo/dev board ?
- FREERTOS section under CubeMX (enable USE_NEWLIB_REENTRANT) and create tasks, queues, semaphores... as needed.
- SYS with a timebase source such as TIM1.
I advise you to watch this great YouTube video done by an other developer.
Kind Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-07 7:25 AM
Hello @Akshay_,
Have you read the article named How to redirect a printf function to a UART for debug messages ?
It may help !
Best Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-07 7:27 AM
Use this button to properly post source code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-07 7:30 AM - edited ‎2024-02-07 7:33 AM
Hello,
- Do you have test printf without RTOS?
- Did you already configure CubeIDE SWV console?
- Why osDelay(x) is commented?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-07 7:38 AM
@Akshay_ what RTOS are you using? Have you checked its documentation for specific support?
@Pierre_Paris wrote:Have you read the article named How to redirect a printf function to a UART for debug messages ?
@Pierre_Paris That's the "bare metal" approach - are you sure it'll work with an (unknown) RTOS ?
eg, https://forums.freertos.org/t/implementation-of-printf-that-works-in-threads/8117/2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-07 2:22 PM
@Akshay_ There is no such thing as "RTOS console". RTOS, such as RTX or FreeRTOS, is not a Linux. You print just to what happens to be the stdout of the C runtime library linked to your firmware. In case of CubeIDE it is the newlib (nano), in Keil or IAR - their proprietary runtime libraries. So just research how printf and its friends work in the used library, with multiple threads. FreeRTOS has a set of extensions, FreeRTOS+, among them is a "CLI" library which can be used to make a console.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-08 2:43 AM - edited ‎2024-02-08 2:44 AM
Hello @Akshay_ & @Andrew Neil,
Q : Are you sure it'll work with an (unknown) RTOS ?
A : It will work with FreeRTOS.
You need to configure at least :
- UART as asynchronous under CubeMX and make sure that pins selected match with hardware. Which STM32 are you using ? with a nucleo/dev board ?
- FREERTOS section under CubeMX (enable USE_NEWLIB_REENTRANT) and create tasks, queues, semaphores... as needed.
- SYS with a timebase source such as TIM1.
I advise you to watch this great YouTube video done by an other developer.
Kind Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-08 8:38 AM
@Pierre_Paris wrote:Hello @Akshay_ & @Andrew Neil,
A : It will work with FreeRTOS.
But will it be Thread-safe ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 1:08 AM
Hello @Andrew Neil,
Q : But will it be Thread-safe ?
A : Indeed, basic functions malloc() and free() are not thread safe. To be thread safe, you need to implement a locking mechanism. This is well explained in this article and comments. Here is the newlib documentation for __malloc_lock() and __malloc_unlock().
Best Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
