Skip to content

Revert cortex-m #605

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@1.61
with:
components: clippy
- run: cargo clippy --all --features cortex-m/critical-section-single-core -- --deny warnings
67 changes: 41 additions & 26 deletions cortex-m-semihosting/src/export.rs
Original file line number Diff line number Diff line change
@@ -1,53 +1,68 @@
//! IMPLEMENTATION DETAILS USED BY MACROS

// This must be replaced by a different solution before rust edition 2024
// https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html
#![allow(static_mut_refs)]

use core::cell::RefCell;
use core::fmt::{self, Write};

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

static mut HSTDOUT: Option<HostStream> = None;
static HSTDOUT: critical_section::Mutex<RefCell<Option<HostStream>>> =
critical_section::Mutex::new(RefCell::new(None));

pub fn hstdout_str(s: &str) {
let _result = critical_section::with(|_| unsafe {
if HSTDOUT.is_none() {
HSTDOUT = Some(hio::hstdout()?);
critical_section::with(|cs| {
let mut hstdout_opt = HSTDOUT.borrow_ref_mut(cs);
if hstdout_opt.is_none() {
if let Ok(hstdout) = hio::hstdout() {
hstdout_opt.replace(hstdout);
} else {
return;
}
}

HSTDOUT.as_mut().unwrap().write_str(s).map_err(drop)
let hstdout = hstdout_opt.as_mut().unwrap();
let _ = hstdout.write_str(s);
});
}

pub fn hstdout_fmt(args: fmt::Arguments) {
let _result = critical_section::with(|_| unsafe {
if HSTDOUT.is_none() {
HSTDOUT = Some(hio::hstdout()?);
critical_section::with(|cs| {
let mut hstdout_opt = HSTDOUT.borrow_ref_mut(cs);
if hstdout_opt.is_none() {
if let Ok(hstdout) = hio::hstdout() {
hstdout_opt.replace(hstdout);
} else {
return;
}
}

HSTDOUT.as_mut().unwrap().write_fmt(args).map_err(drop)
let hstdout = hstdout_opt.as_mut().unwrap();
let _ = hstdout.write_fmt(args);
});
}

static mut HSTDERR: Option<HostStream> = None;
static HSTDERR: critical_section::Mutex<RefCell<Option<HostStream>>> =
critical_section::Mutex::new(RefCell::new(None));

pub fn hstderr_str(s: &str) {
let _result = critical_section::with(|_| unsafe {
if HSTDERR.is_none() {
HSTDERR = Some(hio::hstderr()?);
critical_section::with(|cs| {
let mut hstderr_opt = HSTDERR.borrow_ref_mut(cs);
if let Ok(hstderr) = hio::hstderr() {
hstderr_opt.replace(hstderr);
} else {
return;
}

HSTDERR.as_mut().unwrap().write_str(s).map_err(drop)
let hstderr = hstderr_opt.as_mut().unwrap();
let _ = hstderr.write_str(s);
});
}

pub fn hstderr_fmt(args: fmt::Arguments) {
let _result = critical_section::with(|_| unsafe {
if HSTDERR.is_none() {
HSTDERR = Some(hio::hstderr()?);
critical_section::with(|cs| {
let mut hstderr_opt = HSTDERR.borrow_ref_mut(cs);
if let Ok(hstderr) = hio::hstderr() {
hstderr_opt.replace(hstderr);
} else {
return;
}

HSTDERR.as_mut().unwrap().write_fmt(args).map_err(drop)
let hstderr = hstderr_opt.as_mut().unwrap();
let _ = hstderr.write_fmt(args);
});
}
50 changes: 23 additions & 27 deletions cortex-m/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,31 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

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

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

### Added
- Updated `SCB.ICSR.VECTACTIVE`/`SCB::vect_active()` to be 9 bits instead of 8.
Also fixes `VectActive::from` to take a `u16` and subtract `16` for
`VectActive::Interrupt`s to match `SBC::vect_active()` (#373).
- DWT: add `configure` API for address, cycle count comparison (#342, #367).
- ITM: add `configure` API (#342).
- TPIU: add API for *Formatter and Flush Control* (FFCR) and *Selected Pin Control* (SPPR) registers (#342).
- TPIU: add `swo_supports` for checking what SWO configurations the target supports. (#381)
- 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).
- Added the ability to name the statics generated by `singleton!()` for better debuggability (#364, #380).
- 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)
- Added support for `embedded-hal` version 1 delay traits, requiring rust 1.60.
- `singleton!()` now forwards attributes (#522).
- Added `set_sevonpend` and `clear_sevonpend` (#539).
- Add missing documentation for `critical-section-single-core` feature added
in v0.7.6.

### Fixed
- Fixed `singleton!()` statics sometimes ending up in `.data` instead of `.bss` (#364, #380).
- `interrupt::free` no longer hands out a `CriticalSection` token because it is unsound on multi-core. Use `critical_section::with` instead. (#447)
## [v0.7.6] - 2022-08-12

- 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)

## [v0.7.5] - 2022-05-15

### Deprecated
- the `ptr()` function on all peripherals register blocks in favor of
the associated constant `PTR` (#386).

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

### Removed
- removed all peripherals `ptr()` functions in favor of the associated constant `PTR` (#385).
- removed `inline-asm` feature which is now always enabled
- The `inline-asm` feature no longer requires a nightly Rust compiler, but
does require Rust 1.59 or above.

### Fixed
- Fixed `singleton!()` statics sometimes ending up in `.data` instead of `.bss` (#364, #380).
(Backported from upcoming 0.8 release).

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

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

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


## [v0.7.3] - 2021-07-03

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

[Unreleased]: https://github.com/rust-embedded/cortex-m/compare/v0.7.4...HEAD
[Unreleased]: https://github.com/rust-embedded/cortex-m/compare/v0.7.7...HEAD
[v0.7.7]: https://github.com/rust-embedded/cortex-m/compare/v0.7.6...v0.7.7
[v0.7.6]: https://github.com/rust-embedded/cortex-m/compare/v0.7.5...v0.7.6
[v0.7.5]: https://github.com/rust-embedded/cortex-m/compare/v0.7.4...v0.7.5
[v0.7.4]: https://github.com/rust-embedded/cortex-m/compare/v0.7.3...v0.7.4
[v0.7.3]: https://github.com/rust-embedded/cortex-m/compare/v0.7.2...v0.7.3
[v0.7.2]: https://github.com/rust-embedded/cortex-m/compare/v0.7.1...v0.7.2
Expand Down
23 changes: 14 additions & 9 deletions cortex-m/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,34 @@ license = "MIT OR Apache-2.0"
name = "cortex-m"
readme = "README.md"
repository = "https://github.com/rust-embedded/cortex-m"
version = "0.7.4"
edition = "2021"
rust-version = "1.61"
version = "0.7.7"
edition = "2018"
links = "cortex-m" # prevent multiple versions of this crate to be linked together
rust-version = "1.61"

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

[dependencies.serde]
version = "1"
features = [ "derive" ]
optional = true

[dependencies.serde_json]
version = "1"
optional = true

[features]
cm7 = []
cm7-r0p1 = ["cm7"]
inline-asm = []
linker-plugin-lto = []
std = []
critical-section-single-core = ["critical-section/restore-state-u32"]
critical-section-single-core = ["critical-section/restore-state-bool"]

[package.metadata.docs.rs]
targets = [
Expand Down
2 changes: 1 addition & 1 deletion cortex-m/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This project is developed and maintained by the [Cortex-M team][team].

## Minimum Supported Rust Version (MSRV)

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.
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.

## License

Expand Down
1 change: 1 addition & 0 deletions cortex-m/asm-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly-2021-12-16
Loading
Loading