August 3, 2023

Pi Pico - RP2040, what is where?

Almost the first thing you need to know about a microcontroller is what the address map looks like. Where is RAM? Where are control registers? Where is the boot ROM? The RP2040 has a 639 page datasheet, and you will need to become familiar with it to write bare metal software.
0x0000_0000 - ROM
0x1000_0000 - XIP
0x2000_0000 - SRAM
0x4000_0000 - APB devices
0x5000_0000 - AHB-lite devices
0xd000_0000 - IOPORT registers
0xe000_0000 - Cortex M0+ internal registers
The above gives base addresses, but if you are new to this, everything besides ROM and SRAM is probably unfamiliar. I'll ignore most of these for now and just talk about ROM and RAM.

ROM -- there is a 16K immutable boot ROM at address 0. This makes sense give that the ARM core will begin running at address zero. Note that the bootrom code is freely available!

I am shocked! I have never had this luxury before. I have always had to figure out how to read out a binary image of the bootrom, disassemble it, then spend days studying the disassembled code.
This leaves me almost speechless.

SRAM -- there is 264K of it. It is in six banks. There are four 64K banks and two 4K banks. The first four banks are interleaved as 32 bit words, but at a first cut you can ignore all of this and just be happy dealing with 264K of ram.

XIP

What the heck is this? It is "execute in place"!
This is a scheme for running code that is in flash without first copying it to RAM to execute there. This has been done for the ESP8266, ESP32, as well as other chips.

APB

This is "advanced peripheral bus". It is an ARM thing and here is where you find almost all of the peripherals -- Uart, timer, i2c, and much more.

AHB-lite

This is "advanced high performance bus". Are there any buses that are not "advanced"? The -lite indicates that only a single bus master exists. This bus only has a few things (DMA, USB, PIO)

IOPORT

This contains SIO (single cycle IO, not serial IO). At first glance this looks like a communication mailbox between the two processors, but this may be a hasty generalization. It also has GPIO registers.
Feedback? Questions? Drop me a line!

Tom's Computer Info / [email protected]