From 57f0609e0f6ca0dc1674c716d5f90c4577403bae Mon Sep 17 00:00:00 2001 From: v-tangmeng Date: Thu, 23 Oct 2025 13:20:25 +0800 Subject: [PATCH] arch/xtensa/esp32[-s2|-s3]: add USE_NXTMPDIR_ESP_REPO_DIRECTLY Directly downloading the Git repository is inconvenient for local debugging. This will allow to automatically download external packages from the Internet. If not set, the repo need to be download will need to provide them manually, otherwise an error will occur and the build will be aborted. Add `USE_NXTMPDIR_ESP_REPO_DIRECTLY`, with this we can use `USE_NXTMPDIR_ESP_REPO_DIRECTLY=y make` which can directly use esp-hal-3rdparty under nxtmpdir without CLONE, CHECK_COMMITSHA, reset, checkout and update. Just `cp -rf nxtmpdir/esp-hal-3rdparty chip/$(ESP_HAL_3RDPARTY_REPO)`. Signed-off-by: v-tangmeng --- arch/risc-v/src/common/espressif/Make.defs | 15 +++++++++++++++ arch/risc-v/src/esp32c3-legacy/Make.defs | 13 +++++++++++++ arch/xtensa/src/esp32/Make.defs | 17 +++++++++++++++++ arch/xtensa/src/esp32s2/Make.defs | 17 +++++++++++++++++ arch/xtensa/src/esp32s3/Make.defs | 17 +++++++++++++++++ 5 files changed, 79 insertions(+) diff --git a/arch/risc-v/src/common/espressif/Make.defs b/arch/risc-v/src/common/espressif/Make.defs index 6021697719c05..3a561f20e0c9c 100644 --- a/arch/risc-v/src/common/espressif/Make.defs +++ b/arch/risc-v/src/common/espressif/Make.defs @@ -209,11 +209,22 @@ endif GIT_DEPTH_PARAMETER = --depth=$(GIT_DEPTH) endif +# When set USE_NXTMPDIR_ESP_REPO_DIRECTLY=y, will directly use esp-hal-3rdparty +# under nxtmpdir without CHECK_COMMITSHA, reset, checkout and update. + +USE_NXTMPDIR_ESP_REPO_DIRECTLY ?= n + ifeq ($(STORAGETMP),y) +ifeq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) +define CLONE_ESP_HAL_3RDPARTY_REPO + $(call COPYDIR, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),chip/$(ESP_HAL_3RDPARTY_REPO)) +endef +else define CLONE_ESP_HAL_3RDPARTY_REPO $(call CHECK_COMMITSHA, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),$(ESP_HAL_3RDPARTY_VERSION)) $(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO),$(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO)) endef +endif else define CLONE_ESP_HAL_3RDPARTY_REPO $(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO)) @@ -223,13 +234,17 @@ endif chip/$(ESP_HAL_3RDPARTY_REPO): $(Q) echo "Cloning Espressif HAL for 3rd Party Platforms" $(Q) $(call CLONE_ESP_HAL_3RDPARTY_REPO) +ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) $(Q) echo "Espressif HAL for 3rd Party Platforms: ${ESP_HAL_3RDPARTY_VERSION}" $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) checkout --quiet $(ESP_HAL_3RDPARTY_VERSION) $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/mbedtls/mbedtls +endif ifeq ($(CONFIG_ESP_WIRELESS),y) +ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) $(Q) echo "Espressif HAL for 3rd Party Platforms: initializing submodules..." $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/esp_phy/lib components/esp_wifi/lib components/bt/controller/lib_esp32c3_family components/esp_coex/lib $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls reset --quiet --hard +endif $(Q) echo "Applying patches..." $(Q) cd chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls && git apply ../../../nuttx/patches/components/mbedtls/mbedtls/*.patch endif diff --git a/arch/risc-v/src/esp32c3-legacy/Make.defs b/arch/risc-v/src/esp32c3-legacy/Make.defs index 86f37c92762d7..195efc1eb4ae8 100644 --- a/arch/risc-v/src/esp32c3-legacy/Make.defs +++ b/arch/risc-v/src/esp32c3-legacy/Make.defs @@ -248,11 +248,22 @@ ifndef ESP_HAL_3RDPARTY_URL ESP_HAL_3RDPARTY_URL = https://github.com/espressif/esp-hal-3rdparty.git endif +# When set USE_NXTMPDIR_ESP_REPO_DIRECTLY=y, will directly use esp-hal-3rdparty +# under nxtmpdir without CHECK_COMMITSHA, reset, checkout and update. + +USE_NXTMPDIR_ESP_REPO_DIRECTLY ?= n + ifeq ($(STORAGETMP),y) +ifeq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) +define CLONE_ESP_HAL_3RDPARTY_REPO + $(call COPYDIR, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),chip/$(ESP_HAL_3RDPARTY_REPO)) +endef +else define CLONE_ESP_HAL_3RDPARTY_REPO $(call CHECK_COMMITSHA, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),$(ESP_HAL_3RDPARTY_VERSION)) $(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO),$(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO)) endef +endif else define CLONE_ESP_HAL_3RDPARTY_REPO $(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO)) @@ -262,8 +273,10 @@ endif chip/$(ESP_HAL_3RDPARTY_REPO): $(Q) echo "Cloning Espressif HAL for 3rd Party Platforms" $(Q) $(call CLONE_ESP_HAL_3RDPARTY_REPO) +ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) $(Q) echo "Espressif HAL for 3rd Party Platforms: ${ESP_HAL_3RDPARTY_VERSION}" $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) checkout --quiet $(ESP_HAL_3RDPARTY_VERSION) +endif # Silent preprocessor warnings diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs index 8e2620eaa9a9f..ddfa808135009 100644 --- a/arch/xtensa/src/esp32/Make.defs +++ b/arch/xtensa/src/esp32/Make.defs @@ -237,11 +237,22 @@ endif GIT_DEPTH_PARAMETER = --depth=$(GIT_DEPTH) endif +# When set USE_NXTMPDIR_ESP_REPO_DIRECTLY=y, will directly use esp-hal-3rdparty +# under nxtmpdir without CHECK_COMMITSHA, reset, checkout and update. + +USE_NXTMPDIR_ESP_REPO_DIRECTLY ?= n + ifeq ($(STORAGETMP),y) +ifeq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) +define CLONE_ESP_HAL_3RDPARTY_REPO + $(call COPYDIR, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),chip/$(ESP_HAL_3RDPARTY_REPO)) +endef +else define CLONE_ESP_HAL_3RDPARTY_REPO $(call CHECK_COMMITSHA, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),$(ESP_HAL_3RDPARTY_VERSION)) $(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO),$(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO)) endef +endif else define CLONE_ESP_HAL_3RDPARTY_REPO $(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO)) @@ -251,8 +262,10 @@ endif chip/$(ESP_HAL_3RDPARTY_REPO): $(Q) echo "Cloning Espressif HAL for 3rd Party Platforms" $(Q) $(call CLONE_ESP_HAL_3RDPARTY_REPO) +ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) $(Q) echo "Espressif HAL for 3rd Party Platforms: ${ESP_HAL_3RDPARTY_VERSION}" $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) checkout --quiet $(ESP_HAL_3RDPARTY_VERSION) +endif # Silent preprocessor warnings @@ -273,14 +286,18 @@ include chip/hal.mk include common/espressif/Make.defs context:: chip/$(ESP_HAL_3RDPARTY_REPO) +ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) $(Q) echo "Espressif HAL for 3rd Party Platforms: initializing submodules..." $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/mbedtls/mbedtls components/esp_phy/lib components/esp_wifi/lib components/bt/controller/lib_esp32 components/esp_coex/lib $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls reset --quiet --hard +endif $(Q) echo "Applying patches..." $(Q) cd chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls && git apply ../../../nuttx/patches/components/mbedtls/mbedtls/*.patch ifeq ($(CONFIG_ESPRESSIF_WIRELESS),y) +ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/esp_phy/lib components/esp_wifi/lib components/bt/controller/lib_esp32 components/esp_coex/lib endif +endif distclean:: $(call DELDIR,chip/$(ESP_HAL_3RDPARTY_REPO)) diff --git a/arch/xtensa/src/esp32s2/Make.defs b/arch/xtensa/src/esp32s2/Make.defs index 10a6ab37a87a4..87d0e7974c02d 100644 --- a/arch/xtensa/src/esp32s2/Make.defs +++ b/arch/xtensa/src/esp32s2/Make.defs @@ -140,11 +140,22 @@ ifndef ESP_HAL_3RDPARTY_URL ESP_HAL_3RDPARTY_URL = https://github.com/espressif/esp-hal-3rdparty.git endif +# When set USE_NXTMPDIR_ESP_REPO_DIRECTLY=y, will directly use esp-hal-3rdparty +# under nxtmpdir without CHECK_COMMITSHA, reset, checkout and update. + +USE_NXTMPDIR_ESP_REPO_DIRECTLY ?= n + ifeq ($(STORAGETMP),y) +ifeq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) +define CLONE_ESP_HAL_3RDPARTY_REPO + $(call COPYDIR, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),chip/$(ESP_HAL_3RDPARTY_REPO)) +endef +else define CLONE_ESP_HAL_3RDPARTY_REPO $(call CHECK_COMMITSHA, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),$(ESP_HAL_3RDPARTY_VERSION)) $(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO),$(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO)) endef +endif else define CLONE_ESP_HAL_3RDPARTY_REPO $(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO)) @@ -154,8 +165,10 @@ endif chip/$(ESP_HAL_3RDPARTY_REPO): $(Q) echo "Cloning Espressif HAL for 3rd Party Platforms" $(Q) $(call CLONE_ESP_HAL_3RDPARTY_REPO) +ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) $(Q) echo "Espressif HAL for 3rd Party Platforms: ${ESP_HAL_3RDPARTY_VERSION}" $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) checkout --quiet $(ESP_HAL_3RDPARTY_VERSION) +endif # Silent preprocessor warnings @@ -174,14 +187,18 @@ include common/espressif/Make.defs include chip/Bootloader.mk context:: chip/$(ESP_HAL_3RDPARTY_REPO) +ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) $(Q) echo "Espressif HAL for 3rd Party Platforms: initializing submodules..." $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/mbedtls/mbedtls $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls reset --quiet --hard +endif $(Q) echo "Applying patches..." $(Q) cd chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls && git apply ../../../nuttx/patches/components/mbedtls/mbedtls/*.patch ifeq ($(CONFIG_ESPRESSIF_WIRELESS),y) +ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/esp_phy/lib components/esp_wifi/lib endif +endif distclean:: $(call DELDIR,chip/$(ESP_HAL_3RDPARTY_REPO)) diff --git a/arch/xtensa/src/esp32s3/Make.defs b/arch/xtensa/src/esp32s3/Make.defs index 7eb57f0f3e5d7..59511439aa483 100644 --- a/arch/xtensa/src/esp32s3/Make.defs +++ b/arch/xtensa/src/esp32s3/Make.defs @@ -221,11 +221,22 @@ endif GIT_DEPTH_PARAMETER = --depth=$(GIT_DEPTH) endif +# When set USE_NXTMPDIR_ESP_REPO_DIRECTLY=y, will directly use esp-hal-3rdparty +# under nxtmpdir without CHECK_COMMITSHA, reset, checkout and update. + +USE_NXTMPDIR_ESP_REPO_DIRECTLY ?= n + ifeq ($(STORAGETMP),y) +ifeq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) +define CLONE_ESP_HAL_3RDPARTY_REPO + $(call COPYDIR, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),chip/$(ESP_HAL_3RDPARTY_REPO)) +endef +else define CLONE_ESP_HAL_3RDPARTY_REPO $(call CHECK_COMMITSHA, $(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO),$(ESP_HAL_3RDPARTY_VERSION)) $(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO),$(NXTMPDIR)/$(ESP_HAL_3RDPARTY_REPO)) endef +endif else define CLONE_ESP_HAL_3RDPARTY_REPO $(call CLONE, $(ESP_HAL_3RDPARTY_URL),chip/$(ESP_HAL_3RDPARTY_REPO)) @@ -235,8 +246,10 @@ endif chip/$(ESP_HAL_3RDPARTY_REPO): $(Q) echo "Cloning Espressif HAL for 3rd Party Platforms" $(Q) $(call CLONE_ESP_HAL_3RDPARTY_REPO) +ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) $(Q) echo "Espressif HAL for 3rd Party Platforms: ${ESP_HAL_3RDPARTY_VERSION}" $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) checkout --quiet $(ESP_HAL_3RDPARTY_VERSION) +endif # Silent preprocessor warnings @@ -260,14 +273,18 @@ include chip/hal.mk include common/espressif/Make.defs context:: chip/$(ESP_HAL_3RDPARTY_REPO) +ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) $(Q) echo "Espressif HAL for 3rd Party Platforms: initializing submodules..." $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/mbedtls/mbedtls $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls reset --quiet --hard +endif $(Q) echo "Applying patches..." $(Q) cd chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls && git apply ../../../nuttx/patches/components/mbedtls/mbedtls/*.patch ifeq ($(CONFIG_ESPRESSIF_WIRELESS),y) +ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y) $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/esp_phy/lib components/esp_wifi/lib components/bt/controller/lib_esp32c3_family components/esp_coex/lib endif +endif distclean:: $(call DELDIR,chip/$(ESP_HAL_3RDPARTY_REPO))