knurling-rs / probe-run

Run embedded programs just like native ones
Apache License 2.0
645 stars 75 forks source link

Cannot execute binary file #422

Open adrien3d opened 1 year ago

adrien3d commented 1 year ago

Describe the bug While trying to cargo run this project on my Mac OS 13.5 M1, with rustc 1.71.1 (eb26296b5 2023-08-03) I have the following error:

   Compiling rs-nrf-fw v0.1.0 (/Users/adrien/Dev/rust/rs-nrf-fw)
    Finished dev [unoptimized + debuginfo] target(s) in 30.20s
     Running `target/thumbv7em-none-eabihf/debug/rs-nrf-fw`
target/thumbv7em-none-eabihf/debug/rs-nrf-fw: target/thumbv7em-none-eabihf/debug/rs-nrf-fw: cannot execute binary file

I suspect it is linked to the fact I am using thumbv7em-none-eabihf with hf at the end, and this nrf52840-sample, which is basically based on a bump version of defmt of a 3 year old example project from this tutorial, produces a similar error:


    Finished dev [unoptimized + debuginfo] target(s) in 18.97s
     Running `target/thumbv7em-none-eabihf/debug/nrf52840dk-sample`
target/thumbv7em-none-eabihf/debug/nrf52840dk-sample: target/thumbv7em-none-eabihf/debug/nrf52840dk-sample: cannot execute binary file```
Urhengulas commented 1 year ago

Can you please try what happens if you execute it with probe-rs run instead of probe-run?

You can install the probe-rs cli with:

$ cargo install probe-rs --features cli

And then change your .cargo/config.toml like this:

[target.'cfg(all(target_arch = "arm", target_os = "none"))']
-runner = "probe-run --chip nRF52840_xxAA"
+runner = "probe-rs run --chip nRF52840_xxAA"
Urhengulas commented 1 year ago

What also seems off is the fact that your Running ... line does not mention probe-run. It should look like following:

$ cargo rb hello
    Finished dev [optimized + debuginfo] target(s) in 0.02s
     Running `probe-run --chip nRF52840_xxAA target/thumbv7em-none-eabihf/debug/hello`