arch/risc-v: decouple common source for Espressif's MCUBoot port

Decouples the NuttX build from the MCUBoot common source on RISC-V Espressif
devices. Allows using different branches for each.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
This commit is contained in:
Filipe Cavalcanti 2025-06-12 17:20:59 -03:00 committed by Xiang Xiao
parent e15e6820ca
commit 075addd840
2 changed files with 19 additions and 2 deletions

View file

@ -2,3 +2,4 @@
/esp-nuttx-bootloader
/*.zip
/esp-hal-3rdparty
/esp-hal-3rdparty-mcuboot

View file

@ -26,7 +26,6 @@ CHIP_SERIES = $(patsubst "%",%,$(CONFIG_ESPRESSIF_CHIP_SERIES))
TOOLSDIR = $(TOPDIR)/tools/espressif
CHIPDIR = $(TOPDIR)/arch/risc-v/src/chip
HALDIR = $(CHIPDIR)/esp-hal-3rdparty
BOOTLOADER_SRCDIR = $(CHIPDIR)/bootloader
BOOTLOADER_OUTDIR = $(BOOTLOADER_SRCDIR)/out
BOOTLOADER_CONFIG = $(BOOTLOADER_SRCDIR)/bootloader.conf
@ -36,6 +35,8 @@ BOOTLOADER_CONFIG = $(BOOTLOADER_SRCDIR)/bootloader.conf
MCUBOOT_SRCDIR = $(BOOTLOADER_SRCDIR)/mcuboot
MCUBOOT_ESPDIR = $(MCUBOOT_SRCDIR)/boot/espressif
MCUBOOT_TOOLCHAIN = $(TOOLSDIR)/mcuboot_toolchain_espressif.cmake
HALDIR = $(BOOTLOADER_SRCDIR)/esp-hal-3rdparty-mcuboot
ifndef MCUBOOT_VERSION
MCUBOOT_VERSION = $(CONFIG_ESPRESSIF_MCUBOOT_VERSION)
endif
@ -44,6 +45,10 @@ ifndef MCUBOOT_URL
MCUBOOT_URL = https://github.com/mcu-tools/mcuboot
endif
ifndef ESP_HAL_3RDPARTY_VERSION_FOR_MCUBOOT
ESP_HAL_3RDPARTY_VERSION_FOR_MCUBOOT = 3f02f2139e79ddc60f98ca35ed65c62c6914f079
endif
# Helpers for creating the configuration file
cfg_en = echo "$(1)=$(if $(CONFIG_ESPRESSIF_BOOTLOADER_MCUBOOT),1,y)";
@ -95,13 +100,23 @@ ifeq ($(CONFIG_ESPRESSIF_BOOTLOADER_MCUBOOT),y)
BOOTLOADER_BIN = $(TOPDIR)/mcuboot-$(CHIP_SERIES).bin
define CLONE_ESP_HAL_3RDPARTY_REPO_MCUBOOT
$(call CLONE, $(ESP_HAL_3RDPARTY_URL),$(HALDIR))
endef
$(MCUBOOT_SRCDIR): $(BOOTLOADER_SRCDIR)
$(Q) echo "Cloning MCUboot"
$(Q) git clone --quiet $(MCUBOOT_URL) $(MCUBOOT_SRCDIR)
$(Q) git -C "$(MCUBOOT_SRCDIR)" checkout --quiet $(MCUBOOT_VERSION)
$(Q) git -C "$(MCUBOOT_SRCDIR)" submodule --quiet update --init --recursive ext/mbedtls
$(BOOTLOADER_BIN): chip/$(ESP_HAL_3RDPARTY_REPO) $(MCUBOOT_SRCDIR) $(BOOTLOADER_CONFIG)
$(HALDIR):
$(Q) echo "Cloning Espressif HAL for 3rd Party Platforms (MCUBoot build)"
$(Q) $(call CLONE_ESP_HAL_3RDPARTY_REPO_MCUBOOT)
$(Q) echo "Espressif HAL for 3rd Party Platforms (MCUBoot build): ${ESP_HAL_3RDPARTY_VERSION_FOR_MCUBOOT}"
$(Q) git -C $(HALDIR) checkout --quiet $(ESP_HAL_3RDPARTY_VERSION_FOR_MCUBOOT)
$(BOOTLOADER_BIN): $(HALDIR) $(MCUBOOT_SRCDIR) $(BOOTLOADER_CONFIG)
$(Q) echo "Building MCUboot"
$(Q) $(TOOLSDIR)/build_mcuboot.sh \
-c $(CHIP_SERIES) \
@ -114,6 +129,7 @@ $(BOOTLOADER_BIN): chip/$(ESP_HAL_3RDPARTY_REPO) $(MCUBOOT_SRCDIR) $(BOOTLOADER_
bootloader: $(BOOTLOADER_CONFIG) $(BOOTLOADER_BIN)
clean_bootloader:
$(call DELDIR,$(HALDIR))
$(call DELDIR,$(BOOTLOADER_SRCDIR))
$(call DELFILE,$(BOOTLOADER_BIN))
endif