|
K-FSW v1.2.1-59-gcaca356
KFSW: modular flight software on Zephyr, for small satellites
|
Type commands at the shell prompt:
Wait for @READY before using services. help lists the commands in the build and <command> -h shows the syntax. Tab completes command and subcommand names, but not arguments such as a node or a path. When more than one name fits, Tab lists them one per line with their help. A command with the wrong number of arguments prints its usage:
Required arguments use <name> and optional arguments use [name]. A subcommand that takes arguments ends its help with its usage; one that takes none says nothing further. For example, ftp -h includes get <node> <remote> <local> and put <node> <local> <remote>.
The shell needs CONFIG_KFSW_DEBUG_SHELL. Each command group depends on its service (app/CMakeLists.txt):
| Command | Build option |
|---|---|
status, version, time, log | always |
csp, comms | CONFIG_KFSW_CSP |
comms uart | CONFIG_KFSW_CSP_KISS_UART |
comms can | CONFIG_KFSW_CSP_CAN |
param | CONFIG_KFSW_PARAM; saving needs CONFIG_KFSW_PARAM_PERSISTENCE |
table | CONFIG_KFSW_TABLE |
storage | CONFIG_KFSW_STORAGE |
ftp | CONFIG_KFSW_FTP |
event | CONFIG_KFSW_EVENT |
journal | CONFIG_KFSW_JOURNAL and CONFIG_KFSW_COMMAND |
cmd | CONFIG_KFSW_COMMAND |
reboot | CONFIG_KFSW_COMMAND and CONFIG_REBOOT |
hk | CONFIG_KFSW_HK |
fbo | CONFIG_KFSW_FBO |
fwu | CONFIG_KFSW_FWU_STANDARD |
fwu_lite | CONFIG_KFSW_FWU_LITE_CSP |
golden | CONFIG_KFSW_GOLDEN, or CONFIG_KFSW_BOOT_STORE with CONFIG_KFSW_PARAM |
watchdog | CONFIG_KFSW_WATCHDOG |
health | CONFIG_KFSW_HEALTH |
gndwdt | CONFIG_KFSW_GNDWDT |
resmon | CONFIG_KFSW_RESMON |
limits | CONFIG_KFSW_LIMITS |
scrub | CONFIG_KFSW_SCRUB |
remexec | CONFIG_KFSW_REMEXEC |
comms uhf | CONFIG_KFSW_RADIO_UHF_SHELL |
temp | CONFIG_KFSW_TEMP_EXAMPLE_SHELL |
button_test, test | CONFIG_KFSW_BUTTON_TEST_SHELL |
help lists the shell. cmd list lists the command registry. A name in one need not be in the other.
A shell command is a Zephyr SHELL_CMD_REGISTER group: text in, text out, reachable only from a terminal. It exists only where CONFIG_SHELL is on. The golden recovery profile builds without it, because the shell is a quarter of that image and nobody can reach the console of a node in orbit.
A registered command is an entry in the command service: a name, a numeric ID, up to four typed arguments and a typed result. The registry is a static array of CONFIG_KFSW_COMMAND_MAX_COMMANDS entries (16 by default), fixed once startup ends. A composition whose definition sets exceed that count fails startup with -ENOSPC.
The registry is what everything other than a terminal calls:
| Caller | Names the command |
|---|---|
| The ground, on CSP port 11 | by ID |
| A shell group | by name, through kfsw_shell_run_command() |
| File procedures and the time-tagged queue | by name, read from the file |
| Limits, when a parameter crosses a bound | by name, from the limit |
| The ground watchdog, on another node | by name |
Each caller reaches the same definition and the same handler. With CONFIG_KFSW_EVENT, every dispatch records a COMMAND_INVOKED, COMMAND_UNKNOWN or COMMAND_REJECTED event carrying the command ID, the source node and the status. A shell group that calls a service API directly leaves none of that behind, so an action the ground or a procedure has to run belongs in the registry even when an operator reaches it by typing.
Table 28 counts the same outcomes in cmd_invoked, cmd_failed, cmd_unknown and cmd_rejected. They start at zero at each boot and wrap at 2^32; the ICD gives each one's definition.
remexec goes the other way: it runs an allowlisted shell line on another node, on CSP port 8, and returns the text that line printed.
cmd reads the registry and runs nothing:
| Command | Prints |
|---|---|
cmd list | Every command this node carries, with its ID and flags |
cmd describe | The same, with each argument type and the help |
cmd show <name> | One command |
| Command | Prints |
|---|---|
status [node] | Role, name, CSP node, board, hardware ID, uptime, and the revision of each repository |
version | K-FSW version, repository revisions, Zephyr version, board, SoC, hardware ID and the boot trial counters |
time | Milliseconds and microseconds since boot |
A trailing + marks a repository with uncommitted changes at build time. status 2 runs the info command on node 2, which returns its uptime and storage state, then reads its revisions from its boot_revisions parameter.
Role and name are labels set in the build. time is time since boot; wall time is in csp clock. An image is identified by its revision, the git describe of the build. No compile date is reported, because the date a file was compiled says little about the image it ends up in.
| Command | Arguments | Meaning |
|---|---|---|
log test | none | One message at each level compiled into the image |
log level | [<module> [0..4]] | Show or set the level of each module |
log history | none | Recent retained messages, with sequence, uptime, module, level and truncation |
log remote | <node> [count] [min level] | Another node's newest messages, text or dictionary |
journal remote | <node> [count] | Another node's newest journal records, in one read |
log history needs CONFIG_KFSW_LOG_HISTORY and holds CONFIG_KFSW_LOG_HISTORY_DEPTH messages, 32 by default and 16 in the golden profiles. The log_level and log_levels parameters set the same filters as log level.
log_remote_format on the serving node picks text (0) or dictionary (1). Dictionary lines show pkg=00000000:<hex> crc32=<hex>; tools/ground/log-decode.py --elf turns them back into text. See Logging.
comms uhf status prints the radio implementation, the expected hardware and serial settings, and the link state. With CONFIG_KFSW_RADIO_UHF_CRYPTO, comms uhf connect starts new encrypted sessions with the configured peer.
comms uhf status doesn't talk to the modem. Traffic and errors are in comms uart info and csp interfaces.
| Command | Arguments | Meaning |
|---|---|---|
button_test status | none | Press count, last press and LED states |
| test led | <green|blue|red> <on|off> | Switch one LED |
Holding the button counts one press, and the counts reset at boot. temp status prints the temperature example's cached die temperature and read counters.
| Command | Arguments | Meaning |
|---|---|---|
csp info | none | Local address, identity, revision, libcsp tag, CSP protocol version and free buffers |
csp ident | [node] | Hostname, model, revision and clock |
csp interfaces | none | Interfaces with addresses and packet, error and drop counters |
csp ifstat | <node> <interface> | Remote interface packet/byte/error counters |
csp routes | none | Route table |
csp ping | [node] | Ping with CRC32 and a one-second timeout; this node without one |
csp counters | [clear] | libcsp error counters; see CSP and links |
csp debug | [on\|off] | Log every packet in and out |
csp rdp | [0..2] | RDP trace detail |
csp clock | [set <utc>] or <node> [sync] | Read or set wall time |
csp reboot | <node> <pin> [--retry] | Restart a node |
csp debug on logs each packet's source and destination node and port, priority, flags, size and interface, so the trace also lands in log history. It is off by default and affects only this node.
With several links, csp routes shows the interface and next hop of each route (CSP 1 prints /5 prefixes instead of /14):
Routes are set at build time and can't be changed from the shell. Every request to another node that gets no answer is logged as a warning and kept in log history, for example [WARNING] csp ping: node 5 did not answer. No answer can mean no peer, a wrong address or route, framing errors or no free buffers; check csp interfaces, csp routes and comms uart info.
csp reboot <node> <pin> restarts a node if the pin matches, and reboot <pin> restarts this one:
The pin is reboot_pin in table 2: 0000 by default, persistent, and settable from the ground. It is text, so 0007 doesn't match 7. It travels in clear text and guards only against rebooting the wrong node by mistake.
After a restart the boot table shows why the previous run ended:
All three at zero means no valid reset note was found: power loss, or a reset before a note was written. Check the hardware reset cause as well.
Each link a composition carries is a subcommand of comms.
| Command | Arguments | Meaning |
|---|---|---|
comms uart info | none | Each CSP UART with baud, state, KISS name, address and counters |
comms uart test | [node] | Check that the route uses a UART/KISS link, then ping with a 128-byte payload |
comms can info | none | The CSP CAN interface: bitrate, address and counters |
comms can test | <node> | Check that the route uses CAN, then ping with a 64-byte payload |
comms uhf status | none | See UHF radio, above |
A test refuses this node's own address, whose packets never reach the link. Name the node to test one link of several, for example comms uart test 10. On the NUCLEO the commands run on the ST-LINK console and the packets leave on USART3.
| Command | Arguments | Meaning |
|---|---|---|
param whichtables | [node] | The tables a node carries, without values |
param table | [node] <id> | The parameters of one table, with values |
param listall | [node] | Every parameter of a node, with values |
param get | [node] <name> | Read a value |
param set | [node] <name> <value> | Write a value |
param describe | [table] | What each parameter is, with its unit |
layer names the part of K-FSW that defines a table and holds describes its contents. Local output also has kept, the number of persistent values. Remote table summaries carry their own names and descriptions. For an older node without table-list support, names and descriptions come from this build by table ID; an unknown table is named -.
Mode letters: r read-only, w writable, p saved in the snapshot, b applied at the next boot. Strings are printed quoted and arrays as lists. Input is parsed with the parameter's type; overflow, negative unsigned values and bad numbers are rejected.
echo_enabled makes the console repeat what it receives, and is off by default. Zephyr ignores Tab and the arrow keys while echo is off, so run param set echo_enabled 1 for completion and command history.
With CONFIG_KFSW_PARAM_CSP, put the node before the other arguments:
The node is a decimal number. Remote listings show the table number instead of its name, because table names are not sent over the link.
| Command | Effect |
|---|---|
param save | Write all persistent values to the snapshot |
param persist <table> | Write the snapshot and show that table's share |
param load | Apply the saved snapshot |
param defaults | Reset persistent values to their defaults, in RAM only |
param clear | Delete the snapshot; RAM is unchanged |
These act on the local node. With param_autosave on, a change to a persistent value is saved without param save. See Services.
| Command | Arguments | Meaning |
|---|---|---|
storage info | none | Filesystem, backend, mount point, state, total and free bytes |
storage test | none | Create, write, read, overwrite and delete a test file |
storage test write | <value> | Write the persistence test value |
storage test read | <value> | Read and compare the persistence test value |
storage test writes to flash. The tmp_ lines are the RAM volume, formatted at every boot.
Paths are virtual and rooted at /kfsw/ftp on the node.
| Command | Arguments | Meaning |
|---|---|---|
ftp ls | [node] [directory] | List a directory |
ftp stat | [node] <path> | Kind, size and CRC |
ftp mkdir | [node] <directory> | Create a directory |
ftp rm | [node] <path> | Remove a file or empty directory |
ftp put | <node> <local> <remote> | Upload a file |
ftp get | <node> <remote> <local> | Download a file |
ftp generate | <path> <bytes> | Create a test file of up to 32768 bytes |
ftp verify | <first> <second> | Compare two local files |
Without a node, ls, stat, mkdir and rm act on this node, without a connection; put and get need another node. A transfer that would leave less than CONFIG_KFSW_FTP_SPACE_MARGIN_BYTES (4096) free on its volume is refused before any data moves: not enough free space.
ftp rm refuses directories with entries, read-only paths and the storage root. It does not delete recursively. Removing a missing path reports not found.
Listing / also shows these directories when they exist:
| Directory | Holds | Writable |
|---|---|---|
boot | firmware slots, see Firmware update | no |
hk | housekeeping sample files | no |
tmp | RAM, empty after every boot: 32 KB on Linux and the NUCLEO, 16 KB on the Pico W | yes |
Each entry starts with its kind:
| Kind | Meaning |
|---|---|
dir | directory |
file | file |
img | firmware image, in /boot |
hk | housekeeping samples, in /hk |
proc | procedure, in /procedures |
Paths must start with / and can't contain .. or empty components.
Groups that can ask another node take the node first, as param does: status 2, event stats 2, journal tail 2 0, hk period 2 0 1000, csp reboot 2 <pin>, gndwdt feed 2. A node gets cmd_timeout_ms (3000 by default) to answer; one that does not is logged as a warning. The reply comes back one field per line, after the node it came from:
Each of these is a command of the command service, sent over CSP port 11; the commands are the wire protocol a ground tool speaks. The name is looked up in the local registry before the request is sent, so both nodes need the same command IDs. A remote request that changes the node can end in --retry, for example csp reboot 2 0000 --retry; see Scripts, below. Remote commands need CONFIG_KFSW_COMMAND_CSP. The command service does not authenticate callers: radio encryption can protect that link, and other interfaces need their own access policy.
Four kinds of number are part of the wire contract. Two nodes must agree on each, and none is reused once it has been given out.
Command IDs. Composition commands are defined in app/src/commands/command_definitions.c; a service command carries its ID in the service's header.
| ID | Command | Defined in |
|---|---|---|
| 1 to 3 | noop, info, reboot | k-fsw composition |
| 4, 5 | event_stats, event_tail | k-fsw composition |
| 6 to 8 | hk_define, hk_period, hk_clear | k-fsw composition |
| 9 to 11 | journal_stats, journal_tail, journal_time | k-fsw composition |
| 12 to 15 | free | |
| 16 | ground_wtd | kfsw-services, gndwdt.h |
| 17 to 19 | free | |
| 20 to 23 | fbo_run, fbo_sched_add, fbo_sched_cancel, fbo_sched_clear | kfsw-services, fbo.h |
| 24 | golden_install | k-fsw composition |
| 40 to 43 | gpredict_select, gpredict_enable, gpredict_park, gpredict_clear | kfsw-modules, gpredict.h |
| 64 | temp_clear | kfsw-modules, temperature_sensor_example.h |
CSP ports. 0 is management (CMP) and 1 ping, both from libcsp. K-FSW serves 8 remote shell execution, 9 file transfer, 10 parameter values, 11 commands, 12 parameter descriptors, 13 FWU lite, 14 housekeeping, 15 housekeeping beacons on the receiving node, and 16 log history. Each has a Kconfig option; see CSP and links.
Parameter tables. 1 to 24 are core (1 board, 2 system, 3 telemetry, 4 csp, 5 storage), 25 to 49 services (25 log through 40 limits) and 50 to 99 modules (50 radio-uhf, 51 temp_example, 67 hw_test). param whichtables lists what a node carries.
Node addresses. Under CSP 2, the default, nodes are 1 to 16382 and 16383 is broadcast; under CSP 1 nodes are 1 to 30 and 31 is broadcast. A command given a node outside that range is refused before anything is sent, for example Node must be 1..30: 31. Flight nodes use 1 to 15 and ground roles start at 16, which tools/k-ground enforces.
remexecremexec reads which shell commands a node offers and runs one of them, on CSP port 8. It needs CONFIG_KFSW_REMEXEC, which the Linux, NUCLEO-L496ZG and Pico W images set.
| Command | Meaning |
|---|---|
remexec <node> get | The commands that node offers, one a line |
remexec <node> get <command> | That command and its subcommands, with their help |
remexec <node> run "command args" | Run it there and print what it produced |
The serving node's allowlist decides, and get reports that list. A command not on it is refused by name:
Marking a command marks its arguments as well, so a composition marks only commands whose whole argument space is safe from the ground. The list lives in app/src/remexec/remexec_allowlist.c; Services has the allowlist, the output cap and the limits.
A reply that could not carry everything says how much went missing, separately from whether the command itself succeeded:
remexec always names another node; a node cannot run its own commands this way. remexec_refused and remexec_refusal in table 38 show what a node refused and why, without reading its log.
| Command | Meaning |
|---|---|
event list | Held records, oldest first |
event stats [node] | Held, capacity, recorded, overwritten and rejected counts |
event tail [node] <age> | One record by age, newest is 0 |
event clear | Discard held records; counters are kept |
Payloads are printed as bytes; their layout is in the producer's header. A gap in SEQ means records were overwritten; event stats counts them. The ring is lost at reset. For another node:
| Command | Arguments | Meaning |
|---|---|---|
hk define | [node] <report> [class=N] <[node:]table:offset> ... [--retry] | Set what a report collects |
hk clear | [node] <report> [--retry] | Delete a report |
hk show | none | Reports and counters |
hk collect | <report> | Collect now |
hk get | <report> [count] | Print collected samples |
hk period | [node] <report> <ms> [--retry] | Collect periodically, 0 to stop |
hk store | <report> <ms> | Also write samples to a file, 0 to stop |
hk store_clear | <report> | Stop storing and delete the file |
hk stored | <report> [from=] [to=] [since=] [until=] [skip=] | Print stored samples |
hk extract | <report> <path> [from=] [to=] [since=] [until=] [skip=] | Copy stored samples to a file |
hk beacon | <report> <node> <ms> | Send the latest sample periodically, 0 to stop |
hk save | none | Save the report settings |
--retry applies when a destination node is given.
A leading node sets up that node's reports: hk define 2 0 3:0 3:8 asks node 2 to collect its own uptime and free storage as report 0. An entry always holds a :, so the node is told apart from the report. See Ground station for Yamcs and the ground bridge.
| Command | Arguments | Meaning |
|---|---|---|
fbo run | <name> | Run a procedure file |
fbo stop | none | Stop the running procedure |
fbo status | none | Procedure, current line and counters |
fbo sched add | <+s\|@utc> <node> "<command>" | Release a command later |
fbo sched cancel | <index> | Cancel a scheduled entry |
fbo sched clear | none | Empty the queue |
fbo sched list | none | Every queued entry with its state |
fbo sched status | none | Queue counters and the next deadline |
| Command | Arguments | Meaning |
|---|---|---|
fwu status | none | State, slot geometry and checksums |
fwu begin | <size> <crc32> | Start a transfer by hand |
fwu finish | none | Verify the image and offer it to the bootloader |
fwu abort | none | Abandon a transfer and erase the slot |
fwu_lite send | <node> <path> | Upload an image to a node, or resume an upload |
fwu_lite status | [node] | Progress here, or of an upload this node owns |
fwu_lite validate | <node> | Have the node read back and check the stored bytes |
fwu_lite flash | <node> | Activate a validated image |
fwu_lite abort | <node> | Erase this sender's transfer |
golden status | none | Whether the golden partition holds an image |
golden install | [node] <pin> | Install the recovery image and restart |
golden attempts | [count] | Read or set the startups left before recovery |
fwu_lite needs CONFIG_KFSW_FWU_LITE_CSP. fwu_lite send reports how many blocks had to be resent. Check link counters if retries increase. A transfer that stops part way continues from where it left off rather than starting again, which is why validate is a separate step.
After a transfer, check swap_scheduled in fwu status. If it is not set, MCUboot has nothing to swap and boots the old image. Firmware update has the procedures.
install takes a confirmation pin, so a mistyped command cannot replace the running image. attempts without a count reads the budget; with one it writes it, and the value is persisted. Fault detection and recovery has what spends an attempt.
Services, under Watchdogs, says what feeds each of the three.
The watchdog commands need CONFIG_KFSW_WATCHDOG and a kfsw,watchdog devicetree property. watchdog status shows the state (unconfigured, configured, running or starved), the timeout, the feed interval, the number of feeds and the time since the last one.
watchdog starve confirm can't be undone: the STM32 independent watchdog can't be disarmed, and the board resets within one timeout. health watch also ends in a reset once the deadline passes. The next boot marker shows the cause:
The raw mask is printed as well because several causes can be latched at once; 0x11 is the reset pin and the watchdog.
Remote requests are not retried. With CONFIG_KFSW_COMMAND_RETRY, ending one with --retry sends it with a ticket that suppresses duplicates within that invocation. A new invocation is a new operation. A timeout can mean the reply was lost after the command ran, so check the state before sending it again.
To drive the shell from a script:
@READY.