|
| 1 | +# Testsuite |
| 2 | + |
| 3 | +This workspace contains tests that run on physical and simulated Cortex-M CPUs. |
| 4 | + |
| 5 | +## Building |
| 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 | + |
| 12 | +Assuming you are at the root of the repository you can build like this: |
| 13 | + |
| 14 | +```console |
| 15 | +$ cd testsuite |
| 16 | +$ cargo build --features semihosting |
| 17 | + Compiling testsuite v0.1.0 (cortex-m/testsuite) |
| 18 | + Finished dev [unoptimized + debuginfo] target(s) in 0.08 |
| 19 | +``` |
| 20 | + |
| 21 | +## Running with QEMU |
| 22 | + |
| 23 | +The runner is already configured for QEMU in `testsuite/.cargo/config.toml`. |
| 24 | +Use the `semihosting` feature for logging, QEMU does not have native support for RTT. |
| 25 | + |
| 26 | +For more information on QEMU reference the QEMU section in [The Embedded Rust Book]. |
| 27 | + |
| 28 | +```console |
| 29 | +$ cd testsuite |
| 30 | +$ cargo run --features semihosting |
| 31 | + Finished dev [unoptimized + debuginfo] target(s) in 0.01s |
| 32 | + Running `qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel /cortex-m/target/thumbv7m-none-eabi/debug/testsuite` |
| 33 | +Timer with period zero, disabling |
| 34 | +Hello world! |
| 35 | +(1/1) running `double_take`... |
| 36 | +all tests passed! |
| 37 | +``` |
| 38 | + |
| 39 | +## Running with Physical Hardware |
| 40 | + |
| 41 | +No implementation-specific features are tested right now; any physical `thumbv7m` target should work. |
| 42 | + |
| 43 | +Tests are executed with [probe-run](https://github.com/knurling-rs/probe-run). |
| 44 | + |
| 45 | +* Update `memory.x` in the root of the repository to match your target memory layout. |
| 46 | +* Change the `probe-run` chip argument to match your chip, supported chips can be found with `probe-run --list-chips` |
| 47 | +* Change the target to match your CPU |
| 48 | + |
| 49 | +```console |
| 50 | +$ sed -i 's/FLASH : ORIGIN = 0x00000000, LENGTH = 256K/FLASH : ORIGIN = 0x8000000, LENGTH = 256K/g' memory.x |
| 51 | +$ cd testsuite |
| 52 | +$ cargo build --target thumbv7em-none-eabi --features rtt |
| 53 | + Compiling minitest v0.1.0 (/cortex-m/testsuite/minitest) |
| 54 | + Compiling testsuite v0.1.0 (/cortex-m/testsuite) |
| 55 | + Finished dev [unoptimized + debuginfo] target(s) in 0.16s |
| 56 | +$ probe-run --chip STM32WLE5JCIx --connect-under-reset ../target/thumbv7em-none-eabi/debug/testsuite |
| 57 | +(HOST) INFO flashing program (19 pages / 19.00 KiB) |
| 58 | +(HOST) INFO success! |
| 59 | +──────────────────────────────────────────────────────────────────────────────── |
| 60 | +Hello world! |
| 61 | +(1/2) running `double_take`... |
| 62 | +(2/2) running `cycle_count`... |
| 63 | +all tests passed! |
| 64 | +──────────────────────────────────────────────────────────────────────────────── |
| 65 | +(HOST) INFO device halted without error |
| 66 | +``` |
| 67 | + |
| 68 | +[The Embedded Rust Book]: https://docs.rust-embedded.org/book/start/qemu.html |
| 69 | +[probe-run]: https://github.com/knurling-rs/probe-run |
0 commit comments