Blinky.rs using stm32f4xx-hal

Hi

I am trying to run the blinky.rs file from https://github.com/stm32-rs/stm32f4xx-hal/blob/master/examples/delay-syst-blinky.rs on STM32F439ZI board. I am new to embedded systems and RUST. When I use cargo run I get the following error:


source\repos\f4_t1\src> error[E0463]: can't find crate for testerror[E0463]: can't find crate for test        STM32G081KBUx        STM32G081KBUx

How do I resolve this?

If you type 'rustc --explain E0463' (as indicated in the error message you posted), it explains the error.

I suspect this may be the culprit:

- The crate is not present at all. If using Cargo, add it to `[dependencies]`
  in Cargo.toml.
- The crate is present, but under a different name. If using Cargo, look for
  `package = ` under `[dependencies]` in Cargo.toml.

In this case, it seems to not be able to find that crate (and I can't find anything like that in the git link you posted).

Not sure how to help you from here, but maybe that's enough information to keep researching?

1 Like

test is the name of the crate that is the Rust test harness, which is implicitly used when you run #[test] tests. (It's also sometimes called libtest to distinguish it from other uses of the word.) It's not a Cargo dependency; it's part of the standard library that rustc already knows, like core, alloc, and std are.

If it's not found, that usually means you're trying to cargo test with a target triple that doesn't have std either. It shouldn't be required for cargo run, though.

If you are trying to run #[test] tests, then the answer is that you have to either:

  • run them on the host (machine you're building on), which has such features as stdio and threads that are needed for tests, or
  • provide a custom test harness and a runner command that knows how to take a binary and run it on your target hardware (whether emulated or via attached dev board).

The linked repo already has a runner set up in .cargo/config.toml:

[target.thumbv7em-none-eabihf]
runner = 'probe-run --chip STM32F411CEUx'

That should be sufficient for cargo run (but not cargo test).

1 Like

Thank you @0xMB and @kpreid for the help !!

Consider to report the fix to the upstream project. ( Do more as just saying thank you )