Posts: 117
Joined: Tue Jan 31, 2017 5:04 am

Memory mapping offets clarification

Wed May 30, 2018 3:19 pm

That suppose to be "OFFSETS" - I cannot edit the title

Physical addresses range from 0x20000000 to 0x20FFFFFF for peripherals. The bus addresses for peripherals are set up to map onto the peripheral bus address range starting at 0x7E000000. Thus a peripheral advertised in the manual at bus address 0x7Ennnnnn is available at physical address 0x20nnnnnn.

On RPI 2, the peripheral addresses are different and the bcm2835 library gets them from reading /proc/device-tree/soc/ranges. This is only availble with recent versions of the kernel on RPI 2.

The above is a quote from BCM2835 library document.
The difference between "older" Rpi and RPi 3 is obvious, what is not so clear are the usage of "tree" "offsets" .
Memory mapping prior to RPi2 was explained as "0x2000000 " plus "20000" offset with "results 0x2020000.
( I hope I got all the zeros correct, but that is relatively immaterial for my question ).
In RPi2 and up the "base" changed to 0x3f000000, the mmap is done for this base and to get to GPIO - "base again" offset of 200000 is documented.
Adding x to base pointer in 32 bit system results in address of the base pointer change by 4*x - pointer arithmetic for 32 bit system.

Is that the intend?
Or should the offset to get to GIPO be 200000/4 ?

Or does it matter?
If I only want to work with GPIO and as long as I stay with the original "size" of file descriptor am I OK?

User avatar
Posts: 19
Joined: Thu Jun 20, 2019 5:35 pm
Location: Olinda / PE / Brasil
Contact: ICQ Website

Re: Memory mapping offets clarification

Thu Jun 20, 2019 7:07 pm


Do you have answers to these questions? I am now with the same doubts and it is strange to see that no one in this forum was able to answer your

The datasheet seems to be a copy/paste from an old version and some memory addresses are wrong, for example, the base address of my RPI é 0x3F000000 and not 0x20000000 like the datasheet say
Carlos F. Filho
Delphi Expert

Return to “C/C++”