aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2022-03-04 13:26:33 +0100
committerGravatar Emil Fresk <emil.fresk@gmail.com> 2022-03-05 11:14:36 +0100
commitca2577e3b8b5e05923f0d0d9deba6990940869e5 (patch)
tree237aed39ae4f1da4a197a5c9d374c19ea9ef2f31
parenta765f3fffac95f270ce416dc15acd063b215f027 (diff)
downloadrtic-ca2577e3b8b5e05923f0d0d9deba6990940869e5.tar.gz
rtic-ca2577e3b8b5e05923f0d0d9deba6990940869e5.tar.zst
rtic-ca2577e3b8b5e05923f0d0d9deba6990940869e5.zip
Embedded ci works
-rw-r--r--.github/workflows/build.yml62
-rw-r--r--CHANGELOG.md1
-rw-r--r--Cargo.toml4
-rw-r--r--book/en/src/by-example.md2
-rw-r--r--book/en/src/by-example/app.md2
-rw-r--r--book/en/src/by-example/app_idle.md8
-rw-r--r--book/en/src/by-example/app_init.md4
-rw-r--r--book/en/src/by-example/app_minimal.md2
-rw-r--r--book/en/src/by-example/app_priorities.md4
-rw-r--r--book/en/src/by-example/hardware_tasks.md4
-rw-r--r--book/en/src/by-example/message_passing.md4
-rw-r--r--book/en/src/by-example/monotonic.md8
-rw-r--r--book/en/src/by-example/resources.md24
-rw-r--r--book/en/src/by-example/software_tasks.md4
-rw-r--r--book/en/src/by-example/tips_destructureing.md4
-rw-r--r--book/en/src/by-example/tips_from_ram.md8
-rw-r--r--book/en/src/by-example/tips_indirection.md4
-rw-r--r--book/en/src/by-example/tips_static_lifetimes.md4
-rw-r--r--book/ru/src/by-example/app.md8
-rw-r--r--book/ru/src/by-example/new.md2
-rw-r--r--book/ru/src/by-example/resources.md8
-rw-r--r--book/ru/src/by-example/tasks.md6
-rw-r--r--book/ru/src/by-example/timer-queue.md6
-rw-r--r--book/ru/src/by-example/tips.md12
-rw-r--r--ci/expected/periodic-at.run4
-rw-r--r--ci/expected/periodic-at2.run7
-rw-r--r--ci/expected/pool.run2
-rw-r--r--examples-runner/.cargo/config.toml22
-rw-r--r--examples-runner/.gitignore2
-rw-r--r--examples-runner/Cargo.toml79
-rw-r--r--examples-runner/build.rs38
-rw-r--r--examples-runner/ci/expected/big-struct-opt.run (renamed from ci/expected/big-struct-opt.run)0
-rw-r--r--examples-runner/ci/expected/binds.run (renamed from ci/expected/binds.run)0
-rw-r--r--examples-runner/ci/expected/cancel-reschedule.run (renamed from ci/expected/cancel-reschedule.run)0
-rw-r--r--examples-runner/ci/expected/capacity.run (renamed from ci/expected/capacity.run)0
-rw-r--r--examples-runner/ci/expected/cfg-whole-task.run (renamed from ci/expected/cfg-whole-task.run)0
-rw-r--r--examples-runner/ci/expected/common.run (renamed from ci/expected/common.run)0
-rw-r--r--examples-runner/ci/expected/complex.run (renamed from ci/expected/complex.run)0
-rw-r--r--examples-runner/ci/expected/declared_locals.run (renamed from ci/expected/declared_locals.run)0
-rw-r--r--examples-runner/ci/expected/destructure.run (renamed from ci/expected/destructure.run)0
-rw-r--r--examples-runner/ci/expected/extern_binds.run (renamed from ci/expected/extern_binds.run)0
-rw-r--r--examples-runner/ci/expected/extern_spawn.run (renamed from ci/expected/extern_spawn.run)0
-rw-r--r--examples-runner/ci/expected/generics.run (renamed from ci/expected/generics.run)0
-rw-r--r--examples-runner/ci/expected/hardware.run (renamed from ci/expected/hardware.run)0
-rw-r--r--examples-runner/ci/expected/idle-wfi.run (renamed from ci/expected/idle-wfi.run)0
-rw-r--r--examples-runner/ci/expected/idle.run (renamed from ci/expected/idle.run)0
-rw-r--r--examples-runner/ci/expected/init.run (renamed from ci/expected/init.run)0
-rw-r--r--examples-runner/ci/expected/locals.run (renamed from ci/expected/locals.run)0
-rw-r--r--examples-runner/ci/expected/lock-free.run (renamed from ci/expected/lock-free.run)0
-rw-r--r--examples-runner/ci/expected/lock.run (renamed from ci/expected/lock.run)0
-rw-r--r--examples-runner/ci/expected/message.run (renamed from ci/expected/message.run)0
-rw-r--r--examples-runner/ci/expected/message_passing.run (renamed from ci/expected/message_passing.run)0
-rw-r--r--examples-runner/ci/expected/multilock.run (renamed from ci/expected/multilock.run)0
-rw-r--r--examples-runner/ci/expected/not-sync.run (renamed from ci/expected/not-sync.run)0
-rw-r--r--examples-runner/ci/expected/only-shared-access.run (renamed from ci/expected/only-shared-access.run)0
-rw-r--r--examples-runner/ci/expected/periodic-at.run4
-rw-r--r--examples-runner/ci/expected/periodic-at2.run7
-rw-r--r--examples-runner/ci/expected/periodic.run (renamed from ci/expected/periodic.run)0
-rw-r--r--examples-runner/ci/expected/peripherals-taken.run (renamed from ci/expected/peripherals-taken.run)0
-rw-r--r--examples-runner/ci/expected/pool.run2
-rw-r--r--examples-runner/ci/expected/preempt.run (renamed from ci/expected/preempt.run)0
-rw-r--r--examples-runner/ci/expected/ramfunc.run (renamed from ci/expected/ramfunc.run)0
-rw-r--r--examples-runner/ci/expected/ramfunc.run.grep.bar (renamed from ci/expected/ramfunc.run.grep.bar)0
-rw-r--r--examples-runner/ci/expected/ramfunc.run.grep.foo (renamed from ci/expected/ramfunc.run.grep.foo)0
-rw-r--r--examples-runner/ci/expected/resource-user-struct.run (renamed from ci/expected/resource-user-struct.run)0
-rw-r--r--examples-runner/ci/expected/schedule.run (renamed from ci/expected/schedule.run)0
-rw-r--r--examples-runner/ci/expected/shared.run (renamed from ci/expected/shared.run)0
-rw-r--r--examples-runner/ci/expected/smallest.run (renamed from ci/expected/smallest.run)0
-rw-r--r--examples-runner/ci/expected/spawn.run (renamed from ci/expected/spawn.run)0
-rw-r--r--examples-runner/ci/expected/static.run (renamed from ci/expected/static.run)0
-rw-r--r--examples-runner/ci/expected/t-binds.run (renamed from ci/expected/t-binds.run)0
-rw-r--r--examples-runner/ci/expected/t-cfg-resources.run (renamed from ci/expected/t-cfg-resources.run)0
-rw-r--r--examples-runner/ci/expected/t-htask-main.run (renamed from ci/expected/t-htask-main.run)0
-rw-r--r--examples-runner/ci/expected/t-idle-main.run (renamed from ci/expected/t-idle-main.run)0
-rw-r--r--examples-runner/ci/expected/t-late-not-send.run (renamed from ci/expected/t-late-not-send.run)0
-rw-r--r--examples-runner/ci/expected/t-schedule.run (renamed from ci/expected/t-schedule.run)0
-rw-r--r--examples-runner/ci/expected/t-spawn.run (renamed from ci/expected/t-spawn.run)0
-rw-r--r--examples-runner/ci/expected/task.run (renamed from ci/expected/task.run)0
-rw-r--r--examples-runner/embedded-ci.x10
-rw-r--r--examples-runner/examples_to_runner.sh9
-rw-r--r--examples-runner/qemu.x13
-rw-r--r--examples-runner/src/bin/big-struct-opt.rs (renamed from examples/big-struct-opt.rs)13
-rw-r--r--examples-runner/src/bin/binds.rs (renamed from examples/binds.rs)23
-rw-r--r--examples-runner/src/bin/cancel-reschedule.rs (renamed from examples/cancel-reschedule.rs)18
-rw-r--r--examples-runner/src/bin/capacity.rs (renamed from examples/capacity.rs)14
-rw-r--r--examples-runner/src/bin/cfg-whole-task.rs (renamed from examples/cfg-whole-task.rs)21
-rw-r--r--examples-runner/src/bin/common.rs (renamed from examples/common.rs)41
-rw-r--r--examples-runner/src/bin/complex.rs (renamed from examples/complex.rs)75
-rw-r--r--examples-runner/src/bin/declared_locals.rs (renamed from examples/declared_locals.rs)10
-rw-r--r--examples-runner/src/bin/destructure.rs (renamed from examples/destructure.rs)14
-rw-r--r--examples-runner/src/bin/extern_binds.rs (renamed from examples/extern_binds.rs)24
-rw-r--r--examples-runner/src/bin/extern_spawn.rs (renamed from examples/extern_spawn.rs)10
-rw-r--r--examples-runner/src/bin/generics.rs (renamed from examples/generics.rs)18
-rw-r--r--examples-runner/src/bin/hardware.rs (renamed from examples/hardware.rs)25
-rw-r--r--examples-runner/src/bin/idle-wfi.rs (renamed from examples/idle-wfi.rs)24
-rw-r--r--examples-runner/src/bin/idle.rs (renamed from examples/idle.rs)18
-rw-r--r--examples-runner/src/bin/init.rs (renamed from examples/init.rs)14
-rw-r--r--examples-runner/src/bin/locals.rs (renamed from examples/locals.rs)20
-rw-r--r--examples-runner/src/bin/lock-free.rs (renamed from examples/lock-free.rs)12
-rw-r--r--examples-runner/src/bin/lock.rs (renamed from examples/lock.rs)18
-rw-r--r--examples-runner/src/bin/message.rs (renamed from examples/message.rs)14
-rw-r--r--examples-runner/src/bin/message_passing.rs (renamed from examples/message_passing.rs)10
-rw-r--r--examples-runner/src/bin/multilock.rs (renamed from examples/multilock.rs)10
-rw-r--r--examples-runner/src/bin/not-sync.rs (renamed from examples/not-sync.rs)13
-rw-r--r--examples-runner/src/bin/only-shared-access.rs (renamed from examples/only-shared-access.rs)12
-rw-r--r--examples-runner/src/bin/periodic-at.rs (renamed from examples/periodic-at.rs)10
-rw-r--r--examples-runner/src/bin/periodic-at2.rs (renamed from examples/periodic-at2.rs)12
-rw-r--r--examples-runner/src/bin/periodic.rs (renamed from examples/periodic.rs)10
-rw-r--r--examples-runner/src/bin/peripherals-taken.rs (renamed from examples/peripherals-taken.rs)10
-rw-r--r--examples-runner/src/bin/pool.rs (renamed from examples/pool.rs)16
-rw-r--r--examples-runner/src/bin/preempt.rs (renamed from examples/preempt.rs)18
-rw-r--r--examples-runner/src/bin/ramfunc.rs (renamed from examples/ramfunc.rs)10
-rw-r--r--examples-runner/src/bin/resource-user-struct.rs (renamed from examples/resource-user-struct.rs)16
-rw-r--r--examples-runner/src/bin/schedule.rs (renamed from examples/schedule.rs)16
-rw-r--r--examples-runner/src/bin/shared.rs (renamed from examples/shared.rs)12
-rw-r--r--examples-runner/src/bin/smallest.rs (renamed from examples/smallest.rs)10
-rw-r--r--examples-runner/src/bin/spawn.rs (renamed from examples/spawn.rs)12
-rw-r--r--examples-runner/src/bin/static.rs (renamed from examples/static.rs)10
-rw-r--r--examples-runner/src/bin/t-binds.rs (renamed from examples/t-binds.rs)10
-rw-r--r--examples-runner/src/bin/t-cfg-resources.rs (renamed from examples/t-cfg-resources.rs)15
-rw-r--r--examples-runner/src/bin/t-htask-main.rs (renamed from examples/t-htask-main.rs)10
-rw-r--r--examples-runner/src/bin/t-idle-main.rs (renamed from examples/t-idle-main.rs)14
-rw-r--r--examples-runner/src/bin/t-late-not-send.rs (renamed from examples/t-late-not-send.rs)14
-rw-r--r--examples-runner/src/bin/t-schedule.rs (renamed from examples/t-schedule.rs)17
-rw-r--r--examples-runner/src/bin/t-spawn.rs (renamed from examples/t-spawn.rs)10
-rw-r--r--examples-runner/src/bin/task.rs (renamed from examples/task.rs)18
-rw-r--r--examples-runner/src/lib.rs60
-rw-r--r--examples-runner/xtask/Cargo.toml (renamed from xtask/Cargo.toml)2
-rw-r--r--examples-runner/xtask/src/build.rs (renamed from xtask/src/build.rs)0
-rw-r--r--examples-runner/xtask/src/command.rs (renamed from xtask/src/command.rs)58
-rw-r--r--examples-runner/xtask/src/main.rs (renamed from xtask/src/main.rs)31
131 files changed, 794 insertions, 492 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 875c3f39..e5e2e8f7 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -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:
@@ -157,13 +157,6 @@ jobs:
override: true
components: llvm-tools-preview
- # Use precompiled binutils
- - name: cargo install cargo-binutils
- uses: actions-rs/install@v0.1
- with:
- crate: cargo-binutils
- version: latest
-
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1
@@ -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:
@@ -373,7 +407,8 @@ jobs:
- check
- clippy
- checkexamples
- - testexamples
+ - testexamplesqemu
+ - testexamplesembeddedci
- checkmacros
- testmacros
- tests
@@ -555,7 +590,8 @@ jobs:
- check
- clippy
- checkexamples
- - testexamples
+ - testexamplesqemu
+ - testexamplesembeddedci
- checkmacros
- testmacros
- tests
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f05aeeaf..70cff1a9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/Cargo.toml b/Cargo.toml
index 4393533b..4723f540 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -49,7 +49,9 @@ lto = true
[workspace]
members = [
"macros",
- "xtask",
+]
+exclude = [
+ "examples-runner",
]
# do not optimize proc-macro deps or build scripts
diff --git a/book/en/src/by-example.md b/book/en/src/by-example.md
index 3a523e51..4e89e656 100644
--- a/book/en/src/by-example.md
+++ b/book/en/src/by-example.md
@@ -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}}
```
diff --git a/book/en/src/by-example/app.md b/book/en/src/by-example/app.md
index 2c6aca7a..c015d327 100644
--- a/book/en/src/by-example/app.md
+++ b/book/en/src/by-example/app.md
@@ -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}}
```
diff --git a/book/en/src/by-example/app_idle.md b/book/en/src/by-example/app_idle.md
index 537902a4..910dfe74 100644
--- a/book/en/src/by-example/app_idle.md
+++ b/book/en/src/by-example/app_idle.md
@@ -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.
@@ -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}}
```
diff --git a/book/en/src/by-example/app_init.md b/book/en/src/by-example/app_init.md
index 615c2991..0f978bb0 100644
--- a/book/en/src/by-example/app_init.md
+++ b/book/en/src/by-example/app_init.md
@@ -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
diff --git a/book/en/src/by-example/app_minimal.md b/book/en/src/by-example/app_minimal.md
index d0ff40a3..c0ba8fe9 100644
--- a/book/en/src/by-example/app_minimal.md
+++ b/book/en/src/by-example/app_minimal.md
@@ -3,5 +3,5 @@
This is the smallest possible RTIC application:
``` rust
-{{#include ../../../../examples/smallest.rs}}
+{{#include ../../../../examples-runner/src/bin/smallest.rs}}
```
diff --git a/book/en/src/by-example/app_priorities.md b/book/en/src/by-example/app_priorities.md
index 1a92ec84..54a22a63 100644
--- a/book/en/src/by-example/app_priorities.md
+++ b/book/en/src/by-example/app_priorities.md
@@ -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
diff --git a/book/en/src/by-example/hardware_tasks.md b/book/en/src/by-example/hardware_tasks.md
index 7f8d3c6e..976626db 100644
--- a/book/en/src/by-example/hardware_tasks.md
+++ b/book/en/src/by-example/hardware_tasks.md
@@ -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}}
```
diff --git a/book/en/src/by-example/message_passing.md b/book/en/src/by-example/message_passing.md
index 0dc8f858..c239a1f3 100644
--- a/book/en/src/by-example/message_passing.md
+++ b/book/en/src/by-example/message_passing.md
@@ -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}}
```
diff --git a/book/en/src/by-example/monotonic.md b/book/en/src/by-example/monotonic.md
index 094bd5df..7a3a878b 100644
--- a/book/en/src/by-example/monotonic.md
+++ b/book/en/src/by-example/monotonic.md
@@ -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
@@ -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}}
```
diff --git a/book/en/src/by-example/resources.md b/book/en/src/by-example/resources.md
index 9d51d6c9..57ccd0e8 100644
--- a/book/en/src/by-example/resources.md
+++ b/book/en/src/by-example/resources.md
@@ -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
@@ -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`
@@ -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`].
@@ -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
@@ -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
@@ -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}}
```
diff --git a/book/en/src/by-example/software_tasks.md b/book/en/src/by-example/software_tasks.md
index ea40697d..b57fe287 100644
--- a/book/en/src/by-example/software_tasks.md
+++ b/book/en/src/by-example/software_tasks.md
@@ -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}}
```
diff --git a/book/en/src/by-example/tips_destructureing.md b/book/en/src/by-example/tips_destructureing.md
index 4637b483..78d0265b 100644
--- a/book/en/src/by-example/tips_destructureing.md
+++ b/book/en/src/by-example/tips_destructureing.md
@@ -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}}
```
diff --git a/book/en/src/by-example/tips_from_ram.md b/book/en/src/by-example/tips_from_ram.md
index fc47803f..c9b6353d 100644
--- a/book/en/src/by-example/tips_from_ram.md
+++ b/book/en/src/by-example/tips_from_ram.md
@@ -20,14 +20,14 @@ 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
@@ -35,10 +35,10 @@ 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}}
+{{#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}}
```
diff --git a/book/en/src/by-example/tips_indirection.md b/book/en/src/by-example/tips_indirection.md
index 1a330c51..5eb12e7d 100644
--- a/book/en/src/by-example/tips_indirection.md
+++ b/book/en/src/by-example/tips_indirection.md
@@ -18,10 +18,10 @@ or one can use a statically allocated memory pool like [`heapless::Pool`].
Here's an example where `heapless::Pool` is used to "box" buffers of 128 bytes.
``` rust
-{{#include ../../../../examples/pool.rs}}
+{{#include ../../../../examples-runner/src/bin/pool.rs}}
```
``` console
$ cargo run --target thumbv7m-none-eabi --example pool
-{{#include ../../../../ci/expected/pool.run}}
+{{#include ../../../../examples-runner/ci/expected/pool.run}}
```
diff --git a/book/en/src/by-example/tips_static_lifetimes.md b/book/en/src/by-example/tips_static_lifetimes.md
index 8d3a832c..6924e348 100644
--- a/book/en/src/by-example/tips_static_lifetimes.md
+++ b/book/en/src/by-example/tips_static_lifetimes.md
@@ -13,12 +13,12 @@ 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 ../../../../examples-runner/src/bin/static.rs}}
```
Running this program produces the expected output.
``` console
$ cargo run --target thumbv7m-none-eabi --example static
-{{#include ../../../../ci/expected/static.run}}
+{{#include ../../../../examples-runner/ci/expected/static.run}}
```
diff --git a/book/ru/src/by-example/app.md b/book/ru/src/by-example/app.md
index 5259bfa0..84da4f9b 100644
--- a/book/ru/src/by-example/app.md
+++ b/book/ru/src/by-example/app.md
@@ -51,7 +51,7 @@
``` console
$ cargo run --example init
-{{#include ../../../../ci/expected/init.run}}
+{{#include ../../../../examples-runner/ci/expected/init.run}}
```
> **ПРИМЕЧАНИЕ**: Не забывайте указывать выбранное вами целевое устройство, передавая параметр target
@@ -87,7 +87,7 @@ $ cargo run --example init
``` console
$ cargo run --example idle
-{{#include ../../../../ci/expected/idle.run}}
+{{#include ../../../../examples-runner/ci/expected/idle.run}}
```
## Аппаратные задачи
@@ -109,7 +109,7 @@ mut` переменные безопасны для использования
``` console
$ cargo run --example hardware
-{{#include ../../../../ci/expected/hardware.run}}
+{{#include ../../../../examples-runner/ci/expected/hardware.run}}
```
До сих пор все программы на RTIC, которые мы видели, не отличались от программ,
@@ -145,7 +145,7 @@ $ cargo run --example hardware
``` console
$ cargo run --example preempt
-{{#include ../../../../ci/expected/preempt.run}}
+{{#include ../../../../examples-runner/ci/expected/preempt.run}}
```
Заметьте, что задача `gpiob` *не* вытесняет задачу `gpioc`, потому что ее приоритет
diff --git a/book/ru/src/by-example/new.md b/book/ru/src/by-example/new.md
index fcf52370..a845321f 100644
--- a/book/ru/src/by-example/new.md
+++ b/book/ru/src/by-example/new.md
@@ -80,5 +80,5 @@ $ cargo add panic-semihosting
``` console
$ # ПРИМЕЧАНИЕ: Я раскомментировал опцию `runner` в `.cargo/config`
$ cargo run
-{{#include ../../../../ci/expected/init.run}}
+{{#include ../../../../examples-runner/ci/expected/init.run}}
```
diff --git a/book/ru/src/by-example/resources.md b/book/ru/src/by-example/resources.md
index ed8904ba..ac147d8f 100644
--- a/book/ru/src/by-example/resources.md
+++ b/book/ru/src/by-example/resources.md
@@ -34,7 +34,7 @@
``` console
$ cargo run --example resource
-{{#include ../../../../ci/expected/resource.run}}
+{{#include ../../../../examples-runner/ci/expected/resource.run}}
```
К ресурсу `#[local]` нельзя получить доступ извне задачи к которой он
@@ -76,7 +76,7 @@ $ cargo run --example resource
``` console
$ cargo run --example lock
-{{#include ../../../../ci/expected/lock.run}}
+{{#include ../../../../examples-runner/ci/expected/lock.run}}
```
## Множественное блокировка
@@ -115,7 +115,7 @@ $ cargo run --example lock
``` console
$ cargo run --example only-shared-access
-{{#include ../../../../ci/expected/only-shared-access.run}}
+{{#include ../../../../examples-runner/ci/expected/only-shared-access.run}}
```
## Неблокируемый доступ к изменяемым ресурсам
@@ -136,5 +136,5 @@ $ cargo run --example only-shared-access
``` console
$ cargo run --example lock-free
-{{#include ../../../../ci/expected/lock-free.run}}
+{{#include ../../../../examples-runner/ci/expected/lock-free.run}}
``` \ No newline at end of file
diff --git a/book/ru/src/by-example/tasks.md b/book/ru/src/by-example/tasks.md
index 3c99d00e..376c9e00 100644
--- a/book/ru/src/by-example/tasks.md
+++ b/book/ru/src/by-example/tasks.md
@@ -22,7 +22,7 @@ RTIC также поддерживает *программные* задачи,
``` console
$ cargo run --example task
-{{#include ../../../../ci/expected/task.run}}
+{{#include ../../../../examples-runner/ci/expected/task.run}}
```
## Передача сообщений
@@ -39,7 +39,7 @@ $ cargo run --example task
``` console
$ cargo run --example message
-{{#include ../../../../ci/expected/message.run}}
+{{#include ../../../../examples-runner/ci/expected/message.run}}
```
## Вместимость
@@ -63,7 +63,7 @@ RTIC *не* производит никакого рода аллокаций п
``` console
$ cargo run --example capacity
-{{#include ../../../../ci/expected/capacity.run}}
+{{#include ../../../../examples-runner/ci/expected/capacity.run}}
```
## Обработка ошибок
diff --git a/book/ru/src/by-example/timer-queue.md b/book/ru/src/by-example/timer-queue.md
index c8818d7d..4ba9389c 100644
--- a/book/ru/src/by-example/timer-queue.md
+++ b/book/ru/src/by-example/timer-queue.md
@@ -49,7 +49,7 @@
Запусе программы на реальном оборудовании создает следующий вывод в консоли:
``` text
-{{#include ../../../../ci/expected/schedule.run}}
+{{#include ../../../../examples-runner/ci/expected/schedule.run}}
```
Когда интерфейс `schedule` используется, среда исполнения использует внутри
@@ -73,7 +73,7 @@
`Instant::now` вместо `scheduled` вызвало бы дрейф / колебания.
``` text
-{{#include ../../../../ci/expected/periodic.run}}
+{{#include ../../../../examples-runner/ci/expected/periodic.run}}
```
## Базовое время
@@ -104,5 +104,5 @@
Запуск программы на реальном оборудовании приведет к следующему выводу в консоли:
``` text
-{{#include ../../../../ci/expected/baseline.run}}
+{{#include ../../../../examples-runner/ci/expected/baseline.run}}
```
diff --git a/book/ru/src/by-example/tips.md b/book/ru/src/by-example/tips.md
index 7d4fc2f4..d20e98de 100644
--- a/book/ru/src/by-example/tips.md
+++ b/book/ru/src/by-example/tips.md
@@ -22,7 +22,7 @@
``` console
$ cargo run --example generics
-{{#include ../../../../ci/expected/generics.run}}
+{{#include ../../../../examples-runner/ci/expected/generics.run}}
```
## Условная компиляция
@@ -43,7 +43,7 @@ $ cargo run --example generics
$ cargo run --example cfg --release
$ cargo run --example cfg
-{{#include ../../../../ci/expected/cfg.run}}
+{{#include ../../../../examples-runner/ci/expected/cfg.run}}
```
## Запуск задач из ОЗУ
@@ -75,7 +75,7 @@ RTIC v0.4.x была возможность взаимодействия с др
``` console
$ cargo run --example ramfunc
-{{#include ../../../../ci/expected/ramfunc.run}}
+{{#include ../../../../examples-runner/ci/expected/ramfunc.run}}
```
Можно посмотреть на вывод `cargo-nm`, чтобы убедиться, что `bar` расположен в ОЗУ
@@ -83,12 +83,12 @@ $ cargo run --example ramfunc
``` 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}}
```
## Обходной путь для быстрой передачи сообщений
@@ -113,7 +113,7 @@ $ cargo nm --example ramfunc --release | grep ' bar::'
``` console
$ cargo run --example pool
-{{#include ../../../../ci/expected/pool.run}}
+{{#include ../../../../examples-runner/ci/expected/pool.run}}
```
## Инспектирование раскрываемого кода
diff --git a/ci/expected/periodic-at.run b/ci/expected/periodic-at.run
deleted file mode 100644
index 54020f9e..00000000
--- a/ci/expected/periodic-at.run
+++ /dev/null
@@ -1,4 +0,0 @@
-foo Instant { ticks: 0 }
-foo Instant { ticks: 100 }
-foo Instant { ticks: 200 }
-foo Instant { ticks: 300 }
diff --git a/ci/expected/periodic-at2.run b/ci/expected/periodic-at2.run
deleted file mode 100644
index 47adbef4..00000000
--- a/ci/expected/periodic-at2.run
+++ /dev/null
@@ -1,7 +0,0 @@
-foo Instant { ticks: 0 }
-bar Instant { ticks: 10 }
-foo Instant { ticks: 110 }
-bar Instant { ticks: 120 }
-foo Instant { ticks: 220 }
-bar Instant { ticks: 230 }
-foo Instant { ticks: 330 }
diff --git a/ci/expected/pool.run b/ci/expected/pool.run
deleted file mode 100644
index 81f79d41..00000000
--- a/ci/expected/pool.run
+++ /dev/null
@@ -1,2 +0,0 @@
-bar(0x20000088)
-foo(0x2000010c)
diff --git a/examples-runner/.cargo/config.toml b/examples-runner/.cargo/config.toml
new file mode 100644
index 00000000..8425d873
--- /dev/null
+++ b/examples-runner/.cargo/config.toml
@@ -0,0 +1,22 @@
+[target.thumbv6m-none-eabi]
+runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
+
+[target.thumbv7m-none-eabi]
+runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel"
+
+[target.'cfg(all(target_arch = "arm", target_os = "none"))']
+rustflags = [
+ #"-C", "link-arg=-Tlink.x",
+ "-C", "link-arg=-Tdefmt.x",
+ "-C", "link-arg=--nmagic",
+]
+
+[build]
+# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
+# target = "thumbv7m-none-eabi" # Cortex-M3
+# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
+# target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
+
+[alias]
+rrb = "run --release --bin"
+brb = "build --release --bin"
diff --git a/examples-runner/.gitignore b/examples-runner/.gitignore
new file mode 100644
index 00000000..96ef6c0b
--- /dev/null
+++ b/examples-runner/.gitignore
@@ -0,0 +1,2 @@
+/target
+Cargo.lock
diff --git a/examples-runner/Cargo.toml b/examples-runner/Cargo.toml
new file mode 100644
index 00000000..17ad3c5a
--- /dev/null
+++ b/examples-runner/Cargo.toml
@@ -0,0 +1,79 @@
+[package]
+# TODO(1) fix `authors` and `name` if you didn't use `cargo-generate`
+authors = ["Emil Fresk <emil.fresk@gmail.com>"]
+name = "examples-runner"
+edition = "2018"
+version = "0.1.0"
+
+[dependencies]
+defmt = { version = "0.3.0", optional = true }
+defmt-rtt = { version = "0.3.0", optional = true }
+panic-probe = { version = "0.3.0", optional = true }
+cortex-m-rtic = { path = ".." }
+cortex-m = "0.7"
+systick-monotonic = "1"
+fugit = { version = "0.3", features = ["defmt"] }
+cortex-m-semihosting = { version = "0.3.7", optional = true }
+panic-semihosting = { version = "0.5.6", optional = true }
+heapless = "0.7"
+rtic-monotonic = "1"
+bare-metal = "1"
+
+[dependencies.embedded-ci-pac]
+version = "0.1.0"
+git = "https://github.com/korken89/embedded-ci-pac.git"
+
+[workspace]
+members = [
+ "xtask",
+]
+
+[features]
+embedded-ci = ["defmt", "defmt-rtt", "panic-probe/print-defmt"]
+qemu = ["cortex-m-semihosting", "panic-semihosting/exit"]
+
+# cargo build/run
+[profile.dev]
+codegen-units = 1
+debug = 2
+debug-assertions = true # <-
+incremental = false
+opt-level = "s" # <-
+overflow-checks = true # <-
+
+# cargo test
+[profile.test]
+codegen-units = 1
+debug = 2
+debug-assertions = true # <-
+incremental = false
+opt-level = "s" # <-
+overflow-checks = true # <-
+
+# cargo build/run --release
+[profile.release]
+codegen-units = 1
+debug = 2
+debug-assertions = false # <-
+incremental = false
+lto = 'fat'
+opt-level = "s" # <-
+overflow-checks = false # <-
+
+# cargo test --release
+[profile.bench]
+codegen-units = 1
+debug = 2
+debug-assertions = false # <-
+incremental = false
+lto = 'fat'
+opt-level = "s" # <-
+overflow-checks = false # <-
+
+# uncomment this to switch from the crates.io version of defmt to its git version
+# check app-template's README for instructions
+# [patch.crates-io]
+# defmt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
+# defmt-rtt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
+# defmt-test = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
+# panic-probe = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
diff --git a/examples-runner/build.rs b/examples-runner/build.rs
new file mode 100644
index 00000000..3b241192
--- /dev/null
+++ b/examples-runner/build.rs
@@ -0,0 +1,38 @@
+use std::env;
+use std::fs::File;
+use std::io::Write;
+use std::path::PathBuf;
+
+fn main() {
+ // Put the linker script somewhere the linker can find it
+ let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
+
+ #[cfg(feature = "embedded-ci")]
+ let bytes = include_bytes!("embedded-ci.x");
+
+ #[cfg(feature = "qemu")]
+ let bytes = include_bytes!("qemu.x");
+
+ // If running in test mode, use the memory layout that can be flashed
+ // onto the chip directly
+ File::create(out.join("memory.x"))
+ .unwrap()
+ .write_all(bytes)
+ .unwrap();
+
+ #[cfg(feature = "qemu")]
+ File::create(out.join("defmt.x"))
+ .unwrap()
+ .write_all(b"")
+ .unwrap();
+
+ println!("cargo:rustc-link-search={}", out.display());
+
+ // Only re-run the build script when memory.x is changed,
+ // instead of when any part of the source code changes.
+ println!("cargo:rerun-if-changed=memory.x");
+ println!("cargo:rerun-if-changed=embedded-ci.x");
+ println!("cargo:rerun-if-changed=qemu.x");
+ println!("cargo:rerun-if-changed=link.x");
+ println!("cargo:rerun-if-changed=build.rs");
+}
diff --git a/ci/expected/big-struct-opt.run b/examples-runner/ci/expected/big-struct-opt.run
index e69de29b..e69de29b 100644
--- a/ci/expected/big-struct-opt.run
+++ b/examples-runner/ci/expected/big-struct-opt.run
diff --git a/ci/expected/binds.run b/examples-runner/ci/expected/binds.run
index f84cff01..f84cff01 100644
--- a/ci/expected/binds.run
+++ b/examples-runner/ci/expected/binds.run
diff --git a/ci/expected/cancel-reschedule.run b/examples-runner/ci/expected/cancel-reschedule.run
index 5a947526..5a947526 100644
--- a/ci/expected/cancel-reschedule.run
+++ b/examples-runner/ci/expected/cancel-reschedule.run
diff --git a/ci/expected/capacity.run b/examples-runner/ci/expected/capacity.run
index f96815de..f96815de 100644
--- a/ci/expected/capacity.run
+++ b/examples-runner/ci/expected/capacity.run
diff --git a/ci/expected/cfg-whole-task.run b/examples-runner/ci/expected/cfg-whole-task.run
index e69de29b..e69de29b 100644
--- a/ci/expected/cfg-whole-task.run
+++ b/examples-runner/ci/expected/cfg-whole-task.run
diff --git a/ci/expected/common.run b/examples-runner/ci/expected/common.run
index e69de29b..e69de29b 100644
--- a/ci/expected/common.run
+++ b/examples-runner/ci/expected/common.run
diff --git a/ci/expected/complex.run b/examples-runner/ci/expected/complex.run
index 5df884da..5df884da 100644
--- a/ci/expected/complex.run
+++ b/examples-runner/ci/expected/complex.run
diff --git a/ci/expected/declared_locals.run b/examples-runner/ci/expected/declared_locals.run
index e69de29b..e69de29b 100644
--- a/ci/expected/declared_locals.run
+++ b/examples-runner/ci/expected/declared_locals.run
diff --git a/ci/expected/destructure.run b/examples-runner/ci/expected/destructure.run
index b9b7cc90..b9b7cc90 100644
--- a/ci/expected/destructure.run
+++ b/examples-runner/ci/expected/destructure.run
diff --git a/ci/expected/extern_binds.run b/examples-runner/ci/expected/extern_binds.run
index 9d925d52..9d925d52 100644
--- a/ci/expected/extern_binds.run
+++ b/examples-runner/ci/expected/extern_binds.run
diff --git a/ci/expected/extern_spawn.run b/examples-runner/ci/expected/extern_spawn.run
index 2f8c74f6..2f8c74f6 100644
--- a/ci/expected/extern_spawn.run
+++ b/examples-runner/ci/expected/extern_spawn.run
diff --git a/ci/expected/generics.run b/examples-runner/ci/expected/generics.run
index fb31731e..fb31731e 100644
--- a/ci/expected/generics.run
+++ b/examples-runner/ci/expected/generics.run
diff --git a/ci/expected/hardware.run b/examples-runner/ci/expected/hardware.run
index ef00864b..ef00864b 100644
--- a/ci/expected/hardware.run
+++ b/examples-runner/ci/expected/hardware.run
diff --git a/ci/expected/idle-wfi.run b/examples-runner/ci/expected/idle-wfi.run
index 43077763..43077763 100644
--- a/ci/expected/idle-wfi.run
+++ b/examples-runner/ci/expected/idle-wfi.run
diff --git a/ci/expected/idle.run b/examples-runner/ci/expected/idle.run
index 43077763..43077763 100644
--- a/ci/expected/idle.run
+++ b/examples-runner/ci/expected/idle.run
diff --git a/ci/expected/init.run b/examples-runner/ci/expected/init.run
index b1b71610..b1b71610 100644
--- a/ci/expected/init.run
+++ b/examples-runner/ci/expected/init.run
diff --git a/ci/expected/locals.run b/examples-runner/ci/expected/locals.run
index bf1d2076..bf1d2076 100644
--- a/ci/expected/locals.run
+++ b/examples-runner/ci/expected/locals.run
diff --git a/ci/expected/lock-free.run b/examples-runner/ci/expected/lock-free.run
index 18de0eca..18de0eca 100644
--- a/ci/expected/lock-free.run
+++ b/examples-runner/ci/expected/lock-free.run
diff --git a/ci/expected/lock.run b/examples-runner/ci/expected/lock.run
index a987b372..a987b372 100644
--- a/ci/expected/lock.run
+++ b/examples-runner/ci/expected/lock.run
diff --git a/ci/expected/message.run b/examples-runner/ci/expected/message.run
index 11814db2..11814db2 100644
--- a/ci/expected/message.run
+++ b/examples-runner/ci/expected/message.run
diff --git a/ci/expected/message_passing.run b/examples-runner/ci/expected/message_passing.run
index a1448d8d..a1448d8d 100644
--- a/ci/expected/message_passing.run
+++ b/examples-runner/ci/expected/message_passing.run
diff --git a/ci/expected/multilock.run b/examples-runner/ci/expected/multilock.run
index dd8c1f29..dd8c1f29 100644
--- a/ci/expected/multilock.run
+++ b/examples-runner/ci/expected/multilock.run
diff --git a/ci/expected/not-sync.run b/examples-runner/ci/expected/not-sync.run
index e69de29b..e69de29b 100644
--- a/ci/expected/not-sync.run
+++ b/examples-runner/ci/expected/not-sync.run
diff --git a/ci/expected/only-shared-access.run b/examples-runner/ci/expected/only-shared-access.run
index dcc73e64..dcc73e64 100644
--- a/ci/expected/only-shared-access.run
+++ b/examples-runner/ci/expected/only-shared-access.run
diff --git a/examples-runner/ci/expected/periodic-at.run b/examples-runner/ci/expected/periodic-at.run
new file mode 100644
index 00000000..7be173d2
--- /dev/null
+++ b/examples-runner/ci/expected/periodic-at.run
@@ -0,0 +1,4 @@
+foo ticks: 0
+foo ticks: 100
+foo ticks: 200
+foo ticks: 300
diff --git a/examples-runner/ci/expected/periodic-at2.run b/examples-runner/ci/expected/periodic-at2.run
new file mode 100644
index 00000000..1fdce8c1
--- /dev/null
+++ b/examples-runner/ci/expected/periodic-at2.run
@@ -0,0 +1,7 @@
+foo ticks: 0
+bar ticks: 10
+foo ticks: 110
+bar ticks: 120
+foo ticks: 220
+bar ticks: 230
+foo ticks: 330
diff --git a/ci/expected/periodic.run b/examples-runner/ci/expected/periodic.run
index a1f89441..a1f89441 100644
--- a/ci/expected/periodic.run
+++ b/examples-runner/ci/expected/periodic.run
diff --git a/ci/expected/peripherals-taken.run b/examples-runner/ci/expected/peripherals-taken.run
index e69de29b..e69de29b 100644
--- a/ci/expected/peripherals-taken.run
+++ b/examples-runner/ci/expected/peripherals-taken.run
diff --git a/examples-runner/ci/expected/pool.run b/examples-runner/ci/expected/pool.run
new file mode 100644
index 00000000..12897652
--- /dev/null
+++ b/examples-runner/ci/expected/pool.run
@@ -0,0 +1,2 @@
+bar
+foo
diff --git a/ci/expected/preempt.run b/examples-runner/ci/expected/preempt.run
index 932b2b32..932b2b32 100644
--- a/ci/expected/preempt.run
+++ b/examples-runner/ci/expected/preempt.run
diff --git a/ci/expected/ramfunc.run b/examples-runner/ci/expected/ramfunc.run
index 257cc564..257cc564 100644
--- a/ci/expected/ramfunc.run
+++ b/examples-runner/ci/expected/ramfunc.run
diff --git a/ci/expected/ramfunc.run.grep.bar b/examples-runner/ci/expected/ramfunc.run.grep.bar
index 33e002fe..33e002fe 100644
--- a/ci/expected/ramfunc.run.grep.bar
+++ b/examples-runner/ci/expected/ramfunc.run.grep.bar
diff --git a/ci/expected/ramfunc.run.grep.foo b/examples-runner/ci/expected/ramfunc.run.grep.foo
index 44e88226..44e88226 100644
--- a/ci/expected/ramfunc.run.grep.foo
+++ b/examples-runner/ci/expected/ramfunc.run.grep.foo
diff --git a/ci/expected/resource-user-struct.run b/examples-runner/ci/expected/resource-user-struct.run
index a587a942..a587a942 100644
--- a/ci/expected/resource-user-struct.run
+++ b/examples-runner/ci/expected/resource-user-struct.run
diff --git a/ci/expected/schedule.run b/examples-runner/ci/expected/schedule.run
index 1dbd445c..1dbd445c 100644
--- a/ci/expected/schedule.run
+++ b/examples-runner/ci/expected/schedule.run
diff --git a/ci/expected/shared.run b/examples-runner/ci/expected/shared.run
index 6d3d3e43..6d3d3e43 100644
--- a/ci/expected/shared.run
+++ b/examples-runner/ci/expected/shared.run
diff --git a/ci/expected/smallest.run b/examples-runner/ci/expected/smallest.run
index e69de29b..e69de29b 100644
--- a/ci/expected/smallest.run
+++ b/examples-runner/ci/expected/smallest.run
diff --git a/ci/expected/spawn.run b/examples-runner/ci/expected/spawn.run
index 240cd18f..240cd18f 100644
--- a/ci/expected/spawn.run
+++ b/examples-runner/ci/expected/spawn.run
diff --git a/ci/expected/static.run b/examples-runner/ci/expected/static.run
index 3d3f46f6..3d3f46f6 100644
--- a/ci/expected/static.run
+++ b/examples-runner/ci/expected/static.run
diff --git a/ci/expected/t-binds.run b/examples-runner/ci/expected/t-binds.run
index e69de29b..e69de29b 100644
--- a/ci/expected/t-binds.run
+++ b/examples-runner/ci/expected/t-binds.run
diff --git a/ci/expected/t-cfg-resources.run b/examples-runner/ci/expected/t-cfg-resources.run
index e69de29b..e69de29b 100644
--- a/ci/expected/t-cfg-resources.run
+++ b/examples-runner/ci/expected/t-cfg-resources.run
diff --git a/ci/expected/t-htask-main.run b/examples-runner/ci/expected/t-htask-main.run
index e69de29b..e69de29b 100644
--- a/ci/expected/t-htask-main.run
+++ b/examples-runner/ci/expected/t-htask-main.run
diff --git a/ci/expected/t-idle-main.run b/examples-runner/ci/expected/t-idle-main.run
index e69de29b..e69de29b 100644
--- a/ci/expected/t-idle-main.run
+++ b/examples-runner/ci/expected/t-idle-main.run
diff --git a/ci/expected/t-late-not-send.run b/examples-runner/ci/expected/t-late-not-send.run
index e69de29b..e69de29b 100644
--- a/ci/expected/t-late-not-send.run
+++ b/examples-runner/ci/expected/t-late-not-send.run
diff --git a/ci/expected/t-schedule.run b/examples-runner/ci/expected/t-schedule.run
index e69de29b..e69de29b 100644
--- a/ci/expected/t-schedule.run
+++ b/examples-runner/ci/expected/t-schedule.run
diff --git a/ci/expected/t-spawn.run b/examples-runner/ci/expected/t-spawn.run
index e69de29b..e69de29b 100644
--- a/ci/expected/t-spawn.run
+++ b/examples-runner/ci/expected/t-spawn.run
diff --git a/ci/expected/task.run b/examples-runner/ci/expected/task.run
index de45dce6..de45dce6 100644
--- a/ci/expected/task.run
+++ b/examples-runner/ci/expected/task.run
diff --git a/examples-runner/embedded-ci.x b/examples-runner/embedded-ci.x
new file mode 100644
index 00000000..f57bc988
--- /dev/null
+++ b/examples-runner/embedded-ci.x
@@ -0,0 +1,10 @@
+MEMORY
+{
+ FLASH : ORIGIN = 0x20000000, LENGTH = 22K
+ RAM : ORIGIN = 0x20000000+22K, LENGTH = 10K
+}
+
+/* This is where the call stack will be allocated. */
+/* The stack is of the full descending type. */
+/* NOTE Do NOT modify `_stack_start` unless you know what you are doing */
+_stack_start = ORIGIN(RAM) + LENGTH(RAM);
diff --git a/examples-runner/examples_to_runner.sh b/examples-runner/examples_to_runner.sh
new file mode 100644
index 00000000..0bbbd631
--- /dev/null
+++ b/examples-runner/examples_to_runner.sh
@@ -0,0 +1,9 @@
+
+# Convert old examples to CI runner
+cp ../examples/* ./src/bin/
+sd "use panic_semihosting as _;" "use examples_runner as _;" src/bin/*
+sd "lm3s6965" "examples_runner::pac" src/bin/*
+sd "use cortex_m_semihosting::.*" "use examples_runner::{println, exit};" src/bin/*
+sd "debug::exit.*" "exit();" src/bin/*
+sd "hprintln" "println" src/bin/*
+sd "\"\).unwrap\(\)" "\")" src/bin/*
diff --git a/examples-runner/qemu.x b/examples-runner/qemu.x
new file mode 100644
index 00000000..6e14429c
--- /dev/null
+++ b/examples-runner/qemu.x
@@ -0,0 +1,13 @@
+MEMORY
+{
+ FLASH : ORIGIN = 0x00000000, LENGTH = 32K
+ RAM : ORIGIN = 0x20000000, LENGTH = 32K
+ # RAM only runner
+ # FLASH : ORIGIN = 0x20000000, LENGTH = 22K
+ # RAM : ORIGIN = 0x20000000+22K, LENGTH = 10K
+}
+
+/* This is where the call stack will be allocated. */
+/* The stack is of the full descending type. */
+/* NOTE Do NOT modify `_stack_start` unless you know what you are doing */
+_stack_start = ORIGIN(RAM) + LENGTH(RAM);
diff --git a/examples/big-struct-opt.rs b/examples-runner/src/bin/big-struct-opt.rs
index bbc2535a..8ff7c2b8 100644
--- a/examples/big-struct-opt.rs
+++ b/examples-runner/src/bin/big-struct-opt.rs
@@ -6,7 +6,7 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
/// Some big struct
pub struct BigStruct {
@@ -20,11 +20,11 @@ impl BigStruct {
}
}
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
use super::BigStruct;
use core::mem::MaybeUninit;
- use cortex_m_semihosting::debug;
+ use examples_runner::exit;
#[shared]
struct Shared {
@@ -42,8 +42,6 @@ mod app {
&mut *cx.local.bs.as_mut_ptr()
};
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
-
(
Shared {
// assign the reference so we can use the resource
@@ -54,6 +52,11 @@ mod app {
)
}
+ #[idle]
+ fn idle(_: idle::Context) -> ! {
+ exit();
+ }
+
#[task(binds = UART0, shared = [big_struct])]
fn task(_: task::Context) {}
}
diff --git a/examples/binds.rs b/examples-runner/src/bin/binds.rs
index 56565cbe..30aae4c8 100644
--- a/examples/binds.rs
+++ b/examples-runner/src/bin/binds.rs
@@ -5,13 +5,13 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
// `examples/interrupt.rs` rewritten to use `binds`
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
- use lm3s6965::Interrupt;
+ use examples_runner::{println, exit};
+ use examples_runner::pac::Interrupt;
#[shared]
struct Shared {}
@@ -23,33 +23,28 @@ mod app {
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
rtic::pend(Interrupt::UART0);
- hprintln!("init").unwrap();
+ println!("init");
(Shared {}, Local {}, init::Monotonics())
}
#[idle]
fn idle(_: idle::Context) -> ! {
- hprintln!("idle").unwrap();
+ println!("idle");
rtic::pend(Interrupt::UART0);
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
-
- loop {
- cortex_m::asm::nop();
- }
+ exit();
}
#[task(binds = UART0, local = [times: u32 = 0])]
fn foo(cx: foo::Context) {
*cx.local.times += 1;
- hprintln!(
+ println!(
"foo called {} time{}",
*cx.local.times,
if *cx.local.times > 1 { "s" } else { "" }
- )
- .unwrap();
+ );
}
}
diff --git a/examples/cancel-reschedule.rs b/examples-runner/src/bin/cancel-reschedule.rs
index a38a9c4e..0f9398c4 100644
--- a/examples/cancel-reschedule.rs
+++ b/examples-runner/src/bin/cancel-reschedule.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
use systick_monotonic::*;
#[monotonic(binds = SysTick, default = true)]
@@ -28,7 +28,7 @@ mod app {
// Initialize the monotonic (SysTick rate in QEMU is 12 MHz)
let mono = Systick::new(systick, 12_000_000);
- hprintln!("init").ok();
+ println!("init");
// Schedule `foo` to run 1 second in the future
foo::spawn_after(1.secs()).unwrap();
@@ -42,7 +42,7 @@ mod app {
#[task]
fn foo(_: foo::Context) {
- hprintln!("foo").ok();
+ println!("foo");
// Schedule `bar` to run 2 seconds in the future (1 second after foo runs)
let spawn_handle = baz::spawn_after(2.secs()).unwrap();
@@ -51,7 +51,7 @@ mod app {
#[task]
fn bar(_: bar::Context, baz_handle: baz::SpawnHandle, do_reschedule: bool) {
- hprintln!("bar").ok();
+ println!("bar");
if do_reschedule {
// Reschedule baz 2 seconds from now, instead of the original 1 second
@@ -61,13 +61,13 @@ mod app {
} else {
// Or cancel it
baz_handle.cancel().unwrap();
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
}
#[task]
fn baz(_: baz::Context) {
- hprintln!("baz").ok();
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ println!("baz");
+ exit();
}
}
diff --git a/examples/capacity.rs b/examples-runner/src/bin/capacity.rs
index a6172698..46d8655f 100644
--- a/examples/capacity.rs
+++ b/examples-runner/src/bin/capacity.rs
@@ -5,12 +5,12 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
- use lm3s6965::Interrupt;
+ use examples_runner::{println, exit};
+ use examples_runner::pac::Interrupt;
#[shared]
struct Shared {}
@@ -37,13 +37,13 @@ mod app {
#[task(capacity = 4)]
fn foo(_: foo::Context, x: u32) {
- hprintln!("foo({})", x).unwrap();
+ println!("foo({})", x);
}
#[task]
fn bar(_: bar::Context) {
- hprintln!("bar").unwrap();
+ println!("bar");
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
}
diff --git a/examples/cfg-whole-task.rs b/examples-runner/src/bin/cfg-whole-task.rs
index f41866db..355785c0 100644
--- a/examples/cfg-whole-task.rs
+++ b/examples-runner/src/bin/cfg-whole-task.rs
@@ -5,13 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0, QEI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0, QEI0])]
mod app {
- use cortex_m_semihosting::debug;
- #[cfg(debug_assertions)]
- use cortex_m_semihosting::hprintln;
+ use examples_runner::exit;
#[shared]
struct Shared {
@@ -41,11 +39,11 @@ mod app {
#[idle]
fn idle(_: idle::Context) -> ! {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
- loop {
- cortex_m::asm::nop();
- }
+ // loop {
+ // cortex_m::asm::nop();
+ // }
}
#[task(capacity = 2, shared = [count])]
@@ -84,11 +82,10 @@ mod app {
#[cfg(debug_assertions)]
#[task(capacity = 2)]
fn log(_: log::Context, n: u32) {
- hprintln!(
+ println!(
"foo has been called {} time{}",
n,
if n == 1 { "" } else { "s" }
- )
- .ok();
+ );
}
}
diff --git a/examples/common.rs b/examples-runner/src/bin/common.rs
index 1fe671e6..f1612989 100644
--- a/examples/common.rs
+++ b/examples-runner/src/bin/common.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0, QEI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0, QEI0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
use systick_monotonic::*; // Implements the `Monotonic` trait
// A monotonic timer to enable scheduling in RTIC
@@ -31,12 +31,7 @@ mod app {
}
#[init]
- fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
- let systick = cx.core.SYST;
-
- // Initialize the monotonic (SysTick rate in QEMU is 12 MHz)
- let mono = Systick::new(systick, 12_000_000);
-
+ fn init(_cx: init::Context) -> (Shared, Local, init::Monotonics) {
// Spawn the task `foo` directly after `init` finishes
foo::spawn().unwrap();
@@ -44,17 +39,17 @@ mod app {
// by the `#[monotonic(..)]` above
bar::spawn_after(1.secs()).unwrap();
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
-
- (
- // Initialization of shared resources
- Shared { s1: 0, s2: 1 },
- // Initialization of task local resources
- Local { l1: 2, l2: 3 },
- // Move the monotonic timer to the RTIC run-time, this enables
- // scheduling
- init::Monotonics(mono),
- )
+ exit();
+
+ // (
+ // // Initialization of shared resources
+ // Shared { s1: 0, s2: 1 },
+ // // Initialization of task local resources
+ // Local { l1: 2, l2: 3 },
+ // // Move the monotonic timer to the RTIC run-time, this enables
+ // // scheduling
+ // init::Monotonics(mono),
+ // )
}
// Background task, runs whenever no other tasks are running
@@ -73,7 +68,7 @@ mod app {
// This task is only spawned once in `init`, hence this task will run
// only once
- hprintln!("foo").ok();
+ println!("foo");
}
// Software task, also not bound to a hardware interrupt
@@ -81,7 +76,7 @@ mod app {
// The resources `s1` and `s2` are shared between all other tasks.
#[task(shared = [s1, s2], local = [l2])]
fn bar(_: bar::Context) {
- hprintln!("bar").ok();
+ println!("bar");
// Run `bar` once per second
bar::spawn_after(1.secs()).unwrap();
@@ -97,6 +92,6 @@ mod app {
// Note that RTIC does NOT clear the interrupt flag, this is up to the
// user
- hprintln!("UART0 interrupt!").ok();
+ println!("UART0 interrupt!");
}
}
diff --git a/examples/complex.rs b/examples-runner/src/bin/complex.rs
index e5cf6dbe..f4b453a0 100644
--- a/examples/complex.rs
+++ b/examples-runner/src/bin/complex.rs
@@ -5,13 +5,13 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
- use lm3s6965::Interrupt;
+ use examples_runner::pac::Interrupt;
+ use examples_runner::{exit, println};
#[shared]
struct Shared {
@@ -25,7 +25,7 @@ mod app {
#[init]
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
- hprintln!("init").unwrap();
+ println!("init");
(
Shared {
@@ -40,37 +40,37 @@ mod app {
#[idle(shared = [s2, s3])]
fn idle(mut cx: idle::Context) -> ! {
- hprintln!("idle p0 started").ok();
+ println!("idle p0 started");
rtic::pend(Interrupt::GPIOC);
cx.shared.s3.lock(|s| {
- hprintln!("idle enter lock s3 {}", s).ok();
- hprintln!("idle pend t0").ok();
+ println!("idle enter lock s3 {}", s);
+ println!("idle pend t0");
rtic::pend(Interrupt::GPIOA); // t0 p2, with shared ceiling 3
- hprintln!("idle pend t1").ok();
+ println!("idle pend t1");
rtic::pend(Interrupt::GPIOB); // t1 p3, with shared ceiling 3
- hprintln!("idle pend t2").ok();
+ println!("idle pend t2");
rtic::pend(Interrupt::GPIOC); // t2 p4, no sharing
- hprintln!("idle still in lock s3 {}", s).ok();
+ println!("idle still in lock s3 {}", s);
});
- hprintln!("\nback in idle").ok();
+ println!("\nback in idle");
cx.shared.s2.lock(|s| {
- hprintln!("enter lock s2 {}", s).ok();
- hprintln!("idle pend t0").ok();
+ println!("enter lock s2 {}", s);
+ println!("idle pend t0");
rtic::pend(Interrupt::GPIOA); // t0 p2, with shared ceiling 2
- hprintln!("idle pend t1").ok();
+ println!("idle pend t1");
rtic::pend(Interrupt::GPIOB); // t1 p3, no sharing
- hprintln!("idle pend t2").ok();
+ println!("idle pend t2");
rtic::pend(Interrupt::GPIOC); // t2 p4, no sharing
- hprintln!("idle still in lock s2 {}", s).ok();
+ println!("idle still in lock s2 {}", s);
});
- hprintln!("\nidle exit").ok();
+ println!("\nidle exit");
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
- loop {
- cortex_m::asm::nop();
- }
+ // loop {
+ // cortex_m::asm::nop();
+ // }
}
#[task(binds = GPIOA, priority = 2, local = [times: u32 = 0], shared = [s2, s3])]
@@ -78,13 +78,12 @@ mod app {
// Safe access to local `static mut` variable
*cx.local.times += 1;
- hprintln!(
+ println!(
"t0 p2 called {} time{}",
*cx.local.times,
if *cx.local.times > 1 { "s" } else { "" }
- )
- .ok();
- hprintln!("t0 p2 exit").ok();
+ );
+ println!("t0 p2 exit");
}
#[task(binds = GPIOB, priority = 3, local = [times: u32 = 0], shared = [s3, s4])]
@@ -92,23 +91,22 @@ mod app {
// Safe access to local `static mut` variable
*cx.local.times += 1;
- hprintln!(
+ println!(
"t1 p3 called {} time{}",
*cx.local.times,
if *cx.local.times > 1 { "s" } else { "" }
- )
- .ok();
+ );
cx.shared.s4.lock(|s| {
- hprintln!("t1 enter lock s4 {}", s).ok();
- hprintln!("t1 pend t0").ok();
+ println!("t1 enter lock s4 {}", s);
+ println!("t1 pend t0");
rtic::pend(Interrupt::GPIOA); // t0 p2, with shared ceiling 2
- hprintln!("t1 pend t2").ok();
+ println!("t1 pend t2");
rtic::pend(Interrupt::GPIOC); // t2 p4, no sharing
- hprintln!("t1 still in lock s4 {}", s).ok();
+ println!("t1 still in lock s4 {}", s);
});
- hprintln!("t1 p3 exit").ok();
+ println!("t1 p3 exit");
}
#[task(binds = GPIOC, priority = 4, local = [times: u32 = 0], shared = [s4])]
@@ -116,17 +114,16 @@ mod app {
// Safe access to local `static mut` variable
*cx.local.times += 1;
- hprintln!(
+ println!(
"t2 p4 called {} time{}",
*cx.local.times,
if *cx.local.times > 1 { "s" } else { "" }
- )
- .unwrap();
+ );
cx.shared.s4.lock(|s| {
- hprintln!("enter lock s4 {}", s).ok();
+ println!("enter lock s4 {}", s);
*s += 1;
});
- hprintln!("t3 p4 exit").ok();
+ println!("t3 p4 exit");
}
}
diff --git a/examples/declared_locals.rs b/examples-runner/src/bin/declared_locals.rs
index 52d354bc..5873f2d5 100644
--- a/examples/declared_locals.rs
+++ b/examples-runner/src/bin/declared_locals.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [UART0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [UART0])]
mod app {
- use cortex_m_semihosting::debug;
+ use examples_runner::exit;
#[shared]
struct Shared {}
@@ -22,9 +22,9 @@ mod app {
// Locals in `#[init]` have 'static lifetime
let _a: &'static mut u32 = cx.local.a;
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
- (Shared {}, Local {}, init::Monotonics())
+ // (Shared {}, Local {}, init::Monotonics())
}
#[idle(local = [a: u32 = 0])]
diff --git a/examples/destructure.rs b/examples-runner/src/bin/destructure.rs
index 6019c225..7ecc47b8 100644
--- a/examples/destructure.rs
+++ b/examples-runner/src/bin/destructure.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [UART0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [UART0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {
@@ -31,8 +31,8 @@ mod app {
#[idle]
fn idle(_: idle::Context) -> ! {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
- loop {}
+ exit();
+ // loop {}
}
// Direct destructure
@@ -42,7 +42,7 @@ mod app {
let b = cx.shared.b;
let c = cx.shared.c;
- hprintln!("foo: a = {}, b = {}, c = {}", a, b, c).unwrap();
+ println!("foo: a = {}, b = {}, c = {}", a, b, c);
}
// De-structure-ing syntax
@@ -50,6 +50,6 @@ mod app {
fn bar(cx: bar::Context) {
let bar::SharedResources { a, b, c } = cx.shared;
- hprintln!("bar: a = {}, b = {}, c = {}", a, b, c).unwrap();
+ println!("bar: a = {}, b = {}, c = {}", a, b, c);
}
}
diff --git a/examples/extern_binds.rs b/examples-runner/src/bin/extern_binds.rs
index 4dc6633c..efe02e88 100644
--- a/examples/extern_binds.rs
+++ b/examples-runner/src/bin/extern_binds.rs
@@ -5,19 +5,19 @@
#![no_main]
#![no_std]
-use cortex_m_semihosting::hprintln;
-use panic_semihosting as _;
+use examples_runner as _;
+use examples_runner::println;
// Free function implementing the interrupt bound task `foo`.
fn foo(_: app::foo::Context) {
- hprintln!("foo called").ok();
+ println!("foo called");
}
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
use crate::foo;
- use cortex_m_semihosting::{debug, hprintln};
- use lm3s6965::Interrupt;
+ use examples_runner::pac::Interrupt;
+ use examples_runner::{exit, println};
#[shared]
struct Shared {}
@@ -29,22 +29,22 @@ mod app {
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
rtic::pend(Interrupt::UART0);
- hprintln!("init").unwrap();
+ println!("init");
(Shared {}, Local {}, init::Monotonics())
}
#[idle]
fn idle(_: idle::Context) -> ! {
- hprintln!("idle").unwrap();
+ println!("idle");
rtic::pend(Interrupt::UART0);
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
- loop {
- cortex_m::asm::nop();
- }
+ // loop {
+ // cortex_m::asm::nop();
+ // }
}
extern "Rust" {
diff --git a/examples/extern_spawn.rs b/examples-runner/src/bin/extern_spawn.rs
index 7f9b5a5f..8342756e 100644
--- a/examples/extern_spawn.rs
+++ b/examples-runner/src/bin/extern_spawn.rs
@@ -5,19 +5,19 @@
#![no_main]
#![no_std]
-use cortex_m_semihosting::{debug, hprintln};
-use panic_semihosting as _;
+use examples_runner::{println, exit};
+use examples_runner as _;
// Free function implementing the spawnable task `foo`.
fn foo(_c: app::foo::Context, x: i32, y: u32) {
- hprintln!("foo {}, {}", x, y).unwrap();
+ println!("foo {}, {}", x, y);
if x == 2 {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
app::foo::spawn(2, 3).unwrap();
}
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
use crate::foo;
diff --git a/examples/generics.rs b/examples-runner/src/bin/generics.rs
index 72b861ba..01fb399e 100644
--- a/examples/generics.rs
+++ b/examples-runner/src/bin/generics.rs
@@ -5,14 +5,14 @@
#![no_main]
#![no_std]
-use cortex_m_semihosting::hprintln;
-use panic_semihosting as _;
+use examples_runner as _;
+use examples_runner::println;
use rtic::Mutex;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
- use lm3s6965::Interrupt;
+ use examples_runner::pac::Interrupt;
+ use examples_runner::{exit, println};
#[shared]
struct Shared {
@@ -32,19 +32,19 @@ mod app {
#[task(binds = UART0, shared = [shared], local = [state: u32 = 0])]
fn uart0(c: uart0::Context) {
- hprintln!("UART0(STATE = {})", *c.local.state).unwrap();
+ println!("UART0(STATE = {})", *c.local.state);
// second argument has type `shared::shared`
super::advance(c.local.state, c.shared.shared);
rtic::pend(Interrupt::UART1);
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
#[task(binds = UART1, priority = 2, shared = [shared], local = [state: u32 = 0])]
fn uart1(c: uart1::Context) {
- hprintln!("UART1(STATE = {})", *c.local.state).unwrap();
+ println!("UART1(STATE = {})", *c.local.state);
// second argument has type `shared::shared`
super::advance(c.local.state, c.shared.shared);
@@ -61,5 +61,5 @@ fn advance(state: &mut u32, mut shared: impl Mutex<T = u32>) {
(old, *shared)
});
- hprintln!("shared: {} -> {}", old, new).unwrap();
+ println!("shared: {} -> {}", old, new);
}
diff --git a/examples/hardware.rs b/examples-runner/src/bin/hardware.rs
index 60632247..4b6662aa 100644
--- a/examples/hardware.rs
+++ b/examples-runner/src/bin/hardware.rs
@@ -5,12 +5,12 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
- use lm3s6965::Interrupt;
+ use examples_runner::pac::Interrupt;
+ use examples_runner::{exit, println};
#[shared]
struct Shared {}
@@ -24,7 +24,7 @@ mod app {
// `init` returns because interrupts are disabled
rtic::pend(Interrupt::UART0); // equivalent to NVIC::pend
- hprintln!("init").unwrap();
+ println!("init");
(Shared {}, Local {}, init::Monotonics())
}
@@ -33,15 +33,15 @@ mod app {
fn idle(_: idle::Context) -> ! {
// interrupts are enabled again; the `UART0` handler runs at this point
- hprintln!("idle").unwrap();
+ println!("idle");
rtic::pend(Interrupt::UART0);
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
- loop {
- cortex_m::asm::nop();
- }
+ // loop {
+ // cortex_m::asm::nop();
+ // }
}
#[task(binds = UART0, local = [times: u32 = 0])]
@@ -49,11 +49,10 @@ mod app {
// Safe access to local `static mut` variable
*cx.local.times += 1;
- hprintln!(
+ println!(
"UART0 called {} time{}",
*cx.local.times,
if *cx.local.times > 1 { "s" } else { "" }
- )
- .unwrap();
+ );
}
}
diff --git a/examples/idle-wfi.rs b/examples-runner/src/bin/idle-wfi.rs
index 4a8a8dee..b98e787c 100644
--- a/examples/idle-wfi.rs
+++ b/examples-runner/src/bin/idle-wfi.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {}
@@ -19,7 +19,7 @@ mod app {
#[init]
fn init(mut cx: init::Context) -> (Shared, Local, init::Monotonics) {
- hprintln!("init").unwrap();
+ println!("init");
// Set the ARM SLEEPONEXIT bit to go to sleep after handling interrupts
// See https://developer.arm.com/docs/100737/0100/power-management/sleep-mode/sleep-on-exit-bit
@@ -33,15 +33,15 @@ mod app {
// Locals in idle have lifetime 'static
let _x: &'static mut u32 = cx.local.x;
- hprintln!("idle").unwrap();
+ println!("idle");
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
- loop {
- // Now Wait For Interrupt is used instead of a busy-wait loop
- // to allow MCU to sleep between interrupts
- // https://developer.arm.com/documentation/ddi0406/c/Application-Level-Architecture/Instruction-Details/Alphabetical-list-of-instructions/WFI
- rtic::export::wfi()
- }
+ // loop {
+ // // Now Wait For Interrupt is used instead of a busy-wait loop
+ // // to allow MCU to sleep between interrupts
+ // // https://developer.arm.com/documentation/ddi0406/c/Application-Level-Architecture/Instruction-Details/Alphabetical-list-of-instructions/WFI
+ // rtic::export::wfi()
+ // }
}
}
diff --git a/examples/idle.rs b/examples-runner/src/bin/idle.rs
index 55d6b153..c74999e4 100644
--- a/examples/idle.rs
+++ b/examples-runner/src/bin/idle.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {}
@@ -19,7 +19,7 @@ mod app {
#[init]
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
- hprintln!("init").unwrap();
+ println!("init");
(Shared {}, Local {}, init::Monotonics())
}
@@ -29,12 +29,12 @@ mod app {
// Locals in idle have lifetime 'static
let _x: &'static mut u32 = cx.local.x;
- hprintln!("idle").unwrap();
+ println!("idle");
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
- loop {
- cortex_m::asm::nop();
- }
+ // loop {
+ // cortex_m::asm::nop();
+ // }
}
}
diff --git a/examples/init.rs b/examples-runner/src/bin/init.rs
index b8a5bc5b..dc8e5729 100644
--- a/examples/init.rs
+++ b/examples-runner/src/bin/init.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, peripherals = true)]
+#[rtic::app(device = examples_runner::pac, peripherals = true)]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {}
@@ -23,7 +23,7 @@ mod app {
let _core: cortex_m::Peripherals = cx.core;
// Device specific peripherals
- let _device: lm3s6965::Peripherals = cx.device;
+ let _device: examples_runner::pac::Peripherals = cx.device;
// Locals in `init` have 'static lifetime
let _x: &'static mut u32 = cx.local.x;
@@ -32,10 +32,10 @@ mod app {
// to indicate that this is a critical seciton
let _cs_token: bare_metal::CriticalSection = cx.cs;
- hprintln!("init").unwrap();
+ println!("init");
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
- (Shared {}, Local {}, init::Monotonics())
+ // (Shared {}, Local {}, init::Monotonics())
}
}
diff --git a/examples/locals.rs b/examples-runner/src/bin/locals.rs
index aa5d0fee..93663d0e 100644
--- a/examples/locals.rs
+++ b/examples-runner/src/bin/locals.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [UART0, UART1])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [UART0, UART1])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {}
@@ -45,9 +45,9 @@ mod app {
let local_to_idle = cx.local.local_to_idle;
*local_to_idle += 1;
- hprintln!("idle: local_to_idle = {}", local_to_idle).unwrap();
+ println!("idle: local_to_idle = {}", local_to_idle);
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
// error: no `local_to_foo` field in `idle::LocalResources`
// _cx.local.local_to_foo += 1;
@@ -55,9 +55,9 @@ mod app {
// error: no `local_to_bar` field in `idle::LocalResources`
// _cx.local.local_to_bar += 1;
- loop {
- cortex_m::asm::nop();
- }
+ // loop {
+ // cortex_m::asm::nop();
+ // }
}
// `local_to_foo` can only be accessed from this context
@@ -69,7 +69,7 @@ mod app {
// error: no `local_to_bar` field in `foo::LocalResources`
// cx.local.local_to_bar += 1;
- hprintln!("foo: local_to_foo = {}", local_to_foo).unwrap();
+ println!("foo: local_to_foo = {}", local_to_foo);
}
// `local_to_bar` can only be accessed from this context
@@ -81,6 +81,6 @@ mod app {
// error: no `local_to_foo` field in `bar::LocalResources`
// cx.local.local_to_foo += 1;
- hprintln!("bar: local_to_bar = {}", local_to_bar).unwrap();
+ println!("bar: local_to_bar = {}", local_to_bar);
}
}
diff --git a/examples/lock-free.rs b/examples-runner/src/bin/lock-free.rs
index ea6ff1bf..2281dd55 100644
--- a/examples/lock-free.rs
+++ b/examples-runner/src/bin/lock-free.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [GPIOA])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [GPIOA])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {
@@ -33,7 +33,7 @@ mod app {
*c.shared.counter += 1; // <- no lock API required
let counter = *c.shared.counter;
- hprintln!(" foo = {}", counter).unwrap();
+ println!(" foo = {}", counter);
}
#[task(shared = [counter])] // <- same priority
@@ -42,8 +42,8 @@ mod app {
*c.shared.counter += 1; // <- no lock API required
let counter = *c.shared.counter;
- hprintln!(" bar = {}", counter).unwrap();
+ println!(" bar = {}", counter);
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
}
diff --git a/examples/lock.rs b/examples-runner/src/bin/lock.rs
index f1a16968..6ad0e2a0 100644
--- a/examples/lock.rs
+++ b/examples-runner/src/bin/lock.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [GPIOA, GPIOB, GPIOC])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [GPIOA, GPIOB, GPIOC])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {
@@ -29,7 +29,7 @@ mod app {
// when omitted priority is assumed to be `1`
#[task(shared = [shared])]
fn foo(mut c: foo::Context) {
- hprintln!("A").unwrap();
+ println!("A");
// the lower priority task requires a critical section to access the data
c.shared.shared.lock(|shared| {
@@ -39,7 +39,7 @@ mod app {
// bar will *not* run right now due to the critical section
bar::spawn().unwrap();
- hprintln!("B - shared = {}", *shared).unwrap();
+ println!("B - shared = {}", *shared);
// baz does not contend for `shared` so it's allowed to run now
baz::spawn().unwrap();
@@ -47,9 +47,9 @@ mod app {
// critical section is over: bar can now start
- hprintln!("E").unwrap();
+ println!("E");
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
#[task(priority = 2, shared = [shared])]
@@ -61,11 +61,11 @@ mod app {
*shared
});
- hprintln!("D - shared = {}", shared).unwrap();
+ println!("D - shared = {}", shared);
}
#[task(priority = 3)]
fn baz(_: baz::Context) {
- hprintln!("C").unwrap();
+ println!("C");
}
}
diff --git a/examples/message.rs b/examples-runner/src/bin/message.rs
index 76c5675a..278b7d04 100644
--- a/examples/message.rs
+++ b/examples-runner/src/bin/message.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {}
@@ -26,7 +26,7 @@ mod app {
#[task(local = [count: u32 = 0])]
fn foo(cx: foo::Context) {
- hprintln!("foo").unwrap();
+ println!("foo");
bar::spawn(*cx.local.count).unwrap();
*cx.local.count += 1;
@@ -34,17 +34,17 @@ mod app {
#[task]
fn bar(_: bar::Context, x: u32) {
- hprintln!("bar({})", x).unwrap();
+ println!("bar({})", x);
baz::spawn(x + 1, x + 2).unwrap();
}
#[task]
fn baz(_: baz::Context, x: u32, y: u32) {
- hprintln!("baz({}, {})", x, y).unwrap();
+ println!("baz({}, {})", x, y);
if x + y > 4 {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
foo::spawn().unwrap();
diff --git a/examples/message_passing.rs b/examples-runner/src/bin/message_passing.rs
index ffa95371..106c8e5a 100644
--- a/examples/message_passing.rs
+++ b/examples-runner/src/bin/message_passing.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {}
@@ -29,9 +29,9 @@ mod app {
#[task(capacity = 3)]
fn foo(_c: foo::Context, x: i32, y: u32) {
- hprintln!("foo {}, {}", x, y).unwrap();
+ println!("foo {}, {}", x, y);
if x == 2 {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
}
}
diff --git a/examples/multilock.rs b/examples-runner/src/bin/multilock.rs
index d99bae69..aba5884d 100644
--- a/examples/multilock.rs
+++ b/examples-runner/src/bin/multilock.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [GPIOA])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [GPIOA])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {
@@ -48,9 +48,9 @@ mod app {
*s2 += 1;
*s3 += 1;
- hprintln!("Multiple locks, s1: {}, s2: {}, s3: {}", *s1, *s2, *s3).unwrap();
+ println!("Multiple locks, s1: {}, s2: {}, s3: {}", *s1, *s2, *s3);
});
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
}
diff --git a/examples/not-sync.rs b/examples-runner/src/bin/not-sync.rs
index aa79ad56..9ed19c22 100644
--- a/examples/not-sync.rs
+++ b/examples-runner/src/bin/not-sync.rs
@@ -6,7 +6,7 @@
#![no_std]
use core::marker::PhantomData;
-use panic_semihosting as _;
+use examples_runner as _;
pub struct NotSync {
_0: PhantomData<*const ()>,
@@ -14,11 +14,11 @@ pub struct NotSync {
unsafe impl Send for NotSync {}
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
use super::NotSync;
use core::marker::PhantomData;
- use cortex_m_semihosting::debug;
+ use examples_runner::exit;
#[shared]
struct Shared {
@@ -30,8 +30,6 @@ mod app {
#[init]
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
-
(
Shared {
shared: NotSync { _0: PhantomData },
@@ -41,6 +39,11 @@ mod app {
)
}
+ #[idle]
+ fn idle(_: idle::Context) -> ! {
+ exit();
+ }
+
#[task(shared = [&shared])]
fn foo(c: foo::Context) {
let _: &NotSync = c.shared.shared;
diff --git a/examples/only-shared-access.rs b/examples-runner/src/bin/only-shared-access.rs
index 8b0a77ef..a28e7c0d 100644
--- a/examples/only-shared-access.rs
+++ b/examples-runner/src/bin/only-shared-access.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [UART0, UART1])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [UART0, UART1])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{exit, println};
#[shared]
struct Shared {
@@ -30,13 +30,13 @@ mod app {
#[task(shared = [&key])]
fn foo(cx: foo::Context) {
let key: &u32 = cx.shared.key;
- hprintln!("foo(key = {:#x})", key).unwrap();
+ println!("foo(key = {:#x})", key);
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
#[task(priority = 2, shared = [&key])]
fn bar(cx: bar::Context) {
- hprintln!("bar(key = {:#x})", cx.shared.key).unwrap();
+ println!("bar(key = {:#x})", cx.shared.key);
}
}
diff --git a/examples/periodic-at.rs b/examples-runner/src/bin/periodic-at.rs
index f9fd995f..8e235c23 100644
--- a/examples/periodic-at.rs
+++ b/examples-runner/src/bin/periodic-at.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
use systick_monotonic::*;
#[monotonic(binds = SysTick, default = true)]
@@ -35,11 +35,11 @@ mod app {
#[task(local = [cnt: u32 = 0])]
fn foo(cx: foo::Context, instant: fugit::TimerInstantU64<100>) {
- hprintln!("foo {:?}", instant).ok();
+ println!("foo ticks: {:?}", instant.ticks());
*cx.local.cnt += 1;
if *cx.local.cnt == 4 {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
// Periodic ever 1 seconds
diff --git a/examples/periodic-at2.rs b/examples-runner/src/bin/periodic-at2.rs
index 879f709c..5071c430 100644
--- a/examples/periodic-at2.rs
+++ b/examples-runner/src/bin/periodic-at2.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
use systick_monotonic::*;
#[monotonic(binds = SysTick, default = true)]
@@ -36,11 +36,11 @@ mod app {
// Using the explicit type of the timer implementation
#[task(local = [cnt: u32 = 0])]
fn foo(cx: foo::Context, instant: fugit::TimerInstantU64<100>) {
- hprintln!("foo {:?}", instant).ok();
+ println!("foo ticks: {:?}", instant.ticks());
*cx.local.cnt += 1;
if *cx.local.cnt == 4 {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
// Spawn a new message with 100 ms offset to spawned time
@@ -52,7 +52,7 @@ mod app {
// This remains agnostic to the timer implementation
#[task(local = [cnt: u32 = 0])]
fn bar(_cx: bar::Context, instant: <MyMono as rtic_monotonic::Monotonic>::Instant) {
- hprintln!("bar {:?}", instant).ok();
+ println!("bar ticks: {:?}", instant.ticks());
// Spawn a new message with 1s offset to spawned time
let next_instant = instant + 1.secs();
diff --git a/examples/periodic.rs b/examples-runner/src/bin/periodic.rs
index 40c69257..e6548202 100644
--- a/examples/periodic.rs
+++ b/examples-runner/src/bin/periodic.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
use systick_monotonic::*;
#[monotonic(binds = SysTick, default = true)]
@@ -35,11 +35,11 @@ mod app {
#[task(local = [cnt: u32 = 0])]
fn foo(cx: foo::Context) {
- hprintln!("foo").ok();
+ println!("foo");
*cx.local.cnt += 1;
if *cx.local.cnt == 4 {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
// Periodic ever 1 seconds
diff --git a/examples/peripherals-taken.rs b/examples-runner/src/bin/peripherals-taken.rs
index d542c0e6..67742eb1 100644
--- a/examples/peripherals-taken.rs
+++ b/examples-runner/src/bin/peripherals-taken.rs
@@ -3,11 +3,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::debug;
+ use examples_runner::exit;
#[shared]
struct Shared {}
@@ -18,8 +18,8 @@ mod app {
#[init]
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
assert!(cortex_m::Peripherals::take().is_none());
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
- (Shared {}, Local {}, init::Monotonics())
+ // (Shared {}, Local {}, init::Monotonics())
}
}
diff --git a/examples/pool.rs b/examples-runner/src/bin/pool.rs
index d59bd916..b8a23380 100644
--- a/examples/pool.rs
+++ b/examples-runner/src/bin/pool.rs
@@ -9,17 +9,17 @@ use heapless::{
pool,
pool::singleton::{Box, Pool},
};
-use panic_semihosting as _;
+use examples_runner as _;
use rtic::app;
// Declare a pool of 128-byte memory blocks
pool!(P: [u8; 128]);
-#[app(device = lm3s6965, dispatchers = [SSI0, QEI0])]
+#[app(device = examples_runner::pac, dispatchers = [SSI0, QEI0])]
mod app {
use crate::{Box, Pool};
- use cortex_m_semihosting::{debug, hprintln};
- use lm3s6965::Interrupt;
+ use examples_runner::{println, exit};
+ use examples_runner::pac::Interrupt;
// Import the memory pool into scope
use super::P;
@@ -56,17 +56,17 @@ mod app {
#[task]
fn foo(_: foo::Context, x: Box<P>) {
- hprintln!("foo({:?})", x.as_ptr()).unwrap();
+ println!("foo");
// explicitly return the block to the pool
drop(x);
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
#[task(priority = 2)]
- fn bar(_: bar::Context, x: Box<P>) {
- hprintln!("bar({:?})", x.as_ptr()).unwrap();
+ fn bar(_: bar::Context, _x: Box<P>) {
+ println!("bar");
// this is done automatically so we can omit the call to `drop`
// drop(x);
diff --git a/examples/preempt.rs b/examples-runner/src/bin/preempt.rs
index d0c8cc7d..4b8b657f 100644
--- a/examples/preempt.rs
+++ b/examples-runner/src/bin/preempt.rs
@@ -3,12 +3,12 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
use rtic::app;
-#[app(device = lm3s6965, dispatchers = [SSI0, QEI0])]
+#[app(device = examples_runner::pac, dispatchers = [SSI0, QEI0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {}
@@ -25,21 +25,21 @@ mod app {
#[task(priority = 1)]
fn foo(_: foo::Context) {
- hprintln!("foo - start").unwrap();
+ println!("foo - start");
baz::spawn().unwrap();
- hprintln!("foo - end").unwrap();
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ println!("foo - end");
+ exit();
}
#[task(priority = 2)]
fn bar(_: bar::Context) {
- hprintln!(" bar").unwrap();
+ println!(" bar");
}
#[task(priority = 2)]
fn baz(_: baz::Context) {
- hprintln!(" baz - start").unwrap();
+ println!(" baz - start");
bar::spawn().unwrap();
- hprintln!(" baz - end").unwrap();
+ println!(" baz - end");
}
}
diff --git a/examples/ramfunc.rs b/examples-runner/src/bin/ramfunc.rs
index 54acd7e8..32f885d3 100644
--- a/examples/ramfunc.rs
+++ b/examples-runner/src/bin/ramfunc.rs
@@ -5,10 +5,10 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
#[rtic::app(
- device = lm3s6965,
+ device = examples_runner::pac,
dispatchers = [
UART0,
#[link_section = ".data.UART1"]
@@ -16,7 +16,7 @@ use panic_semihosting as _;
])
]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {}
@@ -34,9 +34,9 @@ mod app {
#[inline(never)]
#[task]
fn foo(_: foo::Context) {
- hprintln!("foo").unwrap();
+ println!("foo");
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
// run this task from RAM
diff --git a/examples/resource-user-struct.rs b/examples-runner/src/bin/resource-user-struct.rs
index ae1918d0..5051c1f9 100644
--- a/examples/resource-user-struct.rs
+++ b/examples-runner/src/bin/resource-user-struct.rs
@@ -5,12 +5,12 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
- use lm3s6965::Interrupt;
+ use examples_runner::{println, exit};
+ use examples_runner::pac::Interrupt;
#[shared]
struct Shared {
@@ -39,12 +39,12 @@ mod app {
// `shared` cannot be accessed from this context
#[idle]
fn idle(_cx: idle::Context) -> ! {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
// error: no `shared` field in `idle::Context`
// _cx.shared.shared += 1;
- loop {}
+ // loop {}
}
// `shared` can be accessed from this context
@@ -55,7 +55,7 @@ mod app {
*shared
});
- hprintln!("UART0: shared = {}", shared).unwrap();
+ println!("UART0: shared = {}", shared);
}
// `shared` can be accessed from this context
@@ -66,6 +66,6 @@ mod app {
*shared
});
- hprintln!("UART1: shared = {}", shared).unwrap();
+ println!("UART1: shared = {}", shared);
}
}
diff --git a/examples/schedule.rs b/examples-runner/src/bin/schedule.rs
index 5bad5a30..4242d7e5 100644
--- a/examples/schedule.rs
+++ b/examples-runner/src/bin/schedule.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
use systick_monotonic::*;
#[monotonic(binds = SysTick, default = true)]
@@ -28,7 +28,7 @@ mod app {
// Initialize the monotonic (SysTick rate in QEMU is 12 MHz)
let mono = Systick::new(systick, 12_000_000);
- hprintln!("init").ok();
+ println!("init");
// Schedule `foo` to run 1 second in the future
foo::spawn_after(1.secs()).unwrap();
@@ -42,7 +42,7 @@ mod app {
#[task]
fn foo(_: foo::Context) {
- hprintln!("foo").ok();
+ println!("foo");
// Schedule `bar` to run 2 seconds in the future (1 second after foo runs)
bar::spawn_after(1.secs()).unwrap();
@@ -50,7 +50,7 @@ mod app {
#[task]
fn bar(_: bar::Context) {
- hprintln!("bar").ok();
+ println!("bar");
// Schedule `baz` to run 1 seconds from now, but with a specific time instant.
baz::spawn_at(monotonics::now() + 1.secs()).unwrap();
@@ -58,7 +58,7 @@ mod app {
#[task]
fn baz(_: baz::Context) {
- hprintln!("baz").ok();
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ println!("baz");
+ exit();
}
}
diff --git a/examples/shared.rs b/examples-runner/src/bin/shared.rs
index d87dca52..fa7bff02 100644
--- a/examples/shared.rs
+++ b/examples-runner/src/bin/shared.rs
@@ -5,13 +5,13 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
use heapless::spsc::{Consumer, Producer, Queue};
- use lm3s6965::Interrupt;
+ use examples_runner::pac::Interrupt;
#[shared]
struct Shared {
@@ -34,9 +34,9 @@ mod app {
fn idle(mut c: idle::Context) -> ! {
loop {
if let Some(byte) = c.shared.c.lock(|c| c.dequeue()) {
- hprintln!("received message: {}", byte).unwrap();
+ println!("received message: {}", byte);
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
} else {
rtic::pend(Interrupt::UART0);
}
diff --git a/examples/smallest.rs b/examples-runner/src/bin/smallest.rs
index b121fcff..c5869d1e 100644
--- a/examples/smallest.rs
+++ b/examples-runner/src/bin/smallest.rs
@@ -3,12 +3,12 @@
#![no_main]
#![no_std]
-use panic_semihosting as _; // panic handler
+use examples_runner as _; // panic handler
use rtic::app;
-#[app(device = lm3s6965)]
+#[app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::debug;
+ use examples_runner::exit;
#[shared]
struct Shared {}
@@ -18,7 +18,7 @@ mod app {
#[init]
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
- (Shared {}, Local {}, init::Monotonics())
+ exit();
+ // (Shared {}, Local {}, init::Monotonics())
}
}
diff --git a/examples/spawn.rs b/examples-runner/src/bin/spawn.rs
index 2db1ab8a..ea63327f 100644
--- a/examples/spawn.rs
+++ b/examples-runner/src/bin/spawn.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {}
@@ -19,7 +19,7 @@ mod app {
#[init]
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
- hprintln!("init").unwrap();
+ println!("init");
foo::spawn().unwrap();
(Shared {}, Local {}, init::Monotonics())
@@ -27,8 +27,8 @@ mod app {
#[task]
fn foo(_: foo::Context) {
- hprintln!("foo").unwrap();
+ println!("foo");
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
}
diff --git a/examples/static.rs b/examples-runner/src/bin/static.rs
index c9aa6046..4563833b 100644
--- a/examples/static.rs
+++ b/examples-runner/src/bin/static.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [UART0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [UART0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
use heapless::spsc::{Consumer, Producer, Queue};
#[shared]
@@ -37,11 +37,11 @@ mod app {
loop {
// Lock-free access to the same underlying queue!
if let Some(data) = c.local.c.dequeue() {
- hprintln!("received message: {}", data).unwrap();
+ println!("received message: {}", data);
// Run foo until data
if data == 3 {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
} else {
foo::spawn().unwrap();
}
diff --git a/examples/t-binds.rs b/examples-runner/src/bin/t-binds.rs
index 12479c0a..59841e67 100644
--- a/examples/t-binds.rs
+++ b/examples-runner/src/bin/t-binds.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::debug;
+ use examples_runner::exit;
#[shared]
struct Shared {}
@@ -19,9 +19,9 @@ mod app {
#[init]
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
- (Shared {}, Local {}, init::Monotonics())
+ // (Shared {}, Local {}, init::Monotonics())
}
// Cortex-M exception
diff --git a/examples/t-cfg-resources.rs b/examples-runner/src/bin/t-cfg-resources.rs
index 99c97ba5..667b57be 100644
--- a/examples/t-cfg-resources.rs
+++ b/examples-runner/src/bin/t-cfg-resources.rs
@@ -3,11 +3,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::debug;
+ use examples_runner::exit;
#[shared]
struct Shared {
@@ -21,8 +21,6 @@ mod app {
#[init]
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
-
(
Shared {
#[cfg(feature = "feature_x")]
@@ -35,8 +33,9 @@ mod app {
#[idle]
fn idle(_cx: idle::Context) -> ! {
- loop {
- cortex_m::asm::nop();
- }
+ exit();
+ // loop {
+ // cortex_m::asm::nop();
+ // }
}
}
diff --git a/examples/t-htask-main.rs b/examples-runner/src/bin/t-htask-main.rs
index 37189faf..62030c8a 100644
--- a/examples/t-htask-main.rs
+++ b/examples-runner/src/bin/t-htask-main.rs
@@ -3,11 +3,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::debug;
+ use examples_runner::exit;
#[shared]
struct Shared {}
@@ -17,13 +17,13 @@ mod app {
#[init]
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
- rtic::pend(lm3s6965::Interrupt::UART0);
+ rtic::pend(examples_runner::pac::Interrupt::UART0);
(Shared {}, Local {}, init::Monotonics())
}
#[task(binds = UART0)]
fn taskmain(_: taskmain::Context) {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
}
diff --git a/examples/t-idle-main.rs b/examples-runner/src/bin/t-idle-main.rs
index 1adc9bf0..f92117a4 100644
--- a/examples/t-idle-main.rs
+++ b/examples-runner/src/bin/t-idle-main.rs
@@ -3,11 +3,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
- use cortex_m_semihosting::debug;
+ use examples_runner::exit;
#[shared]
struct Shared {}
@@ -22,9 +22,9 @@ mod app {
#[idle]
fn taskmain(_: taskmain::Context) -> ! {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
- loop {
- cortex_m::asm::nop();
- }
+ exit();
+ // loop {
+ // cortex_m::asm::nop();
+ // }
}
}
diff --git a/examples/t-late-not-send.rs b/examples-runner/src/bin/t-late-not-send.rs
index 06aedaa2..f80d5f50 100644
--- a/examples/t-late-not-send.rs
+++ b/examples-runner/src/bin/t-late-not-send.rs
@@ -5,17 +5,17 @@
use core::marker::PhantomData;
-use panic_semihosting as _;
+use examples_runner as _;
pub struct NotSend {
_0: PhantomData<*const ()>,
}
-#[rtic::app(device = lm3s6965)]
+#[rtic::app(device = examples_runner::pac)]
mod app {
use super::NotSend;
use core::marker::PhantomData;
- use cortex_m_semihosting::debug;
+ use examples_runner::exit;
#[shared]
struct Shared {
@@ -40,9 +40,9 @@ mod app {
#[idle(shared = [x, y])]
fn idle(_: idle::Context) -> ! {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
- loop {
- cortex_m::asm::nop();
- }
+ exit();
+ // loop {
+ // cortex_m::asm::nop();
+ // }
}
}
diff --git a/examples/t-schedule.rs b/examples-runner/src/bin/t-schedule.rs
index 5ec42087..1f1d7fc6 100644
--- a/examples/t-schedule.rs
+++ b/examples-runner/src/bin/t-schedule.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
- use cortex_m_semihosting::debug;
+ use examples_runner::exit;
use systick_monotonic::*;
#[monotonic(binds = SysTick, default = true)]
@@ -22,15 +22,10 @@ mod app {
struct Local {}
#[init]
- fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
- let systick = cx.core.SYST;
+ fn init(_cx: init::Context) -> (Shared, Local, init::Monotonics) {
+ exit();
- // Initialize the monotonic (SysTick rate in QEMU is 12 MHz)
- let mono = Systick::new(systick, 12_000_000);
-
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
-
- (Shared {}, Local {}, init::Monotonics(mono))
+ // (Shared {}, Local {}, init::Monotonics(mono))
}
#[idle]
diff --git a/examples/t-spawn.rs b/examples-runner/src/bin/t-spawn.rs
index 2bd771d7..6455ac0c 100644
--- a/examples/t-spawn.rs
+++ b/examples-runner/src/bin/t-spawn.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0])]
mod app {
- use cortex_m_semihosting::debug;
+ use examples_runner::exit;
#[shared]
struct Shared {}
@@ -23,9 +23,9 @@ mod app {
let _: Result<(), u32> = bar::spawn(0);
let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
- (Shared {}, Local {}, init::Monotonics())
+ // (Shared {}, Local {}, init::Monotonics())
}
#[idle]
diff --git a/examples/task.rs b/examples-runner/src/bin/task.rs
index 2c53aa23..b6c69e53 100644
--- a/examples/task.rs
+++ b/examples-runner/src/bin/task.rs
@@ -5,11 +5,11 @@
#![no_main]
#![no_std]
-use panic_semihosting as _;
+use examples_runner as _;
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0, QEI0])]
+#[rtic::app(device = examples_runner::pac, dispatchers = [SSI0, QEI0])]
mod app {
- use cortex_m_semihosting::{debug, hprintln};
+ use examples_runner::{println, exit};
#[shared]
struct Shared {}
@@ -26,31 +26,31 @@ mod app {
#[task]
fn foo(_: foo::Context) {
- hprintln!("foo - start").unwrap();
+ println!("foo - start");
// spawns `bar` onto the task scheduler
// `foo` and `bar` have the same priority so `bar` will not run until
// after `foo` terminates
bar::spawn().unwrap();
- hprintln!("foo - middle").unwrap();
+ println!("foo - middle");
// spawns `baz` onto the task scheduler
// `baz` has higher priority than `foo` so it immediately preempts `foo`
baz::spawn().unwrap();
- hprintln!("foo - end").unwrap();
+ println!("foo - end");
}
#[task]
fn bar(_: bar::Context) {
- hprintln!("bar").unwrap();
+ println!("bar");
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
+ exit();
}
#[task(priority = 2)]
fn baz(_: baz::Context) {
- hprintln!("baz").unwrap();
+ println!("baz");
}
}
diff --git a/examples-runner/src/lib.rs b/examples-runner/src/lib.rs
new file mode 100644
index 00000000..13b8c954
--- /dev/null
+++ b/examples-runner/src/lib.rs
@@ -0,0 +1,60 @@
+#![no_std]
+
+
+pub use embedded_ci_pac as pac; // memory layout
+
+#[cfg(feature = "embedded-ci")]
+use core::sync::atomic::{AtomicUsize, Ordering};
+
+#[cfg(feature = "qemu")]
+use panic_semihosting as _;
+
+#[cfg(feature = "embedded-ci")]
+use defmt_rtt as _; // global logger
+#[cfg(feature = "embedded-ci")]
+use panic_probe as _;
+
+#[cfg(feature = "embedded-ci")]
+defmt::timestamp! {"{=u64}", {
+ static COUNT: AtomicUsize = AtomicUsize::new(0);
+ // NOTE(no-CAS) `timestamps` runs with interrupts disabled
+ let n = COUNT.load(Ordering::Relaxed);
+ COUNT.store(n + 1, Ordering::Relaxed);
+ n as u64
+}
+}
+
+// same panicking *behavior* as `panic-probe` but doesn't print a panic message
+// this prevents the panic message being printed *twice* when `defmt::panic` is invoked
+#[cfg(feature = "embedded-ci")]
+#[defmt::panic_handler]
+fn panic() -> ! {
+ cortex_m::asm::udf()
+}
+
+/// Generalize println for QEMU and defmt
+#[cfg(feature = "embedded-ci")]
+#[macro_export]
+macro_rules! println {
+ ($($l:tt)*) => {
+ defmt::println!($($l)*);
+ }
+}
+
+#[cfg(feature = "qemu")]
+#[macro_export]
+macro_rules! println {
+ ($($l:tt)*) => {
+ cortex_m_semihosting::hprintln!($($l)*).ok();
+ }
+}
+
+/// Terminates the application and makes `probe-run` exit with exit-code = 0
+pub fn exit() -> ! {
+ #[cfg(feature = "qemu")]
+ cortex_m_semihosting::debug::exit(cortex_m_semihosting::debug::EXIT_SUCCESS);
+
+ loop {
+ cortex_m::asm::bkpt();
+ }
+}
diff --git a/xtask/Cargo.toml b/examples-runner/xtask/Cargo.toml
index 33e6b3ad..d45965d4 100644
--- a/xtask/Cargo.toml
+++ b/examples-runner/xtask/Cargo.toml
@@ -6,4 +6,4 @@ edition = "2018"
[dependencies]
anyhow = "1.0.43"
os_pipe = "0.9.2"
-structopt = "0.3.22"
+clap = { version = "3.1.5", features = ["derive"] }
diff --git a/xtask/src/build.rs b/examples-runner/xtask/src/build.rs
index 148a9fde..148a9fde 100644
--- a/xtask/src/build.rs
+++ b/examples-runner/xtask/src/build.rs
diff --git a/xtask/src/command.rs b/examples-runner/xtask/src/command.rs
index 2f719bf5..38ddba72 100644
--- a/xtask/src/command.rs
+++ b/examples-runner/xtask/src/command.rs
@@ -1,4 +1,5 @@
use crate::{RunResult, TestRunError};
+use clap::ArgEnum;
use core::fmt;
use os_pipe::pipe;
use std::{fs::File, io::Read, process::Command};
@@ -10,6 +11,12 @@ pub enum BuildMode {
Debug,
}
+#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ArgEnum)]
+pub enum Runner {
+ Qemu,
+ EmbeddedCi,
+}
+
#[derive(Debug)]
pub enum CargoCommand<'a> {
Run {
@@ -17,6 +24,7 @@ pub enum CargoCommand<'a> {
target: &'a str,
features: Option<&'a str>,
mode: BuildMode,
+ runner: Runner,
},
BuildAll {
target: &'a str,
@@ -45,23 +53,43 @@ impl<'a> CargoCommand<'a> {
target,
features,
mode,
- } => {
- let mut args = vec![self.name(), "--example", example, "--target", target];
-
- if let Some(feature_name) = features {
- args.extend_from_slice(&["--features", feature_name]);
+ runner,
+ } => match runner {
+ Runner::Qemu => {
+ let mut args = vec![self.name(), "--bin", example, "--target", target];
+
+ if let Some(feature_name) = features {
+ args.extend_from_slice(&["--features", feature_name]);
+ }
+ if let Some(flag) = mode.to_flag() {
+ args.push(flag);
+ }
+ args
}
- if let Some(flag) = mode.to_flag() {
- args.push(flag);
+ Runner::EmbeddedCi => {
+ let mut args = vec![];
+ if target.contains("thumbv6") {
+ args.extend_from_slice(&["--cores", "cortexm0plus"])
+ } else if target.contains("thumbv7") {
+ args.extend_from_slice(&["--cores", "cortexm3,cortexm4,cortexm7"])
+ } else {
+ panic!("Unknown target: {}", target);
+ }
+ let s = Box::new(format!("target/{target}/{mode}/{example}"));
+ let s = s.into_boxed_str();
+ let s: &'static str = Box::leak(s);
+
+ args.push(s);
+
+ args
}
- args
- }
+ },
CargoCommand::BuildAll {
target,
features,
mode,
} => {
- let mut args = vec![self.name(), "--examples", "--target", target];
+ let mut args = vec![self.name(), "--bins", "--target", target];
if let Some(feature_name) = features {
args.extend_from_slice(&["--features", feature_name]);
@@ -78,6 +106,16 @@ impl<'a> CargoCommand<'a> {
pub fn command(&self) -> &str {
match self {
+ CargoCommand::Run {
+ example: _,
+ target: _,
+ features: _,
+ mode: _,
+ runner,
+ } => match runner {
+ Runner::Qemu => "cargo",
+ Runner::EmbeddedCi => "embedded-ci-client",
+ },
// we need to cheat a little here:
// `cargo size` can't be ran on multiple files, so we're using `rust-size` instead –
// which isn't a command that starts wizh `cargo`. So we're sneakily swapping them out :)
diff --git a/xtask/src/main.rs b/examples-runner/xtask/src/main.rs
index 76ce04bd..459307ac 100644
--- a/xtask/src/main.rs
+++ b/examples-runner/xtask/src/main.rs
@@ -2,6 +2,7 @@ mod build;
mod command;
use anyhow::bail;
+use clap::Parser;
use core::fmt;
use std::{
error::Error,
@@ -11,20 +12,22 @@ use std::{
process::ExitStatus,
str,
};
-use structopt::StructOpt;
use crate::{
build::init_build_dir,
- command::{run_command, run_successful, BuildMode, CargoCommand},
+ command::{run_command, run_successful, BuildMode, CargoCommand, Runner},
};
const ARMV6M: &str = "thumbv6m-none-eabi";
const ARMV7M: &str = "thumbv7m-none-eabi";
-#[derive(Debug, StructOpt)]
+#[derive(Debug, Parser)]
+#[clap(author, version, about, long_about = None)]
struct Options {
- #[structopt(short, long)]
+ #[clap(short, long)]
target: String,
+ #[clap(short, long, arg_enum)]
+ runner: Runner,
}
#[derive(Debug, Clone)]
@@ -86,24 +89,24 @@ fn main() -> anyhow::Result<()> {
let targets = [ARMV7M, ARMV6M];
- let examples: Vec<_> = std::fs::read_dir("./examples")?
+ let examples: Vec<_> = std::fs::read_dir("./src/bin")?
.filter_map(|path| {
path.map(|p| p.path().file_stem().unwrap().to_str().unwrap().to_string())
.ok()
})
.collect();
- let opts = Options::from_args();
+ let opts = Options::parse();
let target = &opts.target;
init_build_dir()?;
if target == "all" {
for t in targets {
- run_test(t, &examples)?;
+ run_tests(t, opts.runner, &examples)?;
}
} else if targets.contains(&target.as_str()) {
- run_test(&target, &examples)?;
+ run_tests(&target, opts.runner, &examples)?;
} else {
eprintln!(
"The target you specified is not available. Available targets are:\
@@ -117,10 +120,15 @@ fn main() -> anyhow::Result<()> {
Ok(())
}
-fn run_test(target: &str, examples: &[String]) -> anyhow::Result<()> {
+fn run_tests(target: &str, runner: Runner, examples: &[String]) -> anyhow::Result<()> {
+ let features = Some(match runner {
+ Runner::Qemu => "qemu",
+ Runner::EmbeddedCi => "embedded-ci",
+ });
+
arm_example(&CargoCommand::BuildAll {
target,
- features: None,
+ features,
mode: BuildMode::Release,
})?;
@@ -128,8 +136,9 @@ fn run_test(target: &str, examples: &[String]) -> anyhow::Result<()> {
let cmd = CargoCommand::Run {
example,
target,
- features: None,
+ features,
mode: BuildMode::Release,
+ runner,
};
arm_example(&cmd)?;