Skip to content

make compilable on stable #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 11, 2018
49 changes: 48 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,62 @@ language: rust
matrix:
include:
- env: TARGET=x86_64-unknown-linux-gnu
rust: nightly

- env: TARGET=thumbv6m-none-eabi
rust: beta
addons:
apt:
packages:
- gcc-arm-none-eabi

- env: TARGET=thumbv7m-none-eabi
rust: beta
addons:
apt:
packages:
- gcc-arm-none-eabi

- env: TARGET=thumbv7em-none-eabi
rust: beta
addons:
apt:
packages:
- gcc-arm-none-eabi

- env: TARGET=thumbv7em-none-eabihf
rust: beta
addons:
apt:
packages:
- gcc-arm-none-eabi

- env: TARGET=thumbv6m-none-eabi
rust: nightly
addons:
apt:
packages:
- gcc-arm-none-eabi

- env: TARGET=thumbv7m-none-eabi
rust: nightly
addons:
apt:
packages:
- gcc-arm-none-eabi

- env: TARGET=thumbv7em-none-eabi
rust: nightly
addons:
apt:
packages:
- gcc-arm-none-eabi

- env: TARGET=thumbv7em-none-eabihf
rust: nightly
addons:
apt:
packages:
- gcc-arm-none-eabi

before_install: set -e

Expand Down
45 changes: 44 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,50 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
## [v0.5.0] - 2018-05-11

### Added

- `DebugMonitor` and `SecureFault` variants to the `Exception` enumeration.

- An optional `"inline-asm"` feature

### Changed

- [breaking-change] This crate now requires `arm-none-eabi-gcc` to be installed and available in
`$PATH` when built with the `"inline-asm"` feature disabled (which is disabled by default).

- [breaking-change] The `register::{apsr,lr,pc}` modules are now behind the `"inline-asm"` feature.

- [breaking-change] Some variants of the `Exception` enumeration are no longer available on
`thumbv6m-none-eabi`. See API docs for details.

- [breaking-change] Several of the variants of the `Exception` enumeration have been renamed to
match the CMSIS specification.

- [breaking-change] fixed typo in `shcrs` field of `scb::RegisterBlock`; it was previously named
`shpcrs`.

- [breaking-change] removed several fields from `scb::RegisterBlock` on ARMv6-M. These registers are
not available on that sub-architecture.

- [breaking-change] changed the type of `scb::RegisterBlock.shpr` from `RW<u8>` to `RW<u32>` on
ARMv6-M. These registers are word accessible only on that sub-architecture.

- [breaking-change] renamed the `mmar` field of `scb::RegisterBlock` to `mmfar` to match the CMSIS
name.

- [breaking-change] removed the `iabr` field from `scb::RegisterBlock` on ARMv6-M. This register is
not available on that sub-architecture.

- [breaking-change] removed several fields from `cpuid::RegisterBlock` on ARMv6-M. These registers
are not available on that sub-architecture.

### Removed

- [breaking-change] The `exception` module has been removed. A replacement for `Exception::active`
can be found in `SCB::vect_active`. A modified version `exception::Exception` can be found in the
`peripheral::scb` module.

## [v0.4.3] - 2018-01-25

Expand Down
11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ keywords = ["arm", "cortex-m", "register", "peripheral"]
license = "MIT OR Apache-2.0"
name = "cortex-m"
repository = "https://github.com/japaric/cortex-m"
version = "0.4.3"
version = "0.5.0"

[build-dependencies]
cc = "1.0.10"

[dependencies]
aligned = "0.1.1"
bare-metal = "0.1.0"
aligned = "0.2.0"
bare-metal = "0.2.0"
volatile-register = "0.2.0"
untagged-option = "0.1.1"

[features]
cm7-r0p1 = []
inline-asm = []
11 changes: 11 additions & 0 deletions asm/basepri_max-cm7-r0p1.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.global __basepri_max
.syntax unified
__basepri_max:
mrs r1, PRIMASK
cpsid i
tst.w r1, #1
msr BASEPRI_MAX, r0
it ne
bxne lr
cpsie i
bx lr
4 changes: 4 additions & 0 deletions asm/basepri_max.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __basepri_max
__basepri_max:
msr BASEPRI_MAX, r0
bx lr
4 changes: 4 additions & 0 deletions asm/basepri_r.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __basepri_r
__basepri_r:
mrs r0, BASEPRI
bx lr
11 changes: 11 additions & 0 deletions asm/basepri_w-cm7-r0p1.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.global __basepri_w
.syntax unified
__basepri_w:
mrs r1, PRIMASK
cpsid i
tst.w r1, #1
msr BASEPRI, r0
it ne
bxne lr
cpsie i
bx lr
4 changes: 4 additions & 0 deletions asm/basepri_w.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __basepri_w
__basepri_w:
msr BASEPRI, r0
bx lr
4 changes: 4 additions & 0 deletions asm/bkpt.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __bkpt
__bkpt:
bkpt
bx lr
4 changes: 4 additions & 0 deletions asm/control.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __control
__control:
mrs r0, CONTROL
bx lr
4 changes: 4 additions & 0 deletions asm/cpsid.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __cpsid
__cpsid:
cpsid i
bx lr
4 changes: 4 additions & 0 deletions asm/cpsie.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __cpsie
__cpsie:
cpsie i
bx lr
4 changes: 4 additions & 0 deletions asm/dmb.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __dmb
__dmb:
dmb 0xF
bx lr
4 changes: 4 additions & 0 deletions asm/dsb.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __dsb
__dsb:
dsb 0xF
bx lr
4 changes: 4 additions & 0 deletions asm/faultmask.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __faultmask
__faultmask:
mrs r0, FAULTMASK
bx lr
4 changes: 4 additions & 0 deletions asm/isb.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __isb
__isb:
isb 0xF
bx lr
4 changes: 4 additions & 0 deletions asm/msp_r.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __msp_r
__msp_r:
mrs r0, MSP
bx lr
4 changes: 4 additions & 0 deletions asm/msp_w.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __msp_w
__msp_w:
msr MSP, r0
bx lr
3 changes: 3 additions & 0 deletions asm/nop.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.global __nop
__nop:
bx lr
4 changes: 4 additions & 0 deletions asm/primask.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __primask
__primask:
mrs r0, PRIMASK
bx lr
4 changes: 4 additions & 0 deletions asm/psp_r.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __psp_r
__psp_r:
mrs r0, PSP
bx lr
4 changes: 4 additions & 0 deletions asm/psp_w.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __psp_w
__psp_w:
msr PSP, r0
bx lr
4 changes: 4 additions & 0 deletions asm/sev.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __sev
__sev:
sev
bx lr
4 changes: 4 additions & 0 deletions asm/wfe.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __wfe
__wfe:
wfe
bx lr
4 changes: 4 additions & 0 deletions asm/wfi.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.global __wfi
__wfi:
wfi
bx lr
42 changes: 41 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,58 @@
extern crate cc;

use std::env;

fn main() {
let target = env::var("TARGET").unwrap();

if target.starts_with("thumb") && env::var_os("CARGO_FEATURE_INLINE_ASM").is_none() {
// NOTE we need to place each routine in a separate assembly file or the linker won't be
// able to discard the unused routines
let mut build = cc::Build::new();
build
.file("asm/basepri_r.s")
.file("asm/bkpt.s")
.file("asm/control.s")
.file("asm/cpsid.s")
.file("asm/cpsie.s")
.file("asm/dmb.s")
.file("asm/dsb.s")
.file("asm/faultmask.s")
.file("asm/isb.s")
.file("asm/msp_r.s")
.file("asm/msp_w.s")
.file("asm/nop.s")
.file("asm/primask.s")
.file("asm/psp_r.s")
.file("asm/psp_w.s")
.file("asm/sev.s")
.file("asm/wfe.s")
.file("asm/wfi.s");

if env::var_os("CARGO_FEATURE_CM7_R0P1").is_some() {
build.file("asm/basepri_max-cm7-r0p1.s");
build.file("asm/basepri_w-cm7-r0p1.s");
} else {
build.file("asm/basepri_max.s");
build.file("asm/basepri_w.s");
}

build.compile("asm");
}

if target.starts_with("thumbv6m-") {
println!("cargo:rustc-cfg=cortex_m");
println!("cargo:rustc-cfg=armv6m");
} else if target.starts_with("thumbv7m-") {
println!("cargo:rustc-cfg=cortex_m");
println!("cargo:rustc-cfg=armv7m");
} else if target.starts_with("thumbv7em-") {
println!("cargo:rustc-cfg=cortex_m");
println!("cargo:rustc-cfg=armv7m");
//println!("cargo:rustc-cfg=armv7em");
}

if target.ends_with("eabihf") {
if target.ends_with("-eabihf") {
println!("cargo:rustc-cfg=has_fpu");
}
}
16 changes: 13 additions & 3 deletions ci/script.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
set -euxo pipefail

main() {
cargo check --target $TARGET

if [ $TRAVIS_RUST_VERSION = nightly ]; then
cargo check --target $TARGET --features inline-asm
fi

case $TARGET in
thumbv7em-none-eabi*)
cargo check --target $TARGET --features cm7-r0p1
cargo check --target $TARGET

if [ $TRAVIS_RUST_VERSION = nightly ]; then
cargo check --target $TARGET --features 'cm7-r0p1 inline-asm'
fi
;;

thumbv*-none-eabi*)
cargo check --target $TARGET
;;
*)

x86_64-unknown-linux-gnu)
cargo test --target $TARGET
;;
esac
Expand Down
Loading