Skip to content

Commit 9632980

Browse files
authored
Merge pull request #605 from thejpster/revert-cortex-m
Revert cortex-m
2 parents 6d566b2 + 9ce7820 commit 9632980

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1328
-1235
lines changed

.github/workflows/clippy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4
15-
- uses: dtolnay/rust-toolchain@stable
15+
- uses: dtolnay/rust-toolchain@1.61
1616
with:
1717
components: clippy
1818
- run: cargo clippy --all --features cortex-m/critical-section-single-core -- --deny warnings

cortex-m-semihosting/src/export.rs

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,68 @@
11
//! IMPLEMENTATION DETAILS USED BY MACROS
22
3-
// This must be replaced by a different solution before rust edition 2024
4-
// https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html
5-
#![allow(static_mut_refs)]
6-
3+
use core::cell::RefCell;
74
use core::fmt::{self, Write};
85

96
use crate::hio::{self, HostStream};
107

11-
static mut HSTDOUT: Option<HostStream> = None;
8+
static HSTDOUT: critical_section::Mutex<RefCell<Option<HostStream>>> =
9+
critical_section::Mutex::new(RefCell::new(None));
1210

1311
pub fn hstdout_str(s: &str) {
14-
let _result = critical_section::with(|_| unsafe {
15-
if HSTDOUT.is_none() {
16-
HSTDOUT = Some(hio::hstdout()?);
12+
critical_section::with(|cs| {
13+
let mut hstdout_opt = HSTDOUT.borrow_ref_mut(cs);
14+
if hstdout_opt.is_none() {
15+
if let Ok(hstdout) = hio::hstdout() {
16+
hstdout_opt.replace(hstdout);
17+
} else {
18+
return;
19+
}
1720
}
18-
19-
HSTDOUT.as_mut().unwrap().write_str(s).map_err(drop)
21+
let hstdout = hstdout_opt.as_mut().unwrap();
22+
let _ = hstdout.write_str(s);
2023
});
2124
}
2225

2326
pub fn hstdout_fmt(args: fmt::Arguments) {
24-
let _result = critical_section::with(|_| unsafe {
25-
if HSTDOUT.is_none() {
26-
HSTDOUT = Some(hio::hstdout()?);
27+
critical_section::with(|cs| {
28+
let mut hstdout_opt = HSTDOUT.borrow_ref_mut(cs);
29+
if hstdout_opt.is_none() {
30+
if let Ok(hstdout) = hio::hstdout() {
31+
hstdout_opt.replace(hstdout);
32+
} else {
33+
return;
34+
}
2735
}
28-
29-
HSTDOUT.as_mut().unwrap().write_fmt(args).map_err(drop)
36+
let hstdout = hstdout_opt.as_mut().unwrap();
37+
let _ = hstdout.write_fmt(args);
3038
});
3139
}
3240

33-
static mut HSTDERR: Option<HostStream> = None;
41+
static HSTDERR: critical_section::Mutex<RefCell<Option<HostStream>>> =
42+
critical_section::Mutex::new(RefCell::new(None));
3443

3544
pub fn hstderr_str(s: &str) {
36-
let _result = critical_section::with(|_| unsafe {
37-
if HSTDERR.is_none() {
38-
HSTDERR = Some(hio::hstderr()?);
45+
critical_section::with(|cs| {
46+
let mut hstderr_opt = HSTDERR.borrow_ref_mut(cs);
47+
if let Ok(hstderr) = hio::hstderr() {
48+
hstderr_opt.replace(hstderr);
49+
} else {
50+
return;
3951
}
40-
41-
HSTDERR.as_mut().unwrap().write_str(s).map_err(drop)
52+
let hstderr = hstderr_opt.as_mut().unwrap();
53+
let _ = hstderr.write_str(s);
4254
});
4355
}
4456

4557
pub fn hstderr_fmt(args: fmt::Arguments) {
46-
let _result = critical_section::with(|_| unsafe {
47-
if HSTDERR.is_none() {
48-
HSTDERR = Some(hio::hstderr()?);
58+
critical_section::with(|cs| {
59+
let mut hstderr_opt = HSTDERR.borrow_ref_mut(cs);
60+
if let Ok(hstderr) = hio::hstderr() {
61+
hstderr_opt.replace(hstderr);
62+
} else {
63+
return;
4964
}
50-
51-
HSTDERR.as_mut().unwrap().write_fmt(args).map_err(drop)
65+
let hstderr = hstderr_opt.as_mut().unwrap();
66+
let _ = hstderr.write_fmt(args);
5267
});
5368
}

cortex-m/CHANGELOG.md

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,31 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
### Breaking changes
10+
- MSRV is 1.61 to match cortex-m-rt crate
1111

12-
- `NVIC::request()` no longer requires `&mut self`.
13-
- `embedded-hal` version 0.2 delay implementations now required the `eh0` feature.
12+
## [v0.7.7] - 2023-01-03
1413

15-
### Added
16-
- Updated `SCB.ICSR.VECTACTIVE`/`SCB::vect_active()` to be 9 bits instead of 8.
17-
Also fixes `VectActive::from` to take a `u16` and subtract `16` for
18-
`VectActive::Interrupt`s to match `SBC::vect_active()` (#373).
19-
- DWT: add `configure` API for address, cycle count comparison (#342, #367).
20-
- ITM: add `configure` API (#342).
21-
- TPIU: add API for *Formatter and Flush Control* (FFCR) and *Selected Pin Control* (SPPR) registers (#342).
22-
- TPIU: add `swo_supports` for checking what SWO configurations the target supports. (#381)
23-
- Add `std` and `serde` crate features for improved host-side ITM decode functionality when working with the downstream `itm`, `cargo-rtic-scope` crates (#363, #366).
24-
- Added the ability to name the statics generated by `singleton!()` for better debuggability (#364, #380).
25-
- Added `critical-section-single-core` feature which provides an implementation for the `critical_section` crate for single-core systems, based on disabling all interrupts. (#447)
26-
- Added support for `embedded-hal` version 1 delay traits, requiring rust 1.60.
27-
- `singleton!()` now forwards attributes (#522).
28-
- Added `set_sevonpend` and `clear_sevonpend` (#539).
14+
- Add missing documentation for `critical-section-single-core` feature added
15+
in v0.7.6.
2916

30-
### Fixed
31-
- Fixed `singleton!()` statics sometimes ending up in `.data` instead of `.bss` (#364, #380).
32-
- `interrupt::free` no longer hands out a `CriticalSection` token because it is unsound on multi-core. Use `critical_section::with` instead. (#447)
17+
## [v0.7.6] - 2022-08-12
18+
19+
- Added `critical-section-single-core` feature which provides an implementation for the `critical-section` crate for single-core systems, based on disabling all interrupts. (#448)
20+
21+
## [v0.7.5] - 2022-05-15
22+
23+
### Deprecated
24+
- the `ptr()` function on all peripherals register blocks in favor of
25+
the associated constant `PTR` (#386).
3326

3427
### Changed
35-
- Inline assembly is now always used, requiring Rust 1.59.
36-
- Bumped MSRV to 1.61 for compatibility with syn versions >=2.0.68.
3728

38-
### Removed
39-
- removed all peripherals `ptr()` functions in favor of the associated constant `PTR` (#385).
40-
- removed `inline-asm` feature which is now always enabled
29+
- The `inline-asm` feature no longer requires a nightly Rust compiler, but
30+
does require Rust 1.59 or above.
31+
32+
### Fixed
33+
- Fixed `singleton!()` statics sometimes ending up in `.data` instead of `.bss` (#364, #380).
34+
(Backported from upcoming 0.8 release).
4135

4236
## [v0.7.4] - 2021-12-31
4337

@@ -70,7 +64,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
7064

7165
[C-GETTER]: https://rust-lang.github.io/api-guidelines/naming.html#c-getter
7266

73-
7467
## [v0.7.3] - 2021-07-03
7568

7669
### Fixed
@@ -764,7 +757,10 @@ fn main() {
764757
- Functions to get the vector table
765758
- Wrappers over miscellaneous instructions like `bkpt`
766759

767-
[Unreleased]: https://github.com/rust-embedded/cortex-m/compare/v0.7.4...HEAD
760+
[Unreleased]: https://github.com/rust-embedded/cortex-m/compare/v0.7.7...HEAD
761+
[v0.7.7]: https://github.com/rust-embedded/cortex-m/compare/v0.7.6...v0.7.7
762+
[v0.7.6]: https://github.com/rust-embedded/cortex-m/compare/v0.7.5...v0.7.6
763+
[v0.7.5]: https://github.com/rust-embedded/cortex-m/compare/v0.7.4...v0.7.5
768764
[v0.7.4]: https://github.com/rust-embedded/cortex-m/compare/v0.7.3...v0.7.4
769765
[v0.7.3]: https://github.com/rust-embedded/cortex-m/compare/v0.7.2...v0.7.3
770766
[v0.7.2]: https://github.com/rust-embedded/cortex-m/compare/v0.7.1...v0.7.2

cortex-m/Cargo.toml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,34 @@ license = "MIT OR Apache-2.0"
1111
name = "cortex-m"
1212
readme = "README.md"
1313
repository = "https://github.com/rust-embedded/cortex-m"
14-
version = "0.7.4"
15-
edition = "2021"
16-
rust-version = "1.61"
14+
version = "0.7.7"
15+
edition = "2018"
1716
links = "cortex-m" # prevent multiple versions of this crate to be linked together
17+
rust-version = "1.61"
1818

1919
[dependencies]
20-
critical-section = "1.0.0"
21-
volatile-register = "0.2.2"
22-
bitfield = "0.15.0"
23-
eh0 = { package = "embedded-hal", version = "0.2.4", optional = true }
24-
eh1 = { package = "embedded-hal", version = "1.0.0" }
20+
bare-metal = { version = "0.2.4", features = ["const-fn"] }
21+
critical-section = { version = "1.0.0", optional = true }
22+
volatile-register = "0.2.0"
23+
bitfield = "0.13.2"
24+
embedded-hal = "0.2.4"
2525

2626
[dependencies.serde]
2727
version = "1"
2828
features = [ "derive" ]
2929
optional = true
3030

31+
[dependencies.serde_json]
32+
version = "1"
33+
optional = true
34+
3135
[features]
3236
cm7 = []
3337
cm7-r0p1 = ["cm7"]
38+
inline-asm = []
3439
linker-plugin-lto = []
3540
std = []
36-
critical-section-single-core = ["critical-section/restore-state-u32"]
41+
critical-section-single-core = ["critical-section/restore-state-bool"]
3742

3843
[package.metadata.docs.rs]
3944
targets = [

cortex-m/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This project is developed and maintained by the [Cortex-M team][team].
1111

1212
## Minimum Supported Rust Version (MSRV)
1313

14-
This crate is guaranteed to compile on stable Rust 1.61.0 and up. It might compile with older versions but that may change in any new patch release.
14+
This crate is guaranteed to compile on stable Rust 1.61 and up. It might compile with older versions but that may change in any new patch release.
1515

1616
## License
1717

cortex-m/asm-toolchain

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nightly-2021-12-16

0 commit comments

Comments
 (0)