SWV / Trace not working on MP1 in production mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-04 4:59 AM
/* USER CODE BEGIN 0 */
uint32_t DDDEBUG = 0;
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
// ... (code generated by CubeIDE) ...
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
DDDEBUG++;
for (char* ptr = "test\n"; *ptr; ptr++)
ITM_SendChar(*ptr);
HAL_Delay(1000);
}
/* USER CODE END 3 */
}
- Labels:
-
STM32MP15 Lines
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-04 5:01 AM - edited ‎2024-12-04 5:02 AM
PS: I attached many screenshots of the configuration, including the ITM registers which look correct (but I'm no expert about these). See also the OpenOCD and GDB commands here:
C:\ST\STM32CubeIDE_1.17.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.openocd.win32_2.4.0.202409170845\tools\bin\openocd.exe "-f" "stm32mp157D_DK1_TEST_CM4.cfg" "-s" "C:/Users/Administrator/STM32CubeIDE/workspace_1.17.0/stm32mp157D_DK1_TEST/CM4" "-s" "C:/ST/STM32CubeIDE_1.17.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.debug.openocd_2.3.0.202411041438/resources/openocd/st_scripts" "-s" "C:/ST/STM32CubeIDE_1.17.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mpu.debug.openocd_2.2.0.202409171044/resources/openocd/st_scripts" "-c" "gdb_report_data_abort enable" "-c" "gdb_port 3333" "-c" "tcl_port 6666" "-c" "telnet_port 4444"
C:\ST\STM32CubeIDE_1.17.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.win32_2.2.0.202409170845\tools\bin\ST-LINK_gdbserver.exe -p 61234 -l 1 -d -z 61235 -s -cp C:\ST\STM32CubeIDE_1.17.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.2.0.202409170845\tools\bin -m 2 -g
I am using CubeIDE 1.17.0, and the firmware on the ST Link is updated to the newest available. The STM32MP1 firmware package is also the latest.
ITM SWT and CoreDebug Registers:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-12-16 12:37 AM
Any thoughts anyone?
 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-03-11 9:12 AM
Ok, here are my findings:
- The Trace CLK needs to be enabled otherwise Cube gives a massive error while trying to set the ITM/DWT registers
- check in Linux with:
cat /sys/kernel/debug/clk/clk_summary | grep -E 'trace|enable|count|---
(run "debug 1" first on my Linux to mount /sys/kernel/debug) - Enable it from the debugger by setting the "TRACECKEN" bit in RCC_DBGCFGR
- Then check again in Linux, the "hardware enable" should have changed from N to Y
- check in Linux with:
- In CubeIDE, the "Core Clock" is NOT the M4 clock but the Trace clock (the one given by the command above), this needs to be set correctly (in my case 133.25 MHz)
- Apparently this only works with OpenOCD and not with the ST-LINK GDB Server
- This is particularly annoying because OpenOCD cannot reset the M4 (but GDB can) - and it takes about 5 minutes to stop the debugger and restart it... See https://community.st.com/t5/stm32-mpus-software-development/reset-stm32mp1-mcu-in-production-mode/td-p/602190
