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,
I recommend to start with the Cortex-A53 Technical Reference Manual PMU section: https://developer.arm.com/docs/ddi0500/g/performance-monitor-unit
Then start with this article: https://developer.arm.com/products/system-design/cycle-models/knowledge-articles/system-performance-analysis-and-the-arm-performance-monitor-unit
It was for Cycle Models but also applies to the R Pi 3.
The code for the article is attached at the bottom of this link: https://community.arm.com/soc/b/blog/posts/system-performance-analysis-and-the-arm-performance-monitor-unit-pmu
You can download and study the code to read the cycle count.
Another useful article is: https://developer.arm.com/products/system-design/cycle-models/knowledge-articles/using-the-arm-performance-monitor-unit-linux-driver
Thanks,
Jason
Hi Jason, Thanks for the help. I will give it a try based on your work on PMU with Linux Kernel in the coming days and let you know on a RPI3. In the mean time, i ran into the evaluation of the PMU versus DWT for cycle count on some ARM familly/architecture HW. It appears that PMU is now days mostly in used (PMUv3) while DWT is now too old. So the method develop in your blog should be the best choice. thanks
Here the matrix computed from the ARM doc. Three column are related to the strategy for cycle count (PMU,DWT or other). The column H/W implementation should be fill with boards name or product name. I tried to aggregate quickly the PMU versions or insert notations to give indications (when found). It's a first quick run and I am happy to received comments or to update the matrix. Feel free to send comments.
Regards