Author Topic: Access ETM only with code without the use of debug kits  (Read 1829 times)

0 Members and 1 Guest are viewing this topic.

Offline lorenrusTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: it
Access ETM only with code without the use of debug kits
« on: November 12, 2018, 06:45:04 pm »
My board is Nucleo F401RE.

 My board is Nucleo F 401 RE

This 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 //Address

unsigned int *pointer = (unsigned int *) ETM_CR;

unsigned int var = 0;

var = *pointer

printf("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
 

Offline lorenrusTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: it
Re: Access ETM only with code without the use of debug kits
« Reply #1 on: November 16, 2018, 08:48:24 pm »
Someone can help me ?

Thanks
 

Offline devan

  • Contributor
  • Posts: 13
  • Country: us
Re: Access ETM only with code without the use of debug kits
« Reply #2 on: November 17, 2018, 03:15:27 am »
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-debugger
http://essentialscrap.com/tips/arm_trace/theory.html

This 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.
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: Access ETM only with code without the use of debug kits
« Reply #3 on: November 17, 2018, 09:12:52 am »
The address of the ETMCR register is 0xE0041000. To write to the ETM registers, you first need to unlock the ETMLAR register. Useful documents:
 
The following users thanked this post: lorenrus

Offline lorenrusTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: it
Re: Access ETM only with code without the use of debug kits
« Reply #4 on: November 28, 2018, 09:07:43 am »
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 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

}

is correct ?

Thank you
 

Offline lorenrusTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: it
Re: Access ETM only with code without the use of debug kits
« Reply #5 on: December 04, 2018, 01:48:21 pm »

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 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

}

is correct ?

Thank you
 

Online ajb

  • Super Contributor
  • ***
  • Posts: 2601
  • Country: us
Re: Access ETM only with code without the use of debug kits
« Reply #6 on: December 04, 2018, 05:51:18 pm »
That should work, but you can include the dereference and pointer typecast in the define make it much more concise:

Code: [Select]
#define ETM_LAR *((unsigned int *)0xE0041FB0) // Address of  ETM_LAR

#define UNLOCK 0xC5ACCE55 // Value to unlock the ETM

int main (void)

{

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

}
 

Offline lorenrusTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: it
Re: Access ETM only with code without the use of debug kits
« Reply #7 on: December 09, 2018, 04:49:20 pm »
That should work, but you can include the dereference and pointer typecast in the define make it much more concise:

Code: [Select]
#define ETM_LAR *((unsigned int *)0xE0041FB0) // Address of  ETM_LAR

#define UNLOCK 0xC5ACCE55 // Value to unlock the ETM

int main (void)

{

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

}

Hi and thanks for reply

Yes , 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
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf