2.1. Bus Fabric
The RP2040 bus fabric routes addresses and data across the chip.
Figure 4 shows the high-level structure of the bus fabric. The main AHB-Lite crossbar routes addresses and data between its 4 upstream ports and 10 downstream ports: up to four bus transfers can take place each cycle. All data paths are 32 bits wide. Memory devices have dedicated ports on the main crossbar, to satisfy their high bandwidth requirements. High-bandwidth AHB-Lite peripherals have a shared port on the crossbar, and an APB bridge provides bus access to system control registers and lower-bandwidth peripherals.
Figure 4. RP2040 bus fabric overview.

The bus fabric connects 4 AHB-Lite masters, i.e. devices which generate addresses:
- • Processor core 0
- • Processor core 1
- • DMA controller Read port
- • DMA controller Write port
These are routed through to 10 downstream ports on the main crossbar:
- • ROM
- • Flash XIP
- • SRAM 0 to 5 (one port each)
- • Fast AHB-Lite peripherals: PI00, PI01, USB, DMA control registers, XIP aux (one shared port)
- • Bridge to all APB peripherals, and system control registers
The four bus masters can access any four different crossbar ports simultaneously, the bus fabric does not add wait
states to any AHB-Lite slave access. So at a system clock of 125MHz the maximum sustained bus bandwidth is 2.0GBps. The system address map has been arranged to make this parallel bandwidth available to as many software use cases as possible – for example, the striped SRAM alias ( Section 2.6.2 ) scatters main memory accesses across four crossbar ports (SRAM0...3), so that more memory accesses can proceed in parallel.
2.1.1. AHB-Lite Crossbar
At the centre of the RP2040 bus fabric is a 4:10 fully-connected crossbar. Its 4 upstream ports are connected to the 4 system bus masters, and the 10 downstream ports connect to the highest-bandwidth AHB-Lite slaves (namely the memory interfaces) and to lower layers of the fabric. Figure 5 shows the structure of a 2:3 AHB-Lite crossbar, arranged identically to the 4:10 crossbar on RP2040, but easier to show in the diagram.
Figure 5. A 2:3 AHB-Lite crossbar. Each upstream port connects to a splitter, which routes bus requests toward one of the 3 downstream ports, and routes responses back. Each downstream port connects to an arbiter, which safely manages concurrent access to the port.

graph TD
U0[Upstream Port 0] <--> S0[Splitter 1:3]
U1[Upstream Port 1] <--> S1[Splitter 1:3]
S0 --> A0[Arbiter 2:1]
S0 --> A1[Arbiter 2:1]
S0 --> A2[Arbiter 2:1]
S1 --> A0
S1 --> A1
S1 --> A2
A0 <--> D0[Downstream Port 0]
A1 <--> D1[Downstream Port 1]
A2 <--> D2[Downstream Port 2]
The crossbar is built from two components:
- • Splitters
- ◦ Perform coarse address decode
- ◦ Route requests (addresses, write data) to the downstream port indicated by the initial address decode
- ◦ Route responses (read data, bus errors) from the correct arbiter back to the upstream port
- • Arbiters
- ◦ Manage concurrent requests to a downstream port
- ◦ Route responses (read data, bus errors) to the correct splitter
- ◦ Implement bus priority rules
The main crossbar on RP2040 consists of 4 1:10 splitters and 10 4:1 arbiters, with a mesh of 40 AHB-Lite bus channels between them. Note that, as AHB-Lite is a pipelined bus, the splitter may be routing back a response to an earlier request from downstream port A, whilst a new request to downstream port B is already in progress. This does not incur any cycle penalty.
2.1.1.1. Bus Priority
The arbiters in the main AHB-Lite crossbar implement a two-level bus priority scheme. Priority levels are configured per-master, using the BUS_PRIORITY register in the BUSCTRL register block.
When there are multiple simultaneous accesses to same arbiter, any requests from high-priority masters (priority level 1) will be considered before any requests from low-priority masters (priority 0). If multiple masters of the same priority level attempt to access the same slave simultaneously, a round-robin tie break is applied, i.e. the arbiter grants access to each master in turn.
NOTEPriority arbitration only applies to multiple masters attempting to access the same slave on the same cycle. Accesses to different slaves, e.g. different SRAM banks, can proceed simultaneously.
When accessing a slave with zero wait states, such as SRAM (i.e. can be accessed once per system clock cycle), high-priority masters will never observe any slowdown or other timing effects caused by accesses from low-priority masters. This allows guaranteed latency and throughput for hard real time use cases; it does however mean a low-priority master may get stalled until there is a free cycle.
2.1.1.2. Bus Performance Counters
The performance counters automatically count accesses to the main AHB-Lite crossbar arbiters. This can assist in diagnosing performance issues, in high-traffic use cases.
There are four performance counters. Each is a 24-bit saturating counter. Counter values can be read from
BUSCTRL_PERFCTR
x, and cleared by writing any value to
BUSCTRL_PERFCTR
x. Each counter can count one of the 20 available events at a time, as selected by
BUSCTRL_PERFSEL
x. The available bus events are:
| PERFSEL x | Event | Description |
|---|---|---|
| 0 | APB access, contested | Completion of an access to the APB arbiter (which is upstream of all APB peripherals), which was previously delayed due to an access by another master. |
| 1 | APB access | Completion of an access to the APB arbiter |
| 2 | FASTPERI access, contested | Completion of an access to the FASTPERI arbiter (which is upstream of PIOs, DMA config port, USB, XIP aux FIFO port), which was previously delayed due to an access by another master. |
| 3 | FASTPERI access | Completion of an access to the FASTPERI arbiter |
| 4 | SRAM5 access, contested | Completion of an access to the SRAM5 arbiter, which was previously delayed due to an access by another master. |
| 5 | SRAM5 access | Completion of an access to the SRAM5 arbiter |
| 6 | SRAM4 access, contested | Completion of an access to the SRAM4 arbiter, which was previously delayed due to an access by another master. |
| 7 | SRAM4 access | Completion of an access to the SRAM4 arbiter |
| 8 | SRAM3 access, contested | Completion of an access to the SRAM3 arbiter, which was previously delayed due to an access by another master. |
| 9 | SRAM3 access | Completion of an access to the SRAM3 arbiter |
| 10 | SRAM2 access, contested | Completion of an access to the SRAM2 arbiter, which was previously delayed due to an access by another master. |
| 11 | SRAM2 access | Completion of an access to the SRAM2 arbiter |
| 12 | SRAM1 access, contested | Completion of an access to the SRAM1 arbiter, which was previously delayed due to an access by another master. |
| 13 | SRAM1 access | Completion of an access to the SRAM1 arbiter |
| 14 | SRAM0 access, contested | Completion of an access to the SRAM0 arbiter, which was previously delayed due to an access by another master. |
| 15 | SRAM0 access | Completion of an access to the SRAM0 arbiter |
| PERFSEL x | Event | Description |
|---|---|---|
| 16 | XIP_MAIN access, contested | Completion of an access to the XIP_MAIN arbiter, which was previously delayed due to an access by another master. |
| 17 | XIP_MAIN access | Completion of an access to the XIP_MAIN arbiter |
| 18 | ROM access, contested | Completion of an access to the ROM arbiter, which was previously delayed due to an access by another master. |
| 19 | ROM access | Completion of an access to the ROM arbiter |
2.1.2. Atomic Register Access
Each peripheral register block is allocated 4kB of address space, with registers accessed using one of 4 methods, selected by address decode.
- • Addr + 0x0000 : normal read write access
- • Addr + 0x1000 : atomic XOR on write
- • Addr + 0x2000 : atomic bitmask set on write
- • Addr + 0x3000 : atomic bitmask clear on write
This allows individual fields of a control register to be modified without performing a read-modify-write sequence in software: instead the changes are posted to the peripheral, and performed in-situ. Without this capability, it is difficult to safely access IO registers when an interrupt service routine is concurrent with code running in the foreground, or when the two processors are running code in parallel.
The four atomic access aliases occupy a total of 16kB. Most peripherals on RP2040 provide this functionality natively, and atomic writes have the same timing as normal read/write access. Some peripherals (I2C, UART, SPI and SSI) instead have this functionality added using a bus interposer, which translates upstream atomic writes into downstream read-modify-write sequences, at the boundary of the peripheral. This extends the access time by two system clock cycles.
The SIO ( Section 2.3.1 ), a single-cycle IO block attached directly to the cores' IO ports, does not support atomic accesses at the bus level, although some individual registers (e.g. GPIO) have set/clear/xor aliases.
2.1.3. APB Bridge
The APB bridge interfaces the high-speed main AHB-Lite interconnect to the lower-bandwidth peripherals. Whilst the AHB-Lite fabric offers zero-wait-state access everywhere, APB accesses have a cycle penalty:
- • APB bus accesses take two cycles minimum (setup phase and access phase)
- • The bridge adds an additional cycle to read accesses, as the bus request and response are registered
- • The bridge adds two additional cycles to write accesses, as the APB setup phase can not begin until the AHB-Lite write data is valid
As a result, the throughput of the APB portion of the bus fabric is somewhat lower than the AHB-Lite portion. However, there is more than sufficient bandwidth to saturate the APB serial peripherals.
2.1.4. Narrow IO Register Writes
Memory-mapped IO registers on RP2040 ignore the width of bus read/write accesses. They treat all writes as though they were 32 bits in size. This means software can not use byte or halfword writes to modify part of an IO register: any write to an address where the 30 address MSBs match the register address will affect the contents of the entire
register.
To update part of an IO register, without a read-modify-write sequence, the best solution on RP2040 is atomic set/clear/XOR (see Section 2.1.2 ). Note that this is more flexible than byte or halfword writes, as any combination of fields can be updated in one operation.
Upon a 8-bit or 16-bit write (such as a
strb instruction on the Cortex-M0+), an IO register will sample the entire 32-bit write databus. The Cortex-M0+ and DMA on RP2040 will always replicate narrow data across the bus:
Pico Examples: https://github.com/raspberrypi/pico-examples/blob/master/system/narrow_io_write/narrow_io_write.c Lines 19 - 62
19 int main() {
20 stdio_init_all();
21
22 // We'll use WATCHDOG_SCRATCH0 as a convenient 32 bit read/write register
23 // that we can assign arbitrary values to
24 io_rw_32 *scratch32 = &watchdog_hw->scratch[0];
25 // Alias the scratch register as two halfwords at offsets +0x0 and +0x2
26 volatile uint16_t *scratch16 = (volatile uint16_t *) scratch32;
27 // Alias the scratch register as four bytes at offsets +0x0, +0x1, +0x2, +0x3:
28 volatile uint8_t *scratch8 = (volatile uint8_t *) scratch32;
29
30 // Show that we can read/write the scratch register as normal:
31 printf("Writing 32 bit value\n");
32 *scratch32 = 0xdeadbeef;
33 printf("Should be 0xdeadbeef: 0x%08x\n", *scratch32);
34
35 // We can do narrow reads just fine -- IO registers treat this as a 32 bit
36 // read, and the processor/DMA will pick out the correct byte lanes based
37 // on transfer size and address LSBs
38 printf("\nReading back 1 byte at a time\n");
39 // Little-endian!
40 printf("Should be ef be ad de: %02x ", scratch8[0]);
41 printf("%02x ", scratch8[1]);
42 printf("%02x ", scratch8[2]);
43 printf("%02x\n", scratch8[3]);
44
45 // Byte writes are replicated four times across the 32-bit bus, and IO
46 // registers usually sample the entire write bus.
47 printf("\nWriting 8 bit value 0xa5 at offset 0\n");
48 scratch8[0] = 0xa5;
49 // Read back the whole scratch register in one go
50 printf("Should be 0xa5a5a5a5: 0x%08x\n", *scratch32);
51
52 // The IO register ignores the address LSBs [1:0] as well as the transfer
53 // size, so it doesn't matter what byte offset we use
54 printf("\nWriting 8 bit value at offset 1\n");
55 scratch8[1] = 0x3c;
56 printf("Should be 0x3c3c3c3c: 0x%08x\n", *scratch32);
57
58 // Halfword writes are also replicated across the write data bus
59 printf("\nWriting 16 bit value at offset 0\n");
60 scratch16[0] = 0xf00d;
61 printf("Should be 0xf00df00d: 0x%08x\n", *scratch32);
62 }
2.1.5. List of Registers
The Bus Fabric registers start at a base address of
0x40030000(defined as
BUSCTRL_BASE in SDK).
Table 4. List of
BUSCTRL registers
| Offset | Name | Info |
|---|---|---|
| 0x00 | BUS_PRIORITY | Set the priority of each master for bus arbitration. |
| 0x04 | BUS_PRIORITY_ACK | Bus priority acknowledge |
| 0x08 | PERFCTR0 | Bus fabric performance counter 0 |
| 0x0c | PERFSEL0 | Bus fabric performance event select for PERFCTR0 |
| 0x10 | PERFCTR1 | Bus fabric performance counter 1 |
| 0x14 | PERFSEL1 | Bus fabric performance event select for PERFCTR1 |
| 0x18 | PERFCTR2 | Bus fabric performance counter 2 |
| 0x1c | PERFSEL2 | Bus fabric performance event select for PERFCTR2 |
| 0x20 | PERFCTR3 | Bus fabric performance counter 3 |
| 0x24 | PERFSEL3 | Bus fabric performance event select for PERFCTR3 |
BUSCTRL: BUS_PRIORITY Register
Offset: 0x00
Description
Set the priority of each master for bus arbitration.
Table 5.
BUS_PRIORITY
Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:13 | Reserved. | - | - |
| 12 | DMA_W : 0 - low priority, 1 - high priority | RW | 0x0 |
| 11:9 | Reserved. | - | - |
| 8 | DMA_R : 0 - low priority, 1 - high priority | RW | 0x0 |
| 7:5 | Reserved. | - | - |
| 4 | PROC1 : 0 - low priority, 1 - high priority | RW | 0x0 |
| 3:1 | Reserved. | - | - |
| 0 | PROC0 : 0 - low priority, 1 - high priority | RW | 0x0 |
BUSCTRL: BUS_PRIORITY_ACK Register
Offset: 0x04
Description
Bus priority acknowledge
Table 6.
BUS_PRIORITY_ACK
Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:1 | Reserved. | - | - |
| 0 | Goes to 1 once all arbiters have registered the new global priority levels. Arbiters update their local priority when servicing a new nonsequential access. In normal circumstances this will happen almost immediately. | RO | 0x0 |
BUSCTRL: PERFCTR0 Register
Offset: 0x08
DescriptionBus fabric performance counter 0
Table 7. PERFCTR0 Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:24 | Reserved. | - | - |
| 23:0 | Busfabric saturating performance counter 0 Count some event signal from the busfabric arbiters. Write any value to clear. Select an event to count using PERFSEL0 | WC | 0x000000 |
Offset: 0x0c
DescriptionBus fabric performance event select for PERFCTR0
Table 8. PERFSEL0 Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:5 | Reserved. | - | - |
| 4:0 | Select an event for PERFCTR0. Count either contested accesses, or all accesses, on a downstream port of the main crossbar. | RW | 0x1f |
| Enumerated values: | |||
| 0x00 → APB_CONTESTED | |||
| 0x01 → APB | |||
| 0x02 → FASTPERI_CONTESTED | |||
| 0x03 → FASTPERI | |||
| 0x04 → SRAM5_CONTESTED | |||
| 0x05 → SRAM5 | |||
| 0x06 → SRAM4_CONTESTED | |||
| 0x07 → SRAM4 | |||
| 0x08 → SRAM3_CONTESTED | |||
| 0x09 → SRAM3 | |||
| 0x0a → SRAM2_CONTESTED | |||
| 0x0b → SRAM2 | |||
| 0x0c → SRAM1_CONTESTED | |||
| 0x0d → SRAM1 | |||
| 0x0e → SRAM0_CONTESTED | |||
| 0x0f → SRAM0 | |||
| 0x10 → XIP_MAIN_CONTESTED | |||
| 0x11 → XIP_MAIN | |||
| 0x12 → ROM_CONTESTED | |||
| 0x13 → ROM |
Bus fabric performance counter 1
Table 9. PERFCTR1 Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:24 | Reserved. | - | - |
| 23:0 | Busfabric saturating performance counter 1 Count some event signal from the busfabric arbiters. Write any value to clear. Select an event to count using PERFSEL1 | WC | 0x000000 |
Bus fabric performance event select for PERFCTR1
Table 10. PERFSEL1 Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:5 | Reserved. | - | - |
| 4:0 | Select an event for PERFCTR1. Count either contested accesses, or all accesses, on a downstream port of the main crossbar. | RW | 0x1f |
| Enumerated values: | |||
| 0x00 → APB_CONTESTED | |||
| 0x01 → APB | |||
| 0x02 → FASTPERI_CONTESTED | |||
| 0x03 → FASTPERI | |||
| 0x04 → SRAM5_CONTESTED | |||
| 0x05 → SRAM5 | |||
| 0x06 → SRAM4_CONTESTED | |||
| 0x07 → SRAM4 | |||
| 0x08 → SRAM3_CONTESTED | |||
| 0x09 → SRAM3 | |||
| 0x0a → SRAM2_CONTESTED | |||
| 0x0b → SRAM2 | |||
| 0x0c → SRAM1_CONTESTED | |||
| 0x0d → SRAM1 | |||
| 0x0e → SRAM0_CONTESTED | |||
| 0x0f → SRAM0 | |||
| 0x10 → XIP_MAIN_CONTESTED | |||
| 0x11 → XIP_MAIN | |||
| 0x12 → ROM_CONTESTED | |||
| 0x13 → ROM |
BUSCTRL: PERFCTR2 Register
Offset: 0x18
Description
Bus fabric performance counter 2
Table 11. PERFCTR2 Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:24 | Reserved. | - | - |
| 23:0 | Busfabric saturating performance counter 2 Count some event signal from the busfabric arbiters. Write any value to clear. Select an event to count using PERFSEL2 | WC | 0x000000 |
BUSCTRL: PERFSEL2 Register
Offset: 0x1c
Description
Bus fabric performance event select for PERFCTR2
Table 12. PERFSEL2 Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:5 | Reserved. | - | - |
| 4:0 | Select an event for PERFCTR2. Count either contested accesses, or all accesses, on a downstream port of the main crossbar. | RW | 0x1f |
| Enumerated values: | |||
| 0x00 → APB_CONTESTED | |||
| 0x01 → APB | |||
| 0x02 → FASTPERI_CONTESTED | |||
| 0x03 → FASTPERI | |||
| 0x04 → SRAM5_CONTESTED | |||
| 0x05 → SRAM5 | |||
| 0x06 → SRAM4_CONTESTED | |||
| 0x07 → SRAM4 | |||
| 0x08 → SRAM3_CONTESTED | |||
| 0x09 → SRAM3 | |||
| 0x0a → SRAM2_CONTESTED | |||
| 0x0b → SRAM2 | |||
| 0x0c → SRAM1_CONTESTED | |||
| 0x0d → SRAM1 | |||
| 0x0e → SRAM0_CONTESTED | |||
| 0x0f → SRAM0 | |||
| 0x10 → XIP_MAIN_CONTESTED | |||
| 0x11 → XIP_MAIN | |||
| 0x12 → ROM_CONTESTED |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 0x13 → ROM |
BUSCTRL: PERFCTR3 Register
Offset: 0x20
Description
Bus fabric performance counter 3
Table 13. PERFCTR3 Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:24 | Reserved. | - | - |
| 23:0 | Busfabric saturating performance counter 3 Count some event signal from the busfabric arbiters. Write any value to clear. Select an event to count using PERFSEL3 | WC | 0x000000 |
BUSCTRL: PERFSEL3 Register
Offset: 0x24
Description
Bus fabric performance event select for PERFCTR3
Table 14. PERFSEL3 Register
| Bits | Description | Type | Reset |
|---|---|---|---|
| 31:5 | Reserved. | - | - |
| 4:0 | Select an event for PERFCTR3. Count either contested accesses, or all accesses, on a downstream port of the main crossbar. | RW | 0x1f |
| Enumerated values: | |||
| 0x00 → APB_CONTESTED | |||
| 0x01 → APB | |||
| 0x02 → FASTPERI_CONTESTED | |||
| 0x03 → FASTPERI | |||
| 0x04 → SRAM5_CONTESTED | |||
| 0x05 → SRAM5 | |||
| 0x06 → SRAM4_CONTESTED | |||
| 0x07 → SRAM4 | |||
| 0x08 → SRAM3_CONTESTED | |||
| 0x09 → SRAM3 | |||
| 0x0a → SRAM2_CONTESTED | |||
| 0x0b → SRAM2 | |||
| 0x0c → SRAM1_CONTESTED | |||
| 0x0d → SRAM1 | |||
| 0x0e → SRAM0_CONTESTED | |||
| 0x0f → SRAM0 | |||
| 0x10 → XIP_MAIN_CONTESTED |
| Bits | Description | Type | Reset |
|---|---|---|---|
| 0x11 → XIP_MAIN | |||
| 0x12 → ROM_CONTESTED | |||
| 0x13 → ROM |