Skip to content

Instantly share code, notes, and snippets.

@max-dark
Last active March 20, 2025 00:40
Show Gist options
  • Save max-dark/490075915e37ed60c6c3bcd0f998b0e8 to your computer and use it in GitHub Desktop.
Save max-dark/490075915e37ed60c6c3bcd0f998b0e8 to your computer and use it in GitHub Desktop.
small patches for custom boards with RP2040 MCU
  • Fix deprecation warning for board/pico-debug.cfg
  • Add support for FLASH_SIZE customisation in target/rp2040.cfg (Allow skip flash auto_probe)
  • Add support for 2 new NOR Flash in src/flash/nor/spi.c (Fix "Error: Unknown flash device")
diff --git a/tcl/board/pico-debug.cfg b/tcl/board/pico-debug.cfg
index ba59f860a..2215816aa 100644
--- a/tcl/board/pico-debug.cfg
+++ b/tcl/board/pico-debug.cfg
@@ -7,4 +7,4 @@ source [find interface/cmsis-dap.cfg]
adapter speed 4000
set CHIPNAME rp2040
-source [find target/rp2040-core0.cfg]
+source [find target/rp2040.cfg]

list of libraries

sudo apt install libjim-dev
sudo apt install libhidapi-dev
sudo apt install libftdi1-dev libftdi-dev
sudo apt install libjaylink-dev
sudo apt install libusb-1.0-0-dev
sudo apt install libusb-dev
diff --git a/src/flash/nor/spi.c b/src/flash/nor/spi.c
index bf654f9f6..ef74f960b 100644
--- a/src/flash/nor/spi.c
+++ b/src/flash/nor/spi.c
@@ -185,6 +185,9 @@ const struct flash_device flash_devices[] = {
FLASH_ID("xtx xt25q128b", 0x03, 0x0b, 0x02, 0xd8, 0xc7, 0x0018600b, 0x100, 0x10000, 0x1000000),
FLASH_ID("zetta zd25q16", 0x03, 0x00, 0x02, 0xd8, 0xc7, 0x001560ba, 0x100, 0x10000, 0x200000),
+ FLASH_ID("zbit zb25vq32" , 0x03, 0x0b, 0x02, 0xd8, 0xc7, 0x0016405e, 0x100, 0x10000, 0x0400000),
+ FLASH_ID("boya by25q128es", 0x03, 0x0b, 0x02, 0xd8, 0xc7, 0x00184068, 0x100, 0x10000, 0x1000000),
+
/* FRAM, no erase commands, no write page or sectors */
/* name read qread page device_id total
diff --git a/tcl/target/rp2040.cfg b/tcl/target/rp2040.cfg
index 5e78c6931..f67f2a862 100644
--- a/tcl/target/rp2040.cfg
+++ b/tcl/target/rp2040.cfg
@@ -99,11 +99,19 @@ if { $_USE_CORE == 1 } {
# The flash is probed during gdb connect if gdb memory_map is enabled (by default).
$_FLASH_TARGET configure -work-area-phys 0x20010000 -work-area-size $_WORKAREASIZE -work-area-backup 1
set _FLASHNAME $_CHIPNAME.flash
-flash bank $_FLASHNAME rp2040_flash 0x10000000 0 0 0 $_FLASH_TARGET
+
+# allow skip flash auto_probe
+if { [info exists FLASH_SIZE] } {
+ set _FLASH_SIZE $FLASH_SIZE
+} else {
+ set _FLASH_SIZE 0
+}
+
+flash bank $_FLASHNAME rp2040_flash 0x10000000 $_FLASH_SIZE 0 0 $_FLASH_TARGET
if { $_BOTH_CORES } {
# Alias to ensure gdb connecting to core 1 gets the correct memory map
- flash bank $_CHIPNAME.alias virtual 0x10000000 0 0 0 $_TARGETNAME_1 $_FLASHNAME
+ flash bank $_CHIPNAME.alias virtual 0x10000000 $_FLASH_SIZE 0 0 $_TARGETNAME_1 $_FLASHNAME
# Select core 0
targets $_TARGETNAME_0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment