I am working on Beagle Bone Black TIMER4. I wanted to access the registers
directly from user space and so opted for dev/mem. But I end up getting bus
error when I try to read the contents in a memory address. The code is
posted below:
#include <unistd.h>#include <fcntl.h>#include <sys/mman.h>#include
<stdio.h>#include<stdlib.h>#include<string.h>#include <signal.h>
#define TIMER4_START_addr 0x48044000#define TIDR 0x00#define TIOCP_CFG 0x10
int main(){
unsigned int reg;
char *timer_addr = NULL;
printf("\n Start Pgm");
int mem, integer;
if ((mem = open ("/dev/mem", O_RDWR | O_SYNC)) < 0)
{
printf("Cannot open /dev/mem\n");
return 1;
}
printf("Opened /dev/mem\n");
timer_addr = mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, mem,
TIMER4_START_addr);
printf("GPIO mapped to %p\n", timer_addr);
reg = *((int*) timer_addr);
printf("GPIO1 configuration: %x\n", reg);
return 0;}
The output that I get is :
Start
PgmOpened /dev/mem
GPIO mapped to 0xb6fb7000
Bus error
Please let me know how to overcome this problem.
Regards Anand
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.