2024-02-05 08:58 PM - last edited on 2024-02-07 07:31 AM by SofLit
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
2024-02-07 07: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.
2024-02-07 07:27 AM
Use this button to properly post source code:
2024-02-07 07:30 AM - edited 2024-02-07 07:33 AM
Hello,
2024-02-07 07: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
2024-02-07 02: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.
2024-02-08 02:43 AM - edited 2024-02-08 02: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 :
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.
2024-02-08 08:38 AM
@Pierre_Paris wrote:Hello @Akshay_ & @Andrew Neil,
A : It will work with FreeRTOS.
But will it be Thread-safe ?
2024-02-12 01: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.