I got this link from a different post on this forum
https://github.com/librerpi/rpi-tools/b ... .c#L17-L27
Downloaded it, compiled and ran it and I get
This is the snippet in questionIf I can't open /dev/mem how do I use mmap ?
https://github.com/librerpi/rpi-tools/b ... .c#L17-L27
Downloaded it, compiled and ran it and I get
Code:
$ sudo chmod 644 /dev/mem $ ls -ld /dev/memcrw-r--r-- 1 root kmem 1, 1 Jan 29 10:55 /dev/mem$ ./boottimeunable to open /dev/mem: Operation not permittedCode:
iint 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; } Statistics: Posted by theoldwizard1 — Thu Jan 29, 2026 7:22 pm — Replies 1 — Views 31