Close

Fixing issues with Rpi.GPIO

A project log for Open Indirect Ophthalmoscope

An open-source, ultra-low cost, portable screening device for retinal diseases

ebin-philipEbin Philip 06/01/2016 at 11:340 Comments

While working on improving our code, our Pi's SD card crashed unexpectedly. After doing a reinstall of Wheezy, we found we were getting the following error on using Rpi.GPIO

No access to /dev/mem. Try running as root!

We used the following linux commands to fix it

sudo chown root.gpio /dev/gpiomem
sudo chmod g+rw /dev/gpiomem

sudo chown root.gpio /dev/mem
sudo chmod g+rw /dev/mem

These commands gave gpio, access to mem and gpiomem which cleared the issue. But these had to be re-executed on each reboot. So we made a bash script for it, permission.sh.

After that we ran the following commands to make it execute on startup

chmod 755 permission.sh
cp permission.sh /etc/init.d
sudo update-rc.d permission.sh default
chmod +x /etc/init.d/permission.sh
Copying to /etc/init.d gets it executed on startup. The next two commands are to unsure the script is added to startup and to make it an executable script.

The permissions issues were fixed but now, we were getting a runtime error in our python code on trying to run the Rpi.GPIO.wait_for_edge(). After a lot of futile attempts to fix the issue, we decided to use another gpio library, pigpio.

Discussions