diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | CHANGELOG.md | 13 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | book/en/src/by-example/new.md | 2 | ||||
-rw-r--r-- | book/en/src/migration.md | 12 | ||||
-rw-r--r-- | book/en/src/preface.md | 3 | ||||
-rw-r--r-- | book/ru/src/by-example/app.md | 2 | ||||
-rw-r--r-- | ci/install.sh | 12 | ||||
-rw-r--r-- | examples/schedule.rs | 1 | ||||
-rw-r--r-- | src/cyccnt.rs | 10 | ||||
-rw-r--r-- | src/tq.rs | 7 |
12 files changed, 50 insertions, 18 deletions
diff --git a/.travis.yml b/.travis.yml index ac5a7b8a..1bb25051 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,7 +46,7 @@ after_script: set +e after_success: - bash ci/after-success.sh -cache: cache +cache: cargo before_cache: - chmod -R a+r $HOME/.cargo; diff --git a/CHANGELOG.md b/CHANGELOG.md index c96df3c5..f7467040 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,15 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -## v0.5.0 - 2019-11-14 +## [v0.5.1] - 2019-11-19 +- Fixed arithmetic wrapping bug in src/cyccntr.rs + elapsed and duration could cause an internal overflow trap + on subtraction in debug mode. + +- Fixed bug in SysTick implementation where the SysTick could be disabled by + accident + +## [v0.5.0] - 2019-11-14 ### Added @@ -297,7 +305,8 @@ Yanked due to a soundness issue in `init`; the issue has been mostly fixed in v0 - Initial release -[Unreleased]: https://github.com/rtfm-rs/cortex-m-rtfm/compare/v0.5.0...HEAD +[Unreleased]: https://github.com/rtfm-rs/cortex-m-rtfm/compare/v0.5.1...HEAD +[v0.5.1]: https://github.com/rtfm-rs/cortex-m-rtfm/compare/v0.5.0...v0.5.1 [v0.5.0]: https://github.com/rtfm-rs/cortex-m-rtfm/compare/v0.4.3...v0.5.0 [v0.4.3]: https://github.com/rtfm-rs/cortex-m-rtfm/compare/v0.4.2...v0.4.3 [v0.4.2]: https://github.com/rtfm-rs/cortex-m-rtfm/compare/v0.4.1...v0.4.2 @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" name = "cortex-m-rtfm" readme = "README.md" repository = "https://github.com/rtfm-rs/cortex-m-rtfm" -version = "0.5.0" +version = "0.5.1" [lib] name = "rtfm" @@ -45,7 +45,7 @@ A concurrency framework for building real time systems. ## [User documentation](https://rtfm.rs) -## [API reference](https://rtfm.rs/api/rtfm/index.html) +## [API reference](https://rtfm.rs/0.5/api) ## Chat Join us and talk about RTFM in the [Matrix room][matrix-room]. diff --git a/book/en/src/by-example/new.md b/book/en/src/by-example/new.md index 4f132e70..e4f7fd93 100644 --- a/book/en/src/by-example/new.md +++ b/book/en/src/by-example/new.md @@ -48,7 +48,7 @@ Here I'll use the `init` example from the `cortex-m-rtfm` crate. ``` console $ curl \ - -L https://github.com/rtfm-rs/cortex-m-rtfm/raw/v0.5.0-beta.1/examples/init.rs \ + -L https://github.com/rtfm-rs/cortex-m-rtfm/raw/v0.5.0/examples/init.rs \ > src/main.rs ``` diff --git a/book/en/src/migration.md b/book/en/src/migration.md index a71773ee..b1e8aefd 100644 --- a/book/en/src/migration.md +++ b/book/en/src/migration.md @@ -15,7 +15,7 @@ First, the version of the `cortex-m-rtfm` dependency needs to be updated to version = "0.4.3" # into this -version = "0.5.0-beta.1" +version = "0.5.0" # and remove this Cargo feature features = ["timer-queue"] @@ -192,7 +192,9 @@ the `monotonic = rtfm::cyccnt::CYCCNT` argument to the `#[rtfm::app]` attribute. Also, the `Duration` and `Instant` types and the `U32Ext` trait have been moved into the `rtfm::cyccnt` module. This module is only available on ARMv7-M+ -devices. +devices. The removal of the `timer-queue` also brings back the `DWT` peripheral +inside the core peripherals struct, this will need to be enabled by the application +inside `init`. Change this: @@ -217,6 +219,12 @@ use rtfm::cyccnt::{Duration, Instant, U32Ext}; #[rtfm::app(/* .. */, monotonic = rtfm::cyccnt::CYCCNT)] // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ const APP: () = { + #[init] + fn init(cx: init::Context) { + cx.core.DWT.enable_cycle_counter(); + // optional, configure the DWT run without a debugger connected + cx.core.DCB.enable_trace(); + } #[task(schedule = [b])] fn a(cx: a::Context) { // .. diff --git a/book/en/src/preface.md b/book/en/src/preface.md index b2f4980f..e6e7e1d6 100644 --- a/book/en/src/preface.md +++ b/book/en/src/preface.md @@ -14,9 +14,6 @@ There is a translation of this book in [Russian]. This is the documentation of v0.5.x of RTFM; for the documentation of version v0.4.x go [here](/0.4). -**HEADS UP** This is a **beta** pre-release; there may be breaking changes in -the API and semantics before a proper release is made. - {{#include ../../../README.md:5:44}} {{#include ../../../README.md:50:}} diff --git a/book/ru/src/by-example/app.md b/book/ru/src/by-example/app.md index bf8d5746..7dc08127 100644 --- a/book/ru/src/by-example/app.md +++ b/book/ru/src/by-example/app.md @@ -63,7 +63,7 @@ $ cargo run --example init `init`, `idle` запустится *с включенными прерываниями* и не может завершиться, поэтому будет работать бесконечно. -Когда функция `idle` определена, рантайм устанавливает бит [SLEEPONEXIT], после чего +Когда функция `idle` не определена, рантайм устанавливает бит [SLEEPONEXIT], после чего отправляет микроконтроллер в состояние сна после выполнения `init`. [SLEEPONEXIT]: https://developer.arm.com/products/architecture/cpu-architecture/m-profile/docs/100737/0100/power-management/sleep-mode/sleep-on-exit-bit diff --git a/ci/install.sh b/ci/install.sh index aa701205..54701224 100644 --- a/ci/install.sh +++ b/ci/install.sh @@ -1,10 +1,16 @@ set -euxo pipefail +install_crate() { + local pkg=$1 vers=$2 + + cargo install --list | grep "$pkg v$vers" || ( cd .. && cargo install -f --vers $vers $pkg ) +} + main() { # these are not needed for doc builds if [ $TRAVIS_BRANCH != master ] || [ $TRAVIS_PULL_REQUEST != false ]; then if [ $TARGET = x86_64-unknown-linux-gnu ]; then - ( cd .. && cargo install microamp-tools --version 0.1.0-alpha.3 -f ) + install_crate microamp-tools 0.1.0-alpha.3 rustup target add thumbv6m-none-eabi thumbv7m-none-eabi fi @@ -17,9 +23,7 @@ main() { pip install linkchecker --user fi - # install mdbook - curl -LSfs https://japaric.github.io/trust/install.sh | \ - sh -s -- --git rust-lang-nursery/mdbook --tag v0.3.1 + install_crate mdbook 0.3.1 } main diff --git a/examples/schedule.rs b/examples/schedule.rs index 8dbe4ab8..d5de9dbf 100644 --- a/examples/schedule.rs +++ b/examples/schedule.rs @@ -22,6 +22,7 @@ const APP: () = { cx.core.DWT.enable_cycle_counter(); // semantically, the monotonic timer is frozen at time "zero" during `init` + // NOTE do *not* call `Instant::now` in this context; it will return a nonsense value let now = cx.start; // the start time of the system hprintln!("init @ {:?}", now).unwrap(); diff --git a/src/cyccnt.rs b/src/cyccnt.rs index 86969cb1..6bc2ef0a 100644 --- a/src/cyccnt.rs +++ b/src/cyccnt.rs @@ -30,6 +30,10 @@ pub struct Instant { impl Instant { /// Returns an instant corresponding to "now" + /// + /// *HEADS UP* this function can, and will, return nonsensical values if called within `init`. + /// Only use it in `idle` and tasks. In `init`, use the `init::Context.start` field, or the + /// `CYCCNT::zero` function, instead of this function pub fn now() -> Self { Instant { inner: DWT::get_cycle_count() as i32, @@ -38,12 +42,14 @@ impl Instant { /// Returns the amount of time elapsed since this instant was created. pub fn elapsed(&self) -> Duration { - Instant::now() - *self + let diff = Instant::now().inner.wrapping_sub(self.inner); + assert!(diff >= 0, "instant now is earlier than self"); + Duration { inner: diff as u32 } } /// Returns the amount of time elapsed from another instant to this one. pub fn duration_since(&self, earlier: Instant) -> Duration { - let diff = self.inner - earlier.inner; + let diff = self.inner.wrapping_sub(earlier.inner); assert!(diff >= 0, "second instant is later than self"); Duration { inner: diff as u32 } } @@ -68,6 +68,13 @@ where .map(|x| x / ratio.denominator) }) { None => MAX, + + // ARM Architecture Reference Manual says: + // "Setting SYST_RVR to zero has the effect of + // disabling the SysTick counter independently + // of the counter enable bit." + Some(0) => 1, + Some(x) => cmp::min(MAX, x), }; mem::transmute::<_, SYST>(()).set_reload(dur); |