|
K-FSW v1.2.1-59-gcaca356
KFSW: modular flight software on Zephyr, for small satellites
|
Keep one responsibility per branch, with the tests and docs that change needs. Save existing work before updating any repository.
From the workspace root:
Dependencies normally end up detached at their manifest SHA. Create a branch before committing changes in one.
Push changes to develop, directly or through a feature PR. Update main only by merging reviewed release changes; do not push commits directly to it. Tag the release merge only after its CI/CD checks pass. Fix failed checks through develop and merge the correction before releasing. Keep unreleased work on develop; do not move published tags.
Use <type>/<issue>-<slug>, or <type>/<slug> when no issue exists.
| Type | Example |
|---|---|
| Feature | feature/42-command-router |
| Fix | fix/43-storage-timeout |
| Refactor | refactor/23-param-csp |
| Documentation | docs/wiki-layout |
Check your identity before committing:
The subject is one or two uppercase area tags, then the thing that changed as a noun phrase:
The first tag is the layer or kind of change (SERVICES, COMMS, DOCS, TEST, BOOT, ...), the optional second one the feature. Keep it under about 72 characters, with no trailing period.
The subject is the whole message. The reason for a change goes in the code, a comment or the documentation, where the next reader of that code finds it. Make one commit per coherent change; related fixes in the same area go in the same commit.
Use the same title format as commits. Keep the body to the change, relevant checks, and issue number if there is one:
Before opening the PR:
Run the checks that cover the change; Tests lists them. A docs change needs Doxygen, the PDF, the link checks and a look at the result. Record a physical test only when someone observed it on the bench.
Each reusable repository has its own branch and PR. The composition PR pins the dependency commit and contains the integration changes.
k-fsw/west.yml.k-fsw PR.For example, inside kfsw-services:
After publishing the dependency commit, from the workspace root:
The checked-out SHA must match the manifest, and hosted CI must be able to fetch it from the declared remote.
libcsp and libparam are pinned to K-FSW forks, dgonzalez97/kfsw-libcsp and dgonzalez97/kfsw-libparam. Check west.yml for the exact revisions and each fork's KFSW.md for its changes from upstream.
Carry a change as one commit with its reason in the message, rebase the branch onto upstream instead of merging upstream into it, and move the west.yml revision the same way as any other dependency. Before tagging a release, check whether upstream has new commits or tags since the pin.
A merge commit preserves the pinned SHA. Squash or rebase produces a new SHA; update the pin and rerun composition CI if either is used. Do not rewrite a commit already pinned by another PR.
| Change | Repository |
|---|---|
| Time, reset, watchdog, storage mechanism | kfsw-platform |
| Reusable service behaviour | kfsw-services |
| CSP, routing, packet buffers, transports | kfsw-comms |
| Device or subsystem client | kfsw-modules |
| Startup, targets, shell adapters, tools, integration tests, docs | k-fsw |
Public APIs go in that repository's include/kfsw/ headers and private helpers in its source tree.
For a new service, add its Kconfig dependencies, conditional build, public API, application startup, and tests for enabled and disabled configurations. Use devicetree for devices and wiring. See Architecture.
Open the multi-repository workspace:
It includes the five project repositories and build/active. Select the compilation database for the target you are editing:
Use nucleo_l496zg for MCU configuration. The selector updates symlinks to the selected build; it refuses to overwrite regular files. Rebuild to refresh generated headers and compile_commands.json.
For NUCLEO debugging, run these in separate terminals:
Use build/nucleo_l496zg/zephyr/zephyr.elf and check that build's .config and zephyr.dts when diagnosing target-specific behaviour.
Edit guides under docs/ and document public C APIs in their headers. For a procedure, give the command, the expected result and its limits. Link to upstream references for RTOS and protocol background.
Draw diagrams as fenced code blocks marked mermaid. GitHub draws them in place, and tools/docs/build.sh passes them through tools/docs/mermaid-filter.py so the HTML manual draws the same source with a pinned Mermaid release. To read the manual offline, point KFSW_MERMAID_JS at a local mermaid.min.js before building. The PDF shows the diagram source.
From the workspace root:
Check navigation, images, tables, and links in HTML and PDF. Keep generated output out of Git. Update Project status from source and recorded test results when capabilities change.
Software CI shows that the code builds and behaves in simulation. Whether the board keeps a log across a reset, answers over CAN, or comes back from an interrupted update needs the bench, so the bench runs before a tag. Back the bench up first.
| Step | Command | Needs |
|---|---|---|
| 1 | tests/hil/preflight.sh | device inventory; confirm wiring separately |
| 2 | tools/ci/all.sh --suite board | software first, then every available automatic board check; reflashes and resets boards |
| 3 | tests/hil/shell-smoke.sh rpi_pico_w | a person to copy the UF2 and reconnect the console |
| 4 | tests/hil/button-test/button-acceptance.sh | a person to press the button and judge its behaviour |
Step 2 reports steps 3 and 4 as NOT RUN. CAN acceptance and encrypted radio need prepared baselines and inputs (Tests); run them separately if another fixture has replaced those baselines.
Record which steps ran, which were skipped for want of hardware, and the exact output of each. The tag notes list the skipped steps.
Every one of these has cost a bench session at least once.
run.sh <shape> does it from preflight.sh. Calling a fixture directly does not, and the numbered /dev/ttyACM* you get by default is whichever board enumerated first.can.robot runs the CAN fixture with --no-build, so it tests whatever is already on the board. Build and flash it first, or run the fixture without Robot so it builds.ERROR-ACTIVE, and one of its assertions wants the counters at zero, so a bus that misbehaved earlier fails a run that is otherwise clean. Bring it up again: sudo tests/hil/stm32/nucleo-l496zg/can-up.sh 500000 normalcan-up.sh command sets and verifies txqueuelen 1000. Check ip -details link show can0 for qlen 1000 or higher. The default queue of 10 can drop CFP1 FWU frames and leave the native driver's CAN TX waiting for a completion that never arrives. The board-can preflight and both CAN FWU scripts reject a short or missing queue length. Software tests on the default vcan0 do not use this queue.tools/k-ground includes the profile and node number in each build directory, so kfsw-gnd-can, kfsw-gnd-uhf and a local -bench.env variant never overwrite each other's configuration. For example, CAN uses build/k-ground/kfsw-gnd-can-node-17; CSP v1 adds the -csp1 suffix.ftdi_sio as a module it has to be loaded, and a module whose BTF does not validate has to have that section stripped before it will load.This one changes the board: it installs MCUboot and moves the application into a signed slot. Back the board up first, and keep the backup until the tag is out.
That is the whole 1 MB, so it covers the application, the golden region at 0x080c0000 and LittleFS at 0x080f0000 without having to reason about which matters. Restore it the same way with flash write_image erase.
Program only the bootloader and the image slots. Do not pass --erase to west flash: the openocd runner has stm32l4x mass_erase 0 configured as its erase command, which takes the golden region and LittleFS with it.
Then follow tests/hil/fwu/README.md, which builds the ground node and the two signed images, installs the baseline, and runs the acceptance.
The acceptance leaves the board running the candidate, and a second run refuses because the candidate and running revisions must differ. Reinstall and confirm the baseline between runs.
Robot runs the same acceptance when both images are named:
Without them that case is skipped and reported as NOT RUN.
tools/release.py checks the source and signing inputs, builds twice, and compares the unsigned application payloads. It verifies both signatures and the bootloader's trust key. It does not create a tag or publish artifacts.
Use the MCUboot profiles in Firmware update, then set:
| Input | Value |
|---|---|
KFSW_IMAGE_VERSION | MCUboot version, for example 1.0.0+0 |
KFSW_RELEASE_SOURCE | Full k-fsw commit SHA |
KFSW_RELEASE_MANIFEST | Frozen manifest from tools/release.py freeze |
SOURCE_DATE_EPOCH | Fixed source timestamp, in Unix seconds |
ZEPHYR_SDK_INSTALL_DIR | SDK directory |
KFSW_RELEASE_COMPILER_SHA256 | SHA256 of the SDK's arm-zephyr-eabi-gcc |
KFSW_MCUBOOT_KEY | Private ECDSA P-256 signing key; development keys are rejected |
From k-fsw, with the workspace virtual environment active:
The output directory must be new. Keep artifacts/release.json with the images; it records sources, tool versions, public-key fingerprint, and artifact hashes.
The image to upload is artifacts/kfsw-<target>-<version>.signed.bin, for example kfsw-nucleo_l496zg-v1.1.0.signed.bin, where the version is git describe of the release commit. Images for different targets and versions can then sit side by side on a node or a ground station. The name is at most 64 characters of letters, digits, ., _ and -, so it always fits an FTP path; a longer or odd name stops the release instead of being cut. The build output itself stays zephyr.signed.bin.
A release also carries kfsw-<target>-recovery.signed.bin, built from the same tree by tools/golden.sh and recorded in release.json as recovery_image. It is the composition in config/profiles/nucleo-golden.conf: CSP over the UART and CAN links, remote parameters, the command server and both update routes, and nothing else. No console, no filesystem, no housekeeping. It exists to be reachable and to take a new image, and tools/golden.sh checks that it fits the 188 KiB golden partition. A target without that partition has no recovery image and recovery_image is null.
Flash it once per board, at 0x080C0000, with tools/golden.sh flash. The release does not flash it, and it stays the same when the flight image changes.
The bootloader only boots the slots, so the image in the golden partition is never run from there. Installing it means copying it into the secondary slot and asking for a swap, which is what the update service already does for an uploaded image, so recovery reuses it rather than writing to flash itself.
Two things can ask for that:
golden_install <pin>, a command like reboot, over CSP or from the shell. An operator who already knows the image is bad does not have to wait.boot_attempts_left reaches zero. The count and boot_attempts_max live in a dedicated flash record, independent of the parameter snapshot. The boot budget section of Firmware update has the details.The swap is a trial, so if the recovery image cannot boot either, the bootloader reverts. The recovery image confirms itself once it has finished starting (CONFIG_KFSW_BOOT_CONFIRM_AT_START), because a node in trouble may have no operator to confirm it. An image the operator confirms leaves that option off.
The early budget survives both confirmation and MCUboot revert. A node with no ground contact can exhaust it even when MCUboot restores the previous image. tests/boot-budget-smoke.sh exercises that budget and installation through a hosted bootloader model, and tests/hil/golden-recovery-smoke.sh installs the image on command and checks the recovery parameter set over CAN. Automatic expiry and real power cuts are bench work.