Git Product home page Git Product logo

espressif / qemu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qemu/qemu

217.0 22.0 55.0 536.93 MB

Fork of QEMU with Espressif patches. See Wiki for details.

Home Page: https://github.com/espressif/esp-toolchain-docs/blob/main/qemu/README.md

License: Other

C 81.27% Makefile 0.11% C++ 11.30% Haxe 0.37% Objective-C 0.11% Assembly 0.56% NSIS 0.01% Shell 1.49% Python 3.85% Perl 0.24% GLSL 0.01% Emacs Lisp 0.01% GDB 0.01% SmPL 0.03% Dockerfile 0.01% Pawn 0.03% Meson 0.48% SourcePawn 0.09% Vim Script 0.01% POV-Ray SDL 0.06%

qemu's Introduction

QEMU README

QEMU is a generic and open source machine & userspace emulator and virtualizer.

QEMU is capable of emulating a complete machine in software without any need for hardware virtualization support. By using dynamic translation, it achieves very good performance. QEMU can also integrate with the Xen and KVM hypervisors to provide emulated hardware while allowing the hypervisor to manage the CPU. With hypervisor support, QEMU can achieve near native performance for CPUs. When QEMU emulates CPUs directly it is capable of running operating systems made for one machine (e.g. an ARMv7 board) on a different machine (e.g. an x86_64 PC board).

QEMU is also capable of providing userspace API virtualization for Linux and BSD kernel interfaces. This allows binaries compiled against one architecture ABI (e.g. the Linux PPC64 ABI) to be run on a host using a different architecture ABI (e.g. the Linux x86_64 ABI). This does not involve any hardware emulation, simply CPU and syscall emulation.

QEMU aims to fit into a variety of use cases. It can be invoked directly by users wishing to have full control over its behaviour and settings. It also aims to facilitate integration into higher level management layers, by providing a stable command line interface and monitor API. It is commonly invoked indirectly via the libvirt library when using open source applications such as oVirt, OpenStack and virt-manager.

QEMU as a whole is released under the GNU General Public License, version 2. For full licensing details, consult the LICENSE file.

Documentation

Documentation can be found hosted online at https://www.qemu.org/documentation/. The documentation for the current development version that is available at https://www.qemu.org/docs/master/ is generated from the docs/ folder in the source tree, and is built by Sphinx.

Building

QEMU is multi-platform software intended to be buildable on all modern Linux platforms, OS-X, Win32 (via the Mingw64 toolchain) and a variety of other UNIX targets. The simple steps to build QEMU are:

mkdir build
cd build
../configure
make

Additional information can also be found online via the QEMU website:

Submitting patches

The QEMU source code is maintained under the GIT version control system.

git clone https://gitlab.com/qemu-project/qemu.git

When submitting patches, one common approach is to use 'git format-patch' and/or 'git send-email' to format & send the mail to the [email protected] mailing list. All patches submitted must contain a 'Signed-off-by' line from the author. Patches should follow the guidelines set out in the style section of the Developers Guide.

Additional information on submitting patches can be found online via the QEMU website

The QEMU website is also maintained under source control.

git clone https://gitlab.com/qemu-project/qemu-web.git

A 'git-publish' utility was created to make above process less cumbersome, and is highly recommended for making regular contributions, or even just for sending consecutive patch series revisions. It also requires a working 'git send-email' setup, and by default doesn't automate everything, so you may want to go through the above steps manually for once.

For installation instructions, please go to

The workflow with 'git-publish' is:

$ git checkout master -b my-feature
$ # work on new commits, add your 'Signed-off-by' lines to each
$ git publish

Your patch series will be sent and tagged as my-feature-v1 if you need to refer back to it in the future.

Sending v2:

$ git checkout my-feature # same topic branch
$ # making changes to the commits (using 'git rebase', for example)
$ git publish

Your patch series will be sent with 'v2' tag in the subject and the git tip will be tagged as my-feature-v2.

Bug reporting

The QEMU project uses GitLab issues to track bugs. Bugs found when running code built from QEMU git or upstream released sources should be reported via:

If using QEMU via an operating system vendor pre-built binary package, it is preferable to report bugs to the vendor's own bug tracker first. If the bug is also known to affect latest upstream code, it can also be reported via GitLab.

For additional information on bug reporting consult:

ChangeLog

For version history and release notes, please visit https://wiki.qemu.org/ChangeLog/ or look at the git history for more detailed information.

Contact

The QEMU community can be contacted in a number of ways, with the two main methods being email and IRC

Information on additional methods of contacting the community can be found online via the QEMU website:

qemu's People

Contributors

afaerber avatar agraf avatar aliguori avatar aurel32 avatar berrange avatar blueswirl avatar bonzini avatar davidhildenbrand avatar dgibson avatar ebblake avatar ehabkost avatar elmarco avatar gkurz avatar huth avatar jan-kiszka avatar jnsnow avatar juanquintela avatar kevmw avatar kraxel avatar legoater avatar mcayland avatar mstsirkin avatar philmd avatar pm215 avatar rth7680 avatar stefanharh avatar stsquad avatar stweil avatar vivier avatar xanclic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qemu's Issues

esp_flash support (QEMU-49)

I'd like to request support for the spi flash emulation, so that I can use esp_vfs_fat_spiflash_mount and all the other related functions from within my unit test

Can't run code when using IDF v4.4

I've successfully used the emulator for running some PlatformIO/Arduino sketches. PlatformIO used IDF v3.3.5.

Recently I switched to IDF v4.4 and ever since the application doesn't run in the emulator anymore. It does run fine when I flash it to the actual hardware, so it looks like the code that's generated runs fine, generally speaking.

I'm running qemu with the following options:
bin/qemu-system-xtensa -nographic -machine esp32 -drive file=../flash_image.bin,if=mtd,format=raw -global driver=esp32.gpio,property=strap_mode,value=0x12 -drive file=../efuse/qemu_efuse.bin,if=none,format=raw,id=efuse -global driver=nvram.esp32.efuse,property=drive,value=efuse

The output I'm getting is

==22289==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
Adding SPI flash device
ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1284
load:0x40078000,len:12808
load:0x40080400,len:3032
entry 0x400805e4
ets ets Jul 29 2019 12:21:46

rst:0x7 (TG0WDT_SYS_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1284
load:0x40078000,len:12808
load:0x40080400,len:3032
entry 0x400805e4

It basically runs into a watchdog timeout. If I disable the watchdog, nothing happens at all.

Please let me know what other useful information I can provide to debug the problem. I upload the firmware through esptool.py and setting the esp32.gpio.property value to 0x01 and writing to the socket:

esptool.py v3.1
Serial port socket://localhost:5555
Connecting...
Device PID identification is only supported on COM and /dev/ serial ports.

Chip is ESP32-D0WDQ6-V3 (revision 3)
Features: WiFi, BT, Dual Core, Coding Scheme None
Crystal is 40MHz
MAC: 00:00:00:00:00:00
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x000bafff...
Compressed 17216 bytes to 11867...
Writing at 0x00001000... (100 %)
Wrote 17216 bytes (11867 compressed) at 0x00001000 in 0.6 seconds (effective 229.0 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 128...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (128 compressed) at 0x00008000 in 0.0 seconds (effective 611.6 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 627.1 kbit/s)...
Hash of data verified.
Compressed 698432 bytes to 445097...
Writing at 0x00010000... (3 %)
Writing at 0x0001d172... (7 %)
Writing at 0x0002a21e... (10 %)
[...]
Writing at 0x000b3f48... (96 %)
Writing at 0x000b9890... (100 %)
Wrote 698432 bytes (445097 compressed) at 0x00010000 in 21.0 seconds (effective 266.5 kbit/s)...
Hash of data verified.

Leaving...

spi_flash_mmap not working

Dear Team and @igrr,

Thanks for the great platform you are providing us an ability to simulate and test our application.

It seems like spi_flash_mmap doesn't seems to be working. spi_flash_read and spi_flash_write works like a charm but when we mmap the region and then write to the region using spi_flash_write, mmaped region doesn't seem to have updated.

Provided some pointer, I will be more than happy to work with you to get this resolved.

Thanks.

MAC OSX Monterey qemu-system-xtensa Library not loaded: @rpath/libclang_rt.asan_osx_dynamic.dylib

maxOS Monterey (x86)

  1. Configure build system with ../configure --target-list=xtensa-softmmu --enable-debug --enable-sanitizers --disable-strip --disable-capstone --disable-vnc --enable-gcrypt
  2. Run make vga=no -j$(nproc)
  3. Run make install
  4. Change directory and compile test project
  5. Run test project with qemu-system-xtensa -nographic -M esp32 -m 4 -drive file=flash.bin,if=mtd,format=raw -nic user,model=open_eth,hostfwd=tcp::80-:80 -s

The next output is observed:

dyld[9082]: Library not loaded: @rpath/libclang_rt.asan_osx_dynamic.dylib
  Referenced from: /usr/local/bin/qemu-system-xtensa
  Reason: tried: '/usr/local/lib/libclang_rt.asan_osx_dynamic.dylib' (no such file), '/usr/lib/libclang_rt.asan_osx_dynamic.dylib' (no such file)
Abort trap: 6

Apply workaround: ../configure --target-list=xtensa-softmmu --enable-debug --enable-sanitizers --disable-strip --disable-capstone --disable-vnc --enable-gcrypt --extra-ldflags="-Wl,-rpath,/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/lib/darwin" to get qemu-system-xtensa running

ESP32-S2 support (QEMU-54)

Hello and thanks for the QEMU 5.0.0 rebase release, although it was a bit hard to find.
Do you have any plans to do a esp32-s2 release?

Unable to build on Windows 10 64bit using MSYS2 (QEMU-59)

Following the guide on (section 1.2.2 Native builds with MSYS2) :

Installed msys2-x86_64-20220904.exe.
Opened mingw64.exe as Administrator and ran the following commands.
pacman -Syu
pacman -Su
pacman -S base-devel mingw-w64-x86_64-toolchain git python ninja
pacman -S mingw-w64-x86_64-glib2 mingw-w64-x86_64-pixman python-setuptools
pacman -S mingw-w64-x86_64-gtk3 mingw-w64-x86_64-SDL2
pacman -S mingw-w64-x86_64-libgcrypt
git clone https://www.gitlab.com/qemu/qemu
cd qemu
./configure --target-list=xtensa-softmmu --enable-gcrypt --enable-debug --enable-sanitizers --disable-strip --disable-user --disable-capstone --disable-vnc --disable-sdl --disable-gtk
ninja -C build
Got the following error :

[331/1601] Compiling C++ object qga/vss-win32/qga-vss.dll.p/requester.cpp.obj
FAILED: qga/vss-win32/qga-vss.dll.p/requester.cpp.obj
"c++" "-m64" "-mcx16" "-Iqga/vss-win32/qga-vss.dll.p" "-Iqga/vss-win32" "-I../qga/vss-win32" "-ID:/ESP/msys64/mingw64/include" "-ID:/ESP/msys64/mingw64/include/glib-2.0" "-ID:/ESP/msys64/mingw64/lib/glib-2.0/include" "-fdiagnostics-color=auto" "-Wall" "-Winvalid-pch" "-Wnon-virtual-dtor" "-Werror" "-std=gnu++11" "-g" "-iquote" "." "-iquote" "D:/ESP/msys64/home/karim/qemu-esp" "-iquote" "D:/ESP/msys64/home/karim/qemu-esp/include" "-iquote" "D:/ESP/msys64/home/karim/qemu-esp/disas/libvixl" "-iquote" "D:/ESP/msys64/home/karim/qemu-esp/tcg/i386" "-D__STDC_LIMIT_MACROS" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D_GNU_SOURCE" "-D_FILE_OFFSET_BITS=64" "-D_LARGEFILE_SOURCE" "-Wundef" "-Wwrite-strings" "-fno-strict-aliasing" "-fno-common" "-fwrapv" "-Wtype-limits" "-Wformat-security" "-Wformat-y2k" "-Winit-self" "-Wignored-qualifiers" "-Wempty-body" "-Wendif-labels" "-Wexpansion-to-defined" "-Wimplicit-fallthrough=2" "-Wno-missing-include-dirs" "-Wno-shift-negative-value" "-Wno-psabi" "-fstack-protector-strong" "-Wno-unknown-pragmas" "-Wno-delete-non-virtual-dtor" "-Wno-non-virtual-dtor" -MD -MQ qga/vss-win32/qga-vss.dll.p/requester.cpp.obj -MF "qga/vss-win32/qga-vss.dll.p/requester.cpp.obj.d" -o qga/vss-win32/qga-vss.dll.p/requester.cpp.obj "-c" ../qga/vss-win32/requester.cpp
../qga/vss-win32/requester.cpp: In function 'void requester_freeze(int*, void*, ErrorSet*)':
../qga/vss-win32/requester.cpp:357:24: error: 'void operator delete(void*)' called on pointer returned from a mismatched allocation function [-Werror=mismatched-new-delete]
357 | delete volume_name_wchar;
| ^~~~~~~~~~~~~~~~~
../qga/vss-win32/requester.cpp:348:48: note: returned from 'void* operator new [](long long unsigned int)'
348 | volume_name_wchar = new wchar_t[len];
| ^
../qga/vss-win32/requester.cpp:362:20: error: 'void operator delete(void*)' called on pointer returned from a mismatched allocation function [-Werror=mismatched-new-delete]
362 | delete volume_name_wchar;
| ^~~~~~~~~~~~~~~~~
../qga/vss-win32/requester.cpp:348:48: note: returned from 'void* operator new [](long long unsigned int)'
348 | volume_name_wchar = new wchar_t[len];
| ^

By the way I was able to use this setup to build qemu.

runtime error: index 16 out of bounds for type 'uint16_t [16]'

Dear sir,

When I execute my ESP32 software on QEMU, I get a no-blocking error (It just appears on QEMU logs but the software "works as expected"):

hw/net/opencores_eth.c:130:41: runtime error: index 16 out of bounds for type 'uint16_t [16]'

I found another issue where the autor say's how he try to fix it:

#2 (comment)

If I do what he says and if I rebuild QEMU, then on the next run it will not work as expected (impossible to get an IP) but the error disapear.

"partition_ops" example executing with errors

I builded "partition_ops" example using idf 4.2. Also I prepared latest builds of qemu for esp32 from esp-develop branch. When I executed "partition_ops" example in emulator the example executed successfully but read ops via partitions API wasn't successful. I opened spi flash image after test's execution and found that data was wrote in proper places according to partition position and offset that was used in example but "esp_partition_read" method always returns data that shifted at +1 byte. After that I added simple hack in "esp-idf/components/spi_flash/partition.c" in method "esp_partition_read" in string 347, 349 i.e. use "partition->address + src_offset - 1" instead "partition->address + src_offset". Further I rebuilded and executed "partition_ops" and "spiffs" examples which was completed successfully.
Because I'm not familiar with qemu source code I'm not strictly localize where the problem is. Can you help me to fix this problem properly? Is this bug in qemu source code or somewhere else?

question: Qemu Semihosting exit from application

Hello im trying to interrupt qemu execution after application finishes, im not able to find how to do this properly, so my qemu start line looks like
xtensa-softmmu/qemu-system-xtensa -nographic -semihosting -machine esp32 -drive file=flash_image.bin,if=mtd,format=raw

in arm cortex m3 im able to do this with semihosting svc options

static inline void _exit_qemu() {
  register u32_t r0 __asm__("r0");
  r0 = 0x18;
  register u32_t r1 __asm__("r1");
  r1 = 0x20026;
  __asm__ volatile("bkpt #0xAB");
}

i found something inside openocd for esp
ADP_Stopped_ApplicationExit 0x20026 which seems to be the answer but im not sure how to use it.

And i also tried exit(0) and exit(1) but qemu keeps esp application rebooting, any help and hints are appreciated

Issues with SD card

I've followed the wiki to attach an SD card.

When calling sdmmc_card_init slot=1, host=SDMMC_HOST_DEFAULT() I'm getting:

E (37117) sdmmc_req: sdmmc_host_wait_for_event returned 0x107
E (47247) sdmmc_req: sdmmc_host_wait_for_event returned 0x107

I've tried increasing host.command_timeout_ms up to 10000, didn't help.

Looking at the debugger, it looks like sdmmc_host_wait_for_event is waiting to some interrupt that is never recieved on s_event_queue.
On QEMU I can see non-implemented reads being sent. For example, sdmmc_io_reset sends a command that is received on the QEMU side by dwc_sdmmc_read with offset 80 but unhandled, I'm not sure whether it's related or not.

Using flash image more that 4Mb works with errors (QEMU-64)

In my work I use 16Mb spi flash and respectively I want to use the same image in qemu. I created flash image of 16M size and tried to use it in qemu. There are two problem was noticed. First of all I found that when I run such image it fails in bootloader code because of error:
E (10154) spi_flash: Detected size(4096k) smaller than the size in the binary image header(16384k). Probe failed.
At first look this difficulty can be overcome using CONFIG_SPI_FLASH_USE_LEGACY_IMPL=y parameter but I found that it isn't. I founded that if we writing in spi flash by adresses more than 0xFFFFFFFF (maximal uin32 value) it leads to damage of spi flash by the adresses lower than 0xFFFFFFFF. It seems to me that somewere in qemu source code 32bit values are using to specify the adresses in flash space and it leads to rounding error if we use flash images more than 4Mb. It is possible to use more than 4Mb flash in qemu and how?

Mounting memory onto host

First, this project is great and I've been having a lot of fun with it. 🙏

I'm trying to access the memory of the emulated ESP32 from my host system, and I was wondering if you'd had any experience with that. Specifically, I'm trying to access the GPIO registers:

memory-region: esp32.gpio
  000000003ff44000-000000003ff44fff (prio 0, i/o): esp32.gpio

I'm starting qemu with the following options in an attempt to mount those 4KB to a file

qemu-system-xtensa -nographic \
    -machine esp32 \
    -drive file=${PROJECT_BIN},if=mtd,format=raw \
    -nic user,model=open_eth,id=lo0,hostfwd=tcp:0.0.0.0:8012-:80 \
    -serial tcp::5555,server,nowait \
    -monitor stdio \
    -object memory-backend-file,id=esp32.gpio,size=4k,mem-path=./qemu-gpio,share=on \
    -machine memory-backend=esp32.gpio

A file of the expected size is created, but it is blank, and does not update at all when running a blink sketch, for example.

Can I use the binary compiled by Arduino IDE instead of ESP-IDF? (QEMU-51)

Hello,
I know it's possible to run binary compiled with ESP-IDF using this fork of QEMU. And the Arduino IDE's support for ESP32 is based on the ESP-IDF framework.

So is it possible to run Arduino IDE's compiled binary on this QEMU? I tried the option Export compiled binary on Arduino IDE and then load the binary to QEMU as described, but it just output

==20167==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
Adding SPI flash device
qemu-system-xtensa: failed to read the initial flash content

Thanks in advance!

WIFI-Scan example

I tried to execute the 'scan' example from the idf package. It gets stucked at:

.check_dport_access_end () at /home/max/esp-idf/components/esp32/./dport_panic_highint_hdl.S:181

With output message:

I (1044) wifi: wifi firmware version: b3258e0
I (1044) wifi: config NVS flash: enabled
I (1044) wifi: config nano formating: disabled
I (1054) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (1064) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
D (1084) nvs: nvs_open_from_partition nvs.net80211 1

Funny thing is, that that it doesn't stuck always at the same point, but always during nvs_set or nvs_get. Do we have a racecondition here?
Is wifi code already working in this qemu port?

Best regards

Failed to init external RAM (QEMU-84)

I try to test my code according to the documentation on this wiki.
The esp-develop branch of today can't seem to allocate PSRAM, see below.

E (2884) quad_psram: PSRAM ID read error: 0x00000000
E (2886) cpu_start: Failed to init external RAM!

Any tips on what I did wrong and how to resolve this?

Thanks

../../qemu/build/qemu-system-xtensa -nographic -machine esp32 -m 4M -drive file=build/flash_image.bin,if=mtd,format=raw
==75211==WARNING: ASan is ignoring requested __asan_handle_no_return: stack type: default top: 0x00016fb0f000; bottom 0x00010affc000; size: 0x000064b13000 (1689333760)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
Adding SPI flash device
ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:7032
load:0x40078000,len:15404
ho 0 tail 12 room 4
load:0x40080400,len:3816
entry 0x40080648
I (655) boot: ESP-IDF v5.1-dev-1626-g4b6d9c8ad3-dirty 2nd stage bootloader
I (662) boot: compile time Nov 14 2022 18:14:06
I (678) boot: chip revision: V000
I (689) boot.esp32: SPI Speed      : 80MHz
I (691) boot.esp32: SPI Mode       : DIO
I (693) boot.esp32: SPI Flash Size : 4MB
I (718) boot: Enabling RNG early entropy source...
I (769) boot: Partition Table:
I (771) boot: ## Label            Usage          Type ST Offset   Length
I (773) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (776) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (778) boot:  2 factory          factory app      00 00 00010000 00160000
I (779) boot:  3 diska            unknown          6f 01 00170000 001f4000
I (799) boot: End of partition table
I (816) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=188bch (100540) map
I (1100) esp_image: segment 1: paddr=000288e4 vaddr=3ffb0000 size=035b4h ( 13748) load
I (1170) esp_image: segment 2: paddr=0002bea0 vaddr=40080000 size=04178h ( 16760) load
I (1253) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=67364h (422756) map
I (2552) esp_image: segment 4: paddr=0009738c vaddr=40084178 size=0fd74h ( 64884) load
I (2784) boot: Loaded app from partition at offset 0x10000
I (2786) boot: Disabling RNG early entropy source...
I (2828) quad_psram: This chip is ESP32-D0WD
E (2884) quad_psram: PSRAM ID read error: 0x00000000
E (2886) cpu_start: Failed to init external RAM!

abort() was called at PC 0x40081928 on core 0

qemu fails to compile: undefined reference to 'gcry_mpi_print' and others

When compiling on Ubuntu 22.04, I get the following compile errors midway through:

/usr/bin/ld: libcommon.fa.p/hw_misc_esp32_rsa.c.o: in function `mpi_gcrypt_to_block':
/home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:79: undefined reference to `gcry_mpi_print'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:81: undefined reference to `gcry_strerror'
/usr/bin/ld: libcommon.fa.p/hw_misc_esp32_rsa.c.o: in function `mpi_block_to_gcrypt':
/home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:59: undefined reference to `gcry_mpi_scan'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:61: undefined reference to `gcry_strerror'
/usr/bin/ld: libcommon.fa.p/hw_misc_esp32_rsa.c.o: in function `esp32_rsa_exp_mod':
/home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:105: undefined reference to `gcry_mpi_new'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:106: undefined reference to `gcry_mpi_powm'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:110: undefined reference to `gcry_mpi_release'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:111: undefined reference to `gcry_mpi_release'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:112: undefined reference to `gcry_mpi_release'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:113: undefined reference to `gcry_mpi_release'
/usr/bin/ld: libcommon.fa.p/hw_misc_esp32_rsa.c.o: in function `esp32_rsa_mod_mul_op':
/home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:186: undefined reference to `gcry_mpi_new'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:187: undefined reference to `gcry_mpi_set_bit'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:188: undefined reference to `gcry_mpi_invm'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:204: undefined reference to `gcry_mpi_new'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:205: undefined reference to `gcry_mpi_new'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:208: undefined reference to `gcry_mpi_mulm'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:210: undefined reference to `gcry_mpi_mulm'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:216: undefined reference to `gcry_mpi_release'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:217: undefined reference to `gcry_mpi_release'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:218: undefined reference to `gcry_mpi_release'
/usr/bin/ld: libcommon.fa.p/hw_misc_esp32_rsa.c.o: in function `esp32_rsa_mul_op':
/home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:151: undefined reference to `gcry_mpi_new'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:152: undefined reference to `gcry_mpi_mul'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:156: undefined reference to `gcry_mpi_release'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:157: undefined reference to `gcry_mpi_release'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:158: undefined reference to `gcry_mpi_release'
/usr/bin/ld: libcommon.fa.p/hw_misc_esp32_rsa.c.o: in function `esp32_rsa_mod_mul_op':
/home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:199: undefined reference to `gcry_mpi_release'
/usr/bin/ld: /home/moefear/source/qemu/build/../hw/misc/esp32_rsa.c:184: undefined reference to `gcry_mpi_new'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
make[1]: *** [Makefile:162: run-ninja] Error 1
make[1]: Leaving directory '/home/moefear/source/qemu/build'
make: *** [GNUmakefile:11: all] Error 2

Previously during compile, it failed due to a missing header which was resolved by installing libgcrypt20-dev. But then the mentioned compile errors occured half-way through the build. They seem related to libgrypt, so I assume there is a version mismatch? If so, how to resolve? Are there precompiled binaries of qemu anywhere that support:

-machine=esp32

?

SPI master device never updates `trans_done`

trans_done is defined in spi_struct.h as following:

            uint32_t trans_done:   1;                       /*The interrupt raw bit for the completion of any operation in both the master mode and the slave mode.*/

Although it's defined under "slave" member in spi_dev_t, it is documented as an indication for both master and slave modes.

esp-idf polls trans_done on spi_device_polling_end in spi_master.c and enters an infinite loop on QEMU since the QEMU SPI master device never updates it...


Tried to open a PR (#40) with a suggested fix, but some bot closed it. 😒

MAC OSX Monterey build failed with gnutls 3.7.3

Run ../configure --target-list=xtensa-softmmu --enable-debug --enable-sanitizers --disable-strip --disable-capstone --disable-vnc with macOS Monterey.
Crypto config:

  Crypto
    TLS priority                 : "NORMAL"
    GNUTLS support               : YES 3.7.3
      GNUTLS crypto              : YES
    libgcrypt                    : NO
    nettle                       : NO
    crypto afalg                 : NO
    rng-none                     : NO
    Linux keyring                : NO

Run make vga=no -j$(nproc). Make ends with:

Undefined symbols for architecture x86_64:
  "_gcry_mpi_invm", referenced from:
      _esp32_rsa_mod_mul_op in hw_misc_esp32_rsa.c.o
  "_gcry_mpi_mul", referenced from:
      _esp32_rsa_mul_op in hw_misc_esp32_rsa.c.o
  "_gcry_mpi_mulm", referenced from:
      _esp32_rsa_mod_mul_op in hw_misc_esp32_rsa.c.o
  "_gcry_mpi_new", referenced from:
      _esp32_rsa_exp_mod in hw_misc_esp32_rsa.c.o
      _esp32_rsa_mod_mul_op in hw_misc_esp32_rsa.c.o
      _esp32_rsa_mul_op in hw_misc_esp32_rsa.c.o
  "_gcry_mpi_powm", referenced from:
      _esp32_rsa_exp_mod in hw_misc_esp32_rsa.c.o
  "_gcry_mpi_print", referenced from:
      _mpi_gcrypt_to_block in hw_misc_esp32_rsa.c.o
  "_gcry_mpi_release", referenced from:
      _esp32_rsa_exp_mod in hw_misc_esp32_rsa.c.o
      _esp32_rsa_mod_mul_op in hw_misc_esp32_rsa.c.o
      _esp32_rsa_mul_op in hw_misc_esp32_rsa.c.o
  "_gcry_mpi_scan", referenced from:
      _mpi_block_to_gcrypt in hw_misc_esp32_rsa.c.o
  "_gcry_mpi_set_bit", referenced from:
      _esp32_rsa_mod_mul_op in hw_misc_esp32_rsa.c.o
  "_gcry_strerror", referenced from:
      _mpi_block_to_gcrypt in hw_misc_esp32_rsa.c.o
      _mpi_gcrypt_to_block in hw_misc_esp32_rsa.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
make: *** [run-ninja] Error 1

Currently compiled with workaround: ../configure --target-list=xtensa-softmmu --enable-debug --enable-sanitizers --disable-strip --disable-capstone --disable-vnc --enable-gcrypt.

PID controller and MMU/MPU support

Is there any plan to add support for the PID controller and MMU/MPU unit?

Given there isn't any reference code on how to use these, being able to debug it in qemu can be really helpful...

Unable to increase the RAM size (QEMU-57)

We are getting following error message when we try to increase the ram size
==2766==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
RAM size larger than 4 MB not supported
Adding SPI flash device

~/qemu/build/qemu-system-xtensa -nographic -machine esp32 -drive file=flash_image.bin,if=mtd,format=raw -nic user,model=open_eth --m 8M

Open Ethernet emulation for esp-idf 3.2 (QEMU-50)

Many popular libraries are built on version 1.0.4 of the espressif/arduino-esp32 layer. This layer compiles against esp-idf 3.2, which does not include open ethernet. Unfortunately, this version of esp-idf does not include the open-eth component, so emulation of applications that are built on it can't do networking.

Can the open-eth component be included on the application side? This will allow applications built on esp-idf 3.2 to use the network features of the emulator.

In the newer versions of esp-idf that include open-eth, open-eth refers to some of the other components, so it is unclear if it can be cleanly separated from the esp-idf it is embedded in for use as a standalone component.

Planning to push to upstream at some point? (QEMU-47)

I ask because it looks like this repo has been relatively quiet and was looking for a sign it has long term espressif commitments in terms of support. For our use it would be super valuable to have this as a tool to use for system level pure software tests.

Error running idf.py interactively with qemu

I was attempting steps in https://github.com/espressif/qemu/wiki#using-esptoolpy-and-espefusepy-to-interact-with-qemu, but encountered error below

Serial port socket://localhost:5555
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
esptool.py failed with exit code 2

To reproduce:

  1. Build the hello world example in https://github.com/espressif/esp-idf/tree/master/examples/get-started/hello_world
  2. Create a flash image flash_image.bin with https://github.com/espressif/qemu/wiki#build-test-app
  3. Load the flash image in the qemu with command xtensa-softmmu/qemu-system-xtensa -nographic -machine esp32 -drive file=flash_image.bin,if=mtd,format=raw -global driver=esp32.gpio,property=strap_mode,value=0x0f -serial tcp::5555,server,nowait
  4. Go back to the hello world folder, and flash the image to the qemu with command idf.py -p socket://localhost:5555 flash
  5. Error encountered from the idf.py flash command as below:
Serial port socket://localhost:5555
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
esptool.py failed with exit code 2

Watchdog timer fires when trying to use SPIFFS

I'm trying to use SPIFFS under QEMU in the same manner as I'm already doing it in a program that runs successfully on a Tiny S2 board. When I run the program in QEMU, the watchdog timer fires:

...
I (10453) example: Initializing SPIFFS
E (15303) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (15303) task_wdt:  - IDLE (CPU 0)
E (15303) task_wdt: Tasks currently running:
E (15303) task_wdt: CPU 0: main
E (15303) task_wdt: CPU 1: IDLE
E (15303) task_wdt: Print CPU 0 (current core) backtrace

Backtrace:0x40184013:0x3FFB0840 0x40084D95:0x3FFB0860 0x40086A64:0x3FFCDC60 0x40085867:0x3FFCDC80 0x400867E5:0x3FFCDCA0 0x40086892:0x3FFCDCC0 0x400872B5:0x3FFCDCE0 0x4008664A:0x3FFCDD00 0x4017FB29:0x3FFCDD40 0x400E0A25:0x3FFCDD70 0x400E4965:0x3FFCDDA0 0x400E25CA:0x3FFCDDD0 0x400E1009:0x3FFCDE10 0x400E00D4:0x3FFCDE40 0x400E098F:0x3FFCDE80 0x400DB77A:0x3FFCDF50 0x400DBA0D:0x3FFCDFA0 0x401A30E7:0x3FFCE020 0x4008E591:0x3FFCE040

E (15303) task_wdt: Print CPU 1 backtrace

Backtrace:0x40087201:0x3FFB0E40 0x40084D95:0x3FFB0E60 0x4000BFED:0x3FFCF440 0x4008E849:0x3FFCF450 0x401842DF:0x3FFCF470 0x401842EB:0x3FFCF4A0 0x400DAF05:0x3FFCF4C0 0x4008CE6D:0x3FFCF4E0 0x4008E591:0x3FFCF500

By using the xtensa-esp32s3-elf-addr2line utility I was able to decode the addresses to the following stack trace:

0x40184013: task_wdt_isr at E:/Users/stm/Downloads/esp-idf/components/esp_common/src/task_wdt.c:189
0x40084d95: _xt_lowint1 at E:/Users/stm/Downloads/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1105
0x40086a64: xt_int_enable_mask at E:/Users/stm/Downloads/esp-idf/components/xtensa/include/xtensa/xtensa_api.h:170
 (inlined by) intr_cntrl_ll_enable_int_mask at E:/Users/stm/Downloads/esp-idf/components/hal/esp32/include/hal/interrupt_controller_ll.h:100
 (inlined by) interrupt_controller_hal_enable_int_mask at E:/Users/stm/Downloads/esp-idf/components/hal/include/hal/interrupt_controller_hal.h:192
 (inlined by) esp_intr_noniram_enable at E:/Users/stm/Downloads/esp-idf/components/esp_system/intr_alloc.c:815
0x40085867: spi_flash_enable_interrupts_caches_and_other_cpu at E:/Users/stm/Downloads/esp-idf/components/spi_flash/cache_utils.c:204
0x400867e5: cache_enable at E:/Users/stm/Downloads/esp-idf/components/spi_flash/spi_flash_os_func_app.c:63
0x40086892: spi1_end at E:/Users/stm/Downloads/esp-idf/components/spi_flash/spi_flash_os_func_app.c:111
0x400872b5: spiflash_end_default at E:/Users/stm/Downloads/esp-idf/components/spi_flash/esp_flash_api.c:125
0x4008664a: esp_flash_read at E:/Users/stm/Downloads/esp-idf/components/spi_flash/esp_flash_api.c:681
0x4017fb29: esp_partition_read at E:/Users/stm/Downloads/esp-idf/components/spi_flash/partition.c:419
0x400e0a25: spiffs_api_read at E:/Users/stm/Downloads/esp-idf/components/spiffs/spiffs_api.c:36
0x400e4965: spiffs_phys_rd at E:/Users/stm/Downloads/esp-idf/components/spiffs/spiffs/src/spiffs_cache.c:146
0x400e25ca: spiffs_obj_lu_scan at E:/Users/stm/Downloads/esp-idf/components/spiffs/spiffs/src/spiffs_nucleus.c:366 (discriminator 4)
0x400e1009: SPIFFS_mount at E:/Users/stm/Downloads/esp-idf/components/spiffs/spiffs/src/spiffs_hydrogen.c:134
0x400e00d4: esp_spiffs_init at E:/Users/stm/Downloads/esp-idf/components/spiffs/esp_spiffs.c:246
0x400e098f: esp_vfs_spiffs_register at E:/Users/stm/Downloads/esp-idf/components/spiffs/esp_spiffs.c:379
0x400db77a: app_init_spiffs at E:\Users\stm\Documents\GIT\esp32-pdflib\esp-qemu-sdcard\build/../main/sd_card_example_main.c:133
0x400dba0d: app_main at E:\Users\stm\Documents\GIT\esp32-pdflib\esp-qemu-sdcard\build/../main/sd_card_example_main.c:242 (discriminator 13)
0x401a30e7: main_task at E:/Users/stm/Downloads/esp-idf/components/freertos/port/port_common.c:133 (discriminator 2)
0x4008e591: vPortTaskWrapper at E:/Users/stm/Downloads/esp-idf/components/freertos/port/xtensa/port.c:168

Should SPIFFS work under QEMU? Are additional command line options for QEMU necessary?

I'm using ESP-IDF v4.3.2.

Control UART from QEMU

Dear sir,

When I try to get the output of the UART's of the ESP32, i can only get the results from the first one.

Example using TCP Server:

qemu/xtensa-softmmu/qemu-system-xtensa -nographic -s -S -machine esp32 -drive file=final.bin,if=mtd,format=raw -nic user,model=open_eth -serial tcp::8880,server,nowait -serial tcp::8881,server,nowait

Example using files:

qemu/xtensa-softmmu/qemu-system-xtensa -nographic -s -S -machine esp32 -drive file=final.bin,if=mtd,format=raw -nic user,model=open_eth -serial file:/tmp/uart0.txt -serial file:/tmp/uart1.txt

Did we have to implement somthing in esp32.c ?

Floating point exception (core dumped)

I test the "uart_echo" example. But failed. It show "Floating point exception (core dumped)"

CMD LOG:

$cd peripherals/uart/uart_echo
$idf.py build
$cd build
$esptool.py --chip esp32 merge_bin --fill-flash-size 4MB -o flash_image.bin 0x8000 partition_table/partition-table.bin 0x1000 bootloader/bootloader.bin 0x10000 uart_echo.bin
$~/other/espressif_qemu/qemu/bin/qemu-system-xtensa -nographic -M esp32 -drive file=flash_image.bin,if=mtd,format=raw

QEMU OUTPUT:

Adding SPI flash device
ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:7064
load:0x40078000,len:14308
load:0x40080400,len:3716
entry 0x40080680
I (888) boot: ESP-IDF v4.3.1 2nd stage bootloader
I (894) boot: compile time 15:19:40
I (904) boot: chip revision: 0
I (912) boot.esp32: SPI Speed : 40MHz
I (912) boot.esp32: SPI Mode : DIO
I (913) boot.esp32: SPI Flash Size : 2MB
I (924) boot: Enabling RNG early entropy source...
I (941) boot: Partition Table:
I (941) boot: ## Label Usage Type ST Offset Length
I (942) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (945) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (946) boot: 2 factory factory app 00 00 00010000 00100000
I (950) boot: End of partition table
I (960) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=08764h ( 34660) map
I (1016) esp_image: segment 1: paddr=0001878c vaddr=3ffb0000 size=0290ch ( 10508) load
I (1046) esp_image: segment 2: paddr=0001b0a0 vaddr=40080000 size=04f78h ( 20344) load
I (1065) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=165c4h ( 91588) map
I (1226) esp_image: segment 4: paddr=000365ec vaddr=40084f78 size=06a88h ( 27272) load
I (1271) esp_image: segment 5: paddr=0003d07c vaddr=50000000 size=00010h ( 16) load
I (1297) boot: Loaded app from partition at offset 0x10000
I (1299) boot: Disabling RNG early entropy source...
I (1313) cpu_start: Pro cpu up.
I (1314) cpu_start: Starting app cpu, entry point is 0x400810e0
I (5429) cpu_start: App cpu up.
I (2247) cpu_start: Pro cpu start user code
I (2248) cpu_start: cpu freq: 160000000
I (2248) cpu_start: Application information:
I (2249) cpu_start: Project name: uart_echo
I (2249) cpu_start: App version: v4.3.1
I (2250) cpu_start: Compile time: Dec 9 2021 15:19:35
I (2251) cpu_start: ELF file SHA256: 29985d43c52312e9...
I (2252) cpu_start: ESP-IDF: v4.3.1
I (2259) heap_init: Initializing. RAM available for dynamic allocation:
I (2263) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (2265) heap_init: At 3FFB31D0 len 0002CE30 (179 KiB): DRAM
I (2266) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (2267) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (2269) heap_init: At 4008BA00 len 00014600 (81 KiB): IRAM
I (2350) spi_flash: detected chip: gd
I (2375) spi_flash: flash io: dio
W (2395) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (2427) cpu_start: Starting scheduler on PRO CPU.
I (10) cpu_start: Starting scheduler on APP CPU.
Floating point exception (core dumped)

QEMU hangs for ESP32-S2 application

I built the Espressif QEMU from the most recent commit commit according to the instructions in the Wiki:

https://github.com/espressif/qemu/wiki#configure

After that I built a flash_image.bin file for an ESP32-S2 app according to the corresponding instructions from this page, and tried to start QEMU with it under Windows 10 WSL2 Debian Linux:

$ build/qemu-system-xtensa -machine esp32 -drive file=flash_image.bin,if=mtd,format=raw
==19816==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
Adding SPI flash device

After that nothing happens anymore, QEMU apparently hangs.

Should QEMU work for an ESP32-S2 application? Or do I have to rebuild the application specifically for ESP32?

ESP8266 support (QEMU-53)

Could you add support for esp8266? Thanks!

This fork of QEMU 2.x provide (some kind of) esp8266 emulator, but I tried it and it didn't work with the serial Hello World test (missing peripherals or something?).

SPI/I2C exposed (QEMU-157)

Hi,

i am trying to understand how to stimulate the Simulated Peripherals.
I do understand how to communicate via Sockets to the UART Peripheral.
Is there any way to use Sockets to communicate to SPI and/or I2C?

Running examples/protocols/http_server/simple with wiki defaults does not respond to requests

Hi all.
I am thankful that with 86ba82e I was able to run the hello-world example, however I'm still not able to make use of the ethernet examples, even though I'm following the wiki

Here is my qemu output:
output.txt

My sdkconfig:
sdkconfig.txt

My commands:
idf.py menuconfig (manually edited latter, removed WiFi, which also threw a panic)
idf.py build
./makeflash-img.sh simple simple.bin
/opt/esp-idf/qemu/xtensa-softmmu/qemu-system-xtensa -nographic -machine esp32 -drive file=simple.bin,if=mtd,format=raw -nic user,model=open_eth

live_capture

How to redirect stdio to a socket to get programmatic control via the console? (QEMU-46)

I'm trying to get access to stdout via a serial port device so I can programmatically interact with the system, get system test results etc. Maybe this isn't the correct approach but I found online how to map devices:

~/projects/qemu/build/qemu-system-xtensa -nographic -machine esp32 -m 2M \
-serial stdio \
-drive 'file=build/flash_image.bin,if=mtd,format=raw'

but this results in:

QEMU 6.2.0 monitor - type 'help' for more information
(qemu) qemu-system-xtensa: -serial stdio: cannot use stdio by multiple character devices
qemu-system-xtensa: -serial stdio: could not connect serial device to character backend 'stdio'

Missing RMT Peripheral (QEMU-61)

RMT's memory is not allocated in the machine so it panics when trying to initialize.

Just adding it as an unimplemented device (esp32_soc_add_unimp_device(sys_mem, "esp32.rmt", DR_REG_RMT_BASE, 0x1000);) seems to satisfy it. I can submit a PR for it (just a one line change).

LoadStorePIFAddrError

Hi

I am using qemu to emulate and debug my esp32 software but I have a problem: When I call the function "ledc_timer_config()", the execution run into an exception "LoadStorePIFAddrError"

Example:

        ledc_timer_config_t ledc_timer =
        {
            .duty_resolution = LEDC_TIMER_10_BIT,
            .freq_hz = 5000,
            .speed_mode = LEDC_LOW_SPEED_MODE,
            .timer_num = LEDC_TIMER_0
        };
        ledc_timer_config(&ledc_timer);

Output:

Guru Meditation Error: Core  0 panic'ed (LoadStorePIFAddrError). Exception was unhandled.
Core 0 register dump:
PC      : 0x401e4470  PS      : 0x00060833  A0      : 0x80150fb2  A1      : 0x3ffbb500
A2      : 0x3ffda2e8  A3      : 0xfffffffd  A4      : 0x00000fa0  A5      : 0x00000000
A6      : 0x00000002  A7      : 0x00000000  A8      : 0x00000001  A9      : 0x3ff59000
A10     : 0xfffffffe  A11     : 0x00060820  A12     : 0x00000000  A13     : 0x00000001
A14     : 0x0000cdcd  A15     : 0xfffffffe  SAR     : 0x0000000b  EXCCAUSE: 0x0000000f
EXCVADDR: 0x3ff59190  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0xffffffff

ELF file SHA256: cc9b36e22e3549cf

Backtrace: 0x401e446d:0x3ffbb500 0x40150faf:0x3ffbb520 0x40151173:0x3ffbb550 0x40103034:0x3ffbb590 0x400f7360:0x3ffbb5e0 0x400f7237:0x3ffbb650 0x400d7ab7:0x3ffbb670 0x400d406b:0x3ffbb6c0

CPU halted.

Callstack:

error

Questions:

Did you know what is the problem ? Something not implemented in qemu ?

Thanks for help

ESP32-S3 support (QEMU-52)

I'd like to request support for esp32-s3 emulation. I think it's a killer chip and support for it in QEMU would be amazing.

timer ISR is getting not trigged, SPIFFS not working, Wifi?

I am trying to start with qemu on an existing project which has already its size. Currently I commented a lot of stuff out to test step by step. I am using the ESP32 Arduino core with PlatformIO (if I have to change some settings, please let me know!).

Currently I am facing different issues:

  1. I am programming a timer which should trigger every second, this is not happening. I am using this code:
void IRAM_ATTR onTimer()
{
	portENTER_CRITICAL_ISR(&timerMux);
	timerTick = true;
	portEXIT_CRITICAL_ISR(&timerMux);
}

void setup_timer()
{
	timer = timerBegin(0, 80, true);
	timerAlarmWrite(timer, 1000000, true);
	timerAttachInterrupt(timer, &onTimer, true);
	timerAlarmEnable(timer);
}

As i was writing: on the HW it is working, any Ideas how to debug this?

  1. SPIFFS not working

I am using this code:
if(!SPIFFS.begin(true)) {

And getting this error message:

E (6389) SPIFFS: mount failed, -10025
E (80510) SPIFFS: mount failed, -10025

So it is trying to format something, but it is not working out.

  1. To have something similar than Wifi I think i have to use the Ethernet approach. Is this correct?

FPU support

Hello,

it was a challenge, but I got qemu working in my CI system based on github actions. It is super interesting how all this can be brought together! Thanks for sharing.

But I ran into a problem: running my tests I noticed exeptions if it tried to do floating point arithmetic. As I enabled qemu unimp-logs, I saw: unimplemented opcode 'lsi' in slot 0 or unimplemented opcode 'wfr' in slot 0. It seems the fpu isn't implemented.

For now, I use a custom type that is normally float but in CI build gets typedef'd to double. So it won't use the fpu.

Is my assumption, that the fpu is not simulated, true? Or do I miss something?

Greetings, Nik

MAC OSX Monterey build warnings

Run build with macOS Monterey. Observe next warnings:

../block/file-posix.c:3335:18: warning: 'IOMasterPort' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
    kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
                 ^~~~~~~~~~~~
                 IOMainPort
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:132:1: note: 'IOMasterPort' has been explicitly marked deprecated here
IOMasterPort( mach_port_t       bootstrapPort,
^
1 warning generated.
...
../audio/coreaudio.c:50:5: warning: 'kAudioObjectPropertyElementMaster' is deprecated: first deprecated in macOS 12.0 [-Wdep
recated-declarations]
    kAudioObjectPropertyElementMaster
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    kAudioObjectPropertyElementMain
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5: note: 'kAudioObjectPropertyElementMaster' has been explicitly marked deprecated here
    kAudioObjectPropertyElementMaster API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain", macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0, 15.0)) = kAudioObjectPropertyElementMain
    ^
../audio/coreaudio.c:72:9: warning: 'kAudioObjectPropertyElementMaster' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
        kAudioObjectPropertyElementMaster
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        kAudioObjectPropertyElementMain
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.h:208:5: note: 'kAudioObjectPropertyElementMaster' has been explicitly marked deprecated here
    kAudioObjectPropertyElementMaster API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain", macos(10.0, 12.0), ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0, 15.0)) = kAudioObjectPropertyElementMain
    ^
../audio/coreaudio.c:89:9: warning: 'kAudioObjectPropertyElementMaster' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
        kAudioObjectPropertyElementMaster
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        kAudioObjectPropertyElementMain
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.
h:208:5: note: 'kAudioObjectPropertyElementMaster' has been explicitly marked deprecated here
    kAudioObjectPropertyElementMaster API_DEPRECATED_WITH_REPLACEMENT("kAudioObjectPropertyElementMain", macos(10.0, 12.0),
ios(2.0, 15.0), watchos(1.0, 8.0), tvos(9.0, 15.0)) = kAudioObjectPropertyElementMain
    ^
6 warnings generated.
...
../ui/cocoa.m:1411:16: warning: 'setAllowedFileTypes:' is deprecated: first deprecated in macOS 12.0 - Use -allowedContentTy
pes instead [-Wdeprecated-declarations]
    [openPanel setAllowedFileTypes: supportedImageFileTypes];
               ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49:
 note: property 'allowedFileTypes' is declared deprecated here
@property (nullable, copy) NSArray<NSString *> *allowedFileTypes API_DEPRECATED("Use -allowedContentTypes instead", macos(10
.3,12.0));
                                                ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49:
 note: 'setAllowedFileTypes:' has been explicitly marked deprecated here
1 warning generated.

Incorrect option syntax for PSRAM in Wiki page

I did not find a way to create a pull request for the Wiki page, therefore I'm creating an issue.

See here: https://github.com/espressif/qemu/wiki#adding-psram

You can add 2MB or 4MB PSRAM using -m 2MB or -m 4MB command line options, respectively.

When I try to use this syntax it is rejected with the following error message:

qemu-system-xtensa: -m 2MB: Parameter 'size' expects a non-negative number below 2^64
Optional suffix k, M, G, T, P or E means kilo-, mega-, giga-, tera-, peta-
and exabytes, respectively.

Thefore the correct syntax is -m 2M or -m 4M.

emulated system seems to boot, but then it just hangs (QEMU-48)

Since I can't get my own project running on qemu, I compiled one of the esp-idf examples, the hello_world, but I'm experiencing the very same issue.

Running qemu-system-xtensa -nographic -M esp32 -m 4 -drive file=build/merged_qemu.bin,if=mtd,format=raw the system seems to boot as expected but the it simply hangs after listing GPIOs. The code should start printing out messages like Restarting in %d seconds... and eventually reboot the esp32. Any ideas?

I'm using a freshly installed esp-idf version 4.4.1 and the latest available release of this project qemu-esp-develop-20220203.

Adding SPI flash device
ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DOUT, clock div:2
load:0x3fff0030,len:6612
load:0x40078000,len:14788
load:0x40080400,len:3792
entry 0x40080694
I (1008) boot: ESP-IDF v4.4.1-dirty 2nd stage bootloader
I (1018) boot: compile time 01:18:56
I (1034) boot: chip revision: 0
I (1044) boot.esp32: SPI Speed      : 40MHz
I (1046) boot.esp32: SPI Mode       : DOUT
I (1047) boot.esp32: SPI Flash Size : 4MB
I (1066) boot: Enabling RNG early entropy source...
I (1091) boot: Partition Table:
I (1092) boot: ## Label            Usage          Type ST Offset   Length
I (1095) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (1099) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (1102) boot:  2 factory          factory app      00 00 00010000 00100000
I (1118) boot: End of partition table
I (1134) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1e404h (123908) map
I (1358) esp_image: segment 1: paddr=0002e42c vaddr=3ffb0000 size=01bech (  7148) load
I (1406) esp_image: segment 2: paddr=00030020 vaddr=400d0020 size=9954ch (628044) map
I (2252) esp_image: segment 3: paddr=000c9574 vaddr=3ffb1bec size=01fc0h (  8128) load
I (2293) esp_image: segment 4: paddr=000cb53c vaddr=40080000 size=15df8h ( 89592) load
I (2449) esp_image: segment 5: paddr=000e133c vaddr=50000000 size=00010h (    16) load
I (2498) boot: Loaded app from partition at offset 0x10000
I (2501) boot: Disabling RNG early entropy source...
I (2533) cpu_start: Pro cpu up.
I (2547) cpu_start: Starting app cpu, entry point is 0x400812bc
I (2069) cpu_start: App cpu up.
I (4726) cpu_start: Pro cpu start user code
I (4734) cpu_start: cpu freq: 160000000
I (4736) cpu_start: Application information:
I (4737) cpu_start: Project name:     hello_world
I (4738) cpu_start: App version:      7084a1b-dirty
I (4739) cpu_start: Compile time:     Jul 15 2022 00:45:22
I (4741) cpu_start: ELF file SHA256:  e669cc31183c9273...
I (4743) cpu_start: ESP-IDF:          v4.4.1-dirty
I (4754) heap_init: Initializing. RAM available for dynamic allocation:
I (4760) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (4763) heap_init: At 3FFC0340 len 0001FCC0 (127 KiB): DRAM
I (4764) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (4765) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (4766) heap_init: At 40095DF8 len 0000A208 (40 KiB): IRAM
I (4908) spi_flash: detected chip: gd
I (4962) spi_flash: flash io: dio
I (5057) cpu_start: Starting scheduler on PRO CPU.
I (20) cpu_start: Starting scheduler on APP CPU.
This is esp32 chip with 2 CPU core(s), WiFi/BT/BLE, silicon revision 0, 4MB external flash
Minimum free heap size: 236436 bytes
I (8631) gpio: GPIO[18]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (8641) gpio: GPIO[19]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (8651) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (8651) gpio: GPIO[23]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (8651) gpio: GPIO[18]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (8651) gpio: GPIO[19]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (8661) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (8661) gpio: GPIO[23]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 

Problem running HTTP_Server example

Hi I am trying to use the HttpServer example, but I am not able to get it to work. I am following all the steps mentioned in the wiki. But when qemu tries to initialize the CPU APP scheduler, it shows an error message and reboots. This is the error it shows me. This is the error it shows me.

imagen

I am using ESP-IDF V4.3-Dirty
The steps I am following are as follows.

  1. idf.py set-target esp32

  2. idf.py menuconfig
    (I disable the WIFI option and enable the ethernet option. Also, I enable the Openeth and flash mode options as DOUT)

  3. idf.py build

  4. I run the script
    ./makeflash-img.sh simple simple.bin

  5. Then I run qeumu as follows:
    / opt / esp-idf / qemu / xtensa-softmmu / qemu-system-xtensa -nographic -machine esp32 -drive file = simple.bin, if = mtd, format = raw -ni cuser, model = open_eth, hostfwd = tcp: : 8082-: 80

So I wanted to ask if I am doing something wrong?

From already thank you very much

Failed to reboot on esp_restart after successful OTA (QEMU-85)

It seems the latest version of espressif qemu esp-develop-20220919 fails to reboot on calling esp_restart after a successful OTA with esp idf v4.4.3

FYI https://github.com/espressif/qemu/releases/tag/esp-develop-20220802 works with both v4.4.2 and v4.4.3 - i.e. after a successful OTA calling esp_restart restarts the firmware

A workaround that seems to work is to call qemu with -no-reboot when launched and manually start qemu when we expected it to shut down after an esp_restart

Using ESP32 v3 eco mode.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.