Skip to content
Advertisement

Failed to open /dev/mem: Permission denied

Today, I tried to use this command on my raspberry Pi:

sox -t mp3 /home/pi/test.mp3 -t wav - | /home/pi/PiFmRds/src/pi_fm_rds -audio -

But I got this error message :

Failed to open /dev/mem: Permission denied.
Terminating: cleanly deactivated the DMA engine and killed the carrier.
sudo: ./sox : command not found

I’ve tried to place “sudo” before the command but I got the same error. How can I resolve this please ? (and sorry if I did a mistake, I started playing with my raspberry today and this is also my first question on this website) Thanks in advance !

Advertisement

Answer

Putting sudo in front of sox will not help you since I am pretty sure the error message “Failed to open /dev/mem” comes from pi_fm_rds. And that is still started without sudo.

You are actually executing two commands. sox is the first, and pi_fm_rds the second. You are sending the output of the first command to the second (via the pipe |).

To call pi_fm_rds with root access you can choose one of these three options:

Call pi_fm_rds with sudo

sox -t mp3 /home/pi/test.mp3 -t wav - | sudo /home/pi/PiFmRds/src/pi_fm_rds -audio -

Or add your user to the kmem group (which allows access to /dev/mem) – requires logout/reboot.

sudo usermod -a -G kmem userName

or make the program setuid root – or setgid kmem

chown root:root /home/pi/PiFmRds/src/pi_fm_rds
chmod u+s /home/pi/PiFmRds/src/pi_fm_rds
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement