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

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


The following commit(s) were added to refs/heads/master by this push:
     new d410a29  Support to run NuttX on ESP32 QEMU
d410a29 is described below

commit d410a29693426629d2d8f1bcee2d3f73eea08680
Author: Miguel Herranz <[email protected]>
AuthorDate: Thu Mar 19 12:22:36 2020 +0100

    Support to run NuttX on ESP32 QEMU
---
 .../xtensa/esp32/esp32-core/configs/nsh/defconfig  |  1 +
 .../esp32/esp32-core/configs/ostest/defconfig      |  1 +
 .../xtensa/esp32/esp32-core/configs/smp/defconfig  |  1 +
 boards/xtensa/esp32/esp32-core/scripts/Config.mk   | 49 +++++++++++++
 boards/xtensa/esp32/esp32-core/scripts/Make.defs   |  1 +
 tools/esp32/Makefile                               | 80 ++++++++++++++++++++++
 6 files changed, 133 insertions(+)

diff --git a/boards/xtensa/esp32/esp32-core/configs/nsh/defconfig 
b/boards/xtensa/esp32/esp32-core/configs/nsh/defconfig
index d10ceaf..02b0bee 100644
--- a/boards/xtensa/esp32/esp32-core/configs/nsh/defconfig
+++ b/boards/xtensa/esp32/esp32-core/configs/nsh/defconfig
@@ -48,6 +48,7 @@ CONFIG_START_DAY=6
 CONFIG_START_MONTH=12
 CONFIG_START_YEAR=2011
 CONFIG_SUPPRESS_CLOCK_CONFIG=y
+CONFIG_SUPPRESS_UART_CONFIG=y
 CONFIG_SYSTEM_NSH=y
 CONFIG_SYSTEM_NSH_CXXINITIALIZE=y
 CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/xtensa/esp32/esp32-core/configs/ostest/defconfig 
b/boards/xtensa/esp32/esp32-core/configs/ostest/defconfig
index e53294a..b5e6505 100644
--- a/boards/xtensa/esp32/esp32-core/configs/ostest/defconfig
+++ b/boards/xtensa/esp32/esp32-core/configs/ostest/defconfig
@@ -42,6 +42,7 @@ CONFIG_START_DAY=6
 CONFIG_START_MONTH=12
 CONFIG_START_YEAR=2011
 CONFIG_SUPPRESS_CLOCK_CONFIG=y
+CONFIG_SUPPRESS_UART_CONFIG=y
 CONFIG_SYSTEM_READLINE=y
 CONFIG_TESTING_OSTEST=y
 CONFIG_TESTING_OSTEST_LOOPS=10
diff --git a/boards/xtensa/esp32/esp32-core/configs/smp/defconfig 
b/boards/xtensa/esp32/esp32-core/configs/smp/defconfig
index fc64679..1b1d1e0 100644
--- a/boards/xtensa/esp32/esp32-core/configs/smp/defconfig
+++ b/boards/xtensa/esp32/esp32-core/configs/smp/defconfig
@@ -58,6 +58,7 @@ CONFIG_START_DAY=6
 CONFIG_START_MONTH=12
 CONFIG_START_YEAR=2011
 CONFIG_SUPPRESS_CLOCK_CONFIG=y
+CONFIG_SUPPRESS_UART_CONFIG=y
 CONFIG_SYSTEM_NSH=y
 CONFIG_SYSTEM_NSH_CXXINITIALIZE=y
 CONFIG_SYSTEM_TASKSET=y
diff --git a/boards/xtensa/esp32/esp32-core/scripts/Config.mk 
b/boards/xtensa/esp32/esp32-core/scripts/Config.mk
new file mode 100644
index 0000000..ee7710c
--- /dev/null
+++ b/boards/xtensa/esp32/esp32-core/scripts/Config.mk
@@ -0,0 +1,49 @@
+############################################################################
+# boards/xtensa/esp32/esp32-core/scripts/Config.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.
+#
+############################################################################
+
+# These are the macros that will be used in the NuttX make system to compile
+# and assembly source files and to insert the resulting object files into an
+# archive.  These replace the default definitions at tools/Config.mk
+
+# POSTBUILD -- Perform post build operations
+
+define POSTBUILD
+       @echo "MKIMAGE: ESP32 binary"
+        $(Q) if ! esptool.py version ; then \
+               echo ""; \
+               echo "Please install ESP-IDF tools"; \
+               echo ""; \
+               echo "Check 
https://docs.espressif.com/projects/esp-idf/en/v4.0/get-started/index.html#installation-step-by-step
 or run the following command"; \
+               echo ""; \
+               echo "cd tools/esp32 && make && cd ../.."; \
+               echo ""; \
+               echo "run make again to create the nuttx.bin image."; \
+       else \
+               echo "Generating: $(NUTTXNAME).bin (ESP32 compatible)"; \
+               esptool.py --chip esp32 elf2image --flash_mode dio --flash_size 
4MB -o nuttx.bin nuttx; \
+               echo "Generated: $(NUTTXNAME).bin (ESP32 compatible)"; \
+               echo "Generating: flash_image.bin"; \
+               dd if=/dev/zero bs=1024 count=4096 of=flash_image.bin && \
+               dd if=$(IDF_PATH)/hello_world/build/bootloader/bootloader.bin 
bs=1 seek=$(shell printf "%d" 0x1000) of=flash_image.bin conv=notrunc && \
+               dd 
if=$(IDF_PATH)/hello_world/build/partition_table/partition-table.bin bs=1 
seek=$(shell printf "%d" 0x8000) of=flash_image.bin conv=notrunc && \
+               dd if=$(NUTTXNAME).bin bs=1 seek=$(shell printf "%d" 0x10000) 
of=flash_image.bin conv=notrunc && \
+               echo "Generated: flash_image.bin (it can be run with 
'qemu-system-xtensa -nographic -machine esp32 -drive 
file=flash_image.bin,if=mtd,format=raw')"; \
+       fi
+endef
diff --git a/boards/xtensa/esp32/esp32-core/scripts/Make.defs 
b/boards/xtensa/esp32/esp32-core/scripts/Make.defs
index c230ad6..30d5e67 100644
--- a/boards/xtensa/esp32/esp32-core/scripts/Make.defs
+++ b/boards/xtensa/esp32/esp32-core/scripts/Make.defs
@@ -35,6 +35,7 @@
 
 include ${TOPDIR}/.config
 include ${TOPDIR}/tools/Config.mk
+include ${TOPDIR}/boards/xtensa/esp32/esp32-core/scripts/Config.mk
 include ${TOPDIR}/arch/xtensa/src/lx6/Toolchain.defs
 
 LDSCRIPT1 = 
$(TOPDIR)/boards/$(CONFIG_ARCH)/$(CONFIG_ARCH_CHIP)/$(CONFIG_ARCH_BOARD)/scripts/esp32_out.ld
diff --git a/tools/esp32/Makefile b/tools/esp32/Makefile
new file mode 100644
index 0000000..3c66828
--- /dev/null
+++ b/tools/esp32/Makefile
@@ -0,0 +1,80 @@
+############################################################################
+# tools/esp32/Makefile
+#
+# 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.
+#
+############################################################################
+
+ESP_PATH  = ${HOME}/esp
+
+IDF_PATH  = ${ESP_PATH}/esp-idf
+QEMU_PATH = ${ESP_PATH}/qemu
+
+QEMU_BIN = ${QEMU_PATH}/xtensa-softmmu/qemu-system-xtensa
+QEMU_LINK = ${IDF_PATH}/tools/qemu-system-xtensa
+
+BOOTLOADER_BIN = ${IDF_PATH}/hello_world/build/bootloader/bootloader.bin
+PARTITION_TABLE_BIN = 
${IDF_PATH}/hello_world/build/partition_table/partition-table.bin
+
+all: ${IDF_PATH} ${BOOTLOADER_BIN} ${PARTITION_TABLE_BIN} ${QEMU_BIN} 
${QEMU_LINK}
+default: all
+.PHONY: clean esp-idf-hello-world
+
+# Add CFLAGS=-g on the make command line to build debug versions
+
+CFLAGS = -O2 -Wall -I.
+
+${IDF_PATH}:
+       mkdir -p ${ESP_PATH}
+       echo "WARNING:this directory can be automatically removed" > 
${ESP_PATH}/README
+       cd ${ESP_PATH} && \
+               ls esp-idf || git clone -b master --recursive 
https://github.com/espressif/esp-idf.git && \
+       cd ${IDF_PATH} && \
+               ./install.sh
+
+${IDF_PATH}/hello_world:
+       cp -r ${IDF_PATH}/examples/get-started/hello_world 
${IDF_PATH}/hello_world
+
+${IDF_PATH}/hello_world/build: SHELL:=/usr/bin/env bash
+${IDF_PATH}/hello_world/build: ${IDF_PATH}/hello_world
+       cd ${IDF_PATH} && \
+               . export.sh && \
+               cd hello_world && \
+               idf.py menuconfig && \
+               echo "CONFIG_ESPTOOLPY_FLASHMODE_DOUT=y" >> sdkconfig && \
+               idf.py build
+
+${BOOTLOADER_BIN}: ${IDF_PATH}/hello_world/build
+
+${PARTITION_TABLE_BIN}: ${IDF_PATH}/hello_world/build
+
+${QEMU_BIN}:
+       cd ${ESP_PATH} && \
+               git clone https://github.com/espressif/qemu && \
+               cd qemu && \
+               ./configure --target-list=xtensa-softmmu \
+                   --enable-debug --enable-sanitizers \
+                   --disable-strip --disable-user \
+                   --disable-capstone --disable-vnc \
+                   --disable-sdl --disable-gtk && \
+               make -j8
+
+${QEMU_LINK}: ${QEMU_BIN}
+       ln -srf ${QEMU_BIN} ${QEMU_LINK}
+
+clean:
+       @rm -rf ${HOME}/.espressif
+       @grep "WARNING:this directory can be automatically removed" 
${ESP_PATH}/README > /dev/null 2> /dev/null && rm -rf ${ESP_PATH}; echo

Reply via email to