Skip to content

Rust build image run or not run (QEMU-271) #135

@ca2oh4

Description

@ca2oh4

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate
  • Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
  • Tested with the latest version to ensure the issue hasn't been fixed

How often does this bug occurs?

always

Expected behavior

我使用最新的 qemu-system-xtensa 进行仿真时,qemu 卡住,同样的镜像在 wokwi 上可以正常运行。

我测试了 linux 和 windows 均是如此

附件 hello.txt 是测试镜像

Actual behavior (suspected bug)

hello.txt

Error logs or terminal output

PS D:\tools\qemu> .\qemu-xtensa\bin\qemu-system-xtensa.exe -nographic -M esp32s3 -m 4 -drive file=hello.img,if=mtd,format=raw
>>
Adding SPI flash device
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x4 (SPI_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2     
load:0x3fce2810,len:0x15a0
load:0x403c8700,len:0x4   
load:0x403c8704,len:0xd24 
load:0x403cb700,len:0x2f04
entry 0x403c8928
I (45) boot: ESP-IDF v5.4.1-426-g3ad36321ea 2nd stage bootloader
I (50) boot: compile time Apr 24 2025 15:55:11
I (52) boot: Multicore bootloader
I (61) boot: chip revision: v0.0
I (63) boot: efuse block revision: v0.0
I (66) boot.esp32s3: Boot SPI Speed : 40MHz
I (68) boot.esp32s3: SPI Mode       : SLOW READ
I (69) boot.esp32s3: SPI Flash Size : 4MB
I (74) boot: Enabling RNG early entropy source...
I (86) boot: Partition Table:
I (87) boot: ## Label            Usage          Type ST Offset   Length
I (89) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (91) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (93) boot:  2 factory          factory app      00 00 00010000 003f0000
I (96) boot: End of partition table
I (99) esp_image: segment 0: paddr=00010020 vaddr=3c050020 size=12518h ( 75032) map
I (166) esp_image: segment 1: paddr=00022540 vaddr=3fc90900 size=02d48h ( 11592) load
I (173) esp_image: segment 2: paddr=00025290 vaddr=40374000 size=0ad88h ( 44424) load
I (193) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=41c78h (269432) map
I (271) esp_image: segment 4: paddr=00071ca0 vaddr=4037ed88 size=01b28h (  6952) load
I (278) boot: Loaded app from partition at offset 0x10000
I (280) boot: Disabling RNG early entropy source...
I (284) cpu_start: Multicore app
W (604) rtcinit: o_code calibration fail

I (329) cpu_start: Pro cpu start user code
I (330) cpu_start: cpu freq: 160000000 Hz
I (331) cpu_start: Application information:
I (331) cpu_start: Project name:     libespidf
I (332) cpu_start: App version:      639f258-dirty
I (333) cpu_start: Compile time:     Aug  6 2025 13:12:23
I (334) cpu_start: ELF file SHA256:  000000000...
I (335) cpu_start: ESP-IDF:          v5.2.3
I (335) cpu_start: Min chip rev:     v0.0
I (336) cpu_start: Max chip rev:     v0.99
I (337) cpu_start: Chip rev:         v0.0
I (338) heap_init: Initializing. RAM available for dynamic allocation:
I (339) heap_init: At 3FC93FD0 len 00055740 (341 KiB): RAM
I (340) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (342) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (342) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM
I (353) spi_flash: detected chip: gd
I (354) spi_flash: flash io: dio
W (355) eFuse: calibration efuse version does not match, set default version to 0


The expectation is that the output should be “hello world”


this wokiwi sim output


I (42) cpu_start: Project name:     libespidf
I (47) cpu_start: App version:      d49b676
I (52) cpu_start: Compile time:     Aug  6 2025 14:08:23
I (58) cpu_start: ELF file SHA256:  000000000...
I (63) cpu_start: ESP-IDF:          v5.2.3
I (68) cpu_start: Min chip rev:     v0.0
I (72) cpu_start: Max chip rev:     v0.99 
I (77) cpu_start: Chip rev:         v0.0
I (82) heap_init: Initializing. RAM available for dynamic allocation:
I (89) heap_init: At 3FC93FD0 len 00055740 (341 KiB): RAM
I (95) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (101) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (107) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM
I (115) spi_flash: detected chip: gd
I (118) spi_flash: flash io: dio
W (124) i2c: This driver is an old driver, please migrate your application code to adapt driver/i2c_master.h
W (132) timer_group: legacy driver is deprecated, please migrate to driver/gptimer.h
I (141) sleep: Configure to isolate all GPIO pins in sleep state
I (148) sleep: Enable automatic switching of GPIO sleep configuration
I (156) main_task: Started on CPU0
I (166) main_task: Calling app_main()
I (166) hello: Hello, world!
I (166) main_task: Returned from app_main()

Steps to reproduce the behavior

参考 https://narukara.github.io/rust-on-esp-book-zh-cn/tooling/simulating/qemu.html 构建了一个 hello world 的镜像

cargo build --release
espflash save-image --chip esp32 --merge target/xtensa-esp32-espidf/release/<NAME> <OUTFILE>

然后运行了

/path/to/qemu-system-xtensa -nographic -machine esp32 -drive file=<OUTFILE>,if=mtd,format=raw -m 4M

结果 输出到这里就不继续了

···
I (80) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM
I (84) spi_flash: detected chip: gd
I (84) spi_flash: flash io: dio
W (84) eFuse: calibration efuse version does not match, set default version to 0

Project release version

esp-develop-9.2.2-20250228

System architecture

other (details in Additional context)

Operating system

Linux

Operating system version

Win10 and debian12

Shell

other (details in Additional context)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions