From d276cf753f5658c456ca6a415d85b577f366e0c0 Mon Sep 17 00:00:00 2001 From: Marek Matej Date: Mon, 6 Jan 2025 20:35:59 +0100 Subject: [PATCH] soc: espressif: Extend the program header Add new fields to the `esp_image_load_header_t` * provide IROM and DROM fields to fix debugging features * extend the header to up to 96 Bytes for future use Signed-off-by: Marek Matej --- soc/espressif/esp32/default.ld | 33 ++++++++++++++++++------- soc/espressif/esp32c2/default.ld | 40 +++++++++++++++++++++++++++++-- soc/espressif/esp32c3/default.ld | 34 +++++++++++++++++++------- soc/espressif/esp32c6/default.ld | 26 ++++++++++++++++---- soc/espressif/esp32s2/default.ld | 33 ++++++++++++++++++------- soc/espressif/esp32s3/default.ld | 41 ++++++++++++++++++++++---------- 6 files changed, 164 insertions(+), 43 deletions(-) diff --git a/soc/espressif/esp32/default.ld b/soc/espressif/esp32/default.ld index 156427ed6ce..c1ea401e7d8 100644 --- a/soc/espressif/esp32/default.ld +++ b/soc/espressif/esp32/default.ld @@ -139,24 +139,41 @@ SECTIONS LONG(LOADADDR(.dram0.data)) LONG(LOADADDR(.dram0.end) + SIZEOF(.dram0.end) - LOADADDR(.dram0.data)) - /* RTC_TEXT metadata: - * 8. Destination address (VMA) for RTC_TEXT region - * 9. Flash offset (LMA) for start of RTC_TEXT region - * 10. Size of RTC region + /* RTC_IRAM metadata: + * 8. Destination address (VMA) for RTC_IRAM region + * 9. Flash offset (LMA) for start of RTC_IRAM region + * 10. Size of RTC_IRAM region */ LONG(ADDR(.rtc.text)) LONG(LOADADDR(.rtc.text)) LONG(SIZEOF(.rtc.text)) - /* RTC_DATA metadata: - * 11. Destination address (VMA) for RTC_DATA region - * 12. Flash offset (LMA) for start of RTC_DATA region - * 13. Size of RTC region + /* RTC_DRAM metadata: + * 11. Destination address (VMA) for RTC_DRAM region + * 12. Flash offset (LMA) for start of RTC_DRAM region + * 13. Size of RTC_DRAM region */ LONG(ADDR(.rtc.data)) LONG(LOADADDR(.rtc.data)) LONG(SIZEOF(.rtc.data)) + /* IROM metadata: + * 14. Destination address (VMA) for IROM region + * 15. Flash offset (LMA) for start of IROM region + * 16. Size of IROM region + */ + LONG(ADDR(.flash.text)) + LONG(LOADADDR(.flash.text)) + LONG(SIZEOF(.flash.text)) + + /* DROM metadata: + * 17. Destination address (VMA) for DROM region + * 18. Flash offset (LMA) for start of DROM region + * 19. Size of DROM region + */ + LONG(ADDR(.flash.rodata)) + LONG(LOADADDR(.flash.rodata)) + LONG(LOADADDR(.flash.rodata_end) - LOADADDR(.flash.rodata)) } > metadata #endif /* CONFIG_BOOTLOADER_MCUBOOT */ diff --git a/soc/espressif/esp32c2/default.ld b/soc/espressif/esp32c2/default.ld index 8febd61ec62..e633adece44 100644 --- a/soc/espressif/esp32c2/default.ld +++ b/soc/espressif/esp32c2/default.ld @@ -59,8 +59,8 @@ MEMORY { #ifdef CONFIG_BOOTLOADER_MCUBOOT mcuboot_hdr (R): org = 0x0, len = 0x20 - metadata (R): org = 0x20, len = 0x20 - FLASH (R): org = 0x40, len = FLASH_SIZE - 0x40 + metadata (R): org = 0x20, len = 0x60 + FLASH (R): org = 0x80, len = FLASH_SIZE - 0x80 #else /* Make safety margin in the FLASH memory size so the * (esp_img_header + (n*esp_seg_headers)) would fit */ @@ -124,6 +124,42 @@ SECTIONS LONG(ADDR(.dram0.data)) LONG(LOADADDR(.dram0.data)) LONG(LOADADDR(.dram0.end) - LOADADDR(.dram0.data)) + + /* LP_IRAM metadata - There is no RTC/LP memory! + * 8. Destination address (VMA) for LP_IRAM region + * 9. Flash offset (LMA) for start of LP_IRAM region + * 10. Size of LP_IRAM region + */ + LONG(0x0) + LONG(0x0) + LONG(0x0) + + /* LP_DRAM metadata - There is no RTC/LP memory! + * 11. Destination address (VMA) for LP_DRAM region + * 12. Flash offset (LMA) for start of LP_DRAM region + * 13. Size of LP_DRAM region + */ + LONG(0x0) + LONG(0x0) + LONG(0x0) + + /* IROM metadata: + * 14. Destination address (VMA) for IROM region + * 15. Flash offset (LMA) for start of IROM region + * 16. Size of IROM region + */ + LONG(ADDR(.flash.text)) + LONG(LOADADDR(.flash.text)) + LONG(SIZEOF(.flash.text)) + + /* DROM metadata: + * 17. Destination address (VMA) for DROM region + * 18. Flash offset (LMA) for start of DROM region + * 19. Size of DROM region + */ + LONG(ADDR(.flash.rodata)) + LONG(LOADADDR(.flash.rodata)) + LONG(LOADADDR(.flash.rodata_end) - LOADADDR(.flash.rodata)) } > metadata #endif /* CONFIG_BOOTLOADER_MCUBOOT */ diff --git a/soc/espressif/esp32c3/default.ld b/soc/espressif/esp32c3/default.ld index aa0e38d09a8..b4ff2ea917e 100644 --- a/soc/espressif/esp32c3/default.ld +++ b/soc/espressif/esp32c3/default.ld @@ -138,23 +138,41 @@ SECTIONS LONG(LOADADDR(.dram0.data)) LONG(LOADADDR(.dram0.end) - LOADADDR(.dram0.data)) - /* RTC_TEXT metadata: - * 8. Destination address (VMA) for RTC_TEXT region - * 9. Flash offset (LMA) for start of RTC_TEXT region - * 10. Size of RTC region + /* RTC_IRAM metadata: + * 8. Destination address (VMA) for RTC_IRAM region + * 9. Flash offset (LMA) for start of RTC_IRAM region + * 10. Size of RTC_IRAM region */ LONG(ADDR(.rtc.text)) LONG(LOADADDR(.rtc.text)) LONG(SIZEOF(.rtc.text)) - /* RTC_DATA metadata: - * 11. Destination address (VMA) for RTC_DATA region - * 12. Flash offset (LMA) for start of RTC_DATA region - * 13. Size of RTC region + /* RTC_DRAM metadata: + * 11. Destination address (VMA) for RTC_DRAM region + * 12. Flash offset (LMA) for start of RTC_DRAM region + * 13. Size of RTC_DRAM region */ LONG(ADDR(.rtc.data)) LONG(LOADADDR(.rtc.data)) LONG(SIZEOF(.rtc.data)) + + /* IROM metadata: + * 14. Destination address (VMA) for IROM region + * 15. Flash offset (LMA) for start of IROM region + * 16. Size of IROM region + */ + LONG(ADDR(.flash.text)) + LONG(LOADADDR(.flash.text)) + LONG(SIZEOF(.flash.text)) + + /* DROM metadata: + * 17. Destination address (VMA) for DROM region + * 18. Flash offset (LMA) for start of DROM region + * 19. Size of DROM region + */ + LONG(ADDR(.flash.rodata)) + LONG(LOADADDR(.flash.rodata)) + LONG(LOADADDR(.flash.rodata_end) - LOADADDR(.flash.rodata)) } > metadata #endif /* CONFIG_BOOTLOADER_MCUBOOT */ diff --git a/soc/espressif/esp32c6/default.ld b/soc/espressif/esp32c6/default.ld index ba5646b5658..4d497dcdade 100644 --- a/soc/espressif/esp32c6/default.ld +++ b/soc/espressif/esp32c6/default.ld @@ -139,25 +139,41 @@ SECTIONS LONG(LOADADDR(.dram0.data)) LONG(LOADADDR(.dram0.end) - LOADADDR(.dram0.data)) - /* LP_IRAM metadata: * 8. Destination address (VMA) for LP_IRAM region * 9. Flash offset (LMA) for start of LP_IRAM region - * 10. Size of RTC region + * 10. Size of LP_IRAM region */ LONG(ADDR(.rtc.text)) LONG(LOADADDR(.rtc.text)) LONG(SIZEOF(.rtc.text)) /* LP_DATA metadata: - * 11. Destination address (VMA) for LP_DATA region - * 12. Flash offset (LMA) for start of LP_DATA region - * 13. Size of RTC region + * 11. Destination address (VMA) for LP_DRAM region + * 12. Flash offset (LMA) for start of LP_DRAM region + * 13. Size of LP_DRAM region */ LONG(ADDR(.rtc.data)) LONG(LOADADDR(.rtc.data)) LONG(SIZEOF(.rtc.data)) + /* IROM metadata: + * 14. Destination address (VMA) for IROM region + * 15. Flash offset (LMA) for start of IROM region + * 16. Size of IROM region + */ + LONG(ADDR(.flash.text)) + LONG(LOADADDR(.flash.text)) + LONG(SIZEOF(.flash.text)) + + /* DROM metadata: + * 17. Destination address (VMA) for DROM region + * 18. Flash offset (LMA) for start of DROM region + * 19. Size of DROM region + */ + LONG(ADDR(.flash.rodata)) + LONG(LOADADDR(.flash.rodata)) + LONG(LOADADDR(.flash.rodata_end) - LOADADDR(.flash.rodata)) } > metadata #endif /* CONFIG_BOOTLOADER_MCUBOOT */ diff --git a/soc/espressif/esp32s2/default.ld b/soc/espressif/esp32s2/default.ld index 67d9e8cdd07..30c4876be38 100644 --- a/soc/espressif/esp32s2/default.ld +++ b/soc/espressif/esp32s2/default.ld @@ -145,24 +145,41 @@ SECTIONS LONG(LOADADDR(.dram0.data)) LONG(LOADADDR(.dram0.data_end) - LOADADDR(.dram0.data)) - /* RTC_TEXT metadata: - * 8. Destination address (VMA) for RTC_TEXT region - * 9. Flash offset (LMA) for start of RTC_TEXT region - * 10. Size of RTC region + /* RTC_IRAM metadata: + * 8. Destination address (VMA) for RTC_IRAM region + * 9. Flash offset (LMA) for start of RTC_IRAM region + * 10. Size of RTC_IRAM region */ LONG(ADDR(.rtc.text)) LONG(LOADADDR(.rtc.text)) LONG(SIZEOF(.rtc.text)) - /* RTC_DATA metadata: - * 11. Destination address (VMA) for RTC_DATA region - * 12. Flash offset (LMA) for start of RTC_DATA region - * 13. Size of RTC region + /* RTC_DRAM metadata: + * 11. Destination address (VMA) for RTC_DRAM region + * 12. Flash offset (LMA) for start of RTC_DRAM region + * 13. Size of RTC_DRAM region */ LONG(ADDR(.rtc.data)) LONG(LOADADDR(.rtc.data)) LONG(SIZEOF(.rtc.data)) + /* IROM metadata: + * 14. Destination address (VMA) for IROM region + * 15. Flash offset (LMA) for start of IROM region + * 16. Size of IROM region + */ + LONG(ADDR(.flash.text)) + LONG(LOADADDR(.flash.text)) + LONG(SIZEOF(.flash.text)) + + /* DROM metadata: + * 17. Destination address (VMA) for DROM region + * 18. Flash offset (LMA) for start of DROM region + * 19. Size of DROM region + */ + LONG(ADDR(.flash.rodata)) + LONG(LOADADDR(.flash.rodata)) + LONG(LOADADDR(.flash.rodata_end) - LOADADDR(.flash.rodata)) } > metadata #endif /* CONFIG_BOOTLOADER_MCUBOOT */ diff --git a/soc/espressif/esp32s3/default.ld b/soc/espressif/esp32s3/default.ld index 396e98181b8..76ff3e8ec05 100644 --- a/soc/espressif/esp32s3/default.ld +++ b/soc/espressif/esp32s3/default.ld @@ -49,13 +49,13 @@ procpu_dram_len = procpu_dram_end - procpu_dram_org; MEMORY { #ifdef CONFIG_BOOTLOADER_MCUBOOT - mcuboot_hdr (R): org = 0x0, len = 0x20 - metadata (R): org = 0x20, len = 0x60 - FLASH (R): org = 0x80, len = FLASH_SIZE - 0x80 + mcuboot_hdr (R): org = 0x0, len = 0x20 + metadata (R): org = 0x20, len = 0x60 + FLASH (R): org = 0x80, len = FLASH_SIZE - 0x80 #else /* Make safety margin in the FLASH memory size so the * (esp_img_header + (n*esp_seg_headers)) would fit */ - FLASH (R): org = 0x0, len = FLASH_SIZE - 0x100 + FLASH (R): org = 0x0, len = FLASH_SIZE - 0x100 #endif /* CONFIG_BOOTLOADER_MCUBOOT */ iram0_0_seg(RX): org = procpu_iram_org, len = procpu_iram_len @@ -149,24 +149,41 @@ SECTIONS LONG(LOADADDR(.dram0.data)) LONG(LOADADDR(.dram0.end) + SIZEOF(.dram0.end) - LOADADDR(.dram0.data)) - /* RTC_TEXT metadata: - * 8. Destination address (VMA) for RTC_TEXT region - * 9. Flash offset (LMA) for start of RTC_TEXT region - * 10. Size of RTC region + /* RTC_IRAM metadata: + * 8. Destination address (VMA) for RTC_IRAM region + * 9. Flash offset (LMA) for start of RTC_IRAM region + * 10. Size of RTC_IRAM region */ LONG(ADDR(.rtc.text)) LONG(LOADADDR(.rtc.text)) LONG(SIZEOF(.rtc.text)) - /* RTC_DATA metadata: - * 11. Destination address (VMA) for RTC_DATA region - * 12. Flash offset (LMA) for start of RTC_DATA region - * 13. Size of RTC region + /* RTC_DRAM metadata: + * 11. Destination address (VMA) for RTC_DRAM region + * 12. Flash offset (LMA) for start of RTC_DRAM region + * 13. Size of RTC_DRAM region */ LONG(ADDR(.rtc.data)) LONG(LOADADDR(.rtc.data)) LONG(SIZEOF(.rtc.data)) + /* IROM metadata: + * 14. Destination address (VMA) for IROM region + * 15. Flash offset (LMA) for start of IROM region + * 16. Size of IROM region + */ + LONG(ADDR(.flash.text)) + LONG(LOADADDR(.flash.text)) + LONG(SIZEOF(.flash.text)) + + /* DROM metadata: + * 17. Destination address (VMA) for DROM region + * 18. Flash offset (LMA) for start of DROM region + * 19. Size of DROM region + */ + LONG(ADDR(.flash.rodata)) + LONG(LOADADDR(.flash.rodata)) + LONG(LOADADDR(.flash.rodata_end) - LOADADDR(.flash.rodata)) } > metadata #endif /* CONFIG_BOOTLOADER_MCUBOOT */