Close

Damned RPi3 !

A project log for C GPIO library for Raspberry Pi

Lightweight GPL'd #include for your C programs

yann-guidon-ygdesYann Guidon / YGDES 02/16/2017 at 17:340 Comments

Trying to turn a LED on with the lib on a RPi3 using the slim 2017-01-11-raspbian-jessie-lite.zip image.

GPIO_on.sh and GPIO_off.sh work but not the C code.

The culprit is found easily because detect_GPIO_BASE.sh doesn't return anything (despite being on RPi3).

pi@raspberrypi:~/ $ cat /proc/iomem 
00000000-3affffff : System RAM
  00008000-007ea673 : Kernel code
  00862000-009901eb : Kernel data
3f007000-3f007eff : /soc/dma@7e007000
3f200000-3f2000b3 : /soc/gpio@7e200000
3f201000-3f201fff : /soc/uart@7e201000
  3f201000-3f201fff : /soc/uart@7e201000
3f300000-3f3000ff : /soc/mmc@7e300000
...

The expected keyword is not found ! Instead of bcm2708_gpio, I get /soc/gpio

Another thing is that I forgot to enable the device tree... But a keyword can be added:

grep -E '/soc/gpio|bcm2708_gpio' /proc/iomem

Result:

pi@raspberrypi:~/projets/files $ . detect_GPIO_BASE.sh 
3f200000-3f2000b3 : /soc/gpio@7e200000
GPIO_BASE=-DGPIO_BASE=(0x3f200000)
pi@raspberrypi:~/projets/files $ echo $GPIO_BASE 
-DGPIO_BASE=(0x3f200000)

Seems legit... But I still have to test with the device tree.


20180118 : don't forget to run the detection script as ROOT !

pi@raspberrypi$ sudo detect_GPIO_BASE.sh 

Raspbian now returns invalid values when run as user:

 $ cat /proc/iomem
00000000-00000000 : System RAM
  00000000-00000000 : Kernel code
  00000000-00000000 : Kernel data
00000000-00000000 : dwc_otg
....

(I should update my files......)

Discussions