Doran
Posts: 4
Joined: Wed Mar 30, 2016 3:11 pm

What is the GPIO base address of the new Raspberry Pi 3?

Wed Mar 30, 2016 3:18 pm

Hi, I am new to this forum and got a question about the Raspberry Pi 3:
I am trying to access the GPIOs directly from a C program. Did some google search and found this link: http://www.pieter-jan.com/node/15
However this example code is for the old Raspberry Pi with BCM2835.
I have the new Raspberry Pi 3 with BCM2837 chip and can't get the code from the link above to work.

Is it possible, that the GPIO base address (and other stuff about the registers) has changed?

Where can I find a datasheet of the BCM2837 chip?

Best regards,
Doran

User avatar
rpdom
Posts: 14483
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: What is the GPIO base address of the new Raspberry Pi 3?

Wed Mar 30, 2016 3:39 pm

The base address hasn't changed from that of the Pi 2.

I'm no sure if there is any datasheet for the BCM2837 yet.

Doran
Posts: 4
Joined: Wed Mar 30, 2016 3:11 pm

Re: What is the GPIO base address of the new Raspberry Pi 3?

Wed Mar 30, 2016 6:18 pm

Ok, thank you very much for your answer.
Does this mean, that the code from the link posted above (http://www.pieter-jan.com/node/15) will work on the Raspberry 3 without any modifications?
(Maybe I did some other mistake, will check that again!)

Any other ideas?

Best regards,
Doran

Doran
Posts: 4
Joined: Wed Mar 30, 2016 3:11 pm

Re: What is the GPIO base address of the new Raspberry Pi 3?

Wed Mar 30, 2016 6:27 pm

Ok, sorry, problem solved now: I used the definition:

Code: Select all

#define BCM2708_PERI_BASE       0x20000000
which seems to work for Raspberry Pi 1 only. After I had a look at the GIT repository linked at the bottom, I found some more code which uses

Code: Select all

#define BCM2708_PERI_BASE       0x3F000000
. Although this has been programmed for the Raspberry 2 it runs fine on my Raspberry 3 aswell ;-)

User avatar
rpdom
Posts: 14483
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: What is the GPIO base address of the new Raspberry Pi 3?

Wed Mar 30, 2016 6:39 pm

Doran wrote:Ok, sorry, problem solved now: I used the definition:

Code: Select all

#define BCM2708_PERI_BASE       0x20000000
which seems to work for Raspberry Pi 1 only. After I had a look at the GIT repository linked at the bottom, I found some more code which uses

Code: Select all

#define BCM2708_PERI_BASE       0x3F000000
. Although this has been programmed for the Raspberry 2 it runs fine on my Raspberry 3 aswell ;-)
Sorry, yes. I should have looked at your link. I just assumed you knew that the Pi 1 and Pi 2 had different base addresses, but didn't know that the Pi 3 had the same address as the Pi 2.

It is all to do with how much memory they have. The Pi 1 (and Zero) has a maximum of 512MB from 0x00000000 to 0x1FFFFFFF, so the IO base was set to be just above that.

The Pi 2 and 3 have 1024MB of memory from 0x00000000 to 0x3FFFFFFF, so you'd expect the IO base to be at 0x40000000 - but that memory range is not available, so the IO address was set to 0x3F000000 instead and the last 1MB of memory was sacrificed to allow the IO to work (so they really only have 1023MB of memory available). It's the best compromise possible with the current chip design.

Doran
Posts: 4
Joined: Wed Mar 30, 2016 3:11 pm

Re: What is the GPIO base address of the new Raspberry Pi 3?

Thu Mar 31, 2016 3:42 pm

Hi,

thank you again for the additional explanations.
This helps a lot ;-)

akshaygodase15
Posts: 1
Joined: Sat Sep 23, 2017 9:06 am

Re: What is the GPIO base address of the new Raspberry Pi 3?

Sat Sep 23, 2017 9:14 am

Hi Doran ,

So did you find perfect code working for BCM2837 i.e RPI 3B to blink LED?
If yes can you post it here please?

Thanks,
Akshay Godase

JohnAdriaan
Posts: 9
Joined: Wed Nov 02, 2016 11:50 am

Re: What is the GPIO base address of the new Raspberry Pi 3?

Sat Apr 28, 2018 10:54 am

rpdom wrote:
Wed Mar 30, 2016 6:39 pm
The Pi 2 and 3 have 1024MB of memory from 0x00000000 to 0x3FFFFFFF, so you'd expect the IO base to be at 0x40000000 - but that memory range is not available, so the IO address was set to 0x3F000000 instead and the last 1MB of memory was sacrificed to allow the IO to work (so they really only have 1023MB of memory available). It's the best compromise possible with the current chip design.
Actually, 0x01000000 is 16 MB, not 1 MB. So those numbers should be "last 16MB" and "really only have 1008MB".

Return to “Advanced users”