Skip to content

esp32s3 does not build with mcuboot and CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256 or CONFIG_BOOT_SIGNATURE_TYPE_RSA #76566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brandon-exact opened this issue Jul 31, 2024 · 8 comments · Fixed by #78656
Assignees
Labels
area: MCUBoot bug The issue is a bug, or the PR is fixing a bug platform: ESP32 Espressif ESP32 priority: low Low impact/importance bug

Comments

@brandon-exact
Copy link
Contributor

brandon-exact commented Jul 31, 2024

Describe the bug

esp32s3 iram overflows when trying to build with mcuboot and CONFIG_BOOT_SIGNATURE_TYPE_*
To Reproduce

diff --git a/samples/sysbuild/with_mcuboot/sysbuild.conf b/samples/sysbuild/with_mcuboot/sysbuild.conf
index 92042e44734..bbf9149c359 100644
--- a/samples/sysbuild/with_mcuboot/sysbuild.conf
+++ b/samples/sysbuild/with_mcuboot/sysbuild.conf
@@ -2,3 +2,4 @@
 
 # Enable MCUboot per default for this sample.
 SB_CONFIG_BOOTLOADER_MCUBOOT=y
+SB_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y
cd zephyr/samples/sysbuild/with_mcuboot
west build -b esp32s3_devkitc/esp32s3/procpu --sysbuild

Expected behavior

The sample builds
Impact

cannot use mcuboot and esp32s3
Logs and console output

/home/brandon/zephyr-sdk-0.16.8/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd: zephyr/zephyr_pre0.elf section `.iram0.text' will not fit in region `iram_seg'
/home/brandon/zephyr-sdk-0.16.8/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd: section .iram0.loader_text LMA [00000000403c6400,00000000403c7c77] overlaps section .iram0.text LMA [00000000403bc000,00000000403c6863]
/home/brandon/zephyr-sdk-0.16.8/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd: region `iram_seg' overflowed by 1124 bytes

Environment (please complete the following information):

  • OS: linux
  • Toolchain: 0.16.8
  • Commit SHA or Version used: main
@brandon-exact brandon-exact added the bug The issue is a bug, or the PR is fixing a bug label Jul 31, 2024
@brandon-exact
Copy link
Contributor Author

If I modify memory.h to get it to compile

diff --git a/soc/espressif/esp32s3/memory.h b/soc/espressif/esp32s3/memory.h
index cd9a0ef984b..5dc2b3aa633 100644
--- a/soc/espressif/esp32s3/memory.h
+++ b/soc/espressif/esp32s3/memory.h
@@ -45,9 +45,9 @@
 
 /* For safety margin between bootloader data section and startup stacks */
 #define BOOTLOADER_STACK_OVERHEAD      0x0
-#define BOOTLOADER_DRAM_SEG_LEN        0x8000
+#define BOOTLOADER_DRAM_SEG_LEN        0xa000
 #define BOOTLOADER_IRAM_LOADER_SEG_LEN 0x1a00
-#define BOOTLOADER_IRAM_SEG_LEN        0xa800
+#define BOOTLOADER_IRAM_SEG_LEN        0xc800

I get a boot loop of

Checksum failure. Calculated 0xe5 stored 0x3c
ets_main.c 329 
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x7 (TG0WDT_SYS_RST),boot:0xa (SPI_FAST_FLASH_BOOT)
Saved PC:0x40043ac8
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fcbfc00,len:0x3094
load:0x403b9c00,len:0xc258
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x10 (RTCWDT_RTC_RST),boot:0xa (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fcbfc00,len:0x3094
load:0x403b9c00,len:0xc258
load:0x403c6400,len:0x1898
Checksum failure. Calculated 0xe5 stored 0x3c
ets_main.c 329 

@nordicjm nordicjm added the platform: ESP32 Espressif ESP32 label Aug 1, 2024
@mmahadevan108 mmahadevan108 added priority: low Low impact/importance bug area: MCUBoot labels Aug 6, 2024
@brandon-exact
Copy link
Contributor Author

Is there going to be a fix for this in the next 3-4 months? Thanks!

@sylvioalves
Copy link
Collaborator

@brandon-exact Really sorry I missed this.
I have just tried using latest main and I get no overflow issues. Would you retry?

@brandon-exact
Copy link
Contributor Author

brandon-exact commented Aug 22, 2024

@sylvioalves I tried on main and still get the same overflow. I ran west update and west blobs fetch hal_espressif

@sylvioalves
Copy link
Collaborator

sylvioalves commented Aug 22, 2024

@brandon-exact, would you manually increase the iram size for the mcuboot bootloader?
https://github.com/zephyrproject-rtos/zephyr/blob/main/soc/espressif/esp32s3/memory.h#L50

#define BOOTLOADER_IRAM_SEG_LEN 0xb000

@marekmatej PTAL.

Edit: I see that you already tried and it worked. This is indeed the resolution for the overflow issue. We will check whether there is an alternative way to improve it somehow.

@marekmatej
Copy link
Collaborator

I think we could increase the IRAM and DRAM to accommodate different build scenarios as it is safe and doesn't make any difference in the user/application memory available.

@brandon-exact
Copy link
Contributor Author

brandon-exact commented Aug 22, 2024

@brandon-exact, would you manually increase the iram size for the mcuboot bootloader? https://github.com/zephyrproject-rtos/zephyr/blob/main/soc/espressif/esp32s3/memory.h#L50

#define BOOTLOADER_IRAM_SEG_LEN 0xb000

@marekmatej PTAL.

Edit: I see that you already tried and it worked. This is indeed the resolution for the overflow issue. We will check whether there is an alternative way to improve it somehow.

This fixes and works on my dev board with SB_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256.

When using SB_CONFIG_BOOT_SIGNATURE_TYPE_RSA there is still overflows in iram and dram

/home/brandon/zephyr-sdk-0.16.8/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd: region `iram_seg' overflowed by 2348 bytes
/home/brandon/zephyr-sdk-0.16.8/xtensa-espressif_esp32s3_zephyr-elf/bin/../lib/gcc/xtensa-espressif_esp32s3_zephyr-elf/12.2.0/../../../../xtensa-espressif_esp32s3_zephyr-elf/bin/ld.bfd: region `dram_seg' overflowed by 1272 bytes

but increasing their segments even more allowed it to work on my dev board.

@sylvioalves
Copy link
Collaborator

@brandon-exact right, thanks. We will increase it and evaluate properly.

@brandon-exact brandon-exact changed the title esp32s3 does not build with mcuboot and CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256 esp32s3 does not build with mcuboot and CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256 or CONFIG_BOOT_SIGNATURE_TYPE_RSA Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: MCUBoot bug The issue is a bug, or the PR is fixing a bug platform: ESP32 Espressif ESP32 priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants