116: v0.4.0 r=japaric a=japaric



Co-authored-by: Jorge Aparicio <jorge@japaric.io>
This commit is contained in:
bors[bot] 2018-12-16 21:05:56 +00:00
commit 3511e915b5
14 changed files with 125 additions and 38 deletions

View file

@ -12,15 +12,15 @@ matrix:
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
- env: TARGET=x86_64-unknown-linux-gnu - env: TARGET=x86_64-unknown-linux-gnu
rust: nightly-2018-12-06 rust: nightly
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
- env: TARGET=thumbv6m-none-eabi - env: TARGET=thumbv6m-none-eabi
rust: nightly-2018-12-06 rust: nightly
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
- env: TARGET=thumbv7m-none-eabi - env: TARGET=thumbv7m-none-eabi
rust: nightly-2018-12-06 rust: nightly
if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master) if: (branch = staging OR branch = trying) OR (type = pull_request AND branch = master)
before_install: set -e before_install: set -e

View file

@ -9,8 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed ### Changed
- This crate now compiles on 1.31-beta and will compile on the stable 1.31 - This crate now compiles on stable 1.31.
release.
- [breaking-change] The `app!` macro has been transformed into an attribute. See - [breaking-change] The `app!` macro has been transformed into an attribute. See
the documentation for details. the documentation for details.

View file

@ -12,7 +12,7 @@ license = "MIT OR Apache-2.0"
name = "cortex-m-rtfm" name = "cortex-m-rtfm"
readme = "README.md" readme = "README.md"
repository = "https://github.com/japaric/cortex-m-rtfm" repository = "https://github.com/japaric/cortex-m-rtfm"
version = "0.4.0-beta.3" version = "0.4.0"
[lib] [lib]
name = "rtfm" name = "rtfm"
@ -36,7 +36,7 @@ required-features = ["timer-queue"]
[dependencies] [dependencies]
cortex-m = "0.5.8" cortex-m = "0.5.8"
cortex-m-rt = "0.6.7" cortex-m-rt = "0.6.7"
cortex-m-rtfm-macros = { path = "macros", version = "0.4.0-beta.3" } cortex-m-rtfm-macros = { path = "macros", version = "0.4.0" }
heapless = "0.4.1" heapless = "0.4.1"
owned-singleton = "0.1.0" owned-singleton = "0.1.0"

View file

@ -2,15 +2,6 @@
A concurrency framework for building real time systems. A concurrency framework for building real time systems.
**IMPORTANT** This crate is currently in pre-release (beta) state . We reserve
the right to make breaking changes in the syntax or to patch memory safety holes
before the v0.4.0 release, which is planned for 2018-12-07. When v0.4.0 is
released *all the pre-releases will be yanked*. If you run into a panic message
or an unhelpful error message (e.g. misleading span), or if something doesn't
behave the way you expect please open [an issue]!
[an issue]: https://github.com/japaric/cortex-m-rtfm/issues
## Features ## Features
- **Tasks** as the unit of concurrency [^1]. Tasks can be *event triggered* - **Tasks** as the unit of concurrency [^1]. Tasks can be *event triggered*
@ -40,7 +31,9 @@ behave the way you expect please open [an issue]!
- **Highly efficient memory usage**: All the tasks share a single call stack and - **Highly efficient memory usage**: All the tasks share a single call stack and
there's no hard dependency on a dynamic memory allocator. there's no hard dependency on a dynamic memory allocator.
- **All Cortex-M devices are fully supported**. - **All Cortex-M devices are supported**. The core features of RTFM are
supported on all Cortex-M devices. The timer queue is currently only supported
on ARMv7-M devices.
- This task model is amenable to known WCET (Worst Case Execution Time) analysis - This task model is amenable to known WCET (Worst Case Execution Time) analysis
and scheduling analysis techniques. (Though we haven't yet developed Rust and scheduling analysis techniques. (Though we haven't yet developed Rust

View file

@ -9,9 +9,9 @@ This is the smallest possible RTFM application:
All RTFM applications use the [`app`] attribute (`#[app(..)]`). This attribute All RTFM applications use the [`app`] attribute (`#[app(..)]`). This attribute
must be applied to a `const` item that contains items. The `app` attribute has must be applied to a `const` item that contains items. The `app` attribute has
a mandatory `device` argument that takes a *path* as a value. This path must a mandatory `device` argument that takes a *path* as a value. This path must
point to a *device* crate generated using [`svd2rust`] **v0.14.x**. The `app` point to a *peripheral access crate* (PAC) generated using [`svd2rust`]
attribute will expand into a suitable entry point so it's not required to use **v0.14.x**. The `app` attribute will expand into a suitable entry point so it's
the [`cortex_m_rt::entry`] attribute. not required to use the [`cortex_m_rt::entry`] attribute.
[`app`]: ../../api/cortex_m_rtfm_macros/attr.app.html [`app`]: ../../api/cortex_m_rtfm_macros/attr.app.html
[`svd2rust`]: https://crates.io/crates/svd2rust [`svd2rust`]: https://crates.io/crates/svd2rust

View file

@ -16,9 +16,9 @@ $ cargo generate \
$ # follow the rest of the instructions $ # follow the rest of the instructions
``` ```
2. Add a device crate that was generated using [`svd2rust`] **v0.14.x**, or a 2. Add a peripheral access crate (PAC) that was generated using [`svd2rust`]
board support crate that depends on one such device crate as a dependency. **v0.14.x**, or a board support crate that depends on one such PAC as a
Make sure that the `rt` feature of the crate is enabled. dependency. Make sure that the `rt` feature of the crate is enabled.
[`svd2rust`]: https://crates.io/crates/svd2rust [`svd2rust`]: https://crates.io/crates/svd2rust
@ -40,7 +40,7 @@ $ rm memory.x build.rs
`timer-queue` feature. `timer-queue` feature.
``` console ``` console
$ cargo add cortex-m-rtfm --allow-prerelease --upgrade=none $ cargo add cortex-m-rtfm
``` ```
4. Write your RTFM application. 4. Write your RTFM application.
@ -49,7 +49,7 @@ Here I'll use the `init` example from the `cortex-m-rtfm` crate.
``` console ``` console
$ curl \ $ curl \
-L https://github.com/japaric/cortex-m-rtfm/raw/v0.4.0-beta.1/examples/init.rs \ -L https://github.com/japaric/cortex-m-rtfm/raw/v0.4.0/examples/init.rs \
> src/main.rs > src/main.rs
``` ```

View file

@ -1,8 +1,16 @@
# Timer queue # Timer queue
When the `timer-queue` feature is enabled the RTFM framework includes a *global When the `timer-queue` feature is enabled the RTFM framework includes a *global
timer queue* that applications can use to *schedule* software tasks to run some timer queue* that applications can use to *schedule* software tasks to run at
time in the future. some time in the future.
> **NOTE**: The timer-queue feature can't be enabled when the target is
> `thumbv6m-none-eabi` because there's no timer queue support for ARMv6-M. This
> may change in the future.
> **NOTE**: When the `timer-queue` feature is enabled you will *not* be able to
> use the `SysTick` exception as a hardware task because the runtime uses it to
> implement the global timer queue.
To be able to schedule a software task the name of the task must appear in the To be able to schedule a software task the name of the task must appear in the
`schedule` argument of the context attribute. When scheduling a task the `schedule` argument of the context attribute. When scheduling a task the

View file

@ -20,6 +20,20 @@ rewrite code. If you consistently use `lock`s to access the data behind shared
resources then your code will continue to compile when you change the priority resources then your code will continue to compile when you change the priority
of tasks. of tasks.
## Conditional compilation
You can use conditional compilation (`#[cfg]`) on resources (`static [mut]`
items) and tasks (`fn` items). The effect of using `#[cfg]` attributes is that
the resource / task will *not* be injected into the prelude of tasks that use
them (see `resources`, `spawn` and `schedule`) if the condition doesn't hold.
The example below logs a message whenever the `foo` task is spawned, but only if
the program has been compiled using the `dev` profile.
``` rust
{{#include ../../../examples/cfg.rs}}
```
## Running tasks from RAM ## Running tasks from RAM
The main goal of moving the specification of RTFM applications to attributes in The main goal of moving the specification of RTFM applications to attributes in

View file

@ -7,6 +7,6 @@
This book contains user level documentation for the Real Time For the Masses This book contains user level documentation for the Real Time For the Masses
(RTFM) framework. The API reference can be found [here](../api/rtfm/index.html). (RTFM) framework. The API reference can be found [here](../api/rtfm/index.html).
{{#include ../../README.md:5:53}} {{#include ../../README.md:5:46}}
{{#include ../../README.md:59:}} {{#include ../../README.md:52:}}

View file

@ -3,6 +3,10 @@ use std::env;
fn main() { fn main() {
let target = env::var("TARGET").unwrap(); let target = env::var("TARGET").unwrap();
if target.starts_with("thumbv6m") {
println!("cargo:rustc-cfg=armv6m")
}
if target.starts_with("thumbv7m") | target.starts_with("thumbv7em") { if target.starts_with("thumbv7m") | target.starts_with("thumbv7em") {
println!("cargo:rustc-cfg=armv7m") println!("cargo:rustc-cfg=armv7m")
} }

View file

@ -12,11 +12,17 @@ main() {
esac esac
cargo check --target $T cargo check --target $T
cargo check --features timer-queue --target $T if [ $TARGET != thumbv6m-none-eabi ]; then
cargo check --features timer-queue --target $T
fi
if [ $TRAVIS_RUST_VERSION = beta ]; then if [ $TRAVIS_RUST_VERSION != nightly ]; then
rm -f .cargo/config rm -f .cargo/config
cargo doc --features timer-queue if [ $TARGET != thumbv6m-none-eabi ]; then
cargo doc --features timer-queue
else
cargo doc
fi
( cd book && mdbook build ) ( cd book && mdbook build )
local td=$(mktemp -d) local td=$(mktemp -d)
@ -33,7 +39,9 @@ main() {
fi fi
cargo check --target $T --examples cargo check --target $T --examples
cargo check --features timer-queue --target $T --examples if [ $TARGET != thumbv6m-none-eabi ]; then
cargo check --features timer-queue --target $T --examples
fi
# run-pass tests # run-pass tests
case $T in case $T in
@ -76,11 +84,13 @@ main() {
diff -u ci/expected/$ex.run - diff -u ci/expected/$ex.run -
fi fi
cargo run --features timer-queue --example $ex --target $T | \ if [ $TARGET != thumbv6m-none-eabi ]; then
diff -u ci/expected/$ex.run - cargo run --features timer-queue --example $ex --target $T | \
diff -u ci/expected/$ex.run -
cargo run --features timer-queue --example $ex --target $T --release | \ cargo run --features timer-queue --example $ex --target $T --release | \
diff -u ci/expected/$ex.run - diff -u ci/expected/$ex.run -
fi
done done
esac esac
} }

54
examples/cfg.rs Normal file
View file

@ -0,0 +1,54 @@
//! examples/cfg.rs
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
extern crate panic_semihosting;
#[cfg(debug_assertions)]
use cortex_m_semihosting::hprintln;
use rtfm::app;
#[app(device = lm3s6965)]
const APP: () = {
#[cfg(debug_assertions)] // <- `true` when using the `dev` profile
static mut COUNT: u32 = 0;
#[init]
fn init() {
// ..
}
#[task(priority = 3, resources = [COUNT], spawn = [log])]
fn foo() {
#[cfg(debug_assertions)]
{
*resources.COUNT += 1;
spawn.log(*resources.COUNT).ok();
}
// this wouldn't compile in `release` mode
// *resources.COUNT += 1;
// ..
}
#[cfg(debug_assertions)]
#[task]
fn log(n: u32) {
hprintln!(
"foo has been called {} time{}",
n,
if n == 1 { "" } else { "s" }
)
.ok();
}
extern "C" {
fn UART0();
fn UART1();
}
};

View file

@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
name = "cortex-m-rtfm-macros" name = "cortex-m-rtfm-macros"
readme = "../README.md" readme = "../README.md"
repository = "https://github.com/japaric/cortex-m-rtfm" repository = "https://github.com/japaric/cortex-m-rtfm"
version = "0.4.0-beta.3" version = "0.4.0"
[lib] [lib]
proc-macro = true proc-macro = true

View file

@ -44,6 +44,11 @@ pub mod export;
#[cfg(feature = "timer-queue")] #[cfg(feature = "timer-queue")]
mod tq; mod tq;
#[cfg(all(feature = "timer-queue", armv6m))]
compile_error!(
"The `timer-queue` feature is currently not supported on ARMv6-M (`thumbv6m-none-eabi`)"
);
/// Core peripherals /// Core peripherals
/// ///
/// This is `cortex_m::Peripherals` minus the peripherals that the RTFM runtime uses /// This is `cortex_m::Peripherals` minus the peripherals that the RTFM runtime uses