esp32s3: Improve selection of the bootloader being used on Kconfig

- A pre-built IDF bootloader is used by default;
- `ESP32S3_PARTITION_TABLE` requires the IDF bootloader to be built
from sources.
- Native MCUboot also can be used to boot the device. It will be
built from sources and depends on !ESP32S3_PARTITION_TABLE.
This commit is contained in:
Tiago Medicci Serrano 2024-01-19 10:52:42 -03:00 committed by Alan Carvalho de Assis
parent 1e1ea7bb5d
commit 641a0df27f
3 changed files with 41 additions and 43 deletions

View File

@ -131,16 +131,6 @@ else ifeq ($(CONFIG_ESP32S3_BOOTLOADER_DOWNLOAD_PREBUILT),y)
BOOTLOADER_VERSION = latest BOOTLOADER_VERSION = latest
BOOTLOADER_URL = https://github.com/espressif/esp-nuttx-bootloader/releases/download/$(BOOTLOADER_VERSION) BOOTLOADER_URL = https://github.com/espressif/esp-nuttx-bootloader/releases/download/$(BOOTLOADER_VERSION)
ifeq ($(CONFIG_ESP32S3_APP_FORMAT_MCUBOOT),y)
bootloader:
$(call DOWNLOAD,$(BOOTLOADER_URL),mcuboot-esp32s3.bin,$(TOPDIR)/mcuboot-esp32s3.bin)
clean_bootloader:
$(call DELFILE,$(TOPDIR)/mcuboot-esp32s3.bin)
else ifeq ($(CONFIG_ESP32S3_APP_FORMAT_LEGACY),y)
bootloader: bootloader:
$(call DOWNLOAD,$(BOOTLOADER_URL),bootloader-esp32s3.bin,$(TOPDIR)/bootloader-esp32s3.bin) $(call DOWNLOAD,$(BOOTLOADER_URL),bootloader-esp32s3.bin,$(TOPDIR)/bootloader-esp32s3.bin)
$(call DOWNLOAD,$(BOOTLOADER_URL),partition-table-esp32s3.bin,$(TOPDIR)/partition-table-esp32s3.bin) $(call DOWNLOAD,$(BOOTLOADER_URL),partition-table-esp32s3.bin,$(TOPDIR)/partition-table-esp32s3.bin)
@ -150,5 +140,3 @@ clean_bootloader:
$(call DELFILE,$(TOPDIR)/partition-table-esp32s3.bin) $(call DELFILE,$(TOPDIR)/partition-table-esp32s3.bin)
endif endif
endif

View File

@ -1894,7 +1894,8 @@ comment "Partition Table configuration"
config ESP32S3_PARTITION_TABLE config ESP32S3_PARTITION_TABLE
bool "Create MTD partitions from Partition Table" bool "Create MTD partitions from Partition Table"
default n default n
depends on ESP32S3_MTD && ESP32S3_BOOTLOADER_BUILD_FROM_SOURCE depends on ESP32S3_MTD && ESP32S3_APP_FORMAT_LEGACY
select ESP32S3_BOOTLOADER_BUILD_FROM_SOURCE
---help--- ---help---
Decode partition table and initialize partitions as MTD. Decode partition table and initialize partitions as MTD.
@ -2170,42 +2171,28 @@ config ESP32S3_LCD_REGDEBUG
endmenu endmenu
menu "Application Image Configuration" menu "Bootloader and Image Configuration"
choice
prompt "Application Image Format"
default ESP32S3_APP_FORMAT_LEGACY
---help---
Depending on the chosen 2nd stage bootloader, the application may
be required to be perform a specific startup routine. Furthermore,
the image binary must be formatted according to the definition from
the 2nd stage bootloader.
config ESP32S3_APP_FORMAT_LEGACY config ESP32S3_APP_FORMAT_LEGACY
bool "Legacy format" bool
default y if !ESP32S3_APP_FORMAT_MCUBOOT
depends on !ESP32S3_APP_FORMAT_MCUBOOT
---help--- ---help---
This is the legacy application image format, as supported by the ESP-IDF This is the legacy application image format, as supported by the ESP-IDF
2nd stage bootloader. 2nd stage bootloader.
config ESP32S3_APP_FORMAT_MCUBOOT config ESP32S3_APP_FORMAT_MCUBOOT
bool "MCUboot-bootable format" bool "Enable MCUboot-bootable format"
depends on !MCUBOOT_BOOTLOADER depends on !MCUBOOT_BOOTLOADER
select ESP32S3_HAVE_OTA_PARTITION select ESP32S3_HAVE_OTA_PARTITION
select ESP32S3_BOOTLOADER_BUILD_FROM_SOURCE
---help--- ---help---
The Espressif port of MCUboot supports the loading of unsegmented firmware Enables the Espressif port of MCUboot to be used as 2nd stage bootloader.
images.
endchoice # Application Image Format
choice
prompt "Source for bootloader binaries"
default ESP32S3_BOOTLOADER_DOWNLOAD_PREBUILT
---help---
Select the action to be taken by the build system for the
"make bootloader" target.
config ESP32S3_BOOTLOADER_DOWNLOAD_PREBUILT config ESP32S3_BOOTLOADER_DOWNLOAD_PREBUILT
bool "Download prebuilt binaries" bool
default y if !ESP32S3_BOOTLOADER_BUILD_FROM_SOURCE
depends on !ESP32S3_BOOTLOADER_BUILD_FROM_SOURCE
---help--- ---help---
The build system will download the prebuilt binaries from The build system will download the prebuilt binaries from
https://github.com/espressif/esp-nuttx-bootloader according to the chosen https://github.com/espressif/esp-nuttx-bootloader according to the chosen
@ -2219,8 +2206,6 @@ config ESP32S3_BOOTLOADER_BUILD_FROM_SOURCE
custom bootloader according to the chosen Application Image Format custom bootloader according to the chosen Application Image Format
(ESP32S3_APP_FORMAT_LEGACY or ESP32S3_APP_FORMAT_MCUBOOT) and partition information. (ESP32S3_APP_FORMAT_LEGACY or ESP32S3_APP_FORMAT_MCUBOOT) and partition information.
endchoice
choice choice
prompt "Target slot for image flashing" prompt "Target slot for image flashing"
default ESP32S3_ESPTOOL_TARGET_PRIMARY default ESP32S3_ESPTOOL_TARGET_PRIMARY
@ -2256,11 +2241,37 @@ config ESP32S3_APP_MCUBOOT_HEADER_SIZE
default 32 default 32
depends on ESP32S3_APP_FORMAT_MCUBOOT depends on ESP32S3_APP_FORMAT_MCUBOOT
config ESP32S3_PARTITION_TABLE_OFFSET config ESP32S3_PARTITION_TABLE_OFFSET_DEFAULT
hex "Partition Table offset" hex
default 0x8000 default 0x8000
depends on ESP32S3_APP_FORMAT_LEGACY depends on ESP32S3_APP_FORMAT_LEGACY
config ESP32S3_CUSTOM_PARTITION_TABLE_OFFSET
bool "Customize partition table offset"
default n
depends on ESP32S3_APP_FORMAT_LEGACY
select ESP32S3_BOOTLOADER_BUILD_FROM_SOURCE
---help---
Enable to select the offset of the partition table in the flash.
if ESP32S3_CUSTOM_PARTITION_TABLE_OFFSET
config ESP32S3_PARTITION_TABLE_OFFSET
hex "Partition Table offset"
default ESP32S3_PARTITION_TABLE_OFFSET_DEFAULT
depends on ESP32S3_APP_FORMAT_LEGACY
endif # ESP32S3_CUSTOM_PARTITION_TABLE_OFFSET
if !ESP32S3_CUSTOM_PARTITION_TABLE_OFFSET
config ESP32S3_PARTITION_TABLE_OFFSET
hex
default ESP32S3_PARTITION_TABLE_OFFSET_DEFAULT
depends on ESP32S3_APP_FORMAT_LEGACY
endif # !ESP32S3_CUSTOM_PARTITION_TABLE_OFFSET
config ESP32S3_KERNEL_OFFSET config ESP32S3_KERNEL_OFFSET
hex hex
default 0x10000 default 0x10000
@ -2294,6 +2305,6 @@ config ESP32S3_KERNEL_RAM_SIZE
endif # BUILD_PROTECTED endif # BUILD_PROTECTED
endmenu # Application Image Configuration endmenu # Bootloader and Image Configuration
endif # ARCH_CHIP_ESP32S3 endif # ARCH_CHIP_ESP32S3

View File

@ -22,7 +22,6 @@ CONFIG_BOARDCTL_RESET=y
CONFIG_BOARD_LOOPSPERMSEC=16717 CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y CONFIG_BUILTIN=y
CONFIG_ESP32S3_APP_FORMAT_MCUBOOT=y CONFIG_ESP32S3_APP_FORMAT_MCUBOOT=y
CONFIG_ESP32S3_BOOTLOADER_BUILD_FROM_SOURCE=y
CONFIG_ESP32S3_SPIFLASH=y CONFIG_ESP32S3_SPIFLASH=y
CONFIG_ESP32S3_UART0=y CONFIG_ESP32S3_UART0=y
CONFIG_FS_PROCFS=y CONFIG_FS_PROCFS=y