rust-embedded / cortex-m

Low level access to Cortex-M processors
Apache License 2.0
820 stars 147 forks source link

thumbv8m.base +inline-asm = "error: invalid operand for instruction" #155

Closed japaric closed 4 years ago

japaric commented 5 years ago

STR

Grab the cortex-m-quickstart template (a version that uses cortex-m v0.6.0) and compile this program:

#[entry]
fn main() -> ! {
    let x = basepri::read();

    loop {}
}

for the thumbv8m.base-none-eabi target but make sure that the "inline-asm" feature of cortex-m has been enabled; you get:

error: <inline asm>:1:10: error: invalid operand for instruction
        mrs r0, BASEPRI
                ^

The BASEPRI register doesn't exist on ARMv8-M devices that don't have the main extension. The register::{basepri,basepri_max,faultmask} APIs should not be exposed for the thumbv8m.base-none-eabi target.

As removing an API is a breaking-change (it breaks libraries; the above error only occurs in applications) I would suggest marking the API as deprecated on the thumbv8m.base-none-eabi target and removing it in the next minor version.

This API should not be removed from the thumbv8m.main-none-eabi* targets (note: main, not base) as it is supported on those devices.

Metadata

$ rustc -V
rustc 1.38.0-nightly (cd2cd4c96 2019-07-10)

I also noted that the thumbv8m.base-none-eabi target is not being tested on Travis and that it doesn't have special handing (cargo:rustc-cfg) in the build.rs so there are may be more errors similar to this one in the crate.

JJJollyjim commented 5 years ago

so there are may be more errors similar to this one in the crate

The crate certainly compiles once I configure out the basepri stuff.

As removing an API is a breaking-change (it breaks libraries...

I can certainly vouch that it breaks rtfm :)

korken89 commented 4 years ago

I think this can be closed now, reopen if the issue persists