I am cross posting this from the Beginners forum hoping to get some traction
Example code
https://github.com/librerpi/rpi-tools/b ... .c#L17-L27
Downloaded it, compiled and ran it and I get an error trying to open /dev/mem
If I can't open /dev/mem how do I use mmap ?
[Mod: please use the other thread]
Example code
https://github.com/librerpi/rpi-tools/b ... .c#L17-L27
Downloaded it, compiled and ran it and I get an error trying to open /dev/mem
Code:
int main(int argc, char **argv) { int fd = open("/dev/mem", O_RDONLY); if (fd == -1) { perror("unable to open /dev/mem"); return 2; } uint64_t physaddr; // physaddr = 0x20000000; // bcm2835 // physaddr = 0xfe000000; // bcm2711 physaddr = 0x1000000000; // bcm2712 //physaddr = bcm_host_get_peripheral_address(); //printf("addr %lx\n", physaddr); void *addr = mmap(NULL, 16 * 1024 * 1024, PROT_READ, MAP_SHARED, fd, physaddr); if (addr == MAP_FAILED) { perror("unable to mmap"); return 1; } [Mod: please use the other thread]
Statistics: Posted by theoldwizard1 — Fri Jan 30, 2026 2:43 pm — Replies 0 — Views 89