BlindDevelopment
Posts: 2
Joined: Thu Jun 27, 2019 1:13 pm

Raspberry Pi 4 GPIO Direct Register Access

Thu Jun 27, 2019 1:34 pm

Hello,

Long time viewer, first time poster.

Apologies in advance for any formatting faux pas, as my name suggests I am blind and doing this largely from a screen reader which doesn't always get it right.

In any case, I have just gotten a new Raspberry Pi 4 B 4GB through work and need to integrate it it into our products which utilise the GPIO pins to perform hardware sensor reads and generally interface on a hardware level. This has been fine historically through several versions of the pi, having used the Direct Register Access method as detailed on the elinux.org page for GPIO access.

However, as the Raspberry Pi 4 is quite new and uses a different chipset my expectation and understanding is that the current setup for accessing the GPIOs is not working, and this seem to hold true in tests using the old code.

Would anyone know what the new settings for this would look like, to enable GPIO access through C/C++? Or if not, could someone point me in the right direction for a topic on how I might discover the correct settings myself? I'm not above trying to work it out myself, I just wouldn't know where to begin with this kind of project - or even what the topics I should be googling for are.

(For clarity, by 'settings' I am assuming that the direct memory access that is going on in the code is pointing to an incorrect memory location now that the chipset is updated, and suspect these values need tweaking slightly, as they did going from RPi2 to RPi3.)

Cheers!

User avatar
pi3g
Authorised Reseller
Authorised Reseller
Posts: 147
Joined: Mon Nov 05, 2012 9:58 pm
Location: Germany
Contact: Website

Re: Raspberry Pi 4 GPIO Direct Register Access

Thu Jul 11, 2019 9:49 pm

reposting joan's answer from main thread, in case anyone comes here from Google:
joan wrote:
Thu Jun 27, 2019 10:10 pm
On the Pi4B the peripheral base address appears to be 0xfe000000 from Linux. The offsets to the various peripherals from that base address appear to be unchanged.
picockpit.com - tools to make your life with the Pi a little bit easier

User avatar
joan
Posts: 14949
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Raspberry Pi 4 GPIO Direct Register Access

Thu Jul 11, 2019 10:01 pm

As well as the base address change there is a change to the way GPIO pull-ups and pull-downs are set on the BCM2711.

See https://github.com/RPi-Distro/raspi-gpi ... spi-gpio.c for details.

Return to “General discussion”