esp-rs / espflash

Serial flasher utility for Espressif SoCs and modules based on esptool.py
Apache License 2.0
478 stars 117 forks source link

Add `--monitor` option to `write-bin` command #684

Open aiotter opened 1 week ago

aiotter commented 1 week ago

I'm using espflash for Rust based and non-Rust based ESP32 project. It is great. However when I'm debugging non-Rust based app like Erlang with AtomVM, I'm stressed a bit to execute espflash monitor just after espflash write-bin again and again.

How about adding --monitor option to write-bin just like flash command?

It looks cli::FlashArgs::{monitor,monitor_baud,log_format} is safe to be copied into WriteBinArgs, and the same logic here can be added at the end of write_bin function as well.

MabezDev commented 1 week ago

Any reason why you can't use the normal flash subcommand to flash your non-Rust esp32 project? That's what I use.

Regardless, I think we'd accept a PR that extended the monitor flag to write-bin.

aiotter commented 1 week ago

I don't expect that it is possible, because espflash flash is for ELF format. I believe the binary file to be flashed into ESP32 is not in ELF format.

$ file MyProject.avm
MyProject.avm: a /usr/bin/env AtomVM script executable (binary data)

On AtomVM project, you write a program first with Erlang, Elixir or any other compatible languages, and then compiles it into BEAM format as usual. AtomVM's packbeam utility will then packs it into AVM binary, which you can espflash write-bin into ESP32's 0x210000 address. AtomVM, flashed at bootloader partition in advance, will execute that AVM binary.

Do you think I can use flash command in my case?

Regardless, I think we'd accept a PR that extended the monitor flag to write-bin.

Thank you for mentioning this! I'll try implementing it and open a PR when I have some time, hopefully.