flash/nor/rp2040: detect flash size including SFDP

Also keep size override by FLASHSIZE Tcl variable possible.

Partially backported from former upstream rp2040.c

Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Change-Id: I224c3644450e8b46e35714bfc5436219ffdee563
Reviewed-on: https://review.openocd.org/c/openocd/+/8451
Tested-by: jenkins
This commit is contained in:
Tomas Vanek
2024-08-14 09:10:31 +02:00
parent 22dfd0efad
commit 2e1a76368e
2 changed files with 299 additions and 18 deletions

View File

@@ -19,6 +19,14 @@ if { [info exists WORKAREASIZE] } {
set _WORKAREASIZE 0x10000
}
# Nonzero FLASHSIZE supresses QSPI flash size detection
if { [info exists FLASHSIZE] } {
set _FLASHSIZE $FLASHSIZE
} else {
# Detect QSPI flash size based on flash ID or SFDP
set _FLASHSIZE 0
}
if { [info exists CPUTAPID] } {
set _CPUTAPID $CPUTAPID
} else {
@@ -143,13 +151,15 @@ if { ![info exists _FLASH_TARGET] && [info exists _TARGETNAME_1] } {
}
}
if { [info exists _FLASH_TARGET] } {
$_FLASH_TARGET configure -work-area-phys 0x20010000 -work-area-size $_WORKAREASIZE
# QSPI flash size detection during gdb connect requires to back-up RAM
set _WKA_BACKUP [expr { $_FLASHSIZE == 0 }]
$_FLASH_TARGET configure -work-area-phys 0x20010000 -work-area-size $_WORKAREASIZE -work-area-backup $_WKA_BACKUP
if { [info exists _TARGETNAME_CM0] && [info exists _TARGETNAME_RV0] } {
$_TARGETNAME_RV0 configure -work-area-phys 0x20010000 -work-area-size $_WORKAREASIZE
$_TARGETNAME_RV0 configure -work-area-phys 0x20010000 \
-work-area-size $_WORKAREASIZE -work-area-backup $_WKA_BACKUP
echo "Info : $_CHIPNAME.flash will be handled by the active one of $_FLASH_TARGET and $_TARGETNAME_RV0 cores"
}
set _FLASHNAME $_CHIPNAME.flash
set _FLASHSIZE 0x00400000
flash bank $_FLASHNAME rp2040_flash 0x10000000 $_FLASHSIZE 0 0 $_FLASH_TARGET
}