2024-11-03 8:56 PM
I get the following error when trying to debug an STM32H757 with SWO enabled.
Failed to enable SWV configuration.
Failed to execute MI command:
-data-write-memory 0x5c003010 x 4 0x77
etc...
It would seem the debugger (ST-link v2) is not able to read the SWO and DBGMCU registers.
With the same debug configuration and code, SWO works on H747 hardware, so I'm wondering if there is an SWO difference between these two micros that is not obvious or documented.
Has anyone come across this issue before and has an idea of how to fix it?
Thanks
2024-11-07 7:00 AM
2025-07-16 7:25 AM - edited 2025-07-16 7:28 AM
Hello @Imen.D,
I've got the same error message than @CWadd, and I havn't found anything in the AN4989 that seems to be related to my problem.
Here is my situation :
I'm debugging a STM32H757XIH6 using STM32CubeIDE v1.18.1
I'm trying to get SWO from CM7, by enabling SWV in the CM7 Debug configuration as on following picture. Note that the SWV is disabled for CM4 Debug configuration
I've got a simple code that works well for SWV and I can see my printf in the SWV ITM view. So my hardware is good, and the IDE is able to display the printf.
But my main project got the error message that @CWadd provided...
This doesn't happen at the first debug session. The first session works, but doesn't output anything in SWV ITM View. Then I'm unable to debug again and got the error message.
In this situation I cannot debug anymore, and always get this message, even with the simple program. So I need to erase all flash with CubeProgrammer, and I can debug again.
I've compared everything between these 2 codes and didn't find anything to solve my problem.
I'm thinking about a write protection on the SWO config registers (which are designated by first addresses in the error message). But I didn't know where to look, and what I can do about that.
Have you got any clues or intuition about something I should check ?
@CWadd did you managed to fix this issue ?
2025-08-11 12:34 AM
Hello,
I have the same issue, I have try to :
* change cables and PC port
* change my PC (Mac and Windows) (STM32CubeIDE 1.18.0)
* set script to set sw register, in Debug Configurations > startup > Run commands
* set by my self swo pin (see below)
* do my own swo_init function called in main after GPIO init (see below)
Has anyone found a solution?
2025-08-31 5:38 AM
I had same problem my fix was. once you paste that at top everything will work
#include "stdio.h"
int _write(int file, char *ptr, int len){
int i=0;
for (i=0; i<len; i++){
ITM_SendChar((*ptr++));
}
}
2025-09-01 1:00 AM
Hello @Spectrewolf777,
Not working for me T_T
2025-09-01 1:53 AM - edited 2025-09-01 1:55 AM
https://youtu.be/JqrUAzjJ0tw what I followed. hope it might be able to help you
AN4989 looks similar to application notes
the stuff code i gave fixed it allowing me to use printf there might be something else that causing that error for you. try using printf to see if you even getting output. Just printf
2025-09-04 12:35 AM
Hi @Spectrewolf777, thanks for you help. Unfortunately, as for @MA4 , it doesn't solves my problem.
In my case the issue seems to be more low level since even calling manually the ITM_SendChar() function in my code with a single caracter doesn't output anything in the console.
When I run my program, I see with the debugger that my printf() correctly go into ITM_SendChar().
Also, I've checked the SWO pin with a scope, and put a printf triggered by a user event like button pressed. And I'm able to see some variation on the signal shape when the printf is expected to be sent. So something is happening, but the IDE is unable to detect or decrypt the data sent by the processor.
I still don't understand what was wrong in my configuration, and why it get stuck until I erase the whole flash.