You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2021/10/19 21:23:52 UTC

[incubator-nuttx] branch master updated (970cbff -> b998528)

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

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


    from 970cbff  fs/partition: Make parse_ptable_partition to partition.h
     new 0299e7d  tools/esp32: Refactor generation of QEMU-compatible image
     new b998528  Documentation: Update "Using QEMU" section for ESP32

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.


Summary of changes:
 Documentation/platforms/xtensa/esp32/index.rst     |  18 ++--
 boards/xtensa/esp32/common/Kconfig                 |   1 +
 boards/xtensa/esp32/esp32-devkitc/src/Make.defs    |   1 -
 .../xtensa/esp32/esp32-ethernet-kit/src/Make.defs  |   1 -
 boards/xtensa/esp32/esp32-wrover-kit/src/Make.defs |   1 -
 boards/xtensa/esp32/ttgo_lora_esp32/src/Make.defs  |   1 -
 tools/esp32/Config.mk                              |  30 +++---
 tools/esp32/mk_qemu_img.sh                         | 106 ---------------------
 8 files changed, 26 insertions(+), 133 deletions(-)
 delete mode 100755 tools/esp32/mk_qemu_img.sh

[incubator-nuttx] 01/02: tools/esp32: Refactor generation of QEMU-compatible image

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

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

commit 0299e7d35d0a7a4d8156d16abaf185e51001a10e
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Thu Oct 14 13:13:31 2021 -0300

    tools/esp32: Refactor generation of QEMU-compatible image
    
    Use the merge_bin builtin function from esptool.py.
    
    Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
 boards/xtensa/esp32/common/Kconfig                 |   1 +
 boards/xtensa/esp32/esp32-devkitc/src/Make.defs    |   1 -
 .../xtensa/esp32/esp32-ethernet-kit/src/Make.defs  |   1 -
 boards/xtensa/esp32/esp32-wrover-kit/src/Make.defs |   1 -
 boards/xtensa/esp32/ttgo_lora_esp32/src/Make.defs  |   1 -
 tools/esp32/Config.mk                              |  30 +++---
 tools/esp32/mk_qemu_img.sh                         | 106 ---------------------
 7 files changed, 15 insertions(+), 126 deletions(-)

diff --git a/boards/xtensa/esp32/common/Kconfig b/boards/xtensa/esp32/common/Kconfig
index 88ae2f0..4a93fca 100644
--- a/boards/xtensa/esp32/common/Kconfig
+++ b/boards/xtensa/esp32/common/Kconfig
@@ -14,6 +14,7 @@ config ESP32_MERGE_BINS
 config ESP32_QEMU_IMAGE
 	bool "ESP32 binary image for QEMU"
 	default n
+	select ESP32_MERGE_BINS
 	---help---
 		Create a binary flash image used for QEMU.
 
diff --git a/boards/xtensa/esp32/esp32-devkitc/src/Make.defs b/boards/xtensa/esp32/esp32-devkitc/src/Make.defs
index 658aa43..9da0238 100644
--- a/boards/xtensa/esp32/esp32-devkitc/src/Make.defs
+++ b/boards/xtensa/esp32/esp32-devkitc/src/Make.defs
@@ -62,7 +62,6 @@ context:: $(SCRIPTOUT)
 
 distclean::
 	$(call DELFILE, $(SCRIPTOUT))
-	$(call DELFILE, $(TOPDIR)/esp32_qemu_img.bin)
 
 DEPPATH += --dep-path board
 VPATH += :board
diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/src/Make.defs b/boards/xtensa/esp32/esp32-ethernet-kit/src/Make.defs
index 112b843..1a8fe0c 100644
--- a/boards/xtensa/esp32/esp32-ethernet-kit/src/Make.defs
+++ b/boards/xtensa/esp32/esp32-ethernet-kit/src/Make.defs
@@ -54,7 +54,6 @@ context:: $(SCRIPTOUT)
 
 distclean::
 	$(call DELFILE, $(SCRIPTOUT))
-	$(call DELFILE, $(TOPDIR)/esp32_qemu_img.bin)
 
 DEPPATH += --dep-path board
 VPATH += :board
diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/Make.defs b/boards/xtensa/esp32/esp32-wrover-kit/src/Make.defs
index 2c5d689..d40703e 100644
--- a/boards/xtensa/esp32/esp32-wrover-kit/src/Make.defs
+++ b/boards/xtensa/esp32/esp32-wrover-kit/src/Make.defs
@@ -64,7 +64,6 @@ context:: $(SCRIPTOUT)
 
 distclean::
 	$(call DELFILE, $(SCRIPTOUT))
-	$(call DELFILE, $(TOPDIR)/esp32_qemu_img.bin)
 
 DEPPATH += --dep-path board
 VPATH += :board
diff --git a/boards/xtensa/esp32/ttgo_lora_esp32/src/Make.defs b/boards/xtensa/esp32/ttgo_lora_esp32/src/Make.defs
index ee2742d..8f92d4c 100644
--- a/boards/xtensa/esp32/ttgo_lora_esp32/src/Make.defs
+++ b/boards/xtensa/esp32/ttgo_lora_esp32/src/Make.defs
@@ -62,7 +62,6 @@ context:: $(SCRIPTOUT)
 
 distclean::
 	$(call DELFILE, $(SCRIPTOUT))
-	$(call DELFILE, $(TOPDIR)/esp32_qemu_img.bin)
 
 DEPPATH += --dep-path board
 VPATH += :board
diff --git a/tools/esp32/Config.mk b/tools/esp32/Config.mk
index d8c4cf5..fe242b4 100644
--- a/tools/esp32/Config.mk
+++ b/tools/esp32/Config.mk
@@ -98,15 +98,8 @@ endif
 
 ESPTOOL_BINS += $(FLASH_APP)
 
-ifeq ($(CONFIG_ESP32_QEMU_IMAGE),y)
-	MK_QEMU_IMG=$(TOPDIR)/tools/esp32/mk_qemu_img.sh -b $(BOOTLOADER) -p $(PARTITION_TABLE)
-else
-	MK_QEMU_IMG=
-endif
-
 # MERGEBIN -- Merge raw binary files into a single file
 
-ifeq ($(CONFIG_ESP32_MERGE_BINS),y)
 define MERGEBIN
 	$(Q) if [ -z $(ESPTOOL_BINDIR) ]; then \
 		echo "MERGEBIN error: Missing argument for binary files directory."; \
@@ -117,15 +110,21 @@ define MERGEBIN
 		echo "Missing Flash memory size configuration for the ESP32 chip."; \
 		exit 1; \
 	fi
-	esptool.py -c esp32 merge_bin --output nuttx.merged.bin $(ESPTOOL_FLASH_OPTS) $(ESPTOOL_BINS)
+	$(eval ESPTOOL_MERGEBIN_OPTS :=                                              \
+		$(if $(CONFIG_ESP32_QEMU_IMAGE),                                         \
+			--fill-flash-size $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ), \
+			$(ESPTOOL_FLASH_OPTS)                                                \
+		)                                                                        \
+	)
+	esptool.py -c esp32 merge_bin --output nuttx.merged.bin $(ESPTOOL_MERGEBIN_OPTS) $(ESPTOOL_BINS)
 	$(Q) echo nuttx.merged.bin >> nuttx.manifest
-	$(Q) echo "Generated: nuttx.merged.bin"
-endef
-else
-define MERGEBIN
 
+	$(Q) if [ "$(CONFIG_ESP32_QEMU_IMAGE)" = "y" ]; then \
+	    echo "Generated: nuttx.merged.bin (QEMU compatible)"; \
+	else \
+	    echo "Generated: nuttx.merged.bin"; \
+	fi
 endef
-endif
 
 # SIGNBIN -- Sign the binary image file
 
@@ -174,13 +173,12 @@ endif
 ifeq ($(CONFIG_ESP32_APP_FORMAT_MCUBOOT),y)
 define POSTBUILD
 	$(call SIGNBIN)
-	$(call MERGEBIN)
+	$(if $(CONFIG_ESP32_MERGE_BINS), $(call MERGEBIN), )
 endef
 else ifeq ($(CONFIG_ESP32_APP_FORMAT_LEGACY),y)
 define POSTBUILD
 	$(call ELF2IMAGE)
-	$(call MERGEBIN)
-	$(Q) $(MK_QEMU_IMG)
+	$(if $(CONFIG_ESP32_MERGE_BINS), $(call MERGEBIN), )
 endef
 endif
 
diff --git a/tools/esp32/mk_qemu_img.sh b/tools/esp32/mk_qemu_img.sh
deleted file mode 100755
index 4dfaeae..0000000
--- a/tools/esp32/mk_qemu_img.sh
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/env bash
-############################################################################
-# tools/esp32/mk_qemu_img.sh
-#
-# 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.
-#
-############################################################################
-
-SCRIPT_NAME=$(basename "${0}")
-
-BOOTLOADER_IMG=""
-PARTITION_IMG=""
-BOOTLOADER_OFFSET=0x1000
-PARTITION_OFFSET=0x8000
-NUTTX_OFFSET=0x10000
-NUTTX_IMG="nuttx.bin"
-FLASH_IMG="esp32_qemu_img.bin"
-
-usage() {
-  echo ""
-  echo "USAGE: ${SCRIPT_NAME} [-h] -b <bootloader> -p <partition_table> [-n <nuttx>] [-i <image_name>]"
-  echo ""
-  echo "Where:"
-  echo "  -b <bootloader> path to the bootloader image"
-  echo "  -p <partition_table> path to the partition table image"
-  echo "  -n <nuttx> path to the nuttx image (default nuttx.bin)"
-  echo "  -i <image_name> name of the resulting image (default esp32_qemu_img.bin)"
-  echo "  -h will show this help and terminate"
-  echo ""
-}
-
-imgappend() {
-  dd of="${1}" if="${2}" bs=1 seek="$(printf '%d' ${3})" conv=notrunc status=none
-}
-
-while [ -n "${1}" ]; do
-  case "${1}" in
-  -b )
-    shift
-    BOOTLOADER_IMG=${1}
-    ;;
-  -p )
-    shift
-    PARTITION_IMG=${1}
-    ;;
-  -n )
-    shift
-    NUTTX_IMG=${1}
-    ;;
-  -i )
-    shift
-    FLASH_IMG=${1}
-    ;;
-  -h )
-    usage
-    exit 0
-    ;;
-  *)
-    usage
-    exit 1
-    ;;
-  esac
-  shift
-done
-
-# Make sure we have the required argument(s)
-
-if [ -z "${BOOTLOADER_IMG}" ] || [ -z "${PARTITION_IMG}" ] ; then
-  echo ""
-  echo "${SCRIPT_NAME}: Missing bootloader and partition table binary images."
-  usage
-  exit 1
-fi
-
-printf "Generating %s...\n" "${FLASH_IMG}"
-printf "\tBootloader: %s\n" "${BOOTLOADER_IMG}"
-printf "\tPartition Table: %s\n" "${PARTITION_IMG}"
-
-dd if=/dev/zero bs=1024 count=4096 of="${FLASH_IMG}" status=none
-imgappend ${FLASH_IMG} ${BOOTLOADER_IMG} ${BOOTLOADER_OFFSET}
-imgappend ${FLASH_IMG} ${PARTITION_IMG} ${PARTITION_OFFSET}
-imgappend ${FLASH_IMG} ${NUTTX_IMG} ${NUTTX_OFFSET}
-
-if [ ${?} -ne 0 ]; then
-  printf "Failed to generate %s!\n" "${FLASH_IMG}"
-  exit 1
-fi
-
-printf "Generated %s successfully!\n" "${FLASH_IMG}"
-printf "You can run it with QEMU using:\n"
-printf "\tqemu-system-xtensa -nographic -machine esp32 -drive file=%s,if=mtd,format=raw\n" "${FLASH_IMG}"
-
-echo "${FLASH_IMG}" >> nuttx.manifest

[incubator-nuttx] 02/02: Documentation: Update "Using QEMU" section for ESP32

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

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

commit b99852872c2ba5489a29ec2a865cf8c6a0d65865
Author: Gustavo Henrique Nihei <gu...@espressif.com>
AuthorDate: Tue Oct 19 12:14:35 2021 -0300

    Documentation: Update "Using QEMU" section for ESP32
    
    Signed-off-by: Gustavo Henrique Nihei <gu...@espressif.com>
---
 Documentation/platforms/xtensa/esp32/index.rst | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/Documentation/platforms/xtensa/esp32/index.rst b/Documentation/platforms/xtensa/esp32/index.rst
index 9cb5b72..3b501d6 100644
--- a/Documentation/platforms/xtensa/esp32/index.rst
+++ b/Documentation/platforms/xtensa/esp32/index.rst
@@ -329,15 +329,19 @@ Using QEMU
 ==========
 
 First follow the instructions `here <https://github.com/espressif/qemu/wiki>`_ to build QEMU.
-Enable the ESP32_QEMU_IMAGE config found in "Board Selection -> ESP32 binary image for QEMU".
+
+Enable the ``ESP32_QEMU_IMAGE`` config found in :menuselection:`Board Selection --> ESP32 binary image for QEMU`.
+
 Download the bootloader and the partition table from https://github.com/espressif/esp-nuttx-bootloader/releases
-and place them in a directory, say ../esp-bins.
-Build and generate the QEMU image: `make ESPTOOL_BINDIR=../esp-bins`
-A new image "esp32_qemu_image.bin" will be created.  It can be run as::
+and place them in a directory, say ``../esp-bins``.
+
+Build and generate the QEMU image::
+
+ $ make ESPTOOL_BINDIR=../esp-bins
+
+A QEMU-compatible ``nuttx.merged.bin`` binary image will be created. It can be run as::
 
- ~/PATH_TO_QEMU/qemu/build/xtensa-softmmu/qemu-system-xtensa -nographic \
-    -machine esp32 \
-    -drive file=esp32_qemu_image.bin,if=mtd,format=raw
+ $ qemu-system-xtensa -nographic -machine esp32 -drive file=nuttx.merged.bin,if=mtd,format=raw
 
 Things to Do
 ============