From baf62b7a987564406a673e59e9388ab40c40c33e Mon Sep 17 00:00:00 2001 From: Marcio Ribeiro Date: Fri, 23 Aug 2024 15:20:36 -0300 Subject: [PATCH] soc: esp32: XIP removed from Espressif targets The way ESP32 XIP works (with MMU and cache) does no fit the way Zephyr XIP is implemented, causing issues related to included Zephyr linker files. Flash code still resides in flash for execution, but MMU/Cache handles it in such way that XIP might not (or should not) be used with current Zephyr approach. To address this problem, XIP configuration option is being removed from Espressif targets. Signed-off-by: Marcio Ribeiro --- soc/espressif/esp32/Kconfig | 1 - soc/espressif/esp32/default.ld | 9 +++++++++ soc/espressif/esp32/mcuboot.ld | 4 ---- soc/espressif/esp32c2/Kconfig | 1 - soc/espressif/esp32c2/default.ld | 17 +++++++++-------- soc/espressif/esp32c2/mcuboot.ld | 6 +----- soc/espressif/esp32c3/Kconfig | 1 - soc/espressif/esp32c3/default.ld | 17 +++++++++-------- soc/espressif/esp32c3/mcuboot.ld | 6 +----- soc/espressif/esp32c6/Kconfig | 1 - soc/espressif/esp32c6/default.ld | 9 +++++++++ soc/espressif/esp32s2/Kconfig | 1 - soc/espressif/esp32s2/default.ld | 9 +++++++++ soc/espressif/esp32s2/mcuboot.ld | 4 ---- soc/espressif/esp32s3/Kconfig | 1 - soc/espressif/esp32s3/default.ld | 9 +++++++++ soc/espressif/esp32s3/mcuboot.ld | 4 ---- 17 files changed, 56 insertions(+), 44 deletions(-) diff --git a/soc/espressif/esp32/Kconfig b/soc/espressif/esp32/Kconfig index 72c77861b15..3059ea322f5 100644 --- a/soc/espressif/esp32/Kconfig +++ b/soc/espressif/esp32/Kconfig @@ -8,7 +8,6 @@ config SOC_SERIES_ESP32 select ARCH_HAS_GDBSTUB select ARCH_SUPPORTS_COREDUMP select PINCTRL - select XIP if !MCUBOOT select HAS_ESPRESSIF_HAL select CPU_HAS_FPU select HAS_PM diff --git a/soc/espressif/esp32/default.ld b/soc/espressif/esp32/default.ld index e4c8d62599a..5a80d593c37 100644 --- a/soc/espressif/esp32/default.ld +++ b/soc/espressif/esp32/default.ld @@ -42,12 +42,21 @@ user_dram_2_seg_len = SRAM1_USER_SIZE; #define RAMABLE_REGION_1 dram0_0_seg #endif +#undef GROUP_DATA_LINK_IN +#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion + +#undef GROUP_NOLOAD_LINK_IN +#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion + /* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA. * Executing directly from LMA is not possible. */ #undef GROUP_ROM_LINK_IN #define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion /* Make sure new sections have consistent alignment between input and output sections */ +#undef SECTION_DATA_PROLOGUE +#define SECTION_DATA_PROLOGUE(name, options, align) name options : ALIGN_WITH_INPUT + #undef SECTION_PROLOGUE #define SECTION_PROLOGUE SECTION_DATA_PROLOGUE diff --git a/soc/espressif/esp32/mcuboot.ld b/soc/espressif/esp32/mcuboot.ld index 37d284cbcd9..8fb1c25decc 100644 --- a/soc/espressif/esp32/mcuboot.ld +++ b/soc/espressif/esp32/mcuboot.ld @@ -10,10 +10,6 @@ #include "memory.h" -#ifdef CONFIG_XIP -#error "Xtensa bootloader cannot use XIP" -#endif /* CONFIG_XIP */ - /* Disable all romable LMA */ #undef GROUP_DATA_LINK_IN #define GROUP_DATA_LINK_IN(vregion, lregion) > vregion diff --git a/soc/espressif/esp32c2/Kconfig b/soc/espressif/esp32c2/Kconfig index 2ff6734b599..cc98488000c 100644 --- a/soc/espressif/esp32c2/Kconfig +++ b/soc/espressif/esp32c2/Kconfig @@ -12,7 +12,6 @@ config SOC_SERIES_ESP32C2 select RISCV_ISA_EXT_C select RISCV_ISA_EXT_ZICSR select HAS_ESPRESSIF_HAL - select XIP if !MCUBOOT if SOC_SERIES_ESP32C2 diff --git a/soc/espressif/esp32c2/default.ld b/soc/espressif/esp32c2/default.ld index 5b62444ed1e..38f43b1edff 100644 --- a/soc/espressif/esp32c2/default.ld +++ b/soc/espressif/esp32c2/default.ld @@ -36,12 +36,21 @@ user_dram_seg_len = user_idram_size; #define RAMABLE_REGION dram0_0_seg #define ROMABLE_REGION FLASH +#undef GROUP_DATA_LINK_IN +#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion + +#undef GROUP_NOLOAD_LINK_IN +#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion + /* Flash segments (rodata and text) should be mapped in the virtual address spaces. * Executing directly from LMA is not possible. */ #undef GROUP_ROM_LINK_IN #define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion /* Make sure new sections have consistent alignment between input and output sections */ +#undef SECTION_DATA_PROLOGUE +#define SECTION_DATA_PROLOGUE(name, options, align) name options : ALIGN_WITH_INPUT + #undef SECTION_PROLOGUE #define SECTION_PROLOGUE SECTION_DATA_PROLOGUE @@ -727,14 +736,6 @@ SECTIONS .flash.rodata_end : ALIGN(0x10) { . = ALIGN(4); - -#ifdef CONFIG_THREAD_LOCAL_STORAGE - /* create explicit symbol for __tdata_start so that it is loaded - * into proper DROM region atributted by AT keyword below - */ - __tdata_start = ADDR(tdata); -#endif - _rodata_reserved_end = ABSOLUTE(.); _image_rodata_end = ABSOLUTE(.); } GROUP_DATA_LINK_IN(RODATA_REGION, ROMABLE_REGION) diff --git a/soc/espressif/esp32c2/mcuboot.ld b/soc/espressif/esp32c2/mcuboot.ld index 4d66262e8be..9bbbad889a5 100644 --- a/soc/espressif/esp32c2/mcuboot.ld +++ b/soc/espressif/esp32c2/mcuboot.ld @@ -10,12 +10,8 @@ #include "memory.h" -#ifdef CONFIG_XIP -#error "ESP32C2 bootloader cannot use XIP" -#endif /* CONFIG_XIP */ - /* Disable all romable LMA */ -#udef GROUP_DATA_LINK_IN +#undef GROUP_DATA_LINK_IN #define GROUP_DATA_LINK_IN(vregion, lregion) > vregion #define RAMABLE_REGION dram_seg diff --git a/soc/espressif/esp32c3/Kconfig b/soc/espressif/esp32c3/Kconfig index 5cdeb6a6a47..c3a562d0f98 100644 --- a/soc/espressif/esp32c3/Kconfig +++ b/soc/espressif/esp32c3/Kconfig @@ -12,7 +12,6 @@ config SOC_SERIES_ESP32C3 select RISCV_ISA_EXT_C select RISCV_ISA_EXT_ZICSR select HAS_ESPRESSIF_HAL - select XIP if !MCUBOOT select HAS_PM select HAS_POWEROFF diff --git a/soc/espressif/esp32c3/default.ld b/soc/espressif/esp32c3/default.ld index 6058e09505c..bbb992fcf6f 100644 --- a/soc/espressif/esp32c3/default.ld +++ b/soc/espressif/esp32c3/default.ld @@ -36,12 +36,21 @@ user_dram_seg_len = user_idram_size; #define RAMABLE_REGION dram0_0_seg #define ROMABLE_REGION FLASH +#undef GROUP_DATA_LINK_IN +#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion + +#undef GROUP_NOLOAD_LINK_IN +#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion + /* Flash segments (rodata and text) should be mapped in the virtual address spaces. * Executing directly from LMA is not possible. */ #undef GROUP_ROM_LINK_IN #define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion /* Make sure new sections have consistent alignment between input and output sections */ +#undef SECTION_DATA_PROLOGUE +#define SECTION_DATA_PROLOGUE(name, options, align) name options : ALIGN_WITH_INPUT + #undef SECTION_PROLOGUE #define SECTION_PROLOGUE SECTION_DATA_PROLOGUE @@ -793,14 +802,6 @@ SECTIONS .flash.rodata_end : ALIGN(0x10) { . = ALIGN(4); - -#ifdef CONFIG_THREAD_LOCAL_STORAGE - /* create explicit symbol for __tdata_start so that it is loaded - * into proper DROM region atributted by AT keyword below - */ - __tdata_start = ADDR(tdata); -#endif - _rodata_reserved_end = ABSOLUTE(.); _image_rodata_end = ABSOLUTE(.); } GROUP_DATA_LINK_IN(RODATA_REGION, ROMABLE_REGION) diff --git a/soc/espressif/esp32c3/mcuboot.ld b/soc/espressif/esp32c3/mcuboot.ld index 4d20238bdbc..44f075893e5 100644 --- a/soc/espressif/esp32c3/mcuboot.ld +++ b/soc/espressif/esp32c3/mcuboot.ld @@ -10,12 +10,8 @@ #include "memory.h" -#ifdef CONFIG_XIP -#error "ESP32C3 bootloader cannot use XIP" -#endif /* CONFIG_XIP */ - /* Disable all romable LMA */ -#udef GROUP_DATA_LINK_IN +#undef GROUP_DATA_LINK_IN #define GROUP_DATA_LINK_IN(vregion, lregion) > vregion #define RAMABLE_REGION dram_seg diff --git a/soc/espressif/esp32c6/Kconfig b/soc/espressif/esp32c6/Kconfig index c33528ac325..7c5c00e4777 100644 --- a/soc/espressif/esp32c6/Kconfig +++ b/soc/espressif/esp32c6/Kconfig @@ -13,7 +13,6 @@ config SOC_SERIES_ESP32C6 select RISCV_ISA_EXT_C select RISCV_ISA_EXT_ZICSR select HAS_ESPRESSIF_HAL - select XIP if !MCUBOOT select HAS_PM select HAS_POWEROFF diff --git a/soc/espressif/esp32c6/default.ld b/soc/espressif/esp32c6/default.ld index 1cf45778086..52fcf69732f 100644 --- a/soc/espressif/esp32c6/default.ld +++ b/soc/espressif/esp32c6/default.ld @@ -29,12 +29,21 @@ user_sram_size = (user_sram_end - user_sram_org); #define RAMABLE_REGION sram0_0_seg #define ROMABLE_REGION FLASH +#undef GROUP_DATA_LINK_IN +#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion + +#undef GROUP_NOLOAD_LINK_IN +#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion + /* Flash segments (rodata and text) should be mapped in the virtual address spaces. * Executing directly from LMA is not possible. */ #undef GROUP_ROM_LINK_IN #define GROUP_ROM_LINK_IN(vregion, lregion) > CACHED_REGION AT > lregion /* Make sure new sections have consistent alignment between input and output sections */ +#undef SECTION_DATA_PROLOGUE +#define SECTION_DATA_PROLOGUE(name, options, align) name options : ALIGN_WITH_INPUT + #undef SECTION_PROLOGUE #define SECTION_PROLOGUE SECTION_DATA_PROLOGUE diff --git a/soc/espressif/esp32s2/Kconfig b/soc/espressif/esp32s2/Kconfig index 64a7180e03d..73ebc878029 100644 --- a/soc/espressif/esp32s2/Kconfig +++ b/soc/espressif/esp32s2/Kconfig @@ -7,7 +7,6 @@ config SOC_SERIES_ESP32S2 select DYNAMIC_INTERRUPTS select CLOCK_CONTROL select PINCTRL - select XIP if !MCUBOOT select HAS_ESPRESSIF_HAL select ARCH_SUPPORTS_COREDUMP select HAS_PM diff --git a/soc/espressif/esp32s2/default.ld b/soc/espressif/esp32s2/default.ld index 6c0ceb5e57f..30956a2d43c 100644 --- a/soc/espressif/esp32s2/default.ld +++ b/soc/espressif/esp32s2/default.ld @@ -37,12 +37,21 @@ user_dram_seg_len = user_idram_size; #define RAMABLE_REGION dram0_0_seg #define ROMABLE_REGION FLASH +#undef GROUP_DATA_LINK_IN +#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion + +#undef GROUP_NOLOAD_LINK_IN +#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion + /* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA. * Executing directly from LMA is not possible. */ #undef GROUP_ROM_LINK_IN #define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion /* Make sure new sections have consistent alignment between input and output sections */ +#undef SECTION_DATA_PROLOGUE +#define SECTION_DATA_PROLOGUE(name, options, align) name options : ALIGN_WITH_INPUT + #undef SECTION_PROLOGUE #define SECTION_PROLOGUE SECTION_DATA_PROLOGUE diff --git a/soc/espressif/esp32s2/mcuboot.ld b/soc/espressif/esp32s2/mcuboot.ld index 092c3a5ae1f..23a15b858b5 100644 --- a/soc/espressif/esp32s2/mcuboot.ld +++ b/soc/espressif/esp32s2/mcuboot.ld @@ -10,10 +10,6 @@ #include "memory.h" -#ifdef CONFIG_XIP -#error "Xtensa bootloader cannot use XIP" -#endif - /* Disable all romable LMA */ #undef GROUP_DATA_LINK_IN #define GROUP_DATA_LINK_IN(vregion, lregion) > vregion diff --git a/soc/espressif/esp32s3/Kconfig b/soc/espressif/esp32s3/Kconfig index ef836684730..cfda258d8c2 100644 --- a/soc/espressif/esp32s3/Kconfig +++ b/soc/espressif/esp32s3/Kconfig @@ -7,7 +7,6 @@ config SOC_SERIES_ESP32S3 select ARCH_SUPPORTS_COREDUMP select CLOCK_CONTROL select PINCTRL - select XIP if !MCUBOOT select HAS_ESPRESSIF_HAL select CPU_HAS_FPU select HAS_PM diff --git a/soc/espressif/esp32s3/default.ld b/soc/espressif/esp32s3/default.ld index dc7e283e39f..7806ab16441 100644 --- a/soc/espressif/esp32s3/default.ld +++ b/soc/espressif/esp32s3/default.ld @@ -36,12 +36,21 @@ user_dram_seg_len = user_idram_size; #define RAMABLE_REGION dram0_0_seg #define ROMABLE_REGION FLASH +#undef GROUP_DATA_LINK_IN +#define GROUP_DATA_LINK_IN(vregion, lregion) > vregion AT > lregion + +#undef GROUP_NOLOAD_LINK_IN +#define GROUP_NOLOAD_LINK_IN(vregion, lregion) > vregion + /* Flash segments (rodata and text) should be mapped in the virtual address spaces. * Executing directly from LMA is not possible. */ #undef GROUP_ROM_LINK_IN #define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion /* Make sure new sections have consistent alignment between input and output sections */ +#undef SECTION_DATA_PROLOGUE +#define SECTION_DATA_PROLOGUE(name, options, align) name options : ALIGN_WITH_INPUT + #undef SECTION_PROLOGUE #define SECTION_PROLOGUE SECTION_DATA_PROLOGUE diff --git a/soc/espressif/esp32s3/mcuboot.ld b/soc/espressif/esp32s3/mcuboot.ld index a8ec6a4d150..46a3c0c3168 100644 --- a/soc/espressif/esp32s3/mcuboot.ld +++ b/soc/espressif/esp32s3/mcuboot.ld @@ -10,10 +10,6 @@ #include "memory.h" -#ifdef CONFIG_XIP -#error "Xtensa bootloader cannot use XIP" -#endif /* CONFIG_XIP */ - /* Disable all romable LMA */ #undef GROUP_DATA_LINK_IN #define GROUP_DATA_LINK_IN(vregion, lregion) > vregion