You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gu...@apache.org on 2021/09/16 17:15:12 UTC

[incubator-nuttx] branch feature/esp32_build_binaries created (now 1ac5783)

This is an automated email from the ASF dual-hosted git repository.

gustavonihei pushed a change to branch feature/esp32_build_binaries
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


      at 1ac5783  tools/esp32: Set ESPTOOL_BINDIR if buildsystem provisioned the binaries

This branch includes the following new commits:

     new d6cfcf7  xtensa/esp32: Enable build system to download or build bins from source
     new 1ac5783  tools/esp32: Set ESPTOOL_BINDIR if buildsystem provisioned the binaries

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[incubator-nuttx] 02/02: tools/esp32: Set ESPTOOL_BINDIR if buildsystem provisioned the binaries

Posted by gu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gustavonihei pushed a commit to branch feature/esp32_build_binaries
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 1ac578320678f8f48d84232fe48aee26cfba9a74
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Wed Sep 15 18:18:25 2021 -0300

    tools/esp32: Set ESPTOOL_BINDIR if buildsystem provisioned the binaries
    
    Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
 tools/esp32/Config.mk | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/esp32/Config.mk b/tools/esp32/Config.mk
index 7605778..0f148b4 100644
--- a/tools/esp32/Config.mk
+++ b/tools/esp32/Config.mk
@@ -60,6 +60,14 @@ endif
 
 ESPTOOL_FLASH_OPTS := -fs $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ)
 
+# Configure ESPTOOL_BINDIR if the build system either downloaded or
+# built the bootloader binaries from source.
+# NOTE: The user-provided value for ESPTOOL_BINDIR shall not be overridden.
+
+ifeq ($(CONFIG_ESP32_BINARIES_BUILD_FROM_SOURCE)$(CONFIG_ESP32_BINARIES_DOWNLOAD_PREBUILT),y)
+	ESPTOOL_BINDIR ?= $(TOPDIR)
+endif
+
 # Configure the variables according to build environment
 
 ifdef ESPTOOL_BINDIR

[incubator-nuttx] 01/02: xtensa/esp32: Enable build system to download or build bins from source

Posted by gu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gustavonihei pushed a commit to branch feature/esp32_build_binaries
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit d6cfcf7dc4c70271a90a9f4d1998ec6f9a7250e3
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Tue Sep 14 10:41:59 2021 -0300

    xtensa/esp32: Enable build system to download or build bins from source
    
    Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
 arch/xtensa/src/esp32/Bootloader.mk | 92 +++++++++++++++++++++++++++++++++++++
 arch/xtensa/src/esp32/Kconfig       | 27 +++++++++++
 arch/xtensa/src/esp32/Make.defs     |  4 ++
 3 files changed, 123 insertions(+)

diff --git a/arch/xtensa/src/esp32/Bootloader.mk b/arch/xtensa/src/esp32/Bootloader.mk
new file mode 100644
index 0000000..1d71a18
--- /dev/null
+++ b/arch/xtensa/src/esp32/Bootloader.mk
@@ -0,0 +1,92 @@
+############################################################################
+# arch/xtensa/src/esp32/Bootloader.mk
+#
+# 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.
+#
+############################################################################
+
+ifeq ($(CONFIG_ESP32_BINARIES_BUILD_FROM_SOURCE),y)
+
+BOOTLOADER_SRCDIR   = esp-nuttx-bootloader
+BOOTLOADER_VERSION  = feature/refactor_mcuboot
+BOOTLOADER_URL      = https://github.com/espressif/esp-nuttx-bootloader
+BOOTLOADER_OUTDIR   = out
+ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
+BOOTLOADER_CONFIG   = mcuboot.conf
+endif
+
+$(BOOTLOADER_SRCDIR):
+	$(Q) echo "Downloading Bootloader sources"
+	$(Q) git clone $(BOOTLOADER_URL) chip/$(BOOTLOADER_SRCDIR) -b $(BOOTLOADER_VERSION)
+
+ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
+$(BOOTLOADER_CONFIG):
+	$(Q) echo "Creating Bootloader configuration"
+	$(Q) {                                                                                                  \
+			echo "CONFIG_ESP_BOOTLOADER_SIZE=0xF000";                                                       \
+			echo "CONFIG_ESP_APPLICATION_PRIMARY_START_ADDRESS=$(CONFIG_ESP32_OTA_PRIMARY_SLOT_OFFSET)";    \
+			echo "CONFIG_ESP_APPLICATION_SIZE=$(CONFIG_ESP32_OTA_SLOT_SIZE)";                               \
+			echo "CONFIG_ESP_APPLICATION_SECONDARY_START_ADDRESS=$(CONFIG_ESP32_OTA_SECONDARY_SLOT_OFFSET)";\
+			echo "CONFIG_ESP_MCUBOOT_WDT_ENABLE=y";                                                         \
+			echo "CONFIG_ESP_SCRATCH_OFFSET=$(CONFIG_ESP32_OTA_SCRATCH_OFFSET)";                            \
+			echo "CONFIG_ESP_SCRATCH_SIZE=$(CONFIG_ESP32_OTA_SCRATCH_SIZE)";                                \
+		} > chip/$(BOOTLOADER_CONFIG)
+endif
+
+context:: $(BOOTLOADER_SRCDIR) $(BOOTLOADER_CONFIG)
+	$(Q) echo "Building Bootloader binaries"
+ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
+	$(Q) chip/$(BOOTLOADER_SRCDIR)/build_mcuboot.sh -c esp32 -s -f chip/$(BOOTLOADER_CONFIG)
+	$(call COPYFILE, chip/$(BOOTLOADER_SRCDIR)/$(BOOTLOADER_OUTDIR)/mcuboot-esp32.bin, $(TOPDIR))
+else ifeq ($(CONFIG_ESP32_APP_FORMAT_LEGACY),y)
+	$(Q) docker run --rm --user=$(shell id -u):$(shell id -g) -v $(CURDIR)/chip/$(BOOTLOADER_SRCDIR):/work -w /work espressif/idf:release-v4.3 ./build_idfboot.sh -c esp32
+	$(call COPYFILE, chip/$(BOOTLOADER_SRCDIR)/$(BOOTLOADER_OUTDIR)/bootloader-esp32.bin, $(TOPDIR))
+	$(call COPYFILE, chip/$(BOOTLOADER_SRCDIR)/$(BOOTLOADER_OUTDIR)/partition-table-esp32.bin, $(TOPDIR))
+endif
+
+distclean::
+	$(call DELDIR, chip/$(BOOTLOADER_SRCDIR))
+ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
+	$(call DELFILE, chip/$(BOOTLOADER_CONFIG))
+	$(call DELFILE, $(TOPDIR)/mcuboot-esp32.bin)
+else ifeq ($(CONFIG_ESP32_APP_FORMAT_LEGACY),y)
+	$(call DELFILE, $(TOPDIR)/bootloader-esp32.bin)
+	$(call DELFILE, $(TOPDIR)/partition-table-esp32.bin)
+endif
+
+else ifeq ($(CONFIG_ESP32_BINARIES_DOWNLOAD_PREBUILT),y)
+
+BOOTLOADER_VERSION  = latest
+BOOTLOADER_URL      = https://github.com/espressif/esp-nuttx-bootloader/releases/download/$(BOOTLOADER_VERSION)
+
+context::
+	$(Q) echo "Downloading Bootloader binaries"
+ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
+	$(Q) curl -L $(BOOTLOADER_URL)/mcuboot-esp32.bin -o $(TOPDIR)/mcuboot-esp32.bin
+else ifeq ($(CONFIG_ESP32_APP_FORMAT_LEGACY),y)
+	$(Q) curl -L $(BOOTLOADER_URL)/bootloader-esp32.bin -o $(TOPDIR)/bootloader-esp32.bin
+	$(Q) curl -L $(BOOTLOADER_URL)/partition-table-esp32.bin -o $(TOPDIR)/partition-table-esp32.bin
+endif
+
+distclean::
+ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
+	$(call DELFILE, $(TOPDIR)/mcuboot-esp32.bin)
+else ifeq ($(CONFIG_ESP32_APP_FORMAT_LEGACY),y)
+	$(call DELFILE, $(TOPDIR)/bootloader-esp32.bin)
+	$(call DELFILE, $(TOPDIR)/partition-table-esp32.bin)
+endif
+
+endif
\ No newline at end of file
diff --git a/arch/xtensa/src/esp32/Kconfig b/arch/xtensa/src/esp32/Kconfig
index a5ecd7b..90714c6 100644
--- a/arch/xtensa/src/esp32/Kconfig
+++ b/arch/xtensa/src/esp32/Kconfig
@@ -1245,6 +1245,33 @@ comment "MCUboot support depends on CONFIG_EXPERIMENTAL"
 endchoice # Application Image Format
 
 choice
+	prompt "Source for required binaries"
+	default ESP32_BINARIES_USER_PROVIDED
+
+config ESP32_BINARIES_USER_PROVIDED
+	bool "User-provided prebuilt binaries"
+	---help---
+		If ESPTOOL_BINDIR argument is passed to "make download", the user is expected
+		to provide all the required binaries to be downloaded to the chip.
+
+config ESP32_BINARIES_DOWNLOAD_PREBUILT
+	bool "Download prebuilt binaries"
+	---help---
+		The build system will download the prebuilt binaries from
+		https://github.com/espressif/esp-nuttx-bootloader according to the chosen
+		Application Image Format (ESP32_APP_FORMAT_LEGACY or ESP32_APP_FORMAT_MCUBOOT)
+
+config ESP32_BINARIES_BUILD_FROM_SOURCE
+	bool "Build binaries from source"
+	---help---
+		The build system will build all the required binaries from source. It will clone
+		the https://github.com/espressif/esp-nuttx-bootloader repository and build a
+		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
 	depends on ESP32_HAVE_OTA_PARTITION
diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs
index d5d1c2f..4f17991 100644
--- a/arch/xtensa/src/esp32/Make.defs
+++ b/arch/xtensa/src/esp32/Make.defs
@@ -236,3 +236,7 @@ EXTRA_LIBS += -lcore -lrtc -lnet80211 -lpp -lsmartconfig -lcoexist -lespnow -lph
 
 LDFLAGS += --gc-sections
 endif
+
+# Provisioning for bootloader-related binary files
+
+include chip/Bootloader.mk