Understanding Rust Error E0775
Overview of Error E0775
Rust Error E0775 occurs when the #[cmse_nonsecure_entry] attribute is used, but the target platform does not support the TrustZone-M extension. The TrustZone-M extension is required for cmse_nonsecure_entry to be a valid attribute.
Erroneous Code Example
#![allow(unused)]
#![feature(cmse_nonsecure_entry)]
fn main() {
#[cmse_nonsecure_entry]
pub extern "C" fn entry_function() {}
}
Resolving Error E0775
To resolve this error, compile your Rust code for a target that supports the TrustZone-M extension. The currently supported targets are: thumbv8m.main-none-eabi, thumbv8m.main-none-eabihf, and thumbv8m.base-none-eabi.
Specifying a Target with Rust Flags
You can specify a target for Rust using the --target flag when compiling with rustc or cargo. For example, you can build with the thumbv8m.base-none-eabi target by running:
rustc --target thumbv8m.base-none-eabi my_source_code.rs
Or, when using Cargo:
cargo build --target thumbv8m.base-none-eabi
Verifying Your Target Support
Ensure that the target platform being used satisfies the requirements for TrustZone-M by either referring to the documentation of a specific platform or checking the platform's cargo config.
For example, here is how you would verify the thumbv8m.main-none-eabi target is supported in your Cargo config:
[build]
target = "thumbv8m.main-none-eabi"