Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Latest commit

 

History

History
162 lines (110 loc) · 3.34 KB

DEVELOPMENT.md

File metadata and controls

162 lines (110 loc) · 3.34 KB

Development

Environment setup

Follow Rust's installation guide.

Install tooling of the embedded Rust target for Cortex-M7F:

rustup target add thumbv7em-none-eabihf

Formatting, linting, unit tests

Run formatting, linter and unit tests:

make

Read the Makefile to learn more.

Benchmark

If a package has a benchmark defined, cd into its directory and run it via:

cargo +nightly bench --bench bench

Use the benchmark for profiling:

rm -f target/release/deps/bench-*
rm -f callgrind.out.*
RUSTFLAGS="-g" cargo +nightly bench --bench bench --no-run
BENCH=$(find target/release/deps -type f -executable -name 'bench-*')
TEST=instrument
valgrind \
    --tool=callgrind \
    --dump-instr=yes \
    --collect-jumps=yes \
    --simulate-cache=yes \
    ${BENCH} --bench --profile-time 10 ${TEST}
kcachegrind callgrind.out.*

Flash via ST-Link

This requires external probe, such as the ST LINK-V3 MINI. The benefit of this approach is that it allows to stay connected to the module, read logs, run a debugger, or execute tests on the module. Note that the module needs to be powered while the probe is connected.

This project uses probe-rs to deal with flashing. Start by installing its dependencies. For Fedora, it can be done by running the following:

sudo dnf install -y libusbx-devel libftdi-devel libudev-devel

You may then install needed udev rules. See the probe-rs getting started to learn how.

Then install Rust dependencies of probe-rs:

cargo install probe-run
cargo install flip-link

To flash the project, call this make target:

make flash

Logging level can be set using an environment variable:

DEFMT_LOG=info make flash

To flash a release build, set a flag:

make flash FLAGS="--release"

Some tests must be executed directly on the module. To run those, use the following target:

make test-embedded

Flash via DFU

Unlike ST-Link, DFU flashing does not require any external probe. Just connect the module to your computer via a USB cable.

First, install dfu-util. On Fedora, this can be done by calling:

sudo dnf install dfu-util

To flash the project, call this make target:

make flash-dfu

To flash a release build, extend the command with a flag:

make flash-dfu FLAGS="--release"

Firmware size

Check firmware size:

cd eurorack && cargo +nightly size --bin firmware --release -- -m # or -A

Run a debugger

I prefer to use gdbgui when I need to attach a debugger to a test run.

First, install gdbgui following its installation guide. The make target also requires jq to be installed in the system.

To attach the debugger to a unit test run:

make debug-test WHAT=ui

After the debugger is open, set breakpoints, type r into the GDB console and click Continue.

Pure data

To try out the project via Pure Data:

make puredata

And more under hack/ and in the Makefile.

Gerbers, BOM and CPL

I extensivelly use https://github.com/Bouni/kicad-jlcpcb-tools to deal with the matters listed in the title, and to prepare project for manufacture.