|
1 | 1 | # Testsuite |
2 | 2 |
|
3 | | -This workspace contains on-target tests. |
| 3 | +This workspace contains tests that run on physical and simulated Cortex-M CPUs. |
4 | 4 |
|
5 | 5 | ## Building |
6 | 6 |
|
| 7 | +Exactly one of these features are required: |
| 8 | + |
| 9 | +* `semihosting` Use semihosting for logging, this is used for QEMU. |
| 10 | +* `rtt` Use RTT for logging, this is used with physical cortex-m CPUs. |
| 11 | + |
7 | 12 | Assuming you are at the root of the repository you can build like this: |
8 | 13 |
|
9 | 14 | ```console |
10 | | -$ cargo build -p testsuite --target thumbv6m-none-eabi |
| 15 | +$ cargo build -p testsuite --target thumbv6m-none-eabi --features testsuite/rtt |
11 | 16 | Compiling testsuite v0.1.0 (cortex-m/testsuite) |
12 | 17 | Finished dev [unoptimized + debuginfo] target(s) in 0.08 |
13 | 18 | ``` |
14 | 19 |
|
15 | | -## Running |
| 20 | +## Running with QEMU |
16 | 21 |
|
17 | | -No implementation-specific features are tested right now; any `thumbv6m-none-eabi` target should work. |
| 22 | +* Use the `semihosting` feature for logging, QEMU does not have native support for RTT |
| 23 | +* Build for the `thumbv7m-none-eabi` target to match the Cortex-M3 lm3s6965evb machine |
18 | 24 |
|
19 | | -Tests are executed with [probe-run](https://github.com/knurling-rs/probe-run): |
| 25 | +For more information on QEMU reference the QEMU section in [The Embedded Rust Book]. |
20 | 26 |
|
21 | 27 | ```console |
| 28 | +$ cargo build -p testsuite --target thumbv7m-none-eabi --features testsuite/semihosting |
| 29 | + Compiling testsuite v0.1.0 (cortex-m/testsuite) |
| 30 | + Finished dev [unoptimized + debuginfo] target(s) in 0.08 |
| 31 | +$ qemu-system-arm \ |
| 32 | + -cpu cortex-m3 \ |
| 33 | + -machine lm3s6965evb \ |
| 34 | + -nographic \ |
| 35 | + -semihosting-config enable=on,target=native \ |
| 36 | + -kernel target/thumbv7m-none-eabi/debug/testsuite |
| 37 | +Timer with period zero, disabling |
| 38 | +(1/3) running `assert_true`... |
| 39 | +(2/3) running `assert_flag`... |
| 40 | +(3/3) running `printing`... |
| 41 | +Hello, World! |
| 42 | +all tests passed! |
| 43 | +``` |
| 44 | + |
| 45 | +## Running with Physical Hardware |
| 46 | + |
| 47 | +No implementation-specific features are tested right now; any physical `thumbv6m-none-eabi` target should work. |
| 48 | + |
| 49 | +Tests are executed with [probe-run](https://github.com/knurling-rs/probe-run). |
| 50 | + |
| 51 | +This example is provided for the `STM32F070RBTx`, if using a different target: |
| 52 | + |
| 53 | +* Change the `probe-run` chip argument to match your chip, supported chips can be found with `probe-run --list-chips` |
| 54 | +* Modify `stm32-memory.x` to match the memory layout of your target |
| 55 | +* Change the build target to match your CPU |
| 56 | + |
| 57 | +```console |
| 58 | +$ cargo build -p testsuite --target thumbv6m-none-eabi --features testsuite/rtt |
| 59 | + Compiling testsuite v0.1.0 (cortex-m/testsuite) |
| 60 | + Finished dev [unoptimized + debuginfo] target(s) in 0.08 |
22 | 61 | $ probe-run --chip STM32F070RBTx --connect-under-reset target/thumbv6m-none-eabi/debug/testsuite |
23 | | -(HOST) INFO flashing program (12.80 KiB) |
| 62 | +(HOST) INFO flashing program (14.26 KiB) |
24 | 63 | (HOST) INFO success! |
25 | 64 | ──────────────────────────────────────────────────────────────────────────────── |
26 | | -(1/2) running `assert_true`... |
27 | | -(2/2) running `assert_flag`... |
| 65 | +(1/3) running `assert_true`... |
| 66 | +(2/3) running `assert_flag`... |
| 67 | +(3/3) running `printing`... |
| 68 | +Hello, World! |
28 | 69 | all tests passed! |
29 | 70 | ──────────────────────────────────────────────────────────────────────────────── |
30 | 71 | stack backtrace: |
31 | 72 | 0: lib::inline::__bkpt |
32 | 73 | at ./asm/inline.rs:13:5 |
33 | 74 | 1: __bkpt |
34 | 75 | at ./asm/lib.rs:49:17 |
35 | | - 2: minitest::export::exit |
36 | | - at testsuite/minitest/src/export.rs:6:9 |
37 | | - 3: main |
38 | | - at testsuite/src/main.rs:23:1 |
39 | | - 4: Reset |
| 76 | + 2: minitest::exit |
| 77 | + at testsuite/minitest/src/lib.rs:55:9 |
| 78 | + 3: testsuite::tests::__cortex_m_rt___minitest_entry |
| 79 | + at testsuite/src/main.rs:19:1 |
| 80 | + 4: main |
| 81 | + at testsuite/src/main.rs:19:1 |
| 82 | + 5: Reset |
40 | 83 | (HOST) WARN call stack was corrupted; unwinding could not be completed |
41 | 84 | (HOST) INFO device halted without error |
42 | 85 | ``` |
43 | 86 |
|
44 | | -## CI |
45 | | - |
46 | | -These tests are run automatically in continuous integration. A self-hosted github actions runner with a NUCLEO-F070RB board is hosted by [newAM](https://github.com/newAM). |
47 | | - |
48 | | -The runner is equiped with a limited selection of packages: |
49 | | -* [Unix Commands](https://en.wikipedia.org/wiki/List_of_Unix_commands) |
50 | | -* clang |
51 | | -* gcc-arm-embedded |
52 | | -* git |
53 | | -* probe-run |
54 | | -* rustup |
55 | | - |
56 | | -The complete host configuration can be found here [here](https://github.com/newAM/nixfiles/blob/main/t430s/configuration.nix). |
57 | | - |
58 | | -⚠️ Hosting a github actions runner in a public repository goes directly against [github's advice](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners#self-hosted-runner-security-with-public-repositories), do not do this yourself unless you are prepared to accept the risks. |
| 87 | +[The Embedded Rust Book]: https://docs.rust-embedded.org/book/start/qemu.html |
| 88 | +[probe-run]: https://github.com/knurling-rs/probe-run |
0 commit comments