From 33295c0f6c4e663f0e5953d8ca599d67732e2d3e Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Wed, 18 Sep 2024 12:11:09 +0000 Subject: [PATCH 01/10] feat(esp32_openeth): move to common/espressif Since this will be used for esp32s3 also, we can have this in common/espressif. --- .../esp32_openeth.c => common/espressif/esp_openeth.c} | 6 +++--- arch/xtensa/src/esp32/Make.defs | 2 +- boards/xtensa/esp32/esp32-devkitc/src/esp32-devkitc.h | 2 +- boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename arch/xtensa/src/{esp32/esp32_openeth.c => common/espressif/esp_openeth.c} (99%) diff --git a/arch/xtensa/src/esp32/esp32_openeth.c b/arch/xtensa/src/common/espressif/esp_openeth.c similarity index 99% rename from arch/xtensa/src/esp32/esp32_openeth.c rename to arch/xtensa/src/common/espressif/esp_openeth.c index a59a7d9af6dc1..5d261b0baab76 100644 --- a/arch/xtensa/src/esp32/esp32_openeth.c +++ b/arch/xtensa/src/common/espressif/esp_openeth.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/xtensa/src/esp32/esp32_openeth.c + * arch/xtensa/src/common/espressif/esp_openeth.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -439,7 +439,7 @@ static int openeth_set_addr(uint8_t *addr) ****************************************************************************/ /**************************************************************************** - * Name: esp32_openeth_initialize + * Name: esp_openeth_initialize * * Description: * Initialize the openeth driver @@ -452,7 +452,7 @@ static int openeth_set_addr(uint8_t *addr) * ****************************************************************************/ -int esp32_openeth_initialize(void) +int esp_openeth_initialize(void) { int ret; struct openeth_priv_s *priv = &g_openeth; diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs index 3e69a2972d979..43990fcde0649 100644 --- a/arch/xtensa/src/esp32/Make.defs +++ b/arch/xtensa/src/esp32/Make.defs @@ -205,7 +205,7 @@ endif endif ifeq ($(CONFIG_ESP32_OPENETH),y) -CHIP_CSRCS += esp32_openeth.c +CHIP_CSRCS += esp_openeth.c endif ############################################################################# diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32-devkitc.h b/boards/xtensa/esp32/esp32-devkitc/src/esp32-devkitc.h index 0e3ad3f7d7f5b..ddce1e7bafea2 100644 --- a/boards/xtensa/esp32/esp32-devkitc/src/esp32-devkitc.h +++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32-devkitc.h @@ -245,7 +245,7 @@ int board_ws2812_initialize( * ****************************************************************************/ #ifdef CONFIG_ESP32_OPENETH -int esp32_openeth_initialize(void); +int esp_openeth_initialize(void); #endif #endif /* __ASSEMBLY__ */ diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c index e3891007bfa1e..3fca7db59b5f9 100644 --- a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c @@ -362,7 +362,7 @@ int esp32_bringup(void) #endif #ifdef CONFIG_ESP32_OPENETH - ret = esp32_openeth_initialize(); + ret = esp_openeth_initialize(); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to initialize Open ETH ethernet.\n"); From f6f94444f0c7db30cce7d44cabf9c8569d9afb3c Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Wed, 18 Sep 2024 15:37:42 +0000 Subject: [PATCH 02/10] feat(esp32s3-devkit): add qemu image option --- boards/xtensa/esp32s3/common/Kconfig | 7 +++++++ tools/esp32s3/Config.mk | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/boards/xtensa/esp32s3/common/Kconfig b/boards/xtensa/esp32s3/common/Kconfig index 97c7c69bd0c82..47c74d04328bd 100644 --- a/boards/xtensa/esp32s3/common/Kconfig +++ b/boards/xtensa/esp32s3/common/Kconfig @@ -12,6 +12,13 @@ config ESP32S3_MERGE_BINS This is only useful when the path to binary files (e.g. bootloader) is provided via the ESPTOOL_BINDIR variable. +config ESP32S3_QEMU_IMAGE + bool "ESP32S3 binary image for QEMU" + default n + select ESP32S3_MERGE_BINS + ---help--- + Create a binary flash image used for QEMU. + config ESP32S3_SPEED_UP_ISR bool "Speed up ISR" default n diff --git a/tools/esp32s3/Config.mk b/tools/esp32s3/Config.mk index 3ca37ea260306..8b44cace29333 100644 --- a/tools/esp32s3/Config.mk +++ b/tools/esp32s3/Config.mk @@ -127,7 +127,13 @@ define MERGEBIN echo "Missing Flash memory size configuration for the ESP32-S3 chip."; \ exit 1; \ fi - esptool.py -c esp32s3 merge_bin --output nuttx.merged.bin $(ESPTOOL_FLASH_OPTS) $(ESPTOOL_BINS) + $(eval ESPTOOL_MERGEBIN_OPTS := \ + $(if $(CONFIG_ESP32S3_QEMU_IMAGE), \ + --fill-flash-size $(FLASH_SIZE) -fm $(FLASH_MODE) -ff $(FLASH_FREQ), \ + $(ESPTOOL_FLASH_OPTS) \ + ) \ + ) + esptool.py -c esp32s3 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 From 43ee977ab591e2256db35fa584b640988f261881 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Wed, 18 Sep 2024 15:38:31 +0000 Subject: [PATCH 03/10] feat(esp32s3): add openeth ethernet driver for qemu We add the config for esp32s3, then move the esp32 specifics to esp32/chip.h, then add the esp32s3 specifics to esp32s3/chip.h. --- .../xtensa/src/common/espressif/esp_openeth.c | 20 +++++++----------- arch/xtensa/src/esp32/chip.h | 13 ++++++++++++ arch/xtensa/src/esp32s3/Kconfig | 21 +++++++++++++++++++ arch/xtensa/src/esp32s3/Make.defs | 4 ++++ arch/xtensa/src/esp32s3/chip.h | 13 ++++++++++++ .../xtensa/src/esp32s3/hardware/esp32s3_soc.h | 2 +- 6 files changed, 60 insertions(+), 13 deletions(-) diff --git a/arch/xtensa/src/common/espressif/esp_openeth.c b/arch/xtensa/src/common/espressif/esp_openeth.c index 5d261b0baab76..8a8c072f9fe3d 100644 --- a/arch/xtensa/src/common/espressif/esp_openeth.c +++ b/arch/xtensa/src/common/espressif/esp_openeth.c @@ -30,10 +30,7 @@ #include #include -#include "hardware/esp32_soc.h" -#include "esp32_irq.h" - -#ifdef CONFIG_ESP32_OPENETH +#include /**************************************************************************** * Pre-processor Definitions @@ -43,7 +40,7 @@ /* DMA buffers configuration */ #define DMA_BUF_SIZE 1600 -#define RX_BUF_COUNT CONFIG_ESP32_OPENETH_DMA_RX_BUFFER_NUM + /* Only need 1 TX buf because packets are transmitted immediately */ #define TX_BUF_COUNT 1 @@ -462,8 +459,9 @@ int esp_openeth_initialize(void) if (REG_READ(OPENETH_MODER_REG) != OPENETH_MODER_DEFAULT) { - nerr("CONFIG_ESP32_OPENETH should only be used when running in QEMU."); - nerr("When running the app on the ESP32, use ESP32 EMAC instead."); + nerr("Openeth should only be used when running in QEMU."); + nerr("When running the app on the real hardware," + "use the real MAC instead."); abort(); } @@ -512,8 +510,8 @@ int esp_openeth_initialize(void) /* Setup interrupts */ - priv->cpuint = esp32_setup_irq(0, ESP32_PERIPH_EMAC, - 1, ESP32_CPUINT_LEVEL); + priv->cpuint = OPENETH_SETUP_IRQ(0, OPENETH_PERIPH_MAC, + 1, OPENETH_CPUINT_LEVEL); if (priv->cpuint < 0) { nerr("ERROR: Failed allocate interrupt\n"); @@ -531,7 +529,7 @@ int esp_openeth_initialize(void) /* Attach the interrupt */ - ret = irq_attach(ESP32_IRQ_EMAC, openeth_isr_handler, priv); + ret = irq_attach(OPENETH_IRQ_MAC, openeth_isr_handler, priv); /* Register the device with the OS so that socket IOCTLs can be * performed. @@ -552,5 +550,3 @@ int esp_openeth_initialize(void) nerr("Failed initializing ret = %d", ret); abort(); } - -#endif /* CONFIG_ESP32_OPENETH */ diff --git a/arch/xtensa/src/esp32/chip.h b/arch/xtensa/src/esp32/chip.h index 1fd16a250b018..47412cf93aa84 100644 --- a/arch/xtensa/src/esp32/chip.h +++ b/arch/xtensa/src/esp32/chip.h @@ -30,10 +30,23 @@ #include "chip_macros.h" #include "chip_memory.h" +#if defined(CONFIG_ESP32_OPENETH) && !defined(__ASSEMBLY__) +#include "hardware/esp32_soc.h" +#include "esp32_irq.h" +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +#if defined(CONFIG_ESP32_OPENETH) +#define OPENETH_PERIPH_MAC ESP32_PERIPH_EMAC +#define OPENETH_CPUINT_LEVEL ESP32_CPUINT_LEVEL +#define OPENETH_IRQ_MAC ESP32_IRQ_EMAC +#define OPENETH_SETUP_IRQ esp32_setup_irq +#define RX_BUF_COUNT CONFIG_ESP32_OPENETH_DMA_RX_BUFFER_NUM +#endif + /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/arch/xtensa/src/esp32s3/Kconfig b/arch/xtensa/src/esp32s3/Kconfig index 64968c3d81344..e3793d0abf832 100644 --- a/arch/xtensa/src/esp32s3/Kconfig +++ b/arch/xtensa/src/esp32s3/Kconfig @@ -1658,6 +1658,27 @@ config ESP32S3_WIFI_LISTEN_INTERVAL endmenu # ESP32S3_WIFI +config ESP32S3_OPENETH + bool "Opencores Ethernet MAC" + default n + depends on !ESP32S3_WIFI + select NET + select SCHED_WORKQUEUE + ---help--- + Enable ESP32S3 ethernet opencores support for use with QEMU. + Disable this if you are using the real device. + +if ESP32S3_OPENETH + +config ESP32S3_OPENETH_DMA_RX_BUFFER_NUM + int "Number of Ethernet DMA Rx buffers" + range 1 64 + default 4 + ---help--- + Number of DMA receive buffers, each buffer is 1600 bytes. + +endif # ESP32S3_OPENETH + menu "BLE Configuration" depends on ESP32S3_BLE diff --git a/arch/xtensa/src/esp32s3/Make.defs b/arch/xtensa/src/esp32s3/Make.defs index 608a985129fce..1e5ecdacd7620 100644 --- a/arch/xtensa/src/esp32s3/Make.defs +++ b/arch/xtensa/src/esp32s3/Make.defs @@ -206,6 +206,10 @@ endif CHIP_CSRCS += esp32s3_pm.c endif +ifeq ($(CONFIG_ESP32S3_OPENETH),y) +CHIP_CSRCS += esp_openeth.c +endif + ############################################################################# # Espressif HAL for 3rd Party Platforms ############################################################################# diff --git a/arch/xtensa/src/esp32s3/chip.h b/arch/xtensa/src/esp32s3/chip.h index 725c54dd092b8..de74a17c482a5 100644 --- a/arch/xtensa/src/esp32s3/chip.h +++ b/arch/xtensa/src/esp32s3/chip.h @@ -30,10 +30,23 @@ #include "chip_macros.h" #include "chip_memory.h" +#if defined(CONFIG_ESP32S3_OPENETH) && !defined(__ASSEMBLY__) +#include "hardware/esp32s3_soc.h" +#include "esp32s3_irq.h" +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +#if defined(CONFIG_ESP32S3_OPENETH) +#define OPENETH_PERIPH_MAC ESP32S3_PERIPH_MAC +#define OPENETH_CPUINT_LEVEL ESP32S3_CPUINT_LEVEL +#define OPENETH_IRQ_MAC ESP32S3_IRQ_MAC +#define OPENETH_SETUP_IRQ esp32s3_setup_irq +#define RX_BUF_COUNT CONFIG_ESP32S3_OPENETH_DMA_RX_BUFFER_NUM +#endif + /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/arch/xtensa/src/esp32s3/hardware/esp32s3_soc.h b/arch/xtensa/src/esp32s3/hardware/esp32s3_soc.h index 35d026f37e801..47ca7321b9a83 100644 --- a/arch/xtensa/src/esp32s3/hardware/esp32s3_soc.h +++ b/arch/xtensa/src/esp32s3/hardware/esp32s3_soc.h @@ -40,7 +40,7 @@ ****************************************************************************/ #define DR_REG_USB_BASE 0x60080000 - +#define DR_REG_EMAC_BASE 0x600CD000 #define DR_REG_ASSIST_DEBUG_BASE 0x600CE000 #define DR_REG_WORLD_CNTL_BASE 0x600D0000 #define DR_REG_DPORT_END 0x600D3FFC From d86d18ab944457d90d9f97c3381c16864e7e75d1 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Wed, 18 Sep 2024 15:38:50 +0000 Subject: [PATCH 04/10] feat(esp32s3-devkit): initialize opencores eth mac --- boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3-devkit.h | 4 ++++ .../xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3-devkit.h b/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3-devkit.h index cafb03f6fdd0c..0a3fe78785574 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3-devkit.h +++ b/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3-devkit.h @@ -269,5 +269,9 @@ int esp32s3_lan9250_initialize(int port); int esp32s3_lan9250_uninitialize(int port); #endif +#ifdef CONFIG_ESP32S3_OPENETH +int esp_openeth_initialize(void); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_DEVKIT_SRC_ESP32S3_DEVKIT_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c index 4017a141e04e1..8718a875db1b5 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c +++ b/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c @@ -438,6 +438,14 @@ int esp32s3_bringup(void) #endif +#ifdef CONFIG_ESP32S3_OPENETH + ret = esp_openeth_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize Open ETH ethernet.\n"); + } +#endif + #ifdef CONFIG_DEV_GPIO ret = esp32s3_gpio_init(); if (ret < 0) From 26bcf3029e0aae952174a5843c7c9b5c5136a94c Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Wed, 18 Sep 2024 15:39:04 +0000 Subject: [PATCH 05/10] feat(esp32s3-devkit): add qemu defconfig --- .../configs/qemu_openeth/defconfig | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 boards/xtensa/esp32s3/esp32s3-devkit/configs/qemu_openeth/defconfig diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/configs/qemu_openeth/defconfig b/boards/xtensa/esp32s3/esp32s3-devkit/configs/qemu_openeth/defconfig new file mode 100644 index 0000000000000..7748659415b55 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-devkit/configs/qemu_openeth/defconfig @@ -0,0 +1,68 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +# CONFIG_ARCH_LEDS is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-devkit" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_DEVKIT=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM1N4=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_ESP32S3_APP_FORMAT_LEGACY=y +CONFIG_ESP32S3_OPENETH=y +CONFIG_ESP32S3_QEMU_IMAGE=y +CONFIG_ESP32S3_UART0=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=3072 +CONFIG_INTELHEX_BINARY=y +CONFIG_NETDB_DNSCLIENT=y +CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x0a000203 +CONFIG_NETDEV_LATEINIT=y +CONFIG_NETDEV_WORK_THREAD=y +CONFIG_NETINIT_DRIPADDR=0x0a000202 +CONFIG_NETINIT_IPADDR=0x0a000215 +CONFIG_NET_BINDTODEVICE=y +CONFIG_NET_ICMP_NPOLLWAITERS=4 +CONFIG_NET_ICMP_SOCKET=y +CONFIG_NET_ROUTE=y +CONFIG_NET_TCP=y +CONFIG_NET_TCPBACKLOG=y +CONFIG_NET_TCP_NPOLLWAITERS=8 +CONFIG_NET_TCP_WRITE_BUFFERS=y +CONFIG_NET_UDP=y +CONFIG_NET_UDP_NPOLLWAITERS=8 +CONFIG_NET_UDP_WRITE_BUFFERS=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=114688 +CONFIG_RAM_START=0x20000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSLOG_BUFFER=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_PING=y +CONFIG_UART0_SERIAL_CONSOLE=y From 26a2088f356e15ea5b5a2318f2a6f5b0c5fc22fd Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Wed, 18 Sep 2024 17:53:10 +0200 Subject: [PATCH 06/10] doc(esp32s3): qemu and openeth --- .../platforms/xtensa/esp32s3/index.rst | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Documentation/platforms/xtensa/esp32s3/index.rst b/Documentation/platforms/xtensa/esp32s3/index.rst index fef95268ffa83..6ae11d3f6d2c2 100644 --- a/Documentation/platforms/xtensa/esp32s3/index.rst +++ b/Documentation/platforms/xtensa/esp32s3/index.rst @@ -317,6 +317,31 @@ possible to track the root cause of the crash. Saving this output to a file and The above output shows the backtrace of the tasks. By checking it, it is possible to track the functions that were being executed when the crash occurred. +Using QEMU +========== + +Get or build QEMU from `here `__. The minimum supported version is 9.0.0. + +Enable the ``ESP32S3_QEMU_IMAGE`` config found in :menuselection:`Board Selection --> ESP32S3 binary image for QEMU`. + +Enable ``ESP32S3_APP_FORMAT_LEGACY``. + +Build and generate the QEMU image:: + + $ make bootloader + $ make ESPTOOL_BINDIR=. + +A QEMU-compatible ``nuttx.merged.bin`` binary image will be created. It can be run as:: + + $ qemu-system-xtensa -nographic -machine esp32s3 -drive file=nuttx.merged.bin,if=mtd,format=raw + +QEMU Networking +--------------- + +Networking is possible using the openeth MAC driver. Enable ``ESP32S3_OPENETH`` option and set the nic in QEMU: + + $ qemu-system-xtensa -nographic -machine esp32s3 -drive file=nuttx.merged.bin,if=mtd,format=raw -nic user,model=open_eth + Peripheral Support ================== From 0bc54fbf72a146bc65404e7393774069e27c87d6 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Wed, 18 Sep 2024 18:17:05 +0200 Subject: [PATCH 07/10] fix(esp32-qemu): enable legacy esp-idf build The current simple boot method is not working with qemu. We enable this option for now until we can make the simple-boot image boot with QEMU. --- boards/xtensa/esp32/esp32-devkitc/configs/qemu-openeth/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/qemu-openeth/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/qemu-openeth/defconfig index 6d0f99d5cf61a..3a91849e46644 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/qemu-openeth/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/qemu-openeth/defconfig @@ -19,6 +19,7 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_ARCH_XTENSA=y CONFIG_BOARD_LOOPSPERMSEC=16717 CONFIG_BUILTIN=y +CONFIG_ESP32_APP_FORMAT_LEGACY=y CONFIG_ESP32_OPENETH=y CONFIG_ESP32_QEMU_IMAGE=y CONFIG_ESP32_UART0=y From 33905efa31047da515273304ae162f1c83e37e84 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Wed, 18 Sep 2024 18:55:59 +0200 Subject: [PATCH 08/10] doc(esp32-qemu): update chip revision and bootloader --- Documentation/platforms/xtensa/esp32/index.rst | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Documentation/platforms/xtensa/esp32/index.rst b/Documentation/platforms/xtensa/esp32/index.rst index 32f698efffaac..c1f8257f810ab 100644 --- a/Documentation/platforms/xtensa/esp32/index.rst +++ b/Documentation/platforms/xtensa/esp32/index.rst @@ -627,25 +627,30 @@ Please check for usage examples using the :doc:`ESP32 DevKitC `__ to build QEMU. +Get or build QEMU from `here `__. 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``. +Enable ``ESP32_APP_FORMAT_LEGACY``. Build and generate the QEMU image:: - $ make ESPTOOL_BINDIR=../esp-bins + $ make bootloader + $ make ESPTOOL_BINDIR=. A QEMU-compatible ``nuttx.merged.bin`` binary image will be created. It can be run as:: $ qemu-system-xtensa -nographic -machine esp32 -drive file=nuttx.merged.bin,if=mtd,format=raw +QEMU for ESP32 does not correctly define the chip revision as v3.0 so you have two options: + +- #define ``ESP32_IGNORE_CHIP_REVISION_CHECK`` in ``arch/xtensa/src/esp32/esp32_start.c`` +- Emulate the efuse as described `here `__. + QEMU Networking --------------- -Networking is possible using the openeth MAC driver. Enable ``ESP32_OPENETH`` option and set the nic in QEMU: +Networking is possible using the openeth MAC driver. Enable ``ESP32_OPENETH`` option and set the nic in QEMU:: $ qemu-system-xtensa -nographic -machine esp32 -drive file=nuttx.merged.bin,if=mtd,format=raw -nic user,model=open_eth From f621daffb9ab0663403048caac41fa5c6e203cb1 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Sat, 12 Oct 2024 13:33:23 +0200 Subject: [PATCH 09/10] fix(esp32-devkit): rename defconfig to use _ --- .../configs/{qemu-openeth => qemu_openeth}/defconfig | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename boards/xtensa/esp32/esp32-devkitc/configs/{qemu-openeth => qemu_openeth}/defconfig (100%) diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/qemu-openeth/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/qemu_openeth/defconfig similarity index 100% rename from boards/xtensa/esp32/esp32-devkitc/configs/qemu-openeth/defconfig rename to boards/xtensa/esp32/esp32-devkitc/configs/qemu_openeth/defconfig From c6071260a066d4d537904cce7db56682e60ec4c1 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Sun, 6 Oct 2024 12:18:31 +0200 Subject: [PATCH 10/10] ci: skip config since this config requires bootloader, we skip it --- tools/ci/testlist/xtensa-01.dat | 2 +- tools/ci/testlist/xtensa-02.dat | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/ci/testlist/xtensa-01.dat b/tools/ci/testlist/xtensa-01.dat index 8d1f5fa4d2a1a..74be477241823 100644 --- a/tools/ci/testlist/xtensa-01.dat +++ b/tools/ci/testlist/xtensa-01.dat @@ -1,4 +1,4 @@ /xtensa/esp32 # We do not set ESPTOOL_BINDIR in this build --esp32-devkitc:qemu-openeth +-esp32-devkitc:qemu_openeth diff --git a/tools/ci/testlist/xtensa-02.dat b/tools/ci/testlist/xtensa-02.dat index 5541451dfbae5..0d325bf303b95 100644 --- a/tools/ci/testlist/xtensa-02.dat +++ b/tools/ci/testlist/xtensa-02.dat @@ -1,3 +1,6 @@ /xtensa/esp32s2 /xtensa/esp32s3 + +# We do not set ESPTOOL_BINDIR in this build +-esp32s3-devkit:qemu_openeth