From aa6baafa568b08a77a31c17c078a6166d16a2ee9 Mon Sep 17 00:00:00 2001 From: Per Lindgren Date: Wed, 1 Feb 2023 21:21:31 +0100 Subject: [PATCH] book remove ramfunc, remove migration --- book/en/src/SUMMARY.md | 6 ++-- book/en/src/by-example/tips_from_ram.md | 33 ++++++++++--------- .../src/by-example/tips_static_lifetimes.md | 15 ++++----- book/en/src/by-example/tips_view_code.md | 25 +++++++------- 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/book/en/src/SUMMARY.md b/book/en/src/SUMMARY.md index 28c986290b..65c72c42e4 100644 --- a/book/en/src/SUMMARY.md +++ b/book/en/src/SUMMARY.md @@ -19,15 +19,15 @@ - [Avoid copies when message passing](./by-example/tips_indirection.md) - [`'static` super-powers](./by-example/tips_static_lifetimes.md) - [Inspecting generated code](./by-example/tips_view_code.md) - - [Running tasks from RAM](./by-example/tips_from_ram.md) + - [RTIC vs. the world](./rtic_vs.md) - [Awesome RTIC examples](./awesome_rtic.md) -- [Migration Guides](./migration.md) + diff --git a/book/en/src/by-example/tips_from_ram.md b/book/en/src/by-example/tips_from_ram.md index fc47803f9d..f6b2173186 100644 --- a/book/en/src/by-example/tips_from_ram.md +++ b/book/en/src/by-example/tips_from_ram.md @@ -1,33 +1,28 @@ # Running tasks from RAM -The main goal of moving the specification of RTIC applications to attributes in -RTIC v0.4.0 was to allow inter-operation with other attributes. For example, the -`link_section` attribute can be applied to tasks to place them in RAM; this can +The main goal of moving the specification of RTIC applications to attributes in RTIC v0.4.0 was to allow inter-operation with other attributes. For example, the `link_section` attribute can be applied to tasks to place them in RAM; this can improve performance in some cases. -> **IMPORTANT**: In general, the `link_section`, `export_name` and `no_mangle` -> attributes are powerful but also easy to misuse. Incorrectly using any of -> these attributes can cause undefined behavior; you should always prefer to use -> safe, higher level attributes around them like `cortex-m-rt`'s `interrupt` and -> `exception` attributes. +> **IMPORTANT**: In general, the `link_section`, `export_name` and `no_mangle` attributes are powerful but also easy to misuse. Incorrectly using any of these attributes can cause undefined behavior; you should always prefer to use safe, higher level attributes around them like `cortex-m-rt`'s `interrupt` and `exception` attributes. > -> In the particular case of RAM functions there's no -> safe abstraction for it in `cortex-m-rt` v0.6.5 but there's an [RFC] for -> adding a `ramfunc` attribute in a future release. +> In the particular case of RAM functions there's no safe abstraction for it in `cortex-m-rt` v0.6.5 but there's an [RFC] for adding a `ramfunc` attribute in a future release. [RFC]: https://github.com/rust-embedded/cortex-m-rt/pull/100 The example below shows how to place the higher priority task, `bar`, in RAM. ``` rust -{{#include ../../../../examples/ramfunc.rs}} +{{#include ../../../../rtic/examples/ramfunc.rs}} ``` Running this program produces the expected output. ``` console $ cargo run --target thumbv7m-none-eabi --example ramfunc -{{#include ../../../../ci/expected/ramfunc.run}} +``` + +``` console +{{#include ../../../../rtic/ci/expected/ramfunc.run}} ``` One can look at the output of `cargo-nm` to confirm that `bar` ended in RAM @@ -35,10 +30,16 @@ One can look at the output of `cargo-nm` to confirm that `bar` ended in RAM ``` console $ cargo nm --example ramfunc --release | grep ' foo::' -{{#include ../../../../ci/expected/ramfunc.run.grep.foo}} ``` ``` console -$ cargo nm --example ramfunc --release | grep ' bar::' -{{#include ../../../../ci/expected/ramfunc.run.grep.bar}} +{{#include ../../../../rtic/ci/expected/ramfunc.run.grep.foo}} +``` + +``` console +$ cargo nm --example ramfunc --target thumbv7m-none-eabi --release | grep '*bar::' +``` + +``` console +{{#include ../../../../rtic/ci/expected/ramfunc.run.grep.bar}} ``` diff --git a/book/en/src/by-example/tips_static_lifetimes.md b/book/en/src/by-example/tips_static_lifetimes.md index dadd9c9461..0eaa59f46b 100644 --- a/book/en/src/by-example/tips_static_lifetimes.md +++ b/book/en/src/by-example/tips_static_lifetimes.md @@ -2,23 +2,22 @@ In `#[init]` and `#[idle]` `local` resources have `'static` lifetime. -Useful when pre-allocating and/or splitting resources between tasks, drivers -or some other object. -This comes in handy when drivers, such as USB drivers, need to allocate memory and -when using splittable data structures such as [`heapless::spsc::Queue`]. +Useful when pre-allocating and/or splitting resources between tasks, drivers or some other object. This comes in handy when drivers, such as USB drivers, need to allocate memory and when using splittable data structures such as [`heapless::spsc::Queue`]. -In the following example two different tasks share a [`heapless::spsc::Queue`] -for lock-free access to the shared queue. +In the following example two different tasks share a [`heapless::spsc::Queue`] for lock-free access to the shared queue. [`heapless::spsc::Queue`]: https://docs.rs/heapless/0.7.5/heapless/spsc/struct.Queue.html ``` rust -{{#include ../../../../examples/static.rs}} +{{#include ../../../../rtic/examples/static.rs}} ``` Running this program produces the expected output. ``` console $ cargo run --target thumbv7m-none-eabi --example static -{{#include ../../../../ci/expected/static.run}} +``` + +``` console +{{#include ../../../../rtic/ci/expected/static.run}} ``` diff --git a/book/en/src/by-example/tips_view_code.md b/book/en/src/by-example/tips_view_code.md index 736b7ac895..b4a9066be9 100644 --- a/book/en/src/by-example/tips_view_code.md +++ b/book/en/src/by-example/tips_view_code.md @@ -1,21 +1,19 @@ # Inspecting generated code -`#[rtic::app]` is a procedural macro that produces support code. If for some -reason you need to inspect the code generated by this macro you have two -options: +`#[rtic::app]` is a procedural macro that produces support code. If for some reason you need to inspect the code generated by this macro you have two options: -You can inspect the file `rtic-expansion.rs` inside the `target` directory. This -file contains the expansion of the `#[rtic::app]` item (not your whole program!) -of the *last built* (via `cargo build` or `cargo check`) RTIC application. The -expanded code is not pretty printed by default, so you'll want to run `rustfmt` -on it before you read it. +You can inspect the file `rtic-expansion.rs` inside the `target` directory. This file contains the expansion of the `#[rtic::app]` item (not your whole program!) of the *last built* (via `cargo build` or `cargo check`) RTIC application. The expanded code is not pretty printed by default, so you'll want to run `rustfmt` on it before you read it. ``` console -$ cargo build --example foo +$ cargo build --example smallest --target thumbv7m-none-eabi +``` +``` console $ rustfmt target/rtic-expansion.rs +``` -tail target/rtic-expansion.rs +``` console +$ tail target/rtic-expansion.rs ``` ``` rust @@ -36,13 +34,14 @@ mod app { } ``` -Or, you can use the [`cargo-expand`] sub-command. This sub-command will expand -*all* the macros, including the `#[rtic::app]` attribute, and modules in your -crate and print the output to the console. +Or, you can use the [`cargo-expand`] sub-command. This sub-command will expand *all* the macros, including the `#[rtic::app]` attribute, and modules in your crate and print the output to the console. [`cargo-expand`]: https://crates.io/crates/cargo-expand ``` console # produces the same output as before +``` + +``` console cargo expand --example smallest | tail ```