From 4178f3ede4b0be561ec7e34b049b48d69707ff65 Mon Sep 17 00:00:00 2001 From: Almir Okato Date: Tue, 28 May 2024 14:44:07 +0200 Subject: [PATCH] esp32s2: remove legacy bootloader support Deprecate Legacy Boot for ESP32-S2. Signed-off-by: Almir Okato --- arch/xtensa/src/esp32s2/Bootloader.mk | 31 +-- arch/xtensa/src/esp32s2/Kconfig | 38 --- arch/xtensa/src/esp32s2/Make.defs | 6 +- .../esp32s2/common/scripts/legacy_sections.ld | 235 ------------------ .../esp32s2-kaluga-1/scripts/Make.defs | 2 - .../esp32s2/esp32s2-saola-1/scripts/Make.defs | 2 - .../franzininho-wifi/scripts/Make.defs | 2 - tools/esp32s2/Config.mk | 36 +-- 8 files changed, 7 insertions(+), 345 deletions(-) delete mode 100644 boards/xtensa/esp32s2/common/scripts/legacy_sections.ld diff --git a/arch/xtensa/src/esp32s2/Bootloader.mk b/arch/xtensa/src/esp32s2/Bootloader.mk index f92624924a..abfe536fcc 100644 --- a/arch/xtensa/src/esp32s2/Bootloader.mk +++ b/arch/xtensa/src/esp32s2/Bootloader.mk @@ -20,7 +20,7 @@ .PHONY: bootloader clean_bootloader -ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),) +ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) TOOLSDIR = $(TOPDIR)/tools/espressif CHIPDIR = $(TOPDIR)/arch/xtensa/src/chip @@ -76,9 +76,6 @@ endif $(if $(CONFIG_ESP32S2_FLASH_FREQ_40M),$(call cfg_en,CONFIG_ESPTOOLPY_FLASHFREQ_40M)) \ $(if $(CONFIG_ESP32S2_FLASH_FREQ_26M),$(call cfg_en,CONFIG_ESPTOOLPY_FLASHFREQ_26M)) \ $(if $(CONFIG_ESP32S2_FLASH_FREQ_20M),$(call cfg_en,CONFIG_ESPTOOLPY_FLASHFREQ_20M)) \ - } > $(BOOTLOADER_CONFIG) -ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) - $(Q) { \ $(if $(CONFIG_ESP32S2_SECURE_BOOT),$(call cfg_en,CONFIG_SECURE_BOOT)$(call cfg_en,CONFIG_SECURE_BOOT_V2_ENABLED)$(call cfg_val,CONFIG_ESP_SIGN_KEY_FILE,$(abspath $(TOPDIR)/$(ESPSEC_KEYDIR)/$(subst ",,$(CONFIG_ESP32S2_SECURE_BOOT_APP_SIGNING_KEY))))) \ $(if $(CONFIG_ESP32S2_SECURE_SIGNED_APPS_SCHEME_RSA_2048),$(call cfg_en,CONFIG_ESP_USE_MBEDTLS)$(call cfg_en,CONFIG_ESP_SIGN_RSA)$(call cfg_val,CONFIG_ESP_SIGN_RSA_LEN,2048)) \ $(if $(CONFIG_ESP32S2_SECURE_SIGNED_APPS_SCHEME_RSA_3072),$(call cfg_en,CONFIG_ESP_USE_MBEDTLS)$(call cfg_en,CONFIG_ESP_SIGN_RSA)$(call cfg_val,CONFIG_ESP_SIGN_RSA_LEN,3072)) \ @@ -107,20 +104,14 @@ ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) $(if $(CONFIG_UART0_SERIAL_CONSOLE),$(call cfg_val,CONFIG_ESP_CONSOLE_UART_NUM,0)) \ $(if $(CONFIG_UART1_SERIAL_CONSOLE),$(call cfg_val,CONFIG_ESP_CONSOLE_UART_NUM,1)) \ } >> $(BOOTLOADER_CONFIG) -else ifeq ($(CONFIG_ESP32S2_APP_FORMAT_LEGACY),y) - $(Q) { \ - $(call cfg_en,CONFIG_PARTITION_TABLE_CUSTOM) \ - $(call cfg_val,CONFIG_PARTITION_TABLE_CUSTOM_FILENAME,\"partitions.csv\") \ - $(call cfg_val,CONFIG_PARTITION_TABLE_OFFSET,$(CONFIG_ESP32S2_PARTITION_TABLE_OFFSET)) \ - } >> $(BOOTLOADER_CONFIG) -endif endif ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y) bootloader: $(Q) echo "Using direct bootloader to boot NuttX." -else ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) +else +# CONFIG_ESP32S2_APP_FORMAT_MCUBOOT BOOTLOADER_BIN = $(TOPDIR)/mcuboot-esp32s2.bin BOOTLOADER_SIGNED_BIN = $(TOPDIR)/mcuboot-esp32s2.signed.bin @@ -169,20 +160,4 @@ clean_bootloader: $(call DELFILE,$(BOOTLOADER_BIN)) $(if $(CONFIG_ESP32S2_SECURE_BOOT_BUILD_SIGNED_BINARIES),$(call DELFILE,$(BOOTLOADER_SIGNED_BIN))) -else ifeq ($(CONFIG_ESP32S2_APP_FORMAT_LEGACY),y) - -$(BOOTLOADER_SRCDIR): $(BOOTLOADER_DIR) - $(Q) git clone $(BOOTLOADER_URL) $(BOOTLOADER_SRCDIR) -b $(BOOTLOADER_VERSION) - -bootloader: $(BOOTLOADER_SRCDIR) $(BOOTLOADER_CONFIG) - $(Q) echo "Building Bootloader binaries" - $(Q) $(BOOTLOADER_SRCDIR)/build_idfboot.sh -c esp32s2 -s -f $(BOOTLOADER_CONFIG) - $(call COPYFILE,$(BOOTLOADER_SRCDIR)/$(BOOTLOADER_OUTDIR)/bootloader-esp32s2.bin,$(TOPDIR)) - $(call COPYFILE,$(BOOTLOADER_SRCDIR)/$(BOOTLOADER_OUTDIR)/partition-table-esp32s2.bin,$(TOPDIR)) - -clean_bootloader: - $(call DELDIR,$(BOOTLOADER_DIR)) - $(call DELFILE,$(TOPDIR)/bootloader-esp32s2.bin) - $(call DELFILE,$(TOPDIR)/partition-table-esp32s2.bin) - endif diff --git a/arch/xtensa/src/esp32s2/Kconfig b/arch/xtensa/src/esp32s2/Kconfig index 0bc2b9bfc0..b98e521000 100644 --- a/arch/xtensa/src/esp32s2/Kconfig +++ b/arch/xtensa/src/esp32s2/Kconfig @@ -1225,16 +1225,8 @@ menu "Bootloader and Image Configuration" config ESPRESSIF_SIMPLE_BOOT bool depends on !ESP32S2_APP_FORMAT_MCUBOOT - depends on !ESP32S2_APP_FORMAT_LEGACY default y -config ESP32S2_APP_FORMAT_LEGACY - bool "Enable Legacy boot format" - depends on !ESP32S2_APP_FORMAT_MCUBOOT - ---help--- - This is the legacy application image format, as supported by the ESP-IDF - 2nd stage bootloader. - config ESP32S2_APP_FORMAT_MCUBOOT bool "Enable MCUboot-bootable format" depends on !MCUBOOT_BOOTLOADER @@ -1278,36 +1270,6 @@ config ESP32S2_APP_MCUBOOT_HEADER_SIZE default 32 depends on ESP32S2_APP_FORMAT_MCUBOOT -config ESP32S2_PARTITION_TABLE_OFFSET_DEFAULT - hex - default 0x8000 - depends on ESP32S2_APP_FORMAT_LEGACY - -config ESP32S2_CUSTOM_PARTITION_TABLE_OFFSET - bool "Customize partition table offset" - default n - depends on ESP32S2_APP_FORMAT_LEGACY - ---help--- - Enable to select the offset of the partition table in the flash. - -if ESP32S2_CUSTOM_PARTITION_TABLE_OFFSET - -config ESP32S2_PARTITION_TABLE_OFFSET - hex "Partition Table offset" - default ESP32S2_PARTITION_TABLE_OFFSET_DEFAULT - depends on ESP32S2_APP_FORMAT_LEGACY - -endif # ESP32S2_CUSTOM_PARTITION_TABLE_OFFSET - -if !ESP32S2_CUSTOM_PARTITION_TABLE_OFFSET - -config ESP32S2_PARTITION_TABLE_OFFSET - hex - default ESP32S2_PARTITION_TABLE_OFFSET_DEFAULT - depends on ESP32S2_APP_FORMAT_LEGACY - -endif # !ESP32S2_CUSTOM_PARTITION_TABLE_OFFSET - source "arch/xtensa/src/esp32s2/Kconfig.security" endmenu # Bootloader and Image Configuration diff --git a/arch/xtensa/src/esp32s2/Make.defs b/arch/xtensa/src/esp32s2/Make.defs index 0f2775c67b..c2efe4f0c8 100644 --- a/arch/xtensa/src/esp32s2/Make.defs +++ b/arch/xtensa/src/esp32s2/Make.defs @@ -29,7 +29,7 @@ HEAD_CSRC = esp32s2_start.c esp32s2_wdt.c CHIP_CSRCS = esp32s2_allocateheap.c esp32s2_clockconfig.c esp32s2_irq.c CHIP_CSRCS += esp32s2_gpio.c esp32s2_rtc_gpio.c esp32s2_region.c esp32s2_user.c CHIP_CSRCS += esp32s2_timerisr.c esp32s2_lowputc.c esp32s2_systemreset.c -CHIP_CSRCS += esp32s2_dma.c esp32s2_libc_stubs.c +CHIP_CSRCS += esp32s2_dma.c esp32s2_libc_stubs.c loader.c # Configuration-dependent ESP32-S2 files @@ -143,10 +143,6 @@ ifeq ($(CONFIG_RTC_DRIVER),y) CHIP_CSRCS += esp32s2_rtc_lowerhalf.c endif -ifeq ($(ESP32S2_APP_FORMAT_LEGACY), ) -CHIP_CSRCS += loader.c -endif - ############################################################################# # Espressif HAL for 3rd Party Platforms ############################################################################# diff --git a/boards/xtensa/esp32s2/common/scripts/legacy_sections.ld b/boards/xtensa/esp32s2/common/scripts/legacy_sections.ld deleted file mode 100644 index 9e77a98763..0000000000 --- a/boards/xtensa/esp32s2/common/scripts/legacy_sections.ld +++ /dev/null @@ -1,235 +0,0 @@ -/**************************************************************************** - * boards/xtensa/esp32s2/common/scripts/legacy_sections.ld - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/* Default entry point: */ - -ENTRY(__start); - -SECTIONS -{ - /* Send .iram0 code to iram */ - - .iram0.vectors : - { - _iram_start = ABSOLUTE(.); - - /* Vectors go to IRAM. */ - - _init_start = ABSOLUTE(.); - - /* Vectors according to builds/RF-2015.2-win32/esp108_v1_2_s5_512int_2/config.html */ - - . = 0x0; - KEEP (*(.window_vectors.text)); - . = 0x180; - KEEP (*(.xtensa_level2_vector.text)); - . = 0x1c0; - KEEP (*(.xtensa_level3_vector.text)); - . = 0x200; - KEEP (*(.xtensa_level4_vector.text)); - . = 0x240; - KEEP (*(.xtensa_level5_vector.text)); - . = 0x280; - KEEP (*(.debug_exception_vector.text)); - . = 0x2c0; - KEEP (*(.nmi_vector.text)); - . = 0x300; - KEEP (*(.kernel_exception_vector.text)); - . = 0x340; - KEEP (*(.user_exception_vector.text)); - . = 0x3c0; - KEEP (*(.double_exception_vector.text)); - . = 0x400; - *(.*_vector.literal) - - . = ALIGN (16); - *(.entry.text) - *(.init.literal) - *(.init) - } >iram0_0_seg - - .iram0.text : - { - /* Code marked as running out of IRAM */ - - *(.iram1 .iram1.*) - - /* align + add 16B for CPU dummy speculative instr. fetch */ - - . = ALIGN(4) + 16; - _iram_text = ABSOLUTE(.); - } >iram0_0_seg - - .dram0_reserved_for_iram (NOLOAD): - { - . = ORIGIN(dram0_0_seg) + _iram_text - _iram_start; - } >dram0_0_seg - - /* Shared RAM */ - - .dram0.bss (NOLOAD) : - { - /* .bss initialized on power-up */ - - . = ALIGN (8); - _sbss = ABSOLUTE(.); - *(.dynsbss) - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.sb.*) - *(.scommon) - *(.sbss2) - *(.sbss2.*) - *(.gnu.linkonce.sb2.*) - *(.dynbss) - KEEP (*(.bss)) - *(.bss.*) - *(.share.mem) - *(.gnu.linkonce.b.*) - *(COMMON) - . = ALIGN(8); - _ebss = ABSOLUTE(.); - } >dram0_0_seg - - .noinit (NOLOAD): - { - /* This section contains data that is not initialized during load, - * or during the application's initialization sequence. - */ - - . = ALIGN(4); - *(.noinit) - . = ALIGN(4); - } >dram0_0_seg - - .dram0.data : - { - /* .data initialized on power-up in ROMed configurations. */ - - _sdata = ABSOLUTE(.); - KEEP (*(.data)) - KEEP (*(.data.*)) - KEEP (*(.gnu.linkonce.d.*)) - KEEP (*(.data1)) - KEEP (*(.sdata)) - KEEP (*(.sdata.*)) - KEEP (*(.gnu.linkonce.s.*)) - KEEP (*(.sdata2)) - KEEP (*(.sdata2.*)) - KEEP (*(.gnu.linkonce.s2.*)) - KEEP (*(.jcr)) - *(.dram1 .dram1.*) - . = ALIGN(4); - _edata = ABSOLUTE(.); - - /* Heap starts at the end of .data */ - - _sheap = ABSOLUTE(.); - } >dram0_0_seg - - .flash.rodata : - { - _srodata = ABSOLUTE(.); - *(.rodata) - *(.rodata.*) - *(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */ - *(.gnu.linkonce.r.*) - *(.rodata1) - __XT_EXCEPTION_TABLE_ = ABSOLUTE(.); - *(.xt_except_table) - *(.gcc_except_table) - *(.gcc_except_table.*) - *(.gnu.linkonce.e.*) - *(.gnu.version_r) - *(.eh_frame) - - . = (. + 3) & ~ 3; - - /* C++ constructor and destructor tables, properly ordered: */ - - _sinit = ABSOLUTE(.); - KEEP (*crtbegin.o(.ctors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) - KEEP (*(SORT(.ctors.*))) - KEEP (*(.ctors)) - _einit = ABSOLUTE(.); - KEEP (*crtbegin.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) - KEEP (*(SORT(.dtors.*))) - KEEP (*(.dtors)) - - /* C++ exception handlers table: */ - - __XT_EXCEPTION_DESCS_ = ABSOLUTE(.); - *(.xt_except_desc) - *(.gnu.linkonce.h.*) - __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); - *(.xt_except_desc_end) - *(.dynamic) - *(.gnu.version_d) - _erodata = ABSOLUTE(.); - - /* Literals are also RO data. */ - - _lit4_start = ABSOLUTE(.); - *(*.lit4) - *(.lit4.*) - *(.gnu.linkonce.lit4.*) - _lit4_end = ABSOLUTE(.); - . = ALIGN(4); - } >default_rodata_seg - - .flash.text : - { - _stext = .; - *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) - *(.irom0.text) /* catch stray ICACHE_RODATA_ATTR */ - *(.fini.literal) - *(.fini) - *(.gnu.version) - - /* CPU will try to prefetch up to 16 bytes of instructions. - * This means that any configuration (e.g. MMU, PMS) must allow - * safe access to up to 16 bytes after the last real instruction, add - * dummy bytes to ensure this - */ - - . += 16; - - _etext = .; - } >default_code_seg - - .rtc.text : - { - . = ALIGN(4); - *(.rtc.literal .rtc.text) - } >rtc_iram_seg - - .rtc.data : - { - *(.rtc.data) - *(.rtc.rodata) - - /* Whatever is left from the RTC memory is used as a special heap. */ - - . = ALIGN (4); - _srtcheap = ABSOLUTE(.); - } >rtc_slow_seg -} diff --git a/boards/xtensa/esp32s2/esp32s2-kaluga-1/scripts/Make.defs b/boards/xtensa/esp32s2/esp32s2-kaluga-1/scripts/Make.defs index d0490b384b..f230acf98e 100644 --- a/boards/xtensa/esp32s2/esp32s2-kaluga-1/scripts/Make.defs +++ b/boards/xtensa/esp32s2/esp32s2-kaluga-1/scripts/Make.defs @@ -35,8 +35,6 @@ ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) ARCHSCRIPT += $(call FINDSCRIPT,mcuboot_sections.ld) else ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y) ARCHSCRIPT += $(call FINDSCRIPT,simple_boot_sections.ld) -else - ARCHSCRIPT += $(call FINDSCRIPT,legacy_sections.ld) endif ARCHPICFLAGS = -fpic diff --git a/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/Make.defs b/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/Make.defs index 8c4e097bfb..567e3f81b7 100644 --- a/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/Make.defs +++ b/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/Make.defs @@ -35,8 +35,6 @@ ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) ARCHSCRIPT += $(call FINDSCRIPT,mcuboot_sections.ld) else ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y) ARCHSCRIPT += $(call FINDSCRIPT,simple_boot_sections.ld) -else - ARCHSCRIPT += $(call FINDSCRIPT,legacy_sections.ld) endif ARCHPICFLAGS = -fpic diff --git a/boards/xtensa/esp32s2/franzininho-wifi/scripts/Make.defs b/boards/xtensa/esp32s2/franzininho-wifi/scripts/Make.defs index 6a1ccb8073..ac1095f0c1 100644 --- a/boards/xtensa/esp32s2/franzininho-wifi/scripts/Make.defs +++ b/boards/xtensa/esp32s2/franzininho-wifi/scripts/Make.defs @@ -35,8 +35,6 @@ ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) ARCHSCRIPT += $(call FINDSCRIPT,mcuboot_sections.ld) else ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y) ARCHSCRIPT += $(call FINDSCRIPT,simple_boot_sections.ld) -else - ARCHSCRIPT += $(call FINDSCRIPT,legacy_sections.ld) endif ARCHPICFLAGS = -fpic diff --git a/tools/esp32s2/Config.mk b/tools/esp32s2/Config.mk index c863f3fd3f..da4f53abe0 100644 --- a/tools/esp32s2/Config.mk +++ b/tools/esp32s2/Config.mk @@ -67,15 +67,7 @@ ESPTOOL_FLASH_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ) # Configure the variables according to build environment ifdef ESPTOOL_BINDIR - ifeq ($(CONFIG_ESP32S2_APP_FORMAT_LEGACY),y) - BL_OFFSET := 0x1000 - PT_OFFSET := $(CONFIG_ESP32S2_PARTITION_TABLE_OFFSET) - BOOTLOADER := $(ESPTOOL_BINDIR)/bootloader-esp32s2.bin - PARTITION_TABLE := $(ESPTOOL_BINDIR)/partition-table-esp32s2.bin - FLASH_BL := $(BL_OFFSET) $(BOOTLOADER) - FLASH_PT := $(PT_OFFSET) $(PARTITION_TABLE) - ESPTOOL_BINS := $(FLASH_BL) $(FLASH_PT) - else ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) + ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) BL_OFFSET := 0x1000 ifeq ($(CONFIG_ESP32S2_SECURE_BOOT),y) @@ -94,11 +86,7 @@ ifdef ESPTOOL_BINDIR endif endif -ifeq ($(CONFIG_ESP32S2_APP_FORMAT_LEGACY),y) - APP_OFFSET := 0x10000 - APP_IMAGE := nuttx.bin - FLASH_APP := $(APP_OFFSET) $(APP_IMAGE) -else ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) +ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) ifeq ($(CONFIG_ESP32S2_ESPTOOL_TARGET_PRIMARY),y) VERIFIED := --confirm APP_OFFSET := $(CONFIG_ESP32S2_OTA_PRIMARY_SLOT_OFFSET) @@ -216,25 +204,7 @@ define MKIMAGE $(if $(CONFIG_ESP32S2_SECURE_BOOT_BUILD_SIGNED_BINARIES),$(call SIGNBIN),$(call HELP_SIGN_APP)) endef else -ifeq ($(CONFIG_ESP32S2_APP_FORMAT_LEGACY),y) -define MKIMAGE - $(Q) echo "MKIMAGE: ESP32-S2 binary" - $(Q) if ! esptool.py version 1>/dev/null 2>&1; then \ - echo ""; \ - echo "esptool.py not found. Please run: \"pip install esptool==4.8.dev4\""; \ - echo ""; \ - echo "Run make again to create the nuttx.bin image."; \ - exit 1; \ - fi - $(Q) if [ -z $(FLASH_SIZE) ]; then \ - echo "Missing Flash memory size configuration for the ESP32-S2 chip."; \ - exit 1; \ - fi - esptool.py -c esp32s2 elf2image $(ESPTOOL_FLASH_OPTS) -o nuttx.bin nuttx - $(Q) echo nuttx.bin >> nuttx.manifest - $(Q) echo "Generated: nuttx.bin (ESP32-S2 compatible)" -endef -else ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) +ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y) define MKIMAGE $(Q) echo "MKIMAGE: ESP32-S2 binary" $(Q) if ! imgtool version 1>/dev/null 2>&1; then \