diff --git a/arch/xtensa/src/esp32/Bootloader.mk b/arch/xtensa/src/esp32/Bootloader.mk index 0c2be5fde08..3041f370a0f 100644 --- a/arch/xtensa/src/esp32/Bootloader.mk +++ b/arch/xtensa/src/esp32/Bootloader.mk @@ -192,15 +192,7 @@ else ifeq ($(CONFIG_ESP32_BOOTLOADER_DOWNLOAD_PREBUILT),y) BOOTLOADER_VERSION = latest BOOTLOADER_URL = https://github.com/espressif/esp-nuttx-bootloader/releases/download/$(BOOTLOADER_VERSION) -ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y) - -bootloader: - $(call DOWNLOAD,$(BOOTLOADER_URL),mcuboot-esp32.bin,$(TOPDIR)/mcuboot-esp32.bin) - -clean_bootloader: - $(call DELFILE,$(TOPDIR)/mcuboot-esp32.bin) - -else ifeq ($(CONFIG_ESP32_APP_FORMAT_LEGACY),y) +ifeq ($(CONFIG_ESP32_APP_FORMAT_LEGACY),y) bootloader: $(call DOWNLOAD,$(BOOTLOADER_URL),bootloader-esp32.bin,$(TOPDIR)/bootloader-esp32.bin) diff --git a/arch/xtensa/src/esp32/Kconfig b/arch/xtensa/src/esp32/Kconfig index 0e374b24d9f..b15a6269408 100644 --- a/arch/xtensa/src/esp32/Kconfig +++ b/arch/xtensa/src/esp32/Kconfig @@ -1870,6 +1870,7 @@ comment "Partition Table Configuration" config ESP32_PARTITION_TABLE bool "Create MTD partitions from Partition Table" default n + select ESP32_BOOTLOADER_BUILD_FROM_SOURCE ---help--- Decode partition table and initialize partitions as MTD. @@ -2443,42 +2444,28 @@ config ESP32_HAVE_OTA_PARTITION bool default n -menu "Application Image Configuration" - -choice - prompt "Application Image Format" - default ESP32_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. +menu "Bootloader and Image Configuration" config ESP32_APP_FORMAT_LEGACY - bool "Legacy format" + bool + default y if !ESP32_APP_FORMAT_MCUBOOT + depends on !ESP32_APP_FORMAT_MCUBOOT ---help--- This is the legacy application image format, as supported by the ESP-IDF 2nd stage bootloader. config ESP32_APP_FORMAT_MCUBOOT - bool "MCUboot-bootable format" + bool "Enable MCUboot-bootable format" depends on !MCUBOOT_BOOTLOADER select ESP32_HAVE_OTA_PARTITION + select ESP32_BOOTLOADER_BUILD_FROM_SOURCE ---help--- - The ESP32 port of MCUboot supports the loading of unsegmented firmware - images. - -endchoice # Application Image Format - -choice - prompt "Source for bootloader binaries" - default ESP32_BOOTLOADER_DOWNLOAD_PREBUILT - ---help--- - Select the action to be taken by the build system for the - "make bootloader" target. + Enables the Espressif port of MCUboot to be used as 2nd stage bootloader. config ESP32_BOOTLOADER_DOWNLOAD_PREBUILT - bool "Download prebuilt binaries" + bool + default y if !ESP32_BOOTLOADER_BUILD_FROM_SOURCE + depends on !ESP32_BOOTLOADER_BUILD_FROM_SOURCE ---help--- The build system will download the prebuilt binaries from https://github.com/espressif/esp-nuttx-bootloader according to the chosen @@ -2492,8 +2479,6 @@ config ESP32_BOOTLOADER_BUILD_FROM_SOURCE custom bootloader according to the chosen Application Image Format (ESP32_APP_FORMAT_LEGACY or ESP32_APP_FORMAT_MCUBOOT) and partition information. -endchoice - choice prompt "Target slot for image flashing" default ESP32_ESPTOOL_TARGET_PRIMARY @@ -2529,11 +2514,37 @@ config ESP32_APP_MCUBOOT_HEADER_SIZE default 32 depends on ESP32_APP_FORMAT_MCUBOOT -config ESP32_PARTITION_TABLE_OFFSET - hex "Partition Table offset" +config ESP32_PARTITION_TABLE_OFFSET_DEFAULT + hex default 0x8000 depends on ESP32_APP_FORMAT_LEGACY +config ESP32_CUSTOM_PARTITION_TABLE_OFFSET + bool "Customize partition table offset" + default n + depends on ESP32_APP_FORMAT_LEGACY + select ESP32_BOOTLOADER_BUILD_FROM_SOURCE + ---help--- + Enable to select the offset of the partition table in the flash. + +if ESP32_CUSTOM_PARTITION_TABLE_OFFSET + +config ESP32_PARTITION_TABLE_OFFSET + hex "Partition Table offset" + default ESP32_PARTITION_TABLE_OFFSET_DEFAULT + depends on ESP32_APP_FORMAT_LEGACY + +endif # ESP32_CUSTOM_PARTITION_TABLE_OFFSET + +if !ESP32_CUSTOM_PARTITION_TABLE_OFFSET + +config ESP32_PARTITION_TABLE_OFFSET + hex + default ESP32_PARTITION_TABLE_OFFSET_DEFAULT + depends on ESP32_APP_FORMAT_LEGACY + +endif # !ESP32_CUSTOM_PARTITION_TABLE_OFFSET + if BUILD_PROTECTED config ESP32_USER_IMAGE_OFFSET diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/mcuboot_nsh/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/mcuboot_nsh/defconfig index 6443f1ade7e..c2d753e8d1f 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/mcuboot_nsh/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/mcuboot_nsh/defconfig @@ -20,7 +20,6 @@ CONFIG_ARCH_XTENSA=y CONFIG_BOARD_LOOPSPERMSEC=16717 CONFIG_BUILTIN=y CONFIG_ESP32_APP_FORMAT_MCUBOOT=y -CONFIG_ESP32_BOOTLOADER_BUILD_FROM_SOURCE=y CONFIG_ESP32_UART0=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/mcuboot_update_agent/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/mcuboot_update_agent/defconfig index 6c82428d8ee..26f9d799fcc 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/mcuboot_update_agent/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/mcuboot_update_agent/defconfig @@ -27,7 +27,6 @@ CONFIG_DEBUG_SYMBOLS=y CONFIG_DRIVERS_IEEE80211=y CONFIG_DRIVERS_WIRELESS=y CONFIG_ESP32_APP_FORMAT_MCUBOOT=y -CONFIG_ESP32_BOOTLOADER_BUILD_FROM_SOURCE=y CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_UART0=y CONFIG_ESP32_WIFI=y