Skip to content
Advertisement

Segmentation fault when maping /dev/mem

I’m trying to mmap a memory from my FPGA on a linux running on my Zedboard SoC. I can read the contents correctly using devmem on the command line, but when trying to read it through C I get a segmentation fault.

The barebones code shown below throws the segmentation fault when trying to print the contents of the memory. I’m careful to use a multiple of the page size to avoid issues from that:

JavaScript

Why can’t I read the memory?

Advertisement

Answer

I feel the issue is flags passed to open it should look like this

fd = open("/dev/mem", O_RDWR|O_SYNC);

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement