I've hit a roadblock, I'm trying to read the DMTIMER_1MS internal counter. This is the code im running.
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "logger.c"
#define DATA_BUF 10
#define DMTIMER_BASE 0x44E31000
#define DMTIMER_SIZE 0x1000 //4096
#define TCRR 0x28
int main (int argc, char *argv[])
{
volatile uint32_t* dmtimer_addr;
volatile uint32_t* dmtimer_tcrr;
int fd = open("/dev/mem", O_RDWR);
if( fd < 0){
log_error("Cannot open /dev/mem");
exit_scale(nau7802_0, log_fd);
return 0;
}
dmtimer_addr = mmap(NULL, DMTIMER_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, DMTIMER_BASE);
dmtimer_tcrr = (dmtimer_addr+TCRR);
close(fd);
printf("0x%08x\n", *dmtimer_addr);
printf("%d\n", *dmtimer_tcrr);
return 0;
}
When I run the code I get the following output
0x00000015
0
If I run devmem from busybox for those two memory locations I get the following
xxxx@beaglebone:~/nfs$ sudo busybox devmem 0x44E31000 32
0x00000015
xxxx@beaglebone:~/nfs$ sudo busybox devmem 0x44E31028 32
0x4DC6133D
xxxx@beaglebone:~/nfs$ sudo busybox devmem 0x44E31028 32
0x4ED5FA3E
xxxx@beaglebone:~/nfs$ sudo busybox devmem 0x44E31028 32
0x4FDC84DD
This leads me to believe two things
I'm not sure what I'm missing.
User contributions licensed under CC BY-SA 3.0