Skip to content

Freezes on launch #4

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

Closed
n8henrie opened this issue Apr 16, 2025 · 2 comments
Closed

Freezes on launch #4

n8henrie opened this issue Apr 16, 2025 · 2 comments

Comments

@n8henrie
Copy link
Contributor

n8henrie commented Apr 16, 2025

Hi again -- thanks for keeping this project going!

I'm back tinkering on my esp32c3 project again (https://github.com/n8henrie/esp32c3-rust-mqtt), and I'd love to be able to test via qemu instead of having to carry real hardware around with me everywhere.

On my Macbook, this project still builds (as long as I specify --option sandbox false -- even relaxed makes the tests fail).

I have an image that runs on real hardware but it seems to freeze if I try to emulate the image.

$ espflash save-image --chip esp32c3 --merge ./target/riscv32imc-unknown-none-elf/release/esp32c3-rust-mqtt for-qemu.bin
[2025-04-16T22:11:16Z INFO ] 🚀 A new version of espflash is available: v3.3.0
Chip type:         esp32c3
Merge:             true
Skip padding:      false
App/part. size:    557,296/4,128,768 bytes, 13.50%
[2025-04-16T22:11:16Z INFO ] Image successfully saved!
$
$
$ esptool.py image_info --version 2 for-qemu.bin
esptool.py v4.8.1
File size: 4194304 (bytes)
Detected image type: ESP32-C3

ESP32-C3 image header
=====================
Image version: 1
Entry point: 0x403cc710
Segments: 3
Flash size: 4MB
Flash freq: 40m
Flash mode: DIO

ESP32-C3 extended image header
==============================
WP pin: 0xee (disabled)
Flash pins drive settings: clk_drv: 0x0, q_drv: 0x0, d_drv: 0x0, cs0_drv: 0x0, hd_drv: 0x0, wp_drv: 0x0
Chip ID: 5 (ESP32-C3)
Minimal chip revision: v0.3, (legacy min_rev = 3)
Maximal chip revision: v1.99

Segments information
====================
Segment   Length   Load addr   File offs  Memory types
-------  -------  ----------  ----------  ------------
      0  0x01714  0x3fcd5820  0x00000018  DRAM, BYTE_ACCESSIBLE
      1  0x00968  0x403cc710  0x00001734  IRAM
      2  0x02f9c  0x403ce710  0x000020a4  IRAM

ESP32-C3 image footer
=====================
Checksum: 0xd1 (valid)
Validation hash: fa8220407199eb91eadb1710c476e6777d63dcac20d6d3c0ef5bcda42cd45753 (valid)
$
$
$ ./qemu-esp32c3/bin/qemu-system-riscv32 -nographic -icount 3 -machine esp32c3 -drive file=./for-qemu.bin,if=mtd,format=raw
Adding SPI flash device
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fcd5820,len:0x1714
load:0x403cc710,len:0x968
load:0x403ce710,len:0x2f9c
entry 0x403cc710
I (0) boot: ESP-IDF v5.1.2-342-gbcf1645e44 2nd stage bootloader
I (0) boot: compile time Dec 12 2023 10:50:58
I (0) boot: chip revision: v0.3
I (0) boot.esp32c3: SPI Speed      : 40MHz
I (0) boot.esp32c3: SPI Mode       : SLOW READ
I (0) boot.esp32c3: SPI Flash Size : 4MB
I (0) boot: Enabling RNG early entropy source...
I (1) boot: Partition Table:
I (1) boot: ## Label            Usage          Type ST Offset   Length
I (1) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (1) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (1) boot:  2 factory          factory app      00 00 00010000 003f0000
I (1) boot: End of partition table
I (1) esp_image: segment 0: paddr=00010020 vaddr=3c080020 size=12104h ( 73988) map
I (9) esp_image: segment 1: paddr=0002212c vaddr=3fc879d8 size=01cd8h (  7384) load
I (10) esp_image: segment 2: paddr=00023e0c vaddr=3fca52a0 size=001ech (   492) load
I (10) esp_image: segment 3: paddr=00024000 vaddr=40380000 size=079d4h ( 31188) load
I (14) esp_image: segment 4: paddr=0002b9dc vaddr=00000000 size=0463ch ( 17980)
I (16) esp_image: segment 5: paddr=00030020 vaddr=42000020 size=680ach (426156) map
I (58) boot: Loaded app from partition at offset 0x10000
I (58) boot: Disabling RNG early entropy source...

It just freezes here indefinitely. Any ideas?

@SFrijters
Copy link
Owner

I've pasted your code into my example code repo, replacing blinky, and I do get the same issue (on x86_64-linux). In particular, I've put in some println and the code hangs at let (controller, interfaces) = esp_wifi::wifi::new(esp_wifi_ctrl, peripherals.WIFI).unwrap();.

But I think this is to be expected, as the espressif QEMU fork doesn't support WiFi? espressif/esp-idf#15087

I'm pretty sure I've seen a fork-of-the-fork somewhere that adds WiFi support and I had plans to add it as a variant to my flake, but I don't seem to be able to find that particular repository anymore. There does seem to be some work in progress: espressif/qemu#80 .

Regarding your comment on "makes the tests fail": do you mean the checkPhase for qemu? You can get around that by overriding enableTests = false;, which also speeds up the build process significantly.

SFrijters added a commit to SFrijters/nix-qemu-esp32c3-rust-example that referenced this issue Apr 18, 2025
@n8henrie
Copy link
Contributor Author

But I think this is to be expected, as the espressif QEMU fork doesn't support WiFi? espressif/esp-idf#15087

Ah, I should have known that. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants