turboscrew
Posts: 174
Joined: Sat Jan 18, 2014 1:50 pm
Location: Nokia (town), Finland

RPi2 memory map

Sat Mar 28, 2015 4:10 pm

First, AWESOME that the document QA7 is available to us!

Now, the arm control logic is right above the GPU peripheral address space (as set up by the 'default' GPU-boot)? The address 0x4000 0000 is the ARM physical address?

It's also not clear to me which lower memory regions might be used by GPU such that ARM-side should not mess with it. The VC SDRAM? What's the 'safe' address range for Arm programs when the default files - bootcode.bin and start.elf are used? I've gotten an impression that the very low addresses (0 - something) have some special (GPU-related) use.
De-bugging is for sissies - real men do de-monstrations.

rst
Posts: 420
Joined: Sat Apr 20, 2013 6:42 pm
Location: Germany

Re: RPi2 memory map

Tue Mar 31, 2015 7:34 pm

turboscrew wrote:First, AWESOME that the document QA7 is available to us!
I agree with that.
Now, the arm control logic is right above the GPU peripheral address space (as set up by the 'default' GPU-boot)? The address 0x4000 0000 is the ARM physical address?
Yes.
It's also not clear to me which lower memory regions might be used by GPU such that ARM-side should not mess with it. The VC SDRAM? What's the 'safe' address range for Arm programs when the default files - bootcode.bin and start.elf are used? I've gotten an impression that the very low addresses (0 - something) have some special (GPU-related) use.
The available memory on the ARM side can be determined by using a mailbox property call (tag 0x00010005). The kernel image is normally loaded at 0x8000. From 0x100 on there is some space used for the ATAGS. To be sure I do not use 0x100-0x7FFF but it may be safe to use (say) 0x4000-0x7FFF (some people do). If you do not use high-vectors the exception vector table has to be placed at 0. You can change most of this by using the config.txt but this should be the default map.

turboscrew
Posts: 174
Joined: Sat Jan 18, 2014 1:50 pm
Location: Nokia (town), Finland

Re: RPi2 memory map

Tue Mar 31, 2015 9:38 pm

Loads of thanks, rst.
De-bugging is for sissies - real men do de-monstrations.

mrvn
Posts: 58
Joined: Wed Jan 09, 2013 6:50 pm

Re: RPi2 memory map

Sun Apr 19, 2015 10:06 am

The bootloader puts ATAGs at 0x100 and passes that address in R2 when it calls your kernel (unless you enabled device tree loading the config.txt). For a simple example for parsing the ATAGs you can look at https://github.com/mrvn/RaspberryPi-bar ... -baremetal. From the ATAGs you get a bunch of usefull informations:

Code: Select all

Memory      : 0x37000000
Initrd start: 0x10000000
Initrd size : 0x00e91566
Commandline : 'dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2709.boardrev=0xa01041 bcm2709.serial=0xc7499b41 smsc95xx.macaddr=B8:27:EB:49:9B:41 bcm2708_fb.fbswap=1 bcm2709.disk_led_gpio=47 bcm2709.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait'
The memory given in the ATAGs is the memory dedicated to the ARM. The portion used by the VC is subtracted already. The commandline also tells you wether you have a Raspberry Pi A/B, Raspberry Pi B+ or Raspberry PI B+ 2. That way you can pick the right peripheral base address and pin for the LED(s) at runtime. See the above URL for details.

Enjoy, Mrvn

Return to “Bare metal, Assembly language”