Raspberry Pi 2 and GPIOs [SOLVED]

Raspberry Pi 2

Raspberry Pi 2 and GPIOs [SOLVED]

Postby RobMeades » Sun Feb 15, 2015 12:55 am

Hi there. I have some C code that follows the examples here:

http://elinux.org/RPi_Low-level_peripherals#C_2

...using "/dev/mem" to memory map GPIOs that I can configure and then read/write on my Raspberry Pi. This code worked fine under Arch Linux on my Pi model B, which I unfortunately broke a few weeks ago.

On my replacement "Pi 2" the same code has no effect on the GPIO pins at all.

Two questions:

1. Has anyone here had success driving GPIOs from C under Arch Linux on a Raspberry Pi 2?
2. If so, would it be possible to see a snippit so that I can determine what the devil I'm doing wrong?

Rob
P.S. I've used WiringPi to show that the ports do work, so there is something I need to change with my configuration/code since the Raspberry Pi B (not B+, B, the one with the smaller connector) days. The GPIOs I am using are not in the extended pins area.
P.P.S. The author of WiringPi notes on his website, "The Pi 2 has the same GPIO interface, however presumably due to the 1GB of RAM the GPIO base location has changed". However I can't find anywhere that tells me what this new GPIO base location is...
Last edited by RobMeades on Sun Feb 15, 2015 12:57 pm, edited 1 time in total.
RobMeades
 
Posts: 18
Joined: Sat May 17, 2014 3:35 pm

Re: Raspberry Pi 2 and GPIOs

Postby RobMeades » Sun Feb 15, 2015 12:57 pm

So, from Gordon Henderson, author of wiringPi:

I changed my line in wiringPi like yours above to:

static volatile unsigned int BCM2708_PERI_BASE = 0x20000000 ; // Variable for Pi2

Then later on when I detect a Pi v1 or v2, in wiringPiSetup(),

if (piModel2)
BCM2708_PERI_BASE = 0x3F000000;

The easiest way to check for a v2 is to scan /proc/cpuinfo and look for the Hardware: line - it's BCM2708 for a v1 or BCM2709 for a v2.


Now everything works again :-).
RobMeades
 
Posts: 18
Joined: Sat May 17, 2014 3:35 pm


Return to Broadcom

Who is online

Users browsing this forum: No registered users and 2 guests