|
K-FSW ec10f94
Modular flight software on Zephyr, for small satellites
|
k-fsw builds the application from four reusable repositories. It selects features, binds hardware, and orders startup.
| Repository | Contents |
|---|---|
k-fsw | Application startup, target configuration, shell adapters, tools, integration tests, docs, and west.yml |
kfsw-platform | Time, reset cause, watchdog, retained reset notes, and storage over Zephyr |
kfsw-services | Boot, logging, parameters, persistence, files, commands, events, health, housekeeping, and firmware update |
kfsw-comms | libcsp setup, one router, routes, UART/KISS and CAN interfaces |
kfsw-modules | Device and subsystem clients, including UHF, button/LED, and temperature examples |
Shared code goes in the repository listed above. Shell handlers parse arguments, call a public API and print the result.
Zephyr supplies the kernel, drivers, filesystem integration, shell, and build tools. libcsp supplies the network stack; libparam supplies the remote parameter codec. The manifest pins K-FSW forks; each keeps its upstream licence.
The application can use all four repositories. Services use platform APIs and, when needed, communications. Communications uses libcsp and platform support. Device modules declare the dependencies they need. None of these layers depends on k-fsw/app.
Local parameters and persistence can run with CSP disabled:
FTP needs CSP and storage. The remote parameter adapter needs CSP and the local parameter core. Kconfig checks these dependencies.
| Input | Sets |
|---|---|
west.yml | Exact dependency revisions |
config/targets/<target>.env | Zephyr board and local tool defaults |
app/prj.conf, board .conf, profile .conf | Enabled software and defaults |
| Board devicetree and overlays | Devices, wiring, and flash partitions |
app/src/main.c | Initialization order and error handling |
Use west manifest --resolve to inspect revisions. See Boards and targets for profiles and Zephyr integration for generated configuration. Changing RTOS requires adapting the Zephyr APIs used by the selected code; moving to another Zephyr board usually changes configuration and device bindings.
A module has its own device state, public API and parameter table. The application selects it and passes its definition set to PARAM.
radio-uhf reports the selected Holybro SiK identity and expected serial configuration. The UART/KISS data path is in kfsw-comms.boton_test handles debouncing, the press count, the last press time and the LED state. Table 67 exposes its values. Use kfsw_boton_test_get_status() for a consistent snapshot of all five fields.temperature-sensor-example reads a configured sensor and publishes samples and status in table 51.Hardware is selected in devicetree. A module should not select a board by name or duplicate a router, transport, or service.
main.c runs the following stages when their features are enabled:
@BOOT and @READY; enter the application health-report loop.Persistence needs storage and registered parameter tables. Network services need initialized CSP; FTP and the other worker servers start after the router.
Startup logs errors and carries on with the stages that don't depend on the failed one. @READY means startup has finished, not that every service started; check storage info, csp info or the service status. The shell prompt can appear before @READY.
| State | Kept in and protected by |
|---|---|
| Storage readiness | Platform storage mutex |
| Parameter values | Each component's storage; PARAM validation and callbacks |
| Parameter index | PARAM mutex and bounded static index |
| Persistence workspace | Persistence mutex and PARAM locking |
| Button and LED snapshot | Module mutex |
| CSP routes and interfaces | Communications; initialized once |
| UART/KISS receive state | One context per interface |
| FTP client | One static workspace, serialized by a mutex |
| FTP server | One worker; overlapping requests return busy |
| Events | Bounded RAM ring protected by a short spinlock |
Parameter reads of individual fields do not provide a consistent multi-field snapshot. Use the module's snapshot API when the fields must agree.
After passing a packet to a send call, don't reuse or free it, even if the send fails.
kfsw_time_monotonic_ms() and kfsw_time_monotonic_us() return elapsed time for deadlines and durations. Resolution depends on the selected Zephyr clock source.
The CSP clock API gives wall time from the RTC for timestamps. Setting it doesn't change monotonic deadlines.