mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-01 16:04:33 +01:00
book remove ramfunc, remove migration
This commit is contained in:
parent
89632f9b22
commit
aa6baafa56
4 changed files with 39 additions and 40 deletions
|
@ -19,15 +19,15 @@
|
||||||
- [Avoid copies when message passing](./by-example/tips_indirection.md)
|
- [Avoid copies when message passing](./by-example/tips_indirection.md)
|
||||||
- [`'static` super-powers](./by-example/tips_static_lifetimes.md)
|
- [`'static` super-powers](./by-example/tips_static_lifetimes.md)
|
||||||
- [Inspecting generated code](./by-example/tips_view_code.md)
|
- [Inspecting generated code](./by-example/tips_view_code.md)
|
||||||
- [Running tasks from RAM](./by-example/tips_from_ram.md)
|
<!-- - [Running tasks from RAM](./by-example/tips_from_ram.md) -->
|
||||||
<!-- - [`#[cfg(..)]` support](./by-example/tips.md) -->
|
<!-- - [`#[cfg(..)]` support](./by-example/tips.md) -->
|
||||||
- [RTIC vs. the world](./rtic_vs.md)
|
- [RTIC vs. the world](./rtic_vs.md)
|
||||||
- [Awesome RTIC examples](./awesome_rtic.md)
|
- [Awesome RTIC examples](./awesome_rtic.md)
|
||||||
- [Migration Guides](./migration.md)
|
<!-- - [Migration Guides](./migration.md)
|
||||||
- [v0.5.x to v1.0.x](./migration/migration_v5.md)
|
- [v0.5.x to v1.0.x](./migration/migration_v5.md)
|
||||||
- [v0.4.x to v0.5.x](./migration/migration_v4.md)
|
- [v0.4.x to v0.5.x](./migration/migration_v4.md)
|
||||||
- [RTFM to RTIC](./migration/migration_rtic.md)
|
- [RTFM to RTIC](./migration/migration_rtic.md)
|
||||||
- [Under the hood](./internals.md)
|
- [Under the hood](./internals.md) -->
|
||||||
<!--- [Interrupt configuration](./internals/interrupt-configuration.md)-->
|
<!--- [Interrupt configuration](./internals/interrupt-configuration.md)-->
|
||||||
<!--- [Non-reentrancy](./internals/non-reentrancy.md)-->
|
<!--- [Non-reentrancy](./internals/non-reentrancy.md)-->
|
||||||
<!--- [Access control](./internals/access.md)-->
|
<!--- [Access control](./internals/access.md)-->
|
||||||
|
|
|
@ -1,33 +1,28 @@
|
||||||
# Running tasks from RAM
|
# Running tasks from RAM
|
||||||
|
|
||||||
The main goal of moving the specification of RTIC applications to attributes in
|
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
|
||||||
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.
|
improve performance in some cases.
|
||||||
|
|
||||||
> **IMPORTANT**: In general, the `link_section`, `export_name` and `no_mangle`
|
> **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.
|
||||||
> 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
|
> 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.
|
||||||
> 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
|
[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.
|
The example below shows how to place the higher priority task, `bar`, in RAM.
|
||||||
|
|
||||||
``` rust
|
``` rust
|
||||||
{{#include ../../../../examples/ramfunc.rs}}
|
{{#include ../../../../rtic/examples/ramfunc.rs}}
|
||||||
```
|
```
|
||||||
|
|
||||||
Running this program produces the expected output.
|
Running this program produces the expected output.
|
||||||
|
|
||||||
``` console
|
``` console
|
||||||
$ cargo run --target thumbv7m-none-eabi --example ramfunc
|
$ 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
|
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
|
``` console
|
||||||
$ cargo nm --example ramfunc --release | grep ' foo::'
|
$ cargo nm --example ramfunc --release | grep ' foo::'
|
||||||
{{#include ../../../../ci/expected/ramfunc.run.grep.foo}}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
``` console
|
``` console
|
||||||
$ cargo nm --example ramfunc --release | grep ' bar::'
|
{{#include ../../../../rtic/ci/expected/ramfunc.run.grep.foo}}
|
||||||
{{#include ../../../../ci/expected/ramfunc.run.grep.bar}}
|
```
|
||||||
|
|
||||||
|
``` console
|
||||||
|
$ cargo nm --example ramfunc --target thumbv7m-none-eabi --release | grep '*bar::'
|
||||||
|
```
|
||||||
|
|
||||||
|
``` console
|
||||||
|
{{#include ../../../../rtic/ci/expected/ramfunc.run.grep.bar}}
|
||||||
```
|
```
|
||||||
|
|
|
@ -2,23 +2,22 @@
|
||||||
|
|
||||||
In `#[init]` and `#[idle]` `local` resources have `'static` lifetime.
|
In `#[init]` and `#[idle]` `local` resources have `'static` lifetime.
|
||||||
|
|
||||||
Useful when pre-allocating and/or splitting resources between tasks, drivers
|
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`].
|
||||||
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`]
|
In the following example two different tasks share a [`heapless::spsc::Queue`] for lock-free access to the shared queue.
|
||||||
for lock-free access to the shared queue.
|
|
||||||
|
|
||||||
[`heapless::spsc::Queue`]: https://docs.rs/heapless/0.7.5/heapless/spsc/struct.Queue.html
|
[`heapless::spsc::Queue`]: https://docs.rs/heapless/0.7.5/heapless/spsc/struct.Queue.html
|
||||||
|
|
||||||
``` rust
|
``` rust
|
||||||
{{#include ../../../../examples/static.rs}}
|
{{#include ../../../../rtic/examples/static.rs}}
|
||||||
```
|
```
|
||||||
|
|
||||||
Running this program produces the expected output.
|
Running this program produces the expected output.
|
||||||
|
|
||||||
``` console
|
``` console
|
||||||
$ cargo run --target thumbv7m-none-eabi --example static
|
$ cargo run --target thumbv7m-none-eabi --example static
|
||||||
{{#include ../../../../ci/expected/static.run}}
|
```
|
||||||
|
|
||||||
|
``` console
|
||||||
|
{{#include ../../../../rtic/ci/expected/static.run}}
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
# Inspecting generated code
|
# Inspecting generated code
|
||||||
|
|
||||||
`#[rtic::app]` is a procedural macro that produces support code. If for some
|
`#[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:
|
||||||
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
|
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.
|
||||||
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
|
``` console
|
||||||
$ cargo build --example foo
|
$ cargo build --example smallest --target thumbv7m-none-eabi
|
||||||
|
```
|
||||||
|
|
||||||
|
``` console
|
||||||
$ rustfmt target/rtic-expansion.rs
|
$ rustfmt target/rtic-expansion.rs
|
||||||
|
```
|
||||||
|
|
||||||
tail target/rtic-expansion.rs
|
``` console
|
||||||
|
$ tail target/rtic-expansion.rs
|
||||||
```
|
```
|
||||||
|
|
||||||
``` rust
|
``` rust
|
||||||
|
@ -36,13 +34,14 @@ mod app {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Or, you can use the [`cargo-expand`] sub-command. This sub-command will expand
|
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.
|
||||||
*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
|
[`cargo-expand`]: https://crates.io/crates/cargo-expand
|
||||||
|
|
||||||
``` console
|
``` console
|
||||||
# produces the same output as before
|
# produces the same output as before
|
||||||
|
```
|
||||||
|
|
||||||
|
``` console
|
||||||
cargo expand --example smallest | tail
|
cargo expand --example smallest | tail
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue