How do you run an IDF example app in QEMU?

inkychris
Posts: 1
Joined: Wed May 20, 2020 10:29 am

How do you run an IDF example app in QEMU?

Postby inkychris » 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:
  1. $ echo CONFIG_ESPTOOLPY_FLASHMODE_DOUT=y > sdkconfig
compile hello-world example:
  1. $ docker run --rm -it \
  2.    -v ${PWD}/build:/opt/esp/idf/examples/get-started/hello-world/build \
  3.    -v ${PWD}/sdkconfig:/opt/esp/idf/examples/get-started/hello-world/sdkconfig \
  4.    -w /opt/esp/idf/examples/get-started/hello-world \
  5.    espressif/idf:release-v4.2 \
  6.    idf.py -G 'Unix Makefiles' build
create flash image:
  1. $ dd if=/dev/zero bs=1024 count=4096 of=flash.bin
  2. $ dd if=build/bootloader/bootloader.bin bs=1 seek=$((0x1000)) of=flash.bin conv=notrunc
  3. $ dd if=build/partition_table/partition-table.bin bs=1 seek=$((0x8000)) of=flash.bin conv=notrunc
  4. $ dd if=build/hello-world.bin bs=1 seek=$((0x10000)) of=flash.bin conv=notrunc
  5. # 4096+0 records in
  6. # 4096+0 records out
  7. # 4194304 bytes (4.2 MB, 4.0 MiB) copied, 2.15955 s, 1.9 MB/s
  8. # 24816+0 records in
  9. # 24816+0 records out
  10. # 24816 bytes (25 kB, 24 KiB) copied, 10.2328 s, 2.4 kB/s
  11. # 3072+0 records in
  12. # 3072+0 records out
  13. # 3072 bytes (3.1 kB, 3.0 KiB) copied, 1.19551 s, 2.6 kB/s
  14. # 149216+0 records in
  15. # 149216+0 records out
  16. # 149216 bytes (149 kB, 146 KiB) copied, 55.8534 s, 2.7 kB/s
run flash image in qemu (using qemu-esp-develop-20191228.tar.bz2):
  1. $ qemu-system-xtensa -nographic -machine esp32 -drive 'file=flash.bin,if=mtd,format=raw'
  2. # Adding SPI flash device
  3. # ets Jun  8 2016 00:22:57
  4. # rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
  5. # configsip: 0, SPIWP:0xee
  6. # clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  7. # mode:DOUT, clock div:2
  8. # load:0x3fff0030,len:4
  9. # load:0x3fff0034,len:7012
  10. # load:0x40078000,len:13696
  11. # load:0x40080400,len:4000
  12. # entry 0x40080688
  13. # I (334) boot: ESP-IDF v4.2-dev-1303-gcd4fa46f5 2nd stage bootloader
  14. # I (348) boot: compile time 10:47:17
  15. # I (362) boot: chip revision: 0
  16. # I (375) boot.esp32: SPI Speed      : 40MHz
  17. # I (379) boot.esp32: SPI Mode       : DOUT
  18. # I (381) boot.esp32: SPI Flash Size : 2MB
  19. # I (401) boot: Enabling RNG early entropy source...
  20. # I (421) boot: Partition Table:
  21. # I (424) boot: ## Label            Usage          Type ST Offset   Length
  22. # I (433) boot:  0 nvs              WiFi data        01 02 00009000 00006000
  23. # I (440) boot:  1 phy_init         RF data          01 01 0000f000 00001000
  24. # I (442) boot:  2 factory          factory app      00 00 00010000 00100000
  25. # I (457) boot: End of partition table
  26. # I (470) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x057c8 ( 22472) map
  27. # I (535) esp_image: segment 1: paddr=0x000157f0 vaddr=0x3ffb0000 size=0x021a8 (  8616) load
  28. # I (573) esp_image: segment 2: paddr=0x000179a0 vaddr=0x40080000 size=0x00404 (  1028) load
  29. # I (604) esp_image: segment 3: paddr=0x00017dac vaddr=0x40080404 size=0x0826c ( 33388) load
  30. # I (697) esp_image: segment 4: paddr=0x00020020 vaddr=0x400d0020 size=0x12fac ( 77740) map
  31. # I (863) esp_image: segment 5: paddr=0x00032fd4 vaddr=0x40088670 size=0x016e4 (  5860) load
  32. # I (945) boot: Loaded app from partition at offset 0x10000
  33. # I (948) boot: Disabling RNG early entropy source...
  34. # I (974) cpu_start: Pro cpu up.
  35. # I (975) cpu_start: Application information:
  36. # I (976) cpu_start: Project name:     hello-world
  37. # I (977) cpu_start: App version:      v4.2-dev-1303-gcd4fa46f5
  38. # I (979) cpu_start: Compile time:     May 20 2020 10:49:37
  39. # I (983) cpu_start: ELF file SHA256:  60a10154ecbceb86...
  40. # I (983) cpu_start: ESP-IDF:          v4.2-dev-1303-gcd4fa46f5
  41. # I (985) cpu_start: Starting app cpu, entry point is 0x40081270
  42. # I (5161) cpu_start: App cpu up.
  43. # I (6358) heap_init: Initializing. RAM available for dynamic allocation:
  44. # I (6387) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
  45. # I (6400) heap_init: At 3FFB29E8 len 0002D618 (181 KiB): DRAM
  46. # I (6409) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
  47. # I (6416) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
  48. # I (6426) heap_init: At 40089D54 len 000162AC (88 KiB): IRAM
  49. # I (6496) cpu_start: Pro cpu start user code

Who is online

Users browsing this forum: aygh4266, MicroController and 83 guests