diff --git a/.github/actions/setup-target/action.yml b/.github/actions/setup-target/action.yml index 146bc75d..38b9ded5 100644 --- a/.github/actions/setup-target/action.yml +++ b/.github/actions/setup-target/action.yml @@ -60,7 +60,7 @@ runs: if: inputs.target == 'x86_64-unknown-linux-gnu' || inputs.target == 'x86_64-unknown-linux-musl' shell: bash run: | - sudo apt-get update && sudo apt-get install musl-tools libudev-dev + sudo apt-get update && sudo apt-get -y install musl-tools libudev-dev pkg-config - name: Set environment variables if: inputs.arch != 'x86_64' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f14d86e9..c64c0381 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,13 @@ on: pull_request: branches: - main + paths-ignore: + - "**/hil.yml" + - "**/*.md" push: + paths-ignore: + - "**/hil.yml" + - "**/*.md" workflow_dispatch: env: diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml new file mode 100644 index 00000000..02776c15 --- /dev/null +++ b/.github/workflows/hil.yml @@ -0,0 +1,154 @@ +name: HIL + +on: + pull_request: + branches: + - main + paths-ignore: + - "**/ci.yml" + - "**/*.md" + push: + paths-ignore: + - "**/ci.yml" + - "**/*.md" + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +# Cancel any currently running workflows from the same PR, branch, or +# tag when a new workflow is triggered. +# +# https://stackoverflow.com/a/66336834 +concurrency: + cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + + +jobs: + build-espflash: + name: Build espflash + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-target + with: + arch: x86_64 + target: x86_64-unknown-linux-gnu + + - name: Build espflash + run: cargo build --release + working-directory: espflash + + - uses: actions/upload-artifact@v3 + with: + name: espflash + path: target/release/espflash + if-no-files-found: error + + run-target: + name: ${{ matrix.board.mcu }}${{ matrix.board.freq }} + if: ${{ github.repository_owner == 'esp-rs' }} + needs: build-espflash + runs-on: [self-hosted, linux, x64, "${{ matrix.board.mcu }}${{ matrix.board.freq }}" ] + strategy: + matrix: + board: + - mcu: esp32 + - mcu: esp32c2 + freq: -26mhz + flag: -x 26mhz + - mcu: esp32c3 + - mcu: esp32c6 + - mcu: esp32h2 + - mcu: esp32s2 + - mcu: esp32s3 + fail-fast: false + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v3 + with: + name: espflash + path: espflash_app + + - run: chmod +x espflash_app/espflash + + - name: board-info test + env: + ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }} + shell: bash + run: | + result=$(espflash_app/espflash board-info) + echo "$result" + if [[ $? -ne 0 || ! "$result" =~ "esp32" ]]; then + exit 1 + fi + + - name: flash test + env: + ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }} + ESPFLASH_APP: espflash/resources/apps/${{ matrix.board.mcu }} + shell: bash + run: | + result=$(espflash_app/espflash flash ${{ env.ESPFLASH_APP }} 2>&1) + echo "$result" + if [[ ! $result =~ "Flashing has completed!" ]]; then + exit 1 + fi + + - name: monitor test + env: + ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }} + shell: bash + run: | + result=$(timeout 5s espflash_app/espflash monitor --non-interactive || true) + echo "$result" + if ! echo "$result" | grep -q "Hello world!"; then + exit 1 + fi + + - name: erase/read flash test + env: + ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }} + run: | + result=$(espflash_app/espflash erase-flash 2>&1) + echo "$result" + if [[ ! $result =~ "Flash has been erased!" ]]; then + exit 1 + fi + result=$(espflash_app/espflash read-flash 0 0x200 flash_content.bin 2>&1) + echo "$result" + if [[ ! $result =~ "Flash content successfully read and written to" ]]; then + exit 1 + fi + echo "Checking if flash is empty" + if hexdump -v -e '/1 "%02x"' "flash_content.bin" | grep -qv '^ff*$'; then + exit 1 + fi + echo "Flash is empty!" + + - name: save-image/write-bin test + env: + ESPFLASH_PORT: /dev/serial_ports/${{ matrix.board.mcu }} + ESPFLASH_APP: espflash/resources/apps/${{ matrix.board.mcu }} + run: | + result=$(espflash_app/espflash save-image --merge --chip ${{ matrix.board.mcu }} ${{ matrix.board.flag }} ${{ env.ESPFLASH_APP }} app.bin 2>&1) + echo "$result" + if [[ ! $result =~ "Image successfully saved!" ]]; then + exit 1 + fi + echo "Writting binary" + result=$(espflash_app/espflash write-bin 0x0 app.bin 2>&1) + echo "$result" + if [[ ! $result =~ "Binary successfully written to flash!" ]]; then + exit 1 + fi + echo "Monitoring..." + result=$(timeout 5s espflash_app/espflash monitor --non-interactive || true) + echo "$result" + if ! echo "$result" | grep -q "Hello world!"; then + exit 1 + fi + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 432b4945..9dbf8ba8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add CI check to verify that CHANGELOG is updated (#560) - Add `--before` and `--after` reset arguments (#561) - Add `read-flash` command (#558) +- Add HIL testing (#596) ### Fixed diff --git a/Cargo.lock b/Cargo.lock index 094d95fa..7cbbd82f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,9 +34,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540" dependencies = [ "anstyle", "anstyle-parse", @@ -82,9 +82,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" [[package]] name = "arc-swap" @@ -213,9 +213,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.0" +version = "3.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f" +checksum = "a3b1be7772ee4501dba05acbe66bb1e8760f6a6c474a36035631638e4415f130" [[package]] name = "bytemuck" @@ -234,7 +234,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -324,7 +324,7 @@ dependencies = [ "sha1", "shell-escape", "supports-hyperlinks 2.1.0", - "syn 2.0.49", + "syn 2.0.50", "tar", "tempfile", "time", @@ -451,11 +451,10 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730" dependencies = [ - "jobserver", "libc", ] @@ -467,9 +466,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.0" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" +checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" dependencies = [ "clap_builder", "clap_derive", @@ -477,9 +476,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.0" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" +checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" dependencies = [ "anstream", "anstyle", @@ -490,9 +489,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.0" +version = "4.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "299353be8209bd133b049bf1c63582d184a8b39fd9c04f15fe65f50f88bdfe6c" +checksum = "885e4d7d5af40bfb99ae6f9433e292feac98d452dcb3ec3d25dfe7552b77da8c" dependencies = [ "clap", ] @@ -506,7 +505,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -1112,9 +1111,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "erased-serde" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55d05712b2d8d88102bc9868020c9e5c7a1f5527c452b9b97450a1d006140ba7" +checksum = "388979d208a049ffdfb22fa33b9c81942215b940910bccfe258caeb25d125cb3" dependencies = [ "serde", ] @@ -1780,7 +1779,7 @@ checksum = "d75e7ab728059f595f6ddc1ad8771b8d6a231971ae493d9d5948ecad366ee8bb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2688,13 +2687,13 @@ dependencies = [ [[package]] name = "maybe-async" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc95a651c82daf7004c824405aa1019723644950d488571bd718e3ed84646ed" +checksum = "5cf92c10c7e361d6b99666ec1c6f9805b0bea2c3bd8c78dc6fe98ac5bd78db11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2773,7 +2772,7 @@ checksum = "f301c3f54f98abc6c212ee722f5e5c62e472a334415840669e356f04850051ec" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2852,11 +2851,11 @@ dependencies = [ [[package]] name = "normpath" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec60c60a693226186f5d6edf073232bfb6464ed97eb22cf3b01c1e8198fd97f5" +checksum = "5831952a9476f2fed74b77d74182fa5ddc4d21c72ec45a333b250e3ed0272804" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2939,9 +2938,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.63" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c9d69dd87a29568d4d017cfe8ec518706046a05184e5aea92d0af890b803c8" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ "bitflags 2.4.2", "cfg-if", @@ -2960,7 +2959,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -2980,9 +2979,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.99" +version = "0.9.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e1bf214306098e4832460f797824c05d25aacdf896f64a985fb0fd992454ae" +checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" dependencies = [ "cc", "libc", @@ -3391,16 +3390,17 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.7" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if", "getrandom", "libc", "spin", "untrusted", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -3524,9 +3524,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "same-file" @@ -3601,18 +3601,18 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] @@ -3639,13 +3639,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.196" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -3659,9 +3659,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.113" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -3943,7 +3943,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -3956,7 +3956,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -4008,9 +4008,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.49" +version = "2.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496" +checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" dependencies = [ "proc-macro2", "quote", @@ -4093,9 +4093,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ "smawk", "unicode-linebreak", @@ -4119,14 +4119,14 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] name = "thread_local" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ "cfg-if", "once_cell", @@ -4275,7 +4275,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.1", + "winnow 0.6.2", ] [[package]] @@ -4303,7 +4303,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", ] [[package]] @@ -4411,9 +4411,9 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-normalization" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ "tinyvec", ] @@ -4550,7 +4550,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", "wasm-bindgen-shared", ] @@ -4584,7 +4584,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.49", + "syn 2.0.50", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4794,9 +4794,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d90f4e0f530c4c69f62b80d839e9ef3855edc9cba471a160c4d692deed62b401" +checksum = "7a4191c47f15cc3ec71fcb4913cb83d58def65dd3787610213c649283b5ce178" dependencies = [ "memchr", ] diff --git a/cargo-espflash/src/main.rs b/cargo-espflash/src/main.rs index 8b47adf8..ebe6cfa6 100644 --- a/cargo-espflash/src/main.rs +++ b/cargo-espflash/src/main.rs @@ -357,6 +357,7 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> { pid, args.flash_args.monitor_baud.unwrap_or(default_baud), args.flash_args.log_format, + true, ) } else { Ok(()) diff --git a/espflash/Cargo.toml b/espflash/Cargo.toml index 446789d9..34c0e9d4 100644 --- a/espflash/Cargo.toml +++ b/espflash/Cargo.toml @@ -83,4 +83,3 @@ cli = [ "dep:update-informer", ] serialport = ["dep:serialport"] - diff --git a/espflash/resources/apps/esp32 b/espflash/resources/apps/esp32 new file mode 100755 index 00000000..b0120b65 Binary files /dev/null and b/espflash/resources/apps/esp32 differ diff --git a/espflash/resources/apps/esp32c2 b/espflash/resources/apps/esp32c2 new file mode 100755 index 00000000..550cfff7 Binary files /dev/null and b/espflash/resources/apps/esp32c2 differ diff --git a/espflash/resources/apps/esp32c3 b/espflash/resources/apps/esp32c3 new file mode 100755 index 00000000..7317bd89 Binary files /dev/null and b/espflash/resources/apps/esp32c3 differ diff --git a/espflash/resources/apps/esp32c6 b/espflash/resources/apps/esp32c6 new file mode 100755 index 00000000..4f5d44c7 Binary files /dev/null and b/espflash/resources/apps/esp32c6 differ diff --git a/espflash/resources/apps/esp32h2 b/espflash/resources/apps/esp32h2 new file mode 100755 index 00000000..3107c716 Binary files /dev/null and b/espflash/resources/apps/esp32h2 differ diff --git a/espflash/resources/apps/esp32s2 b/espflash/resources/apps/esp32s2 new file mode 100755 index 00000000..c275fee3 Binary files /dev/null and b/espflash/resources/apps/esp32s2 differ diff --git a/espflash/resources/apps/esp32s3 b/espflash/resources/apps/esp32s3 new file mode 100755 index 00000000..1dbf4c13 Binary files /dev/null and b/espflash/resources/apps/esp32s3 differ diff --git a/espflash/src/bin/espflash.rs b/espflash/src/bin/espflash.rs index 9a8ccac3..0bc6f87e 100644 --- a/espflash/src/bin/espflash.rs +++ b/espflash/src/bin/espflash.rs @@ -200,6 +200,8 @@ pub fn erase_parts(args: ErasePartsArgs, config: &Config) -> Result<()> { .connection() .reset_after(!args.connect_args.no_stub)?; + info!("Specified partitions successfully erased!"); + Ok(()) } @@ -292,6 +294,7 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> { pid, args.flash_args.monitor_baud.unwrap_or(default_baud), args.flash_args.log_format, + true, ) } else { Ok(()) diff --git a/espflash/src/cli/mod.rs b/espflash/src/cli/mod.rs index 790bb4ae..34cf2f08 100644 --- a/espflash/src/cli/mod.rs +++ b/espflash/src/cli/mod.rs @@ -252,6 +252,9 @@ pub struct MonitorArgs { /// Optional file name of the ELF image to load the symbols from #[arg(short = 'e', long, value_name = "FILE")] elf: Option, + /// Avoids asking the user for interactions like resetting the device + #[arg(long)] + non_interactive: bool, /// Logging format. #[arg(long, short = 'L', default_value = "serial", requires = "elf")] pub log_format: LogFormat, @@ -439,6 +442,7 @@ pub fn serial_monitor(args: MonitorArgs, config: &Config) -> Result<()> { pid, args.connect_args.baud.unwrap_or(default_baud), args.log_format, + !args.non_interactive, ) } @@ -509,6 +513,8 @@ pub fn save_elf_as_image( } } + info!("Image successfully saved!"); + Ok(()) } @@ -575,6 +581,8 @@ pub fn erase_flash(args: EraseFlashArgs, config: &Config) -> Result<()> { flash.erase_flash()?; flash.connection().reset_after(!args.connect_args.no_stub)?; + info!("Flash has been erased!"); + Ok(()) } diff --git a/espflash/src/cli/monitor/mod.rs b/espflash/src/cli/monitor/mod.rs index 41a80cbf..d0dc0d1e 100644 --- a/espflash/src/cli/monitor/mod.rs +++ b/espflash/src/cli/monitor/mod.rs @@ -71,11 +71,16 @@ pub fn monitor( pid: u16, baud: u32, log_format: LogFormat, + interactive_mode: bool, ) -> miette::Result<()> { - println!("Commands:"); - println!(" CTRL+R Reset chip"); - println!(" CTRL+C Exit"); - println!(); + if interactive_mode { + println!("Commands:"); + println!(" CTRL+R Reset chip"); + println!(" CTRL+C Exit"); + println!(); + } else { + reset_after_flash(&mut serial, pid).into_diagnostic()?; + } // Explicitly set the baud rate when starting the serial monitor, to allow using // different rates for flashing. @@ -109,7 +114,7 @@ pub fn monitor( // Don't forget to flush the writer! stdout.flush().ok(); - if poll(Duration::from_secs(0)).into_diagnostic()? { + if interactive_mode && poll(Duration::from_secs(0)).into_diagnostic()? { if let Event::Key(key) = read().into_diagnostic()? { if key.modifiers.contains(KeyModifiers::CONTROL) { match key.code { diff --git a/espflash/src/flasher/mod.rs b/espflash/src/flasher/mod.rs index f6bd2237..07fbda99 100644 --- a/espflash/src/flasher/mod.rs +++ b/espflash/src/flasher/mod.rs @@ -974,7 +974,11 @@ impl Flasher { addr, data: Cow::from(data), }; - self.write_bins_to_flash(&[segment], progress) + self.write_bins_to_flash(&[segment], progress)?; + + info!("Binary successfully written to flash!"); + + Ok(()) } /// Load multiple bin images to flash at specific addresses @@ -1091,7 +1095,7 @@ impl Flasher { .write(true) .truncate(true) .create(true) - .open(file_path)?; + .open(&file_path)?; self.connection .with_timeout(CommandType::ReadFlash.timeout(), |connection| { @@ -1148,6 +1152,11 @@ impl Flasher { file.write_all(&data)?; + info!( + "Flash content successfully read and written to '{}'!", + file_path.display() + ); + Ok(()) }