-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Right now, the cmox crate is failing tests because of some low-level failures.
First, note that in order to build / run the cmox crate at all, you will need to tell it where to find some things. The command line to run the tests will look something like:
ARM_STDLIB_PATH=<path to directory with ARM stdlib headers> \
CMOX_PATH=<path to STMCryptographic library and headers> \
cargo test -F stm32f4 --test self-testIf you run that with an ST-LINK attached to the UI chip (ev12 or ev13), you should see the test firmware being flashed to the chip, followed by a bunch of defmt output. With the code as it is checked in, tests should pass. If you activate one of the ignored tests (comment out #[ignore] in tests/self-test.rs), you should see a failure. Here's what the failure looks like on my device with the hash test enabled:
test unit_tests::hash ... [INFO ] Running test: Test { name: "unit_tests::hash", function: 0x80018e5, should_panic: false, ignored: false, timeout: None } (embedded_test embedded-test-0.6.2/src/fmt.rs:36)
[DEBUG] flash: latency=5 (embassy_stm32 src/rcc/f247.rs:264)
[DEBUG] rcc: Clocks { hclk1: MaybeHertz(168000000), hclk2: MaybeHertz(168000000), hse: MaybeHertz(0), lse: MaybeHertz(0), lsi: MaybeHertz(0), pclk1: MaybeHertz(42000000), pclk1_tim: MaybeHertz(84000000), pclk2: MaybeHertz(84000000), pclk2_tim: MaybeHertz(168000000), pll1_q: MaybeHertz(48000000), plli2s1_p: MaybeHertz(0), plli2s1_q: MaybeHertz(0), plli2s1_r: MaybeHertz(0), pllsai1_q: MaybeHertz(0), rtc: MaybeHertz(32000), sys: MaybeHertz(168000000) } (embassy_stm32 src/rcc/mod.rs:71)
Error: The CPU halted unexpectedly: Multiple. Test should signal failure via a panic handler that calls `semihosting::proces::abort()` instead
error: test failed, to rerun pass `--test self-test`
Caused by:
process didn't exit successfully: `probe-rs run --chip STM32F405RGTx /Users/richbarn/Projects/hactar/bare-rust/cmox/cmox/target/thumbv7em-none-eabihf/debug/deps/self_test-854bb2304458eb23` (exit status: 1)
It appears that the Multiple status code is what probe-rs reports when it doesn't know what caused a halt (i.e., not a breakpoint).
My suspicion here is that this error indicates that something below the Rust layer has failed, likely due to the hardware not being initialized properly. The reason for the latter "likely" is that as I was writing the rust-crypto test case, I got similar failures trying to instantiate the RNG, which went away after I added the code to initialize the clocks.
It might be a good idea to look at the initialization code in the C++ firmware that corresponds to the init() and ll_init() functions:
- https://github.com/Quicr/hactar/blob/main/firmware/ui/Core/Src/stm32f4xx_hal_msp.c
- https://github.com/Quicr/hactar/blob/main/firmware/ui/Core/Src/main.c
- https://github.com/Quicr/hactar/blob/main/firmware/ui/src/app_main.cc#L126
It might also be useful to run the tests in a debugger, though the test framework doesn't make it easy to do that. Getting useful debug information might require converting the test binary to an example binary and running that more directly.