Skip to content

SergioGasquez/esp-flasher-stub

 
 

Repository files navigation

esp-flasher-stub

GitHub Workflow Status MSRV Matrix

Rust implementation of flasher stub located in esptool.

Supports the ESP32, ESP32-C2/C3/C6, ESP32-H2, and ESP32-S2/S3. Currently UART and USB Serial JTAG are the supported transport modes, and support for other modes is planned.

Quickstart

To ease the building process we have included a build subcommand in the xtask package which will apply all the appropriate build configuration for one or more devices:

cd xtask/
cargo run -- build esp32
cargo run -- build esp32c2 esp32c3

In order to build the flasher stub manually, you must specify the appropriate toolchain, provide a feature to cargo selecting the device, and additionally specify the target:

# ESP32
cargo +esp build --release --features=esp32 --target=xtensa-esp32-none-elf

# ESP32-C2
cargo +nightly build --release --features=esp32c2 --target=riscv32imc-unknown-none-elf

# ESP32-C3
cargo +nightly build --release --features=esp32c3 --target=riscv32imc-unknown-none-elf

# ESP32-C6
cargo +nightly build --release --features=esp32c6 --target=riscv32imac-unknown-none-elf

# ESP32-H2
cargo +nightly build --release --features=esp32h2 --target=riscv32imac-unknown-none-elf

# ESP32-S2
cargo +esp build --release --features=esp32s2 --target=xtensa-esp32s2-none-elf

# ESP32-S3
cargo +esp build --release --features=esp32s3 --target=xtensa-esp32s3-none-elf

In order to generate the JSON stub files for one or more devices, you can again use the xtask package:

cd xtask/
cargo run -- wrap esp32c3
cargo run -- wrap esp32 esp32s2 esp32s3

JSON stub files will be generated in the project root directory.

Testing

In order to run test_esptool.py follow steps below:

  • Build esp-flasher-stub as described in the section above.
  • Clone esptool, if you don't have it yet:
    git clone https://github.com/espressif/esptool
    
  • Copy the stub JSON files into esptool installation. You can use the following one-liner:
    for n in esp*.json; do cp $n $ESPTOOL_PATH/esptool/targets/stub_flasher/stub_flasher_${n#esp}; done
    where ESPTOOL_PATH is set to the location where you have cloned esptool.
  • Run tests
    cd $ESPTOOL_PATH/test
    pytest test_esptool.py --port /dev/ttyUSB0 --chip esp32 --baud 115200

Debug logs

In order to use debug logs you have to build the project with dprint feature, for example:

cargo build --release --target=riscv32imc-unknown-none-elf --features=esp32c3,dprint

Then you can view logs using, for example screen:

screen /dev/ttyUSB2 115200

Warning

For ESP32 and ESP32-S2, please use a baud rate of 57,600 instead:

screen /dev/ttyUSB2 57600

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 97.0%
  • RPC 3.0%