-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I use the binary compiled by Arduino IDE instead of ESP-IDF? (QEMU-51) #30
Comments
I think the binary exported by Arduino IDE only includes the application. You probably need to combine it with the bootloader and partition table binaries at correct offsets. The resulting file should be exactly 4 megabytes. Please check the wiki page for an example script which does this using dd commands. |
Can you provide me the link? |
Hello, Why the wiki I saw (by clicking to OK let's come to the main problem: After follow the instructions in the wiki, QEMU does not print out
and then nothing else print out! Here are my steps:
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello World");
}
void loop() {
// put your main code here, to run repeatedly:
} Board configure in Arduino IDE: Then I built it by using Build log:
user@machine:/mnt/c/Users/USER/AppData/Local/Temp/arduino_build_60522$ dd if=/dev/zero bs=1024 count=4096 of=esp32.qemu.bin
4096+0 records in
4096+0 records out
4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.145199 s, 28.9 MB/s
user@machine:/mnt/c/Users/USER/AppData/Local/Temp/arduino_build_60522$ dd if=bootloader_dout_40m.bin bs=1 seek=$((0x1000)) of=esp32.qemu.bin conv=notrunc
17088+0 records in
17088+0 records out
17088 bytes (17 kB, 17 KiB) copied, 0.583094 s, 29.3 kB/s
user@machine:/mnt/c/Users/USER/AppData/Local/Temp/arduino_build_60522$ dd if=esp32test.ino.partitions.bin bs=1 seek=$((0x8000)) of=esp32.qemu.bin conv=notrunc
3072+0 records in
3072+0 records out
3072 bytes (3.1 kB, 3.0 KiB) copied, 0.117866 s, 26.1 kB/s
user@machine:/mnt/c/Users/USER/AppData/Local/Temp/arduino_build_60522$ dd if=esp32test.ino.bin bs=1 seek=$((0x10000)) of=esp32.qemu.bin conv=notrunc
204576+0 records in
204576+0 records out
204576 bytes (205 kB, 200 KiB) copied, 8.40457 s, 24.3 kB/s The file
qemu-system-xtensa -nographic -machine esp32 -drive file=esp32.qemu.bin,if=mtd,format=raw And the result:
P/S: Nothing else output, but QEMU eats nearly all my CPU (Is it not work or too slow?) What am I doing wrong here? Thanks in advance! |
The latest version of the wiki was updated to use esptool.py for generation of flash binary image. This is easier than using It looks like you are using 1.0.6 version of arduino-esp32 core to test this. I suspect that something in the way that version of the core works with UART interface is not compatible with QEMU. It seems that arduino-esp32 version 2.0.x fixes this issue. |
Ok I will try to clone the latest source in arduino-esp32 repo and try again. Thanks for the information and I will post a comment here when I have something new. |
Okay I switched to Ubuntu (not WSL anymore) and install latest After using Or you can find it on Github Gist here In the directory
I modified the script
Run it with QEMU:
It stuck in a forever loop until I press CTRL+A and then X to quit QEMU. Is the part
interesting for you? |
After setting the option
|
@raspiduino thanks for trying this out, sorry it didn't work as expected! Seems like you are using version 2.0.2 which still has the issue reported in #26. It is fixed in arduino-esp32 master branch (installable via git) but is not in any release yet. |
I tried the latest source from git repo, but it still:
|
Include the qtest reproducer provided by Alexander Bulekov in https://gitlab.com/qemu-project/qemu/-/issues/542. Without the previous commit, we get: $ make check-qtest-i386 ... Running test tests/qtest/intel-hda-test AddressSanitizer:DEADLYSIGNAL ================================================================= ==1580408==ERROR: AddressSanitizer: stack-overflow on address 0x7ffc3d566fe0 #0 0x63d297cf in address_space_translate_internal softmmu/physmem.c:356 #1 0x63d27260 in flatview_do_translate softmmu/physmem.c:499:15 #2 0x63d27af5 in flatview_translate softmmu/physmem.c:565:15 #3 0x63d4ce84 in flatview_write softmmu/physmem.c:2850:10 #4 0x63d4cb18 in address_space_write softmmu/physmem.c:2950:18 #5 0x63d4d387 in address_space_rw softmmu/physmem.c:2960:16 #6 0x62ae12f2 in dma_memory_rw_relaxed include/sysemu/dma.h:89:12 #7 0x62ae104a in dma_memory_rw include/sysemu/dma.h:132:12 #8 0x62ae6157 in dma_memory_write include/sysemu/dma.h:173:12 #9 0x62ae5ec0 in stl_le_dma include/sysemu/dma.h:275:1 #10 0x62ae5ba2 in stl_le_pci_dma include/hw/pci/pci.h:871:1 #11 0x62ad59a6 in intel_hda_response hw/audio/intel-hda.c:372:12 #12 0x62ad2afb in hda_codec_response hw/audio/intel-hda.c:107:5 #13 0x62aec4e1 in hda_audio_command hw/audio/hda-codec.c:655:5 #14 0x62ae05d9 in intel_hda_send_command hw/audio/intel-hda.c:307:5 #15 0x62adff54 in intel_hda_corb_run hw/audio/intel-hda.c:342:9 #16 0x62adc13b in intel_hda_set_corb_wp hw/audio/intel-hda.c:548:5 #17 0x62ae5942 in intel_hda_reg_write hw/audio/intel-hda.c:977:9 #18 0x62ada10a in intel_hda_mmio_write hw/audio/intel-hda.c:1054:5 #19 0x63d8f383 in memory_region_write_accessor softmmu/memory.c:492:5 #20 0x63d8ecc1 in access_with_adjusted_size softmmu/memory.c:554:18 #21 0x63d8d5d6 in memory_region_dispatch_write softmmu/memory.c:1504:16 #22 0x63d5e85e in flatview_write_continue softmmu/physmem.c:2812:23 #23 0x63d4d05b in flatview_write softmmu/physmem.c:2854:12 #24 0x63d4cb18 in address_space_write softmmu/physmem.c:2950:18 #25 0x63d4d387 in address_space_rw softmmu/physmem.c:2960:16 #26 0x62ae12f2 in dma_memory_rw_relaxed include/sysemu/dma.h:89:12 #27 0x62ae104a in dma_memory_rw include/sysemu/dma.h:132:12 #28 0x62ae6157 in dma_memory_write include/sysemu/dma.h:173:12 #29 0x62ae5ec0 in stl_le_dma include/sysemu/dma.h:275:1 #30 0x62ae5ba2 in stl_le_pci_dma include/hw/pci/pci.h:871:1 #31 0x62ad59a6 in intel_hda_response hw/audio/intel-hda.c:372:12 #32 0x62ad2afb in hda_codec_response hw/audio/intel-hda.c:107:5 #33 0x62aec4e1 in hda_audio_command hw/audio/hda-codec.c:655:5 #34 0x62ae05d9 in intel_hda_send_command hw/audio/intel-hda.c:307:5 #35 0x62adff54 in intel_hda_corb_run hw/audio/intel-hda.c:342:9 #36 0x62adc13b in intel_hda_set_corb_wp hw/audio/intel-hda.c:548:5 #37 0x62ae5942 in intel_hda_reg_write hw/audio/intel-hda.c:977:9 #38 0x62ada10a in intel_hda_mmio_write hw/audio/intel-hda.c:1054:5 #39 0x63d8f383 in memory_region_write_accessor softmmu/memory.c:492:5 #40 0x63d8ecc1 in access_with_adjusted_size softmmu/memory.c:554:18 #41 0x63d8d5d6 in memory_region_dispatch_write softmmu/memory.c:1504:16 #42 0x63d5e85e in flatview_write_continue softmmu/physmem.c:2812:23 #43 0x63d4d05b in flatview_write softmmu/physmem.c:2854:12 #44 0x63d4cb18 in address_space_write softmmu/physmem.c:2950:18 #45 0x63d4d387 in address_space_rw softmmu/physmem.c:2960:16 #46 0x62ae12f2 in dma_memory_rw_relaxed include/sysemu/dma.h:89:12 qemu#47 0x62ae104a in dma_memory_rw include/sysemu/dma.h:132:12 #48 0x62ae6157 in dma_memory_write include/sysemu/dma.h:173:12 ... SUMMARY: AddressSanitizer: stack-overflow softmmu/physmem.c:356 in address_space_translate_internal ==1580408==ABORTING Broken pipe Aborted (core dumped) Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Acked-by: Thomas Huth <[email protected]> Message-Id: <[email protected]> Signed-off-by: Thomas Huth <[email protected]>
I have verified that QEMU can be used to emulate binaries produced with Arduino IDE, using arduino-esp32 core v2.0.4.
The final line is important, we have to disable the Timer Group watchdog emulation, otherwise it will trigger during the boot process. This is because the boot process for an Arduino sketch is notably slower in QEMU than on a real chip. Note that there is also some delay between |
Thanks! I will try this as soon as I can. |
Hi! I made a github action out of this: https://github.com/tobozo/esp32-qemu-sim I'm still struggling with psram though, apparently you can can't set |
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 outputThanks in advance!
The text was updated successfully, but these errors were encountered: