Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Use cargo espflash instead of esptool.py for qemu (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
svenstaro authored May 15, 2022
1 parent 356c81f commit 45f041d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ build-std = ["std", "panic_abort"]
#ESP_IDF_VERSION = { value = "master" }

# Comment out this when using the PlatformIO build (it only supports `v4.3.2`)
ESP_IDF_VERSION = { value = "release/v4.4" }
ESP_IDF_VERSION = { value = "release/v4.4" }

# These configurations will pick up your custom "sdkconfig.release", "sdkconfig.debug" or "sdkconfig.defaults[.*]" files
# that you might put in the root of the project
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Highlights:
- **Support for Rust STD** (threads, console, TCP/IP) safe APIs
- ... upstreamed and [part of the Rust STD library](https://github.com/rust-lang/rust/pull/87666)
- **New, experimental!** Support for asynchronous networking using [smol](https://github.com/smol-rs/smol)
- **New, experimental!** Support for running in the [Espressif fork of QEMU](https://github.com/espressif/qemu/wiki)
- Support for running in the [Espressif fork of QEMU](https://github.com/espressif/qemu/wiki)
- Rust Safe APIs for various ESP-IDF services like WiFi, Ping, Httpd and logging
- ... via [esp-idf-svc](https://crates.io/crates/esp-idf-svc) ([embedded-svc](https://crates.io/crates/embedded-svc) abstractions implemented on top of ESP-IDF)
- NAPT support (Router from the SoftAP to the STA interface). **NOTE**: In production, do NOT leave the SoftAP interface open (without password)!
Expand Down Expand Up @@ -48,10 +48,10 @@ Highlights:
- Note that other RMII Ethernet boards might work just fine as well, but you'll have to change the chip from `RmiiEthDriver::IP101` to whatever chip your board is using, in the demo code itself.
- (Only if you happen to have an ESP32-S2 board and can connect a LED to GPIO Pin 04 and GND): Try accessing `http://<dhcp-ip-of-the-board>>/ulp` once build is flashed on the MCU

## QEMU (WIP, experimental)
## QEMU

- Rather than flashing on the chip, you can now run the demo in QEMU:
- Clone and then build [the Espressif fork of QEMU](https://github.com/espressif/qemu) by following the [build instructions](https://github.com/espressif/qemu/wiki)
- Install the [esptool.py](https://github.com/espressif/esptool) utility
- Uncomment `CONFIG_ETH_USE_OPENETH=y`, `CONFIG_MBEDTLS_HARDWARE_AES=n`, and `CONFIG_MBEDTLS_HARDWARE_SHA=n` in `sdkconfig.defaults.esp32` (it is not enabled by default because this somehow causes issues when compiling for the ESP32S2)
- Build the app with `cargo build --features qemu`
- NOTE: Only ESP32 is supported for the moment, so make sure that the `xtensa-esp32-espidf` target (the default one) is active in your `.cargo/config.toml` file (or override with `cargo build --features qemu --target xtensa-esp32-espidf`)
Expand Down
5 changes: 2 additions & 3 deletions qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ BUILD=debug

TARGET=xtensa-esp32-espidf # Don't change this. Only the ESP32 chip is supported in QEMU for now

esptool.py --chip esp32 elf2image target/$TARGET/$BUILD/rust-esp32-std-demo
esptool.py --chip esp32 merge_bin --output target/$TARGET/$BUILD/rust-esp32-std-demo-qemu.bin --fill-flash-size 4MB 0x1000 qemu_bins/bootloader.bin 0x8000 qemu_bins/partitions.bin 0x10000 target/$TARGET/$BUILD/rust-esp32-std-demo.bin --flash_mode dio --flash_freq 40m --flash_size 4MB
$ESP_QEMU_PATH/qemu-system-xtensa -nographic -machine esp32 -nic user,model=open_eth,id=lo0,hostfwd=tcp:127.0.0.1:7888-:80 -drive file=target/$TARGET/$BUILD/rust-esp32-std-demo-qemu.bin,if=mtd,format=raw
cargo espflash save-image --features qemu --merge target/$TARGET/$BUILD/rust-esp32-std-demo.bin
$ESP_QEMU_PATH/qemu-system-xtensa -nographic -machine esp32 -nic user,model=open_eth,id=lo0,hostfwd=tcp:127.0.0.1:7888-:80 -drive file=target/$TARGET/$BUILD/rust-esp32-std-demo.bin,if=mtd,format=raw
Binary file removed qemu_bins/bootloader.bin
Binary file not shown.
Binary file removed qemu_bins/partitions.bin
Binary file not shown.

0 comments on commit 45f041d

Please sign in to comment.