How do you run an IDF example app in QEMU?
Posted: Wed May 20, 2020 11:02 am
I'm trying to compile and run the IDF `hello-world` binary and run it with QEMU; however, the QEMU process exits with non-zero status code after reaching "start user code". Any ideas how I can get QEMU working? I'm currently doing the following:
create custom sdkconfig:
compile hello-world example:
create flash image:
run flash image in qemu (using qemu-esp-develop-20191228.tar.bz2):
create custom sdkconfig:
- $ echo CONFIG_ESPTOOLPY_FLASHMODE_DOUT=y > sdkconfig
- $ docker run --rm -it \
- -v ${PWD}/build:/opt/esp/idf/examples/get-started/hello-world/build \
- -v ${PWD}/sdkconfig:/opt/esp/idf/examples/get-started/hello-world/sdkconfig \
- -w /opt/esp/idf/examples/get-started/hello-world \
- espressif/idf:release-v4.2 \
- idf.py -G 'Unix Makefiles' build
- $ dd if=/dev/zero bs=1024 count=4096 of=flash.bin
- $ dd if=build/bootloader/bootloader.bin bs=1 seek=$((0x1000)) of=flash.bin conv=notrunc
- $ dd if=build/partition_table/partition-table.bin bs=1 seek=$((0x8000)) of=flash.bin conv=notrunc
- $ dd if=build/hello-world.bin bs=1 seek=$((0x10000)) of=flash.bin conv=notrunc
- # 4096+0 records in
- # 4096+0 records out
- # 4194304 bytes (4.2 MB, 4.0 MiB) copied, 2.15955 s, 1.9 MB/s
- # 24816+0 records in
- # 24816+0 records out
- # 24816 bytes (25 kB, 24 KiB) copied, 10.2328 s, 2.4 kB/s
- # 3072+0 records in
- # 3072+0 records out
- # 3072 bytes (3.1 kB, 3.0 KiB) copied, 1.19551 s, 2.6 kB/s
- # 149216+0 records in
- # 149216+0 records out
- # 149216 bytes (149 kB, 146 KiB) copied, 55.8534 s, 2.7 kB/s
- $ qemu-system-xtensa -nographic -machine esp32 -drive 'file=flash.bin,if=mtd,format=raw'
- # Adding SPI flash device
- # ets Jun 8 2016 00:22:57
- # 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:4
- # load:0x3fff0034,len:7012
- # load:0x40078000,len:13696
- # load:0x40080400,len:4000
- # entry 0x40080688
- # I (334) boot: ESP-IDF v4.2-dev-1303-gcd4fa46f5 2nd stage bootloader
- # I (348) boot: compile time 10:47:17
- # I (362) boot: chip revision: 0
- # I (375) boot.esp32: SPI Speed : 40MHz
- # I (379) boot.esp32: SPI Mode : DOUT
- # I (381) boot.esp32: SPI Flash Size : 2MB
- # I (401) boot: Enabling RNG early entropy source...
- # I (421) boot: Partition Table:
- # I (424) boot: ## Label Usage Type ST Offset Length
- # I (433) boot: 0 nvs WiFi data 01 02 00009000 00006000
- # I (440) boot: 1 phy_init RF data 01 01 0000f000 00001000
- # I (442) boot: 2 factory factory app 00 00 00010000 00100000
- # I (457) boot: End of partition table
- # I (470) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x057c8 ( 22472) map
- # I (535) esp_image: segment 1: paddr=0x000157f0 vaddr=0x3ffb0000 size=0x021a8 ( 8616) load
- # I (573) esp_image: segment 2: paddr=0x000179a0 vaddr=0x40080000 size=0x00404 ( 1028) load
- # I (604) esp_image: segment 3: paddr=0x00017dac vaddr=0x40080404 size=0x0826c ( 33388) load
- # I (697) esp_image: segment 4: paddr=0x00020020 vaddr=0x400d0020 size=0x12fac ( 77740) map
- # I (863) esp_image: segment 5: paddr=0x00032fd4 vaddr=0x40088670 size=0x016e4 ( 5860) load
- # I (945) boot: Loaded app from partition at offset 0x10000
- # I (948) boot: Disabling RNG early entropy source...
- # I (974) cpu_start: Pro cpu up.
- # I (975) cpu_start: Application information:
- # I (976) cpu_start: Project name: hello-world
- # I (977) cpu_start: App version: v4.2-dev-1303-gcd4fa46f5
- # I (979) cpu_start: Compile time: May 20 2020 10:49:37
- # I (983) cpu_start: ELF file SHA256: 60a10154ecbceb86...
- # I (983) cpu_start: ESP-IDF: v4.2-dev-1303-gcd4fa46f5
- # I (985) cpu_start: Starting app cpu, entry point is 0x40081270
- # I (5161) cpu_start: App cpu up.
- # I (6358) heap_init: Initializing. RAM available for dynamic allocation:
- # I (6387) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
- # I (6400) heap_init: At 3FFB29E8 len 0002D618 (181 KiB): DRAM
- # I (6409) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
- # I (6416) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
- # I (6426) heap_init: At 40089D54 len 000162AC (88 KiB): IRAM
- # I (6496) cpu_start: Pro cpu start user code