161.27. probe-rs-0.32.0
ARM and RISC-V flash and debug over CMSIS-DAP, ST-Link and J-Link, with RTT
| Version | 0.32.0, release 1 |
| Shelf | embedded — Microcontroller and bare-metal development: cross toolchains, C libraries, flashers, debug probes and serial consoles |
| Phase | 41_system (System), 486 of 1047 in build order |
| Licence | MIT OR Apache-2.0 |
| Homepage | https://probe.rs/ |
| Build time | 5.4 SBU |
| Installed size | 34.4 MiB in 5 files |
| Recipe | ports/core/embedded/probe-rs/kpkgbuild |
About
probe-rs flashes and debugs ARM Cortex-M, RISC-V and Xtensa microcontrollers through a debug probe: CMSIS-DAP (DAPLink), ST-Link, J-Link, FTDI probes, the ESP32’s built-in USB-JTAG, WCH-Link and the Black Magic Probe. Beside flashing it reads RTT (Real-Time Transfer), a channel through a ring buffer in the target’s own RAM over the debug probe, so a running chip can print without a UART or a spare pin; it also offers a GDB server and a Debug Adapter Protocol server for editors. The port installs three programs from the probe-rs-tools crate: probe-rs itself, and the cargo subcommands cargo-flash, which programs a compiled Rust project or any ELF into the chip, and cargo-embed, which adds an RTT terminal and a GDB server.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/embedded.txt:
RTT is the best embedded printf channel there is, and probe-rs is the one free implementation that also flashes over CMSIS-DAP, ST-Link and J-Link.
Sources
probe-rs-0.32.0.tar.gz(17.9 MiB)
sha2569c4ba2046d4709f6a07e47933b1aa7edaf72a4d0a9f482b81d81798879070229
upstream: https://github.com/probe-rs/probe-rs/archive/refs/tags/v0.32.0.tar.gz
archive copy: sources-2/embedded--probe-rs-0.32.0.tar.gzprobe-rs-vendor-0.32.0.tar.xz(40.1 MiB)
sha2563ccf4860c716066cf8629c4497be79114fa80f0723e0a361b540003f647cc9c0
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-2/embedded--probe-rs-vendor-0.32.0.tar.xz
Dependencies
Required by: no port names it.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install probe-rs'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/embedded/probe-rs.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/embedded/probe-rs
echo '9c4ba2046d4709f6a07e47933b1aa7edaf72a4d0a9f482b81d81798879070229 probe-rs-0.32.0.tar.gz' | sha256sum -c -
echo '3ccf4860c716066cf8629c4497be79114fa80f0723e0a361b540003f647cc9c0 probe-rs-vendor-0.32.0.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/probe-rs
SRC=$SRC_ROOT/probe-rs-0.32.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf probe-rs-0.32.0.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz
export CARGO_HOME="$SRC_ROOT/.cargo"
export RUSTFLAGS="-C target-feature=-crt-static"
export CARGO_NET_OFFLINE=true
cargo build --release --frozen --offline -p probe-rs-tools
install -Dm755 target/release/probe-rs $PKG/usr/bin/probe-rs
install -Dm755 target/release/cargo-flash $PKG/usr/bin/cargo-flash
install -Dm755 target/release/cargo-embed $PKG/usr/bin/cargo-embed
The switches, and why each is set:
-p probe-rs-tools— Builds only theprobe-rs-toolspackage of upstream’s workspace, the one that holds the three programs. The other members are the libraries those programs are built from and upstream’s own tools (target-gen,smoke-tester,xtask).CARGO_NET_OFFLINE=true— Cargo’s environment form ofnet.offline, the same as--offlineon the command line.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/probe-rs, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf probe-rs-0.32.0-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/probe-rs, and runs the triggers its paths call for.
Contents
Installed programs: cargo-embed, cargo-flash, probe-rs.
Installed directories: /usr/share/licenses/probe-rs.
Notes
- The chip descriptions are compiled in. The
probe-rslibrary’s defaultbuiltin-targetsfeature builds the target descriptions underprobe-rs/targetsinto the program, and theprobe-rs-espressifcrate builds in the Espressif ones under its owntargets, each with its memory map and the flash algorithms that run on the chip, so nothing has to be downloaded for a supported part. A part outside that set needs a chip description file, which upstream’starget-genmakes from a CMSIS-Pack, given with--chip-description-path. The flash algorithms are code for the target, carried as upstream publishes them; see What is built from source. - No C library is linked for USB. Probes are reached through
nusband throughhidapiwith itslinux-native-basic-udevback end, both of which talk to/dev/bus/usband/dev/hidraw*directly, so the only shared libraries the program links are the C library andlibgcc_s. Access to the probes as the desktop user comes fromfs/etc/udev/rules.d/70-kdos-debug.rules.