Access ETM only with code without the use of debug kits - Page 1
Forum section: electronics / general

author: lorenrus
author_rank: Regular Contributor
timestamp: November 12, 2018, 06:45:04 pm
content: My board is Nucleo F401RE.My board is Nucleo F 401 REThis is the first time I've ever been doing this.I am using a pointer to the main registry of ETM, its address I read it on the datasheet.I would like to change the bits of this log but I do not change it the correct way.my code:#define ETM_CR 0xE0042000 //Addressunsigned int *pointer = (unsigned int *) ETM_CR;unsigned int var = 0;var = *pointerprintf("Value of var: %d\n, var)now i want to modify *pointer, for example:*pointer = 0x1;Now i expected to have in *pointer 0x1 but there insn't 0x1, there ins't the last value but there is another value.Thank you

author: lorenrus
author_rank: Regular Contributor
timestamp: November 16, 2018, 08:48:24 pm
content: Someone can help me ?Thanks

author: devan
author_rank: Contributor
timestamp: November 17, 2018, 03:15:27 am
content: Unfortunately, it's not always possible to write to debug registers like the ITM/ETM unless an external debugger has already connected to the core and enabled debugging.See one of the following links for more discussion on this:https://community.arm.com/tools/f/discussions/796/output-data-via-swo-without-debuggerhttp://essentialscrap.com/tips/arm_trace/theory.htmlThis is kind of disappointing, since there are cases where it would be convenient to collect trace data with a logic analyzer without also having to connect a debugger.

author: andersm
author_rank: Super Contributor
timestamp: November 17, 2018, 09:12:52 am
content: The address of the ETMCR register is 0xE0041000. To write to the ETM registers, you first need to unlock the ETMLAR register. Useful documents:CoreSight ETM‑M4 Technical Reference ManualEmbedded Trace Macrocell v3 Architecture SpecificationCortex‑M4 Processor Technical Reference ManualSTM32F401 Reference Manual

author: lorenrus
author_rank: Regular Contributor
timestamp: November 28, 2018, 09:07:43 am
content: Hi and thanks for the reply.To unlock ETM_LAR I have to write to his memory cell the value 0xC5ACCE55.To do this assignment I thought I'd do it with pointers this way#define ETM_LAR 0xE0041FB0 // Address of ETM_LAR#define UNLOCK 0xC5ACCE55 // Value to unlock the ETMint 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}is correct ?Thank you

author: lorenrus
author_rank: Regular Contributor
timestamp: December 04, 2018, 01:48:21 pm
content: Hi and thanks for the reply.To unlock ETM_LAR I have to write to his memory cell the value 0xC5ACCE55.To do this assignment I thought I'd do it with pointers this way#define ETM_LAR 0xE0041FB0 // Address of ETM_LAR#define UNLOCK 0xC5ACCE55 // Value to unlock the ETMint 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}is correct ?Thank you

author: ajb
author_rank: Super Contributor
timestamp: December 04, 2018, 05:51:18 pm
content: That should work, but you can include the dereference and pointer typecast in the define make it much more concise:Code:#define ETM_LAR *((unsigned int *)0xE0041FB0) // Address of ETM_LAR#define UNLOCK 0xC5ACCE55 // Value to unlock the ETMint main (void){ETM_LAR = UNLOCK; // Cheque UNLOCK to the contents of the memory address ETM_LAR}

author: lorenrus
author_rank: Regular Contributor
timestamp: December 09, 2018, 04:49:20 pm
content: Quote from: ajb on December 04, 2018, 05:51:18 pmHi and thanks for replyYes , also I did the same thing but the problem is that I think I do not change physically, but I change only the value of the variable.Thanks