Greetings everyone I hope you all are doing great!
The problem I'm facing is that all the crates I add as dependency, get as unresolved imports, albeit I've made sure to properly set the dependencies in the corresponding Cargo.toml file.
error[E0432]: unresolved import `panic_halt`
--> cortex-m7/src/main.rs:5:5
|
5 | use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch p...
| ^^^^^^^^^^^^^^^ no `panic_halt` in the root
error[E0432]: unresolved import `cortex_m`
--> cortex-m7/src/main.rs:10:5
|
10 | use cortex_m::asm;
| ^^^^^^^^ maybe a missing crate `cortex_m`?
|
= help: consider adding `extern crate cortex_m` to use the `cortex_m` crate
error[E0432]: unresolved import `cortex_m_rt`
--> cortex-m7/src/main.rs:11:5
|
11 | use cortex_m_rt::entry;
| ^^^^^^^^^^^ maybe a missing crate `cortex_m_rt`?
|
= help: consider adding `extern crate cortex_m_rt` to use the `cortex_m_rt` crate
error[E0432]: unresolved import `greeter`
--> cortex-m7/src/main.rs:12:5
|
12 | use greeter;
| ^^^^^^^ no `greeter` in the root
error: cannot determine resolution for the attribute macro `entry`
--> cortex-m7/src/main.rs:14:3
|
14 | #[entry]
| ^^^^^
|
= note: import resolution is stuck, try simplifying macro imports
error: `#[panic_handler]` function required, but not found
For more information about this error, try `rustc --explain E0432`.
error: could not compile `cortex-m7` (bin "cortex-m7") due to 6 previous errors
As the title says, I'm trying to setup an environment for dual core programming in Rust, I've already successfully setup another environment for a single core MCU, so I don't really see it quite clear where might I be failing.
Here is my detailed setup:
1.Project structure:
.
|-- Cargo.lock
|-- Cargo.toml
|-- cortex-m4
| |-- Cargo.toml
| |-- build.rs
| |-- memory.x
| |-- openocd.cfg
| |-- openocd.dbg
| `-- src
| `-- main.rs
|-- cortex-m7
| |-- Cargo.toml
| |-- build.rs
| |-- memory.x
| |-- openocd.cfg
| |-- openocd.dbg
| `-- src
| `-- main.rs
`-- shared
`-- greeter
|-- Cargo.toml
`-- src
`-- lib.rs
main.rs:
The code within cortex-m7/src/main.rs is actually quite simple and is exactly the same in cortex-m4/src/main.rs
#![no_std]
#![no_main]
// pick a panicking behavior
use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
// use panic_abort as _; // requires nightly
// use panic_itm as _; // logs messages over ITM; requires ITM support
// use panic_semihosting as _; // logs messages to the host stderr; requires a debugger
use cortex_m::asm;
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
asm::nop(); // To not have main optimize to abort in release mode, remove when you add code
loop {
// your code goes here
}
}
Cargo.toml:
This is the Cargo.toml file within each of the cores directories. (NOT the global Cargo.toml)
//cortex-m7/Cargo.toml
[package]
name = "cortex-m7"
version.workspace = true
authors.workspace = true
description.workspace = true
# Dependencis for bare metal dev
[dependencies]
cortex-m.workspace = true
cortex-m-rt.workspace = true
panic-halt.workspace = true
#cortex-m-semihosting.workspace = true #un-comment to enable semihosting
### cortex-m7 bin config
[[bin]]
name = "cortex-m7"
path = "src/main.rs"
4.Cargo.toml (root of the project)
### Workspaces
[workspace]
members = [
"cortex-m7",
"cortex-m4",
"shared/greeter",
]
default-members = ["cortex-m7"]
resolver = "2"
[workspace.package]
version = "0.1.0"
authors = ["Juan David Tangarife Hernandez <[email protected]>"]
description = "Dual core project for STM32H755ZI"
[workspace.dependencies]
cortex-m = "0.6.0"
cortex-m-rt = "0.6.10"
panic-halt = "0.2.0"
cortex-m-semihosting = "0.3.3" # un-comment to enable semihosting
### Debug build config
[profile.dev]
opt-level = 0 # No optimizations, full debug info
### Release build config
[profile.release]
codegen-units = 1 # better optimizations
debug = true # symbols are nice and they don't increase the size on Flash
lto = true # better optimizations
When I go into either of the cortex-m7 or cortex-m4 directories and run cargo build, I get errors related to the crates not being found:
error[E0432]: unresolved import `panic_halt`
--> cortex-m7/src/main.rs:5:5
|
5 | use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch p...
| ^^^^^^^^^^^^^^^ no `panic_halt` in the root
error[E0432]: unresolved import `cortex_m`
--> cortex-m7/src/main.rs:10:5
|
10 | use cortex_m::asm;
| ^^^^^^^^ maybe a missing crate `cortex_m`?
|
= help: consider adding `extern crate cortex_m` to use the `cortex_m` crate
error[E0432]: unresolved import `cortex_m_rt`
--> cortex-m7/src/main.rs:11:5
|
11 | use cortex_m_rt::entry;
| ^^^^^^^^^^^ maybe a missing crate `cortex_m_rt`?
|
= help: consider adding `extern crate cortex_m_rt` to use the `cortex_m_rt` crate
error[E0432]: unresolved import `greeter`
--> cortex-m7/src/main.rs:12:5
|
12 | use greeter;
| ^^^^^^^ no `greeter` in the root
error: cannot determine resolution for the attribute macro `entry`
--> cortex-m7/src/main.rs:14:3
|
14 | #[entry]
| ^^^^^
|
= note: import resolution is stuck, try simplifying macro imports
error: `#[panic_handler]` function required, but not found
For more information about this error, try `rustc --explain E0432`.
error: could not compile `cortex-m7` (bin "cortex-m7") due to 6 previous errors
I followed exactly the same approach for my single core setup (with a few changes, obviously) and it worked just great.
It might be obvious the answer, but I don't really see it. Help would be appreciated, I want to start programming my stm32h755zi haha.