Skip to content

Commit

Permalink
Embedded ci works
Browse files Browse the repository at this point in the history
  • Loading branch information
korken89 committed Mar 5, 2022
1 parent a765f3f commit f73650f
Show file tree
Hide file tree
Showing 131 changed files with 794 additions and 492 deletions.
62 changes: 49 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ jobs:
args: --examples --target=${{ matrix.target }}

# Verify the example output with run-pass tests
testexamples:
name: testexamples
testexamplesqemu:
name: testexamplesqemu
runs-on: ubuntu-20.04
strategy:
matrix:
Expand All @@ -157,13 +157,6 @@ jobs:
override: true
components: llvm-tools-preview

# Use precompiled binutils
- name: cargo install cargo-binutils
uses: actions-rs/[email protected]
with:
crate: cargo-binutils
version: latest

- name: Cache Dependencies
uses: Swatinem/rust-cache@v1

Expand All @@ -176,8 +169,49 @@ jobs:
run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs

- name: Run-pass tests
run:
cargo xtask --target ${{ matrix.target }}
run: |
cd examples-runner
cargo xtask --target ${{ matrix.target }} --runner qemu
testexamplesembeddedci:
name: testexamplesembeddedci
runs-on: ubuntu-20.04
strategy:
matrix:
target:
- thumbv7m-none-eabi
- thumbv6m-none-eabi
toolchain:
- stable
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }}
override: true
components: llvm-tools-preview

- name: Cache Dependencies
uses: Swatinem/rust-cache@v1

- name: Install embedded-ci-client
run: |
cargo install --git https://github.com/korken89/embedded-ci.git embedded-ci-client
- name: Fail on warnings
run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs

- name: Run-pass tests
env:
EMBEDDED_CI_TOKEN: ${{ secrets.EMBEDDED_CI_TOKEN }}
EMBEDDED_CI_SERVER: ${{ secrets.EMBEDDED_CI_SERVER }}
run: |
cd examples-runner
cargo xtask --target ${{ matrix.target }} --runner embedded-ci
# Check the correctness of macros/ crate
checkmacros:
Expand Down Expand Up @@ -373,7 +407,8 @@ jobs:
- check
- clippy
- checkexamples
- testexamples
- testexamplesqemu
- testexamplesembeddedci
- checkmacros
- testmacros
- tests
Expand Down Expand Up @@ -555,7 +590,8 @@ jobs:
- check
- clippy
- checkexamples
- testexamples
- testexamplesqemu
- testexamplesembeddedci
- checkmacros
- testmacros
- tests
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!

### Added

- HIL tests (embedded-ci)
- Improve how CHANGELOG.md merges are handled
- If current $stable and master version matches, dev-book redirects to $stable book
- During deploy stage, merge master branch into current stable IFF cargo package version matches
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ lto = true
[workspace]
members = [
"macros",
"xtask",
]
exclude = [
"examples-runner",
]

# do not optimize proc-macro deps or build scripts
Expand Down
2 changes: 1 addition & 1 deletion book/en/src/by-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ $ cargo run --target thumbv7m-none-eabi --example locals
Yields this output:

``` console
{{#include ../../../ci/expected/locals.run}}
{{#include ../../../examples-runner/ci/expected/locals.run}}
```
2 changes: 1 addition & 1 deletion book/en/src/by-example/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ To give a flavour of RTIC, the following example contains commonly used features
In the following sections we will go through each feature in detail.

``` rust
{{#include ../../../../examples/common.rs}}
{{#include ../../../../examples-runner/src/bin/common.rs}}
```
8 changes: 4 additions & 4 deletions book/en/src/by-example/app_idle.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ are safe to access.
The example below shows that `idle` runs after `init`.

``` rust
{{#include ../../../../examples/idle.rs}}
{{#include ../../../../examples-runner/src/bin/idle.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example idle
{{#include ../../../../ci/expected/idle.run}}
{{#include ../../../../examples-runner/ci/expected/idle.run}}
```

By default, the RTIC `idle` task does not try to optimize for any specific targets.
Expand All @@ -43,10 +43,10 @@ default [`nop()`][NOP] with [`wfi()`][WFI].
[NOP]: https://developer.arm.com/documentation/dui0662/b/The-Cortex-M0--Instruction-Set/Miscellaneous-instructions/NOP

``` rust
{{#include ../../../../examples/idle-wfi.rs}}
{{#include ../../../../examples-runner/src/bin/idle-wfi.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example idle-wfi
{{#include ../../../../ci/expected/idle-wfi.run}}
{{#include ../../../../examples-runner/ci/expected/idle-wfi.run}}
```
4 changes: 2 additions & 2 deletions book/en/src/by-example/app_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ The `device` field is available when the `peripherals` argument is set to the de
In the rare case you want to implement an ultra-slim application you can explicitly set `peripherals` to `false`.

``` rust
{{#include ../../../../examples/init.rs}}
{{#include ../../../../examples-runner/src/bin/init.rs}}
```

Running the example will print `init` to the console and then exit the QEMU process.

``` console
$ cargo run --target thumbv7m-none-eabi --example init
{{#include ../../../../ci/expected/init.run}}
{{#include ../../../../examples-runner/ci/expected/init.run}}
```

> **NOTE**: You can choose target device by passing a target
Expand Down
2 changes: 1 addition & 1 deletion book/en/src/by-example/app_minimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
This is the smallest possible RTIC application:

``` rust
{{#include ../../../../examples/smallest.rs}}
{{#include ../../../../examples-runner/src/bin/smallest.rs}}
```
4 changes: 2 additions & 2 deletions book/en/src/by-example/app_priorities.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ Task Priority
The following example showcases the priority based scheduling of tasks:

``` rust
{{#include ../../../../examples/preempt.rs}}
{{#include ../../../../examples-runner/src/bin/preempt.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example preempt
{{#include ../../../../ci/expected/preempt.run}}
{{#include ../../../../examples-runner/ci/expected/preempt.run}}
```

Note that the task `bar` does *not* preempt task `baz` because its priority
Expand Down
4 changes: 2 additions & 2 deletions book/en/src/by-example/hardware_tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ The example below demonstrates the use of the `#[task(binds = InterruptName)]` a
hardware task bound to an interrupt handler.

``` rust
{{#include ../../../../examples/hardware.rs}}
{{#include ../../../../examples-runner/src/bin/hardware.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example hardware
{{#include ../../../../ci/expected/hardware.run}}
{{#include ../../../../examples-runner/ci/expected/hardware.run}}
```
4 changes: 2 additions & 2 deletions book/en/src/by-example/message_passing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ pending spawns of `foo`. Exceeding this capacity is an `Error`.
The number of arguments to a task is not limited:

``` rust
{{#include ../../../../examples/message_passing.rs}}
{{#include ../../../../examples-runner/src/bin/message_passing.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example message_passing
{{#include ../../../../ci/expected/message_passing.run}}
{{#include ../../../../examples-runner/ci/expected/message_passing.run}}
```
8 changes: 4 additions & 4 deletions book/en/src/by-example/monotonic.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ This activates the monotonics making it possible to use them.
See the following example:

``` rust
{{#include ../../../../examples/schedule.rs}}
{{#include ../../../../examples-runner/src/bin/schedule.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example schedule
{{#include ../../../../ci/expected/schedule.run}}
{{#include ../../../../examples-runner/ci/expected/schedule.run}}
```

## Canceling or rescheduling a scheduled task
Expand All @@ -51,10 +51,10 @@ If `cancel` or `reschedule_at`/`reschedule_after` returns an `Err` it means that
too late and that the task is already sent for execution. The following example shows this in action:

``` rust
{{#include ../../../../examples/cancel-reschedule.rs}}
{{#include ../../../../examples-runner/src/bin/cancel-reschedule.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example cancel-reschedule
{{#include ../../../../ci/expected/cancel-reschedule.run}}
{{#include ../../../../examples-runner/ci/expected/cancel-reschedule.run}}
```
24 changes: 12 additions & 12 deletions book/en/src/by-example/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ The example application shown below contains two tasks where each task has acces
`#[local]` resource, plus that the `idle` task has its own `#[local]` as well.

``` rust
{{#include ../../../../examples/locals.rs}}
{{#include ../../../../examples-runner/src/bin/locals.rs}}
```

Running the example:

``` console
$ cargo run --target thumbv7m-none-eabi --example locals
{{#include ../../../../ci/expected/locals.run}}
{{#include ../../../../examples-runner/ci/expected/locals.run}}
```

### Task local initialized resources
Expand All @@ -64,12 +64,12 @@ are not crossing any thread boundary.
In the example below the different uses and lifetimes are shown:

``` rust
{{#include ../../../../examples/declared_locals.rs}}
{{#include ../../../../examples-runner/src/bin/declared_locals.rs}}
```

<!-- ``` console
$ cargo run --target thumbv7m-none-eabi --example declared_locals
{{#include ../../../../ci/expected/declared_locals.run}}
{{#include ../../../../examples-runner/ci/expected/declared_locals.run}}
``` -->

## `#[shared]` resources and `lock`
Expand Down Expand Up @@ -97,12 +97,12 @@ resource for accessing the data. The highest priority handler, which do not acce
resource, is free to preempt the critical section created by the lowest priority handler.

``` rust
{{#include ../../../../examples/lock.rs}}
{{#include ../../../../examples-runner/src/bin/lock.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example lock
{{#include ../../../../ci/expected/lock.run}}
{{#include ../../../../examples-runner/ci/expected/lock.run}}
```

Types of `#[shared]` resources have to be both [`Send`] and [`Sync`].
Expand All @@ -113,12 +113,12 @@ As an extension to `lock`, and to reduce rightward drift, locks can be taken as
following examples show this in use:

``` rust
{{#include ../../../../examples/multilock.rs}}
{{#include ../../../../examples-runner/src/bin/multilock.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example multilock
{{#include ../../../../ci/expected/multilock.run}}
{{#include ../../../../examples-runner/ci/expected/multilock.run}}
```

## Only shared (`&-`) access
Expand All @@ -143,12 +143,12 @@ In the example below a key (e.g. a cryptographic key) is loaded (or created) at
used from two tasks that run at different priorities without any kind of lock.

``` rust
{{#include ../../../../examples/only-shared-access.rs}}
{{#include ../../../../examples-runner/src/bin/only-shared-access.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example only-shared-access
{{#include ../../../../ci/expected/only-shared-access.run}}
{{#include ../../../../examples-runner/ci/expected/only-shared-access.run}}
```

## Lock-free resource access of shared resources
Expand All @@ -165,10 +165,10 @@ tasks running at different priorities will result in a *compile-time* error -- n
API would be a data race in that case.

``` rust
{{#include ../../../../examples/lock-free.rs}}
{{#include ../../../../examples-runner/src/bin/lock-free.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example lock-free
{{#include ../../../../ci/expected/lock-free.run}}
{{#include ../../../../examples-runner/ci/expected/lock-free.run}}
```
4 changes: 2 additions & 2 deletions book/en/src/by-example/software_tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ The framework will give a compilation error if there are not enough dispatchers
See the following example:

``` rust
{{#include ../../../../examples/spawn.rs}}
{{#include ../../../../examples-runner/src/bin/spawn.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example spawn
{{#include ../../../../ci/expected/spawn.run}}
{{#include ../../../../examples-runner/ci/expected/spawn.run}}
```
4 changes: 2 additions & 2 deletions book/en/src/by-example/tips_destructureing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ resources.
Here are two examples on how to split up the resource struct:

``` rust
{{#include ../../../../examples/destructure.rs}}
{{#include ../../../../examples-runner/src/bin/destructure.rs}}
```

``` console
$ cargo run --target thumbv7m-none-eabi --example destructure
{{#include ../../../../ci/expected/destructure.run}}
{{#include ../../../../examples-runner/ci/expected/destructure.run}}
```
8 changes: 4 additions & 4 deletions book/en/src/by-example/tips_from_ram.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ improve performance in some cases.
The example below shows how to place the higher priority task, `bar`, in RAM.

``` rust
{{#include ../../../../examples/ramfunc.rs}}
{{#include ../../../../examples-runner/src/bin/ramfunc.rs}}
```

Running this program produces the expected output.

``` console
$ cargo run --target thumbv7m-none-eabi --example ramfunc
{{#include ../../../../ci/expected/ramfunc.run}}
{{#include ../../../../examples-runner/ci/expected/ramfunc.run}}
```

One can look at the output of `cargo-nm` to confirm that `bar` ended in RAM
(`0x2000_0000`), whereas `foo` ended in Flash (`0x0000_0000`).

``` console
$ cargo nm --example ramfunc --release | grep ' foo::'
{{#include ../../../../ci/expected/ramfunc.run.grep.foo}}
{{#include ../../../../examples-runner/ci/expected/ramfunc.run.grep.foo}}
```

``` console
$ cargo nm --example ramfunc --release | grep ' bar::'
{{#include ../../../../ci/expected/ramfunc.run.grep.bar}}
{{#include ../../../../examples-runner/ci/expected/ramfunc.run.grep.bar}}
```
Loading

0 comments on commit f73650f

Please sign in to comment.