jerabaul29 / embassy_experiments

My embassy experiments
0 stars 0 forks source link

how to start a default, bare bone stm32u5a5 project, set it up, and build it? #1

Closed jerabaul29 closed 1 year ago

jerabaul29 commented 1 year ago

I am trying to get inspiration from the example at https://github.com/embassy-rs/embassy/tree/main/examples/stm32u5 to understand how to "start" a new project with embassy.

If I understand correctly, I have to link to the source in the Cargo.toml file, i.e. something like:

embassy-stm32 = { version = "0.1.0", path = "../../../embassy/embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u5a5zj", "time-driver-any", "memory-x" ]  }

and not something like:

embassy-stm32 = { version = "0.1.0", features = ["nightly", "defmt", "unstable-pac", "stm32u5a5zj", "time-driver-any", "memory-x" ]  }

as the crate is empty online (same for the other embassy stm32 crates):

https://crates.io/crates/embassy-stm32 .

However, trying to adapt the working example from the embassy repo https://github.com/embassy-rs/embassy/tree/main/examples/stm32u5 , into my own example https://github.com/jerabaul29/embassy_experiments/tree/main/examples/blink , I get issues:

kzm@kzm-bpq:~/Desktop/Git/embassy_experiments/examples/blink$ cargo run --bin blinky --release
   Compiling thiserror-impl v1.0.49
   Compiling proc-macro-error v1.0.4
   Compiling futures-macro v0.3.28
   Compiling cortex-m-rt-macros v0.7.0
   Compiling cortex-m v0.7.7
   Compiling darling_core v0.20.3
   Compiling stm32-metapac v14.0.0 (https://github.com/embassy-rs/stm32-data-generated?tag=stm32-data-8ee2862086886cd8ebaf5fd5e3bd6cfbe5baa840#fc2eb79e)
   Compiling serde v1.0.188
   Compiling num-traits v0.2.16
error[E0425]: cannot find function `__basepri_r` in module `crate::asm::inline`
 --> /home/kzm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cortex-m-0.7.7/src/register/basepri.rs:6:15
  |
6 |     call_asm!(__basepri_r() -> u8)
  |               ^^^^^^^^^^^ not found in `crate::asm::inline`

error[E0425]: cannot find function `__basepri_w` in module `crate::asm::inline`
  --> /home/kzm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cortex-m-0.7.7/src/register/basepri.rs:22:19
   |
22 |         call_asm!(__basepri_w(basepri: u8));
   |                   ^^^^^^^^^^^ not found in `crate::asm::inline`

error[E0425]: cannot find function `__basepri_max` in module `crate::asm::inline`
  --> /home/kzm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cortex-m-0.7.7/src/register/basepri_max.rs:19:19
   |
19 |         call_asm!(__basepri_max(basepri: u8));
   |                   ^^^^^^^^^^^^^ not found in `crate::asm::inline`

error[E0425]: cannot find function `__faultmask_r` in module `crate::asm::inline`
  --> /home/kzm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cortex-m-0.7.7/src/register/faultmask.rs:29:28
   |
29 |     let r: u32 = call_asm!(__faultmask_r() -> u32);
   |                            ^^^^^^^^^^^^^ not found in `crate::asm::inline`

error: invalid register `r0`: unknown register
   --> /home/kzm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cortex-m-0.7.7/src/../asm/inline.rs:197:24
    |
197 |     asm!("bkpt #0xab", inout("r0") nr, in("r1") arg, options(nomem, nostack, preserves_flags));
    |                        ^^^^^^^^^^^^^^

error: invalid register `r1`: unknown register
   --> /home/kzm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cortex-m-0.7.7/src/../asm/inline.rs:197:40
    |
197 |     asm!("bkpt #0xab", inout("r0") nr, in("r1") arg, options(nomem, nostack, preserves_flags));
    |                                        ^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0425`.
error: could not compile `cortex-m` (lib) due to 6 previous errors
warning: build failed, waiting for other jobs to finish...
jerabaul29 commented 1 year ago

(FYI @gauteh , this was tonight's embassy hacking, if you have ideas of why this is broken / where I am doing something wrong just let me know - not very used to setting up new projects, cargo, etc, on my end :) . If not, I will ask on matrix the embassy users :) ).

gauteh commented 1 year ago

Are you building it for the correct target? Thumbv7 or similar?

jerabaul29 commented 1 year ago

Good point, many thanks for the help, I added a .cargo config with target information copied from the embassy example (pushed to this repo now), this solved a couple of issues, getting new ones now :) . Any idea?

✔ ~/Desktop/Git/embassy_experiments/examples/blink [main|✔]> cargo build --bin blinky --release
[...]
   Compiling embedded-hal-async v1.0.0-rc.1
error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /home/jrmet/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-hal-async-1.0.0-rc.1/src/lib.rs:4:1
  |
4 | #![feature(async_fn_in_trait, impl_trait_projections)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

   Compiling embedded-storage-async v0.4.0
error[E0554]: `#![feature]` may not be used on the stable release channel
 --> /home/jrmet/.cargo/registry/src/index.crates.io-6f17d22bba15001f/embedded-storage-async-0.4.0/src/lib.rs:7:1
  |
7 | #![feature(async_fn_in_trait)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0554`.
error: could not compile `embedded-storage-async` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `embedded-hal-async` (lib) due to previous error
✘-INT ~/Desktop/Git/embassy_experiments/examples/blink [main| …4]> 
✘-INT ~/Desktop/Git/embassy_experiments/examples/blink [main| …4]> cargo +nightly build --bin blinky --release
   Compiling proc-macro2 v1.0.67
   Compiling unicode-ident v1.0.12
   Compiling syn v1.0.109
   Compiling defmt v0.3.5
   Compiling version_check v0.9.4
   Compiling thiserror v1.0.49
   Compiling defmt-macros v0.3.6
   Compiling semver-parser v0.7.0
   Compiling semver v0.9.0
   Compiling bitflags v1.3.2
error[E0463]: can't find crate for `core`
  |
  = note: the `thumbv8m.main-none-eabihf` target may not be installed
  = help: consider downloading the target with `rustup target add thumbv8m.main-none-eabihf`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error[E0463]: can't find crate for `compiler_builtins`

error[E0463]: can't find crate for `core`
   --> /home/jrmet/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bitflags-1.3.2/src/lib.rs:282:1
    |
282 | pub extern crate core as _core;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
    |
    = note: the `thumbv8m.main-none-eabihf` target may not be installed
    = help: consider downloading the target with `rustup target add thumbv8m.main-none-eabihf`
    = help: consider building the standard library from source with `cargo build -Zbuild-std`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `bitflags` (lib) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
gauteh commented 1 year ago

Looks like you need to rustup add target the correct target, e.g. for armv7: rustup target add thumbv7em-none-eabihf

jerabaul29 commented 1 year ago

Many thanks for the help, after a bit of trial and errors this worked out :) . The trick is that I needed to use nightly, and to install what I needed also in nightly (not in stable). I.e.:

✔ ~/Desktop/Git/embassy_experiments/examples/blink [main| …4]> rustup target add thumbv8m.main-none-eabihf
info: component 'rust-std' for target 'thumbv8m.main-none-eabihf' is up to date
✔ ~/Desktop/Git/embassy_experiments/examples/blink [main| …4]> cargo +nightly build --bin blinky --release
[...]
   Compiling futures-core v0.3.28
error[E0463]: can't find crate for `core`
  |
  = note: the `thumbv8m.main-none-eabihf` target may not be installed
  = help: consider downloading the target with `rustup target add thumbv8m.main-none-eabihf`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`
✘-101 ~/Desktop/Git/embassy_experiments/examples/blink [main| …4]> rustup +nightly target add thumbv8m.main-none-eabihf
info: downloading component 'rust-std' for 'thumbv8m.main-none-eabihf'
info: installing component 'rust-std' for 'thumbv8m.main-none-eabihf'
✔ ~/Desktop/Git/embassy_experiments/examples/blink [main| …4]> cargo +nightly build --bin blinky --release
[...]
    Finished release [optimized + debuginfo] target(s) in 22.54s

A bit tricky to get going the first time, but looks like it is all good now :) . Thanks again for the help :) .

I will definitely have to set up some form of container to be able to easily build this - otherwise I think I am going to bump my head on these points again and again ^^ .