mmap - Segmentation fault
Posted: Wed Oct 17, 2018 8:23 pm
Hey everyone,
right now I am trying to understand how to program the Red Pitaya's FPGA, so I'm following Anton Potočnik's tutorial to build a stopwatch.
When compiling a C program to read out the clock count from the given address I always get a "Segmentation fault (program as)" - this seems to be independent of the FPGA program loaded, and I could narrow it down to the following part of the C code:
Is the address I'm trying to use reserved for some other purpose? I cannot seem to find an address that makes this error disappear...
Or am I handling pointers wrong?
Is it somehow related to the Red Pitaya's OS version (I'm running 0.98-617 on a STEM14)?
I'd be happy about any help or advice, I don't seem to be able to figure this out by myself...
Thanks in advance!
right now I am trying to understand how to program the Red Pitaya's FPGA, so I'm following Anton Potočnik's tutorial to build a stopwatch.
When compiling a C program to read out the clock count from the given address I always get a "Segmentation fault (program as)" - this seems to be independent of the FPGA program loaded, and I could narrow it down to the following part of the C code:
Code: Select all
int fd;
void *cfg;
fd = open("/dev/mem", O_RDWR | O_SYNC);
cfg = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE,
MAP_SHARED, fd, 0x42000000);
Or am I handling pointers wrong?
Is it somehow related to the Red Pitaya's OS version (I'm running 0.98-617 on a STEM14)?
I'd be happy about any help or advice, I don't seem to be able to figure this out by myself...
Thanks in advance!