swv itm data console stop printing after few lines
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-07 2:18 AM
Hi There,
I am using a SWV ITM to print the messages but it always stoped printing after 221 counter number as below image. Could any tell us what needs to be set to see continues printing.
- Labels:
-
STM32G4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-07 3:38 AM
What do you use to print? printf from the newlib/nano? With FreeRTOS?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-07 10:42 AM - edited ‎2024-01-07 10:52 AM
With FreeRTOS. Below is the code sample.
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN 5 */
uint32_t i = 0;
/* Infinite loop */
for(;;)
{
printf("%lu: StartDefaultTask\n", i++);
osDelay(300);
}
/* USER CODE END 5 */
}
/* USER CODE BEGIN Header_Task2_init */
/**
* @brief Function implementing the Task2 thread.
* argument: Not used
* @retval None
*/
/* USER CODE END Header_Task2_init */
void Task2_init(void *argument)
{
/* USER CODE BEGIN Task2_init */
uint32_t i = 0;
/* Infinite loop */
for(;;)
{
printf("%lu: Task2_init\n", i++);
osDelay(300);
}
/* USER CODE END Task2_init */
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-07 10:53 AM
Is it crashing, or Hard Faulting ?
If you stop in the debugger, where does it stop? In the for loop in _write() ?
Using ST-LINK?Which version, which firmware?
Do you see the same behaviour if you use the SWV function of STM32 Cube Programmer ?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-07 11:20 AM - edited ‎2024-01-07 11:20 AM
Aha so that's printf. Most likely you have a C library reentrancy issue with printf (a.k.a. Dr. Nadler's syndrome). To test this, please call printf in a loop 230 times before starting the RTOS scheduler and see if it all prints out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-07 1:12 PM
Ah no, it is not crash or hard fault.
When i debug, It does go inside the _write() function but never print out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-07 1:25 PM - edited ‎2024-01-07 1:31 PM
I call printf 230 times before RTOS scheduler and it can print out 230 times but it stoped at 81 counter value inside rtos task.
uint8_t i = 0;
for (i = 0; i < 230; i++)
{
printf("%u: Before Task initialised\n", i);
}
/* USER CODE END 2 */
/* Init scheduler */
osKernelInitialize();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-09 1:27 PM
Well so the problem is not in SWV/ITM but in integration of printf (and likely other newlib library stuff too) and FreeRTOS.
This is complicated, and one of recent CubeIDE updates seems to have regression in multi-thread locks. Please google (or whatever search engine you prefer) for STM32 + newlib + locking.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-10 3:01 PM
Thanks Pavel A,
I google it but seems like nobody has found the proper solution.
I will not use SWV for now. I think i will use serial to print the data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-10 3:44 PM
Your problem is not in SWV but in printf. Like it fails with ITM it will fail for you with a UART without a proper fix.
