We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi,
I am trying to use the Data Watch and Trace natively on RPI3 without debugger to count Cycle but got a core dump. here the code to compile and run on a RPI3. . My objective is to count cycle to do accurate benchmarking.
I have a core dumped on line *DEMCR = *DEMCR | 0x01000000;
What is the issue here ?
Thanks for any help. Regards
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h> volatile uint32_t count = 0;
// addresses of registers
volatile uint32_t *DWT_CONTROL = (uint32_t *)0xE0001000;
volatile uint32_t *DWT_CYCCNT = (uint32_t *)0xE0001004;
volatile uint32_t *DEMCR = (uint32_t *)0xE000EDFC;
int main () { // enable the use DWT
printf("Init \n");
*DEMCR = *DEMCR | 0x01000000;
printf(" never here ? \n");
// Reset cycle counter *DWT_CYCCNT = 0; // enable cycle counter
*DWT_CONTROL = *DWT_CONTROL | 1 ;
// some code here
// number of cycles stored in count variable
count = *DWT_CYCCNT;
printf("count = %d \n",count);
return 0; }
The output is : Init Segmentation fault (core dumped)
Hi,
Are you running on a Raspberry Pi 3? The R Pi 3 has a quad core Cortex-A53 and the registers you are accessing are for Cortex-M
Is your C application a Linux application? If so, you can use a tool like perf or Arm Streamline
Thanks,
Jason