feat(system): add OCD stub bin support for more targets

Add SOC_DEBUG_HAVE_OCD_STUB_BINS for esp32c5, esp32c61, esp32h4,
esp32h21 and esp32p4. Update TEE linker scripts with
correct esp_tee_app_config offsets for the 0x3000 stub reservation
This commit is contained in:
Erhan Kurubas
2026-09-03 13:09:36 +02:00
committed by Samuel Obuch
parent 7674571d46
commit a799ef99ef
13 changed files with 51 additions and 5 deletions
+7
View File
@@ -585,6 +585,7 @@ menu "ESP System Settings"
bool "Preload OpenOCD stub binaries to speed up debugging. 12K memory will be reserved"
default n
depends on SOC_DEBUG_HAVE_OCD_STUB_BINS
depends on !IDF_TARGET_ESP32P4 || ESP32P4_SELECTS_REV_LESS_V3 || CACHE_L2_CACHE_512KB
help
OpenOCD uses stub code to access flash during programming or when inserting and removing
SW flash breakpoints.
@@ -594,6 +595,12 @@ menu "ESP System Settings"
By enabling this option, 12K of memory in RAM will be preallocated with the stub code,
eliminating the need to back up and restore the memory region.
The stub binaries are prebuilt and linked to run at the start of IRAM (_iram_start).
On ESP32-P4 rev >= v3, _iram_start is 0x4FF00000 + L2 cache size, so it only matches the
stub's link address (0x4FF80000) when the L2 cache is 512KB. This option is therefore
only available on ESP32-P4 rev >= v3 when CACHE_L2_CACHE_512KB is selected. Earlier P4
revisions and other targets place _iram_start at a fixed address and are not affected.
config ESP_DEBUG_OCDAWARE
bool "Make exception and panic handlers JTAG/OCD aware"
default y
@@ -15,10 +15,14 @@ set(openocd_path $ENV{OPENOCD_SCRIPTS})
if(openocd_path)
set(stub_bin_path ${openocd_path}/../espressif/stub_bins)
if(IS_DIRECTORY ${stub_bin_path} AND IS_DIRECTORY ${stub_bin_path}/${target})
set(code_bin "${stub_bin_path}/${target}/stub_flash_idf_binary_code.inc")
set(data_bin "${stub_bin_path}/${target}/stub_flash_idf_binary_data.inc")
set(img_header "${stub_bin_path}/${target}/stub_flash_idf_image.h")
set(stub_target_dir ${target})
if(target STREQUAL "esp32p4" AND CONFIG_ESP32P4_REV_MIN_FULL LESS 300)
set(stub_target_dir "esp32p4-rev1")
endif()
if(IS_DIRECTORY ${stub_bin_path} AND IS_DIRECTORY ${stub_bin_path}/${stub_target_dir})
set(code_bin "${stub_bin_path}/${stub_target_dir}/stub_flash_idf_binary_code.inc")
set(data_bin "${stub_bin_path}/${stub_target_dir}/stub_flash_idf_binary_data.inc")
set(img_header "${stub_bin_path}/${stub_target_dir}/stub_flash_idf_image.h")
if(EXISTS ${code_bin} AND EXISTS ${data_bin} AND EXISTS ${img_header})
set(dest_dir "${CMAKE_BINARY_DIR}/openocd_stub_bins")
set(output_code_bin "${dest_dir}/stub_flash_idf_binary_code.inc")