System Workbench for STM32

Access ETM of Nucleo F401RE without using a debug kit


i’m using Nucleo board F401RE.

i want to access to ETM with code.

My code:

  1. define ETM_CR 0xE0041000 // Address of ETM_CR

  1. define ETM_LAR 0xE0041FB0 // Address of ETM_LAR

  1. define UNLOCK 0xC5ACCE55 // Value to unlock the ETM

int main (void)


unsigned int *pointer_1 = (unsigned int *) ETM_LAR; // The pointer_1 will point to the address contained in the variable ETM_LAR

  • pointer_1 = UNLOCK; // Cheque UNLOCK to the contents of the memory address ETM_LAR

unsigned int *pointer_2 = (unsigned int *) ETM_CR; // The pointer_2 will point to the address contained in the variable ETM_CR

unsigned int var = 0x0; // I initialize a variable called var

var = *pointer_1; // I assign the contents of pointer_1 to the variable var

while (1)

printf(“Il contenuto in esadecimale è: %p\n”, *pointer_1); // I expect to see on the terminal the value of UNLOCK



So what is your question?
I guess that you had missed to modify the _write function in syscall.c.


My question is whether with the code I wrote I can access ETM or if there is need for other settings since I do not use a debug kit.

Thank you

Ok, then you want to ask a question.
By my knowledge and experience, certainly there are some other things to do.
First of all, how you want to connect to your ETM physically or electrically when you don’t want to use a debugger? Yes there are some of ways to do, but you need to decide and chose. Would you intend to configure your ETM output as UART style and then hook up a TTL serial to SWO? Or other ways.
Second, to firmware for STM32F401, as I mentioned, you need to write your own _write function to make the output to STD device to ETM, in order to use printf to write through ETM.
Do a search to get a big picture first, then ask a specific question, then people will be able to help.

I have connected the card to my PC via USB-mini USB cable. I apologize if I may not be clear, but it is the first time I use this card. Anyway if I upload my code via my USB-USB cable mini.il code is really uploaded to my card? Also I can read, but when I go to change the contents of a memory address, it does not change me.

Thank you very much

Ok, now you give little more details but still lot of things remain unknown.
First of all, the board of Nucleo-F401RE comes with built-in debugger, which connect the debug interface of STM32F401 via SWD, and the USB interface to your host. Other than that, the composite USB also provides mass storage device and virtual serial port, which connect to one of USART port on STM32F401.
When you said downloading the firmware through the usb interface, I guess you are talking about to use ST-Link utility program running on your PC? Or inside of Atollic TrueStudio through the OpenOCD->SWD debugger?
It seems like you should spend little more time to read the “user’s manual for Nucleo-F401RE”, and the schematic to the board, and maybe the datasheet of STM32F401? That is the big picture I’m talking about.

So why ask here? This is the forum for the use of System Workbench for STM32; you should ask IAR ...
Bernard (Ac6)

Now it is even confused. You said that you’re using IAR Workbench, and in this forum we are talking about to use System Workbench for STM32, which replace IAR Workbench completely.
In a short word, if you intend to use IAR Workbench, most likely you are not belong here.

Now i’m using System Workbench for STM32.

I have to physically change the contents of the ETM_LAR log. I can make this change via pointers in this way:

  1. define ETM_LAR 0xE0041FB0 // Address of ETM_LAR

  1. define UNLOCK 0xC5ACCE55 // Value to write in ETMLAR useful to unlock the ETM

unsigned int *p_2 = (unsigned int*) ETM_LAR;

  • p_2 = UNLOCK;