Skip to content

Ers zephyr work#19

Open
tedhavelka wants to merge 126 commits into
masterfrom
ers-zephyr-work
Open

Ers zephyr work#19
tedhavelka wants to merge 126 commits into
masterfrom
ers-zephyr-work

Conversation

@tedhavelka
Copy link
Copy Markdown

@tedhavelka tedhavelka commented Dec 21, 2025

This pull request introduces a Zephyr RTOS based ERS drogue board firmware application.

Pending tasks to change this PR to "Open":

[ ] update top level README design document

[ ] retest code with lock ring assembly and sister ERS boards

[ ] apply any code amendments needed based on tests with LV3.1 avionics

Note, while it is simple to add a configuration flag and have this code base support both drogue parachute and main parachute ERS firmware apps, the code does not implement the ERS "Sender" application. This could be done, but is already implemented in William Jeffrey's Rust language ERS project.

This Zephyr application written in large part to compare C and Zephyr implementation with Rust and Embassy implementation.

tedhavelka and others added 30 commits October 14, 2025 21:12
… . .

board firmware.  These files comprise three sample apps in a source tree which
somewhat mirrors Zephyr RTOS source tree organization.

These files are added in
`lv3.1-recovery/controlSystem/RecoveryBoard/firmware-zephyr`.  This directory
exists alongside as indicated by the command named 'tree':

.
├── firmware
├── firmware-zephyr
├── pcb
└── README.md

Note these tiny samples assume there is a Zephyr workspace, or Zephyr source
tree in some parent directory above the directory in which these ERS firmware
project files are cloned.
ERS application in progress, with all basic peripherals such as ADC, DAC,
CANBus, GPIO in code base.  What remains to be completed:

(1) logic to lock and to unlock drogue chute lock ring.

(2) API to drive the motor at various currents and in both directions.

(3) full testing of lock ring position determination.
…and . . .

perform some organizing and clean up in ERS shell commands module.
…tion . . .

determination.  The timer allows for an easier way to enable and disable ring
position figuring, as well as to set its frequency at build time and at run time
by changing a single parameter.
…nd . . .

add comments to "keeper" module about three kinds of data stored in this
module:  configuration, readings, and run time state data.
Simple error to fix, needed to ensure we do not fall through to successive IF
constructs in comparison tests of Hall reading with Hall sensor defined limits.
…to . . .

change lock ring position detection interval at run time.

Note also observing a problem with work element submission.  The work element
only runs for a few seconds, then continues to be submitted but no longer runs.
Tried:

  (1)  confirming that routine body of submitted work runs.
  (2)  checked return values of k_work_submit() call.
  (3)  added call to k_work_flush() and checked its return values.
  (4)  commented out mutex in keeper module protecting Hall readings access.

Still no success.  Investigation underway . . .
…ge in . . .

lines of code but a significant change in scheduling.
… . . .

reading limits.

Also noting that motor turns over at a minimum DAC output somewhere between
350 DAC steps and 450 DAC steps.
…for . . .

implementing commands to lock and to unlock drogue (or main) parachute ring.
…a . . .

duplicate module logging symbol code for ADC module.  Set arbiter log level to
"ERR".
… yet . . .

connected to code which detects ring position.
…2.0.

Note, there is some problem in which on two of Ted's localhosts a call to
`west update` checks all of Zephyr's third party modules but skips Zephyr RTOS
itself.
…c . . .

and adjust DAC setting for motor in situ.  Observing ring to lock and to unlock
over about 300 milliseconds.  Checking ring position every 10 ms.  DAC setting
is 800.  But unsure whether ring position test is getting correct data as motion
always stops at the maximum count of ring position checks, a kind of "hard"
timeout.
Ted Havelka and others added 7 commits February 12, 2026 22:24
… . .

necessary in order to make use of these values in a given firmware run time.
… . . .

the preprocessor built-in paste macro `##`.
… . . .

some or even many of these configuration items could be moved into Kconfig, and
be useful this way so long as firmware is Zephyr based or built in a larger
system which supports Kconfig.
tedhavelka and others added 22 commits February 15, 2026 07:02
…mit . . .

Zephyr third party modules to those needed by ERS and a few more.  Reduces
download tie and disk space by many hundreds of megabytes.
directories: bootloader, modules, tools, zephyr.
… off . . .

the injection of spoofed sender board heart CAN frames.  Add a helper script
to start venv and set a Zephyr envvar that's unset on a particular localhost.
…each . . .

with RING_POS_ instead of RING_ to make them more distinct from ring state enum
element names.
…ephyr,

which should be set up by some other means for the ERS Zephyr workspace.
while hacky will help "tame" Zephyr shell module which echoes all Zephyr log
messages.
…mprove

response time to system state changes.
This is a more involved commit, and unexpected.  After a month away from ERS
code (for mag card work and L1 rocket certification) Ted performs `west udpate`.
The Zephyr ERS app happens to be building against Zephyr 3.7.0 LTS which sees
very few changes as a stable release.  But something must have changed as the
compilation after a month's time failed with many doubly defined symbols.  The
repeat definitions were reported in a couple of header files of Pico standard C
library.

Zephyr supports multiple reduced footprint C libraries, newlibc among them.
The ERS hardware is also not Raspberry Pi Pico based, so this commit switches
embedded C libraries from picolibc to newlibc.  (Unsure why Zephyr's build
system would default to picolibc in first place.)

Newlibc requires for its printf family functions an explicit pound include of
stdio.h.  This include added to two source files where needed.

The ERS app then compiled and ran for a short while but hard-faulted.  Gdb shows
that the arbiter module was overflowing its stack space, so increase that from
512 bytes to 1024 bytes.

On the support and utils side, rename 'build.sh' to 'compile.sh'.  This is a
tiny script to capture the handful of options to 'west build' which take a
little time to type and are easy to forget.  This renaming supports tab
completion which is hampered by cmake's default behavior of making an output
directory named 'build', which in our situation then looks similar to
'build.sh'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant