Skip to content

Commit 11b08d2

Browse files
committed
snippets: add a snippet for RAM boot on RP2350 SoC
Should be also possible on RP2040 but has less practical applications due to lack of UART boot. Usage: `west build -b rpi_pico2/rp2350a/m33 -S rp2350-ram-boot samples/subsys/usb/console` Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
1 parent f7c97c9 commit 11b08d2

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2025 Dmitrii Sharshakov
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/* We should partition SRAM between executable and data */
8+
/delete-node/ &sram0;
9+
10+
&flash0 {
11+
/* remove image definition and code partition in Flash */
12+
/delete-node/ partitions;
13+
};
14+
15+
#define RP2350_RAM_TOTAL_SIZE DT_SIZE_K(520)
16+
#define RP2350_RAM_CODE_SIZE DT_SIZE_K(256)
17+
// Has to be adjusted as 0x20000000 + RP2350_RAM_CODE_SIZE if code partition is resized
18+
#define RP2350_RAM_OFFSET 20040000
19+
#define RP2350_IMAGE_DEF_SIZE 0x100
20+
21+
/ {
22+
chosen {
23+
zephyr,sram = &sram0_ram;
24+
zephyr,flash = &sram0_code;
25+
};
26+
27+
sram0_code: memory@20000000 {
28+
compatible = "mmio-sram";
29+
reg = <0x20000000 RP2350_RAM_CODE_SIZE>;
30+
31+
partitions {
32+
compatible = "fixed-partitions";
33+
#address-cells = <1>;
34+
#size-cells = <1>;
35+
36+
/* Reserved memory for an image definition block added by linker.
37+
* The block is much smaller than 256 bytes, but in practice the
38+
* linker places the vector table at a much larger alignment offset.
39+
*/
40+
image_def: partition@0 {
41+
label = "image_def";
42+
reg = <0x00000000 RP2350_IMAGE_DEF_SIZE>;
43+
read-only;
44+
};
45+
46+
/* Actual code, whole code RAM - 0x100 for header */
47+
code_partition: partition@100 {
48+
label = "code-partition";
49+
reg = <RP2350_IMAGE_DEF_SIZE
50+
(RP2350_RAM_CODE_SIZE - RP2350_IMAGE_DEF_SIZE)>;
51+
read-only;
52+
};
53+
};
54+
};
55+
56+
sram0_ram: memory@RP2350_RAM_OFFSET {
57+
compatible = "mmio-sram";
58+
reg = <(0x20000000 + RP2350_RAM_CODE_SIZE)
59+
(RP2350_RAM_TOTAL_SIZE - RP2350_RAM_CODE_SIZE - RP2350_IMAGE_DEF_SIZE)>;
60+
};
61+
};

snippets/rp2350-ram-boot/snippet.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) 2025 Dmitrii Sharshakov
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: rp2350-ram-boot
5+
append:
6+
EXTRA_DTC_OVERLAY_FILE: rp2350-ram-boot.overlay

soc/raspberrypi/rpi_pico/rp2350/linker.ld

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
*/
88

99
#if CONFIG_RP2_REQUIRES_IMAGE_DEFINITION_BLOCK
10+
#include <zephyr/devicetree.h>
11+
1012
MEMORY
1113
{
12-
IMAGE_DEF_FLASH (r) : ORIGIN = 0x10000000, LENGTH = 128
14+
/* place image definition before the image start as per DT */
15+
IMAGE_DEF_FLASH (r) : ORIGIN = DT_REG_ADDR(DT_CHOSEN(zephyr_flash)), LENGTH = 128
1316
}
1417

1518
SECTIONS

0 commit comments

Comments
 (0)