Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit 1cd2044

Browse files
bors[bot]thejpster
andcommitted
Merge #182
182: Add thumbv8m.main support. r=korken89 a=thejpster * Add thumbv8m.main support. * Also adds feature flags into build.rs so SecureFault gets included. Co-authored-by: Jonathan 'theJPster' Pallant <[email protected]>
2 parents 3bf85b9 + 5027cea commit 1cd2044

11 files changed

+60
-17
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ matrix:
2222
rust: stable
2323
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
2424

25+
- env: TARGET=thumbv8m.main-none-eabi
26+
rust: stable
27+
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
28+
2529
- env: TARGET=x86_64-unknown-linux-gnu
2630
rust: nightly
2731
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
@@ -42,6 +46,10 @@ matrix:
4246
rust: nightly
4347
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
4448

49+
- env: TARGET=thumbv8m.main-none-eabi
50+
rust: nightly
51+
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
52+
4553
before_install: set -e
4654

4755
install:

Cargo.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,21 @@ autoexamples = true
1919
r0 = "0.2.2"
2020
cortex-m-rt-macros = { path = "macros", version = "0.1.5" }
2121

22+
[target.thumbv7em-none-eabihf.dev-dependencies]
23+
cortex-m-semihosting = "0.3.1"
24+
25+
[target.thumbv7em-none-eabi.dev-dependencies]
26+
cortex-m-semihosting = "0.3.1"
27+
28+
[target.thumbv7m-none-eabi.dev-dependencies]
29+
cortex-m-semihosting = "0.3.1"
30+
31+
[target.thumbv6m-none-eabi.dev-dependencies]
32+
cortex-m-semihosting = "0.3.1"
33+
2234
[dev-dependencies]
23-
cortex-m = ">= 0.5.7, <0.7"
35+
cortex-m = "0.6"
2436
panic-halt = "0.2.0"
25-
cortex-m-semihosting = "0.3.1"
2637

2738
[dev-dependencies.rand]
2839
default-features = false

assemble.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ ar crs bin/thumbv7em-none-eabihf.a bin/$crate.o
2222
arm-none-eabi-as -march=armv8-m.base asm.s -o bin/$crate.o
2323
ar crs bin/thumbv8m.base-none-eabi.a bin/$crate.o
2424

25+
arm-none-eabi-as -march=armv8-m.main asm.s -o bin/$crate.o
26+
ar crs bin/thumbv8m.main-none-eabi.a bin/$crate.o
27+
2528
rm bin/$crate.o

bin/thumbv6m-none-eabi.a

0 Bytes
Binary file not shown.

bin/thumbv7em-none-eabi.a

0 Bytes
Binary file not shown.

bin/thumbv7em-none-eabihf.a

0 Bytes
Binary file not shown.

bin/thumbv7m-none-eabi.a

0 Bytes
Binary file not shown.

bin/thumbv8m.base-none-eabi.a

0 Bytes
Binary file not shown.

bin/thumbv8m.main-none-eabi.a

944 Bytes
Binary file not shown.

build.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ fn main() {
88
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
99

1010
has_fpu(&target);
11-
let is_armv6m = is_armv6m(&target);
1211

1312
if target.starts_with("thumbv") {
1413
fs::copy(
@@ -43,7 +42,23 @@ INCLUDE device.x"#
4342
f
4443
};
4544

46-
let max_int_handlers = if is_armv6m { 32 } else { 240 };
45+
let max_int_handlers = if target.starts_with("thumbv6m-") {
46+
println!("cargo:rustc-cfg=cortex_m");
47+
println!("cargo:rustc-cfg=armv6m");
48+
32
49+
} else if target.starts_with("thumbv7m-") || target.starts_with("thumbv7em-") {
50+
println!("cargo:rustc-cfg=cortex_m");
51+
println!("cargo:rustc-cfg=armv7m");
52+
240
53+
} else if target.starts_with("thumbv8m") {
54+
println!("cargo:rustc-cfg=cortex_m");
55+
println!("cargo:rustc-cfg=armv8m");
56+
240
57+
} else {
58+
// Non ARM target. We assume you're just testing the syntax.
59+
// This value seems as soon as any
60+
240
61+
};
4762

4863
// checking the size of the interrupts portion of the vector table is sub-architecture dependent
4964
writeln!(
@@ -58,6 +73,10 @@ handlers.");
5873
max_int_handlers
5974
).unwrap();
6075

76+
if target.ends_with("-eabihf") {
77+
println!("cargo:rustc-cfg=has_fpu");
78+
}
79+
6180
println!("cargo:rustc-link-search={}", out.display());
6281

6382
println!("cargo:rerun-if-changed=build.rs");
@@ -69,12 +88,3 @@ fn has_fpu(target: &str) {
6988
println!("cargo:rustc-cfg=has_fpu");
7089
}
7190
}
72-
73-
fn is_armv6m(target: &str) -> bool {
74-
if target.starts_with("thumbv6m-") {
75-
println!("cargo:rustc-cfg=armv6m");
76-
true
77-
} else {
78-
false
79-
}
80-
}

examples/qemu.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,39 @@
22
#![no_main]
33
#![no_std]
44

5-
extern crate cortex_m;
65

6+
extern crate cortex_m;
77
extern crate cortex_m_rt as rt;
8+
9+
#[cfg(not(armv8m))]
810
extern crate cortex_m_semihosting as semihosting;
11+
912
extern crate panic_halt;
1013

11-
use core::fmt::Write;
1214
use cortex_m::asm;
1315
use rt::entry;
1416

17+
#[cfg(not(armv8m))]
1518
#[entry]
1619
fn main() -> ! {
20+
use core::fmt::Write;
1721
let x = 42;
1822

1923
loop {
2024
asm::nop();
2125

2226
// write something through semihosting interface
2327
let mut hstdout = semihosting::hio::hstdout().unwrap();
24-
write!(hstdout, "x = {}\n", x);
25-
28+
write!(hstdout, "x = {}\n", x).unwrap();
2629
// exit from qemu
2730
semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS);
2831
}
2932
}
33+
34+
#[cfg(armv8m)]
35+
#[entry]
36+
fn main() -> ! {
37+
loop {
38+
asm::nop();
39+
}
40+
}

0 commit comments

Comments
 (0)