|
K-FSW v1.2.1-59-gcaca356
KFSW: modular flight software on Zephyr, for small satellites
|
k-ground runs Linux ground nodes built from the same application and services as KFSW-Linux. A node file sets each role's name, address, peer and build options.
| Role | CSP address | Use |
|---|---|---|
kfsw-gnd-uhf | 16 | Opens the UHF radio for the ground network |
kfsw-gnd-can | 17 | Reaches a flight node over a SocketCAN interface |
kfsw-beacon | 18 | Receives beacons from a flight node |
kfsw-ops | 19 | Operator shell; doesn't open the radio |
kfsw-rotctl | 20 | Antenna rotator control |
The address says which link the ground node is on: 16 is reached over KISS and 17 over CAN. A flight profile that carries both links names one route per link, as nucleo-can.conf does with "3 CAN,17 CAN,16 KISS,0/0 KISS".
Each node file sets:
| Variable | Meaning |
|---|---|
KFSW_ROLE | Role name; must match the file name |
KFSW_CSP_NODE | The node's own address. tools/k-ground refuses a ground node below 16, and accepts up to 16382 under CSP 2 and 30 under CSP 1 |
KFSW_CSP_PEER | The node at the other end of the serial link, the one comms uart test pings when given no node. It becomes CONFIG_KFSW_CSP_UART_PEER_ADDRESS and is not a route |
KFSW_CSP_ROUTES | The route table, at most 99 characters |
KFSW_CSP_VERSION | 1 builds for a CSP 1 satellite; unset or 2 otherwise. A CSP 1 node gets its own configuration file and build directory, with a -csp1 suffix |
KFSW_RADIO_UHF | holybro selects the radio module |
KFSW_EXTRA_KCONFIG, KFSW_EXTRA_OVERLAY | Extra Kconfig lines and a devicetree overlay |
To make a bench variant of a role, for example the UHF gateway routed to flight node 2:
nodes/kfsw-gnd-uhf.env to nodes/kfsw-gnd-uhf-bench.env. Git ignores *-bench.env, so device paths and bench routes stay on the machine they belong to.KFSW_ROLE=kfsw-gnd-uhf-bench in it, and the peer and routes the bench needs.k-ground run kfsw-gnd-uhf-bench.status shows the node identity and comms uhf status the radio settings:
A normal Linux image keeps the kfsw:~$ prompt and Role: flight.
| Layer | Contents | Loaded by |
|---|---|---|
Workspace .venv | Python, west and Zephyr tools | Your shell; K-FSW scripts activate it themselves |
ground-station/nodes/*.env | Role, CSP address, peer and routes | tools/k-ground |
| Holybro bench file | Serial paths and radio settings of one host | Sourced before a hardware test |
From the workspace root:
socat is needed for the local CSP/KISS links (sudo apt install socat). See Getting started for the workspace setup.
The launcher reads the station from KGROUND_STATION_DIR when it is set, otherwise from ./ground-station when that holds the role's node file, otherwise from k-fsw/ground-station. It builds under KGROUND_BUILD_ROOT, which defaults to $KFSW_OUTPUT_ROOT/k-ground or build/k-ground. Each role builds in <role>-node-<node>, with -csp1 appended for CSP 1, for example build/k-ground/kfsw-gnd-uhf-node-16. The generated Kconfig fragment of the same name is in config/ under the build root. k-ground writes it to a temporary file and replaces it only when its contents change, so a repeated build does not rerun CMake; a failed write leaves the previous file in place. To use other directories in the current shell:
Keep USB device paths out of the node files and put them in the bench file.
A node file is a shell environment file; see kfsw-gnd-uhf.env for the gateway and kfsw-gnd-can.env for one that adds Kconfig and an overlay.
KFSW_CSP_ROUTES such as ‘'2 KISS’means node 2 in either CSP version. tools/k-groundchecks its length and characters and writes it to CONFIG_KFSW_CSP_ROUTE_TABLE; without it the node keeps0/0 KISSfrom config/profiles/k-ground.conf.kfsw-gnd-canenables CAN through KFSW_EXTRA_KCONFIGandKFSW_EXTRA_OVERLAY`.
Ground nodes include FWU lite and host-file reading by default. From kfsw-ops, fwu_lite send <node> /absolute/host/path sends an image without extra Kconfig. See Firmware update for validation and activation.
To copy the reference configuration into your workspace:
init [directory] creates ./ground-station by default and refuses a path that already exists.
Start the UHF gateway and the operator shell in two terminals:
When the peer is a ground node (16 or above), run joins the KISS PTYs of the two peers through a Unix socket in runtime/ under the build root. The options are:
| Option | Effect |
|---|---|
--node N, --peer N | Override the node file's addresses |
--no-local-link | Leave the PTY unconnected, for a serial bridge |
-- ARGS | Pass the rest to zephyr.exe, for example --can-if=can0 |
Without a -flash= argument, the node keeps its storage in k-ground-storage.bin in its build directory.
k-ground demo starts both and opens the operator shell. k-ground test checks both identities, prompts and ping directions (tests/k-ground-csp-smoke.sh):
Ground nodes include the file transfer service. From the operator shell:
The same CRC on both nodes and on the returned copy means the file came back unchanged. The gateway can list its own files without a connection:
tests/k-ground-ftp-smoke.sh runs this sequence, including a missing file.
After checking the copies, ftp rm 16 /uplink/test.txt removes the remote file. ftp rm 16 /uplink then removes the empty directory. Omit the node to remove a local file or empty directory.
Yamcs stores housekeeping samples and has a telemetry browser and archive. Its configuration is the ground-station/yamcs submodule.
Nodes answer housekeeping requests, so the bridge polls them:
The bridge talks CSP over KISS, pulls samples and sends each one to Yamcs on UDP port 10015. Point it at a Linux node's uart_1 PTY, or at the Holybro serial device to reach a flight node over the radio. It speaks CSP 2; add --csp-version 1 for a node built with config/profiles/csp-v1.conf.
A report can also send its latest sample periodically:
Beacons use the same frame format as polled samples. Receive them without polling:
CONFIG_KFSW_HK_BEACON_FLOOR_MS (5000 ms) return -ERANGE.CONFIG_KFSW_HK_BEACON_BUFFER_RESERVE CSP buffers are free; check hk show and hk_beacons_skipped in table 33.Beacons are sent to their own port (KFSW_HK_BEACON_PORT) so they never reach a request handler. With persistence enabled, beacon settings are saved with the report.
A pass read on a console is gone when the console closes. --store keeps every accepted sample in a SQLite file, so a value can be read against last week instead of only now:
Two things decide the shape of that file, and both come from how housekeeping works on the node.
A frame carries values and no names, so the report definition is the schema. --definitions stores the document beside the samples and points each sample at the definition that was in force when it arrived. A definition that changes gets a new row, so a sample recorded under the old one is never decoded with the new one.
A gap is data. Every sample carries a sequence number precisely so a missing one is visible, so the store never fills one in. The gap view reports what was not heard, and it knows the sequence is sixteen bits, so the step from 65535 to 0 is one sample and not a loss of sixty-five thousand:
A row is one reception, not one unique sample: a duplicate is evidence of the link too. clock_set says whether the node knew the time, because a sample stamped by the host is not the same evidence as one stamped by the node.
This file and Yamcs are not alternatives, and one run feeds both: --yamcs forwards every sample to the archive that plots it, and --store keeps the frames as they arrived with the definition that decodes them and the sequence gaps. Yamcs is where a trend is read; this file is what the trend was built from, and it needs no Java and no server during a pass.
Gpredict computes the pass and speaks only as a client: it connects to a rotator daemon and a radio daemon and sends them bearings and a Doppler-corrected frequency. It exposes nothing that accepts orders, so nothing here tells Gpredict what to track. The proxy listens where those daemons listen instead.
Every decision stays Gpredict's. The proxy sees each one, applies the selected profile's rules, and forwards it or refuses it with RPRT -1, which Gpredict shows as an error.
With no upstream the command is accepted, checked and printed but driven nowhere, which is how to watch Gpredict without a rotator attached. Add --rotator-upstream 127.0.0.1:4533 and --radio-upstream 127.0.0.1:4532 to drive the real daemons, and run the proxy on different ports so it can sit in front of them.
ground-station/tle/tracked.txt holds the TLEs of the spacecraft in the profiles below. Gpredict imports them through its TLE update from local files; refresh the file before a pass, because a TLE a few weeks old puts the antenna off the spacecraft.
In Gpredict, Edit > Preferences > Interfaces > Rotators and > Radios, add one of each with host localhost and the proxy's ports, 4533 and 4532 by default. Then open a module, Radio Control and Antenna Control from its menu, pick the satellite and the device, and press Engage and Track. Bearings start arriving once the spacecraft is above the horizon, so for a first look use one that is up now.
ground-station/satellites.json holds one profile per spacecraft, seeded with LUR-1 (60506), ROADS 1 (64535) and ROADS 2 (64549). Each carries the travel it allows and what to do with the frequency:
| Policy | What the radio gets |
|---|---|
follow | What Gpredict sent. Gpredict owns the Doppler. |
hold | The profile's own frequency. Gpredict keeps correcting every cycle, so this is a standing override and not a value set once. |
ignore | Nothing. The rotator is unaffected. |
The profile is selected by hand because the protocol carries angles and a frequency and never says which spacecraft they are for. Choosing it from the frequency breaks the day two share a band. A profile with "enabled": false is defined but cannot be selected.
Yamcs needs Java 17; Maven comes through ./mvnw.
It prints Yamcs started and serves http://localhost:8090. The instance is kfsw. Keep it running while recording.
Check the mission database before connecting hardware. In another terminal, from k-fsw/ground-station/yamcs:
It sends a recorded housekeeping frame to Yamcs and reads the values back; CI runs it on every push. Expect MDB CHECK RESULT: PASS.
Then set up a report on the node:
hk show prints the collections, failures, missing values and stored samples. Set the clock first, otherwise samples have a zero timestamp and the bridge uses the host time.
Start the bridge on the node's link:
The bridge prints each sample. With --yamcs none it prints the frames as hex and sends nothing.
| Yamcs page | What to check |
|---|---|
| Links | hk-udp shows OK, receiving on 10015; valid datagrams go up, invalid stays at zero |
| Telemetry, Packets | One packet per sample in the nucleo_temperature container |
| Telemetry, Parameters | /kfsw/nucleo_temperature_temp_mcu in degrees, marked ACQUIRED |
| Archive | The stored history |
INVALID instead of ACQUIRED means the value is outside its valid range, for example the reserved value sent when the sensor can't be read. Check temp_valid and temp_failures.
The same data is available from the Yamcs API:
If nothing arrives, look at the frames with --yamcs none, check that hk show counts collections, and then check Links for invalid datagrams.
Yamcs only records telemetry. Housekeeping is configured from a ground shell with the node first; hk define, hk period and hk clear work over CSP/KISS or CAN:
Housekeeping frames carry the values in report order, without names. hk-report.py generates the node command and the Yamcs XTCE database from one YAML file. Put the node number after hk define to send it from the ground:
hk-report.py check compares the file with a node's param listall, which catches a parameter that moved.
Each UDP datagram has a 12-byte header followed by the frame from the node:
The bridge sends one datagram per sample, preserving its timestamp.
tests/hk-yamcs-smoke.sh checks that the bytes the bridge receives match what the node's shell prints for the same sample.
Only one process opens each physical interface. A serial bridge connects the kfsw-gnd-uhf KISS PTY to the Holybro device; other ground roles reach the gateway over CSP. See the Holybro fixture below for the bridge command.
kfsw-comms has the UART, KISS and CSP code. kfsw-modules has the radio-uhf module and its holybro-sik implementation, which reports the expected radio settings and adds encryption. Table 50 has the radio identity, status and encryption settings. TX power, network ID and air rate are not writable because the module doesn't use SiK command mode.
raw-nucleo-smoke.sh flashes a raw test peer on the NUCLEO and exchanges numbered messages over the radio.csp-kiss-smoke.sh builds ground node 16 and NUCLEO node 2 at 57600 baud, bridges the ground PTY to the USB radio, and checks the interfaces, routes, ping in both directions and the counters.Radio settings and commands are in tests/hil/radio-uhf/holybro/README.md.
Three set-ups cover most work. Each opens a serial device or a pseudo-terminal exclusively, so run one reader per device at a time.
./k-fsw/tools/kfsw-linux run starts a node with its shell on the terminal and prints the pseudo-terminal of its CSP UART (uart_1). Host tools talk CSP over KISS on that device without a ground node:
The first pulls report 0 into Yamcs, the second asks node 1 for its identity. Define the report on the node's own shell first, for example hk define 0 3:0x00 3:0x0c. The CSP tools are an optional project in west.yml; fetch and build them once with west update kfsw-csp-tools && ./k-fsw/tools/kfsw-linux csp build, which needs Rust.
k-ground run kfsw-gnd-uhf and k-ground run kfsw-ops in two terminals, as under Running above, give a gateway and an operator shell joined by a local link. Everything an operator does to a flight node is typed in the kfsw-ops shell with the node number first: param get 2 boot_image, event tail 2 0, hk define 2 0 ..., ftp put 2 ..., csp reboot 2 <pin>. A node left on Golden goes back to the application with the steps in Returning from Golden over CAN.
For a flight node over the radio, add the radio bridge to the gateway (see Radio below), start Yamcs and the bridge, and let the Gpredict proxy drive the antenna:
During the pass, feed the ground watchdog (gndwdt feed 2), read what happened since the last pass (journal remote 2, event stats 2), then pull stored housekeeping and files.
From k-fsw, capture accepted HK samples to a new JSONL file:
Each version-1 record contains the source node, host receipt time in milliseconds, and original HK bytes. Replay opens no serial device and sends the saved samples in file order without delays. The Yamcs envelope uses the original sample time, or the saved receipt time when the node's clock was unset. An invalid or truncated record stops replay; earlier records may already have been sent.
Distinct reports with the same sequence number are kept. Exact duplicate samples from the same node are suppressed for up to 60 seconds, within a 1024-entry window. A changed timestamp or value makes a sample distinct. There is no boot identifier on the wire, so a byte-identical sample after a reset cannot be distinguished until it leaves that window. Captures contain samples accepted after this filtering, not every raw frame on the link.
Polling counts only matching replies towards --count; unrelated beacons can still be captured. An incomplete --once poll exits unsuccessfully and retains any accepted samples. Continuous polling reports the timeout and retries after --interval. Passive listening stays active between receive windows.
The bridge checks framing, CRCs, HK version, flags and size bounds. It cannot verify each value's width without the report definition; keep the matching report YAML with a capture. JSONL files grow with accepted samples, so stop or rotate captures between runs. Live serial access needs PySerial; offline replay uses only Python's standard library.