nucleo-l053r8-benches/README.md
2025-07-31 16:53:01 +02:00

58 lines
1.9 KiB
Markdown
Executable file

# NUCLEO L053R8 Benches
This repository contains code to measure the performance of embedded C and
Rust code for an STM32 Microcontroller, specifically the `STM32L053R` on a
`NUCLEO-L053R` evaluation board.
It implements a variety of algorithms in both C and Rust
(`crate/algorithms`). These Algorithm programs are then executed by the
executable program written in Rust. C code is called using Rust's FFI with
manually implemented bindings. To measure the actual runtime of the algorithms,
you need to attach an oscilluscope to the configured port of the board while
the prgrams are running.
## Building
See [build.sh](./scripts/build.sh).
## Flashing
See [flash.sh](./scripts/flash.sh).
## Host-Benchmarks
The algorithms have benchmarks that can run on regular consumer laptops, so that
you can see the implementation difference on a bigger architecture like
`x86_64`.
See [bench_algorithms.sh](./scripts/bench_algorithms.sh).
### Dependencies
This program requires Rust to be installed. I made it with `Rust 1.88.0`, but
the theoretical MSRV is `Rust 1.85.1` (according to `cargo-msrv`).
In addition to some crates from crates.io, this project requires the following
to be installed to compile and link to the algorithms-c implementations.
```
# on debian bookworm
# compiler for your architecture if you want to run the unit tests
apt install gcc
# compiler for the target architecture
apt install binutils-arm-none-eabi gcc-arm-none-eabi
# ceedling is the used build system for algorithms-c, and needs to be installed with gem, the ruby package manager
apt install ruby
gem install ceedling
```
To actually flash the program onto an STM32, you also need
[probe-rs](https://probe.rs/docs/getting-started/installation/). I used
`probe-rs 0.29.1`.
## Acknowledgements
For implementing the SHA-2-256 Algorithm, [this](https://sha256algorithm.com/)
website was very helpful.
The algorithms themselves are mostly reference implementation of various RFCs.