Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ repos:
rev: v5.0.0
hooks:
- id: trailing-whitespace
# patches/*.patch are machine-generated diffs applied via `git apply`;
# their context/removed lines must byte-match the real upstream files,
# which can legitimately have trailing whitespace. Stripping it here
# silently breaks patch application.
exclude: ^patches/
- id: end-of-file-fixer
exclude: ^patches/
- id: check-yaml
exclude: ^mkdocs\.yml$
- id: check-json
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ help: ## Display this help.
submodules: ## Initialize and update git submodules
@git submodule foreach --recursive 'git checkout -- . && git clean -fd' || true
@git submodule update --init --recursive
@echo "Applying fprime TlmPacketizer I16 packetOffset patch (upstream candidate)..."
@cd lib/fprime && \
if git apply --check ../../patches/fprime-tlmpacketizer-i16-offset.patch 2>/dev/null; then \
git apply ../../patches/fprime-tlmpacketizer-i16-offset.patch && \
echo "✓ Applied TlmPacketizer I16 packetOffset patch"; \
elif git apply --reverse --check ../../patches/fprime-tlmpacketizer-i16-offset.patch 2>/dev/null; then \
echo "⚠ Patch already applied"; \
else \
echo "❌ Error: Unable to apply TlmPacketizer I16 patch. Run 'cd lib/fprime && git status' to check."; \
exit 1; \
fi

export VIRTUAL_ENV ?= $(shell pwd)/fprime-venv
.PHONY: fprime-venv
Expand Down
18 changes: 18 additions & 0 deletions patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

This directory contains patches that are automatically applied to git submodules during the build process.

## fprime-tlmpacketizer-i16-offset.patch

Shrinks `Svc::TlmPacketizer`'s per-channel `packetOffset` array from `FwSignedSizeType`
(64-bit) to `I16` in `lib/fprime`. The offset is a byte index into a ComBuffer-sized
packet (or the -1 "not in this packet" sentinel), so I16 is ample; the range `FW_ASSERT`
in `setPacketList` is tightened to the I16 max.

**Why:** With this project's `MAX_PACKETIZER_CHANNELS=202` and `MAX_PACKETIZER_PACKETS=22`,
the dense channels×packets offset matrix dominates the component: the patch shrinks the
`tlmSend` instance from 60,480 to 33,008 B of BSS (−27,472 B), which flows 1:1 into the
libc malloc arena (free-at-boot measured 11,504 → 38,976 B on a v5e board).

**Status:** Upstream candidate for nasa/fprime; carried here until accepted.

**Application:** Applied automatically by `make submodules` with a reverse-apply
idempotency check. As with the other fprime patches, `lib/fprime` will show as modified —
do not commit the submodule pointer.

## fprime-gds-version.patch

This patch updates the `fprime-gds` version requirement in `lib/fprime/requirements.txt` from 4.1.0 to 4.1.1a2.
Expand Down
31 changes: 31 additions & 0 deletions patches/fprime-tlmpacketizer-i16-offset.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/Svc/TlmPacketizer/TlmPacketizer.cpp b/Svc/TlmPacketizer/TlmPacketizer.cpp
index 89af22e1d..ba1c68555 100644
--- a/Svc/TlmPacketizer/TlmPacketizer.cpp
+++ b/Svc/TlmPacketizer/TlmPacketizer.cpp
@@ -89,10 +89,10 @@ void TlmPacketizer::setPacketList(const TlmPacketizerPacketList& packetList,
entry.ignored = false;
entry.channelSize = packetList.list[pktEntry]->list[tlmEntry].size;
// the offset into the buffer will be the current packet length
- // the offset must fit within FwSignedSizeType to allow for negative values
- FW_ASSERT(packetLen <= static_cast<FwSizeType>(std::numeric_limits<FwSignedSizeType>::max()),
+ // the offset must fit within I16 to allow for the -1 sentinel value
+ FW_ASSERT(packetLen <= static_cast<FwSizeType>(std::numeric_limits<I16>::max()),
static_cast<FwAssertArgType>(packetLen));
- entry.packetOffset[pktEntry] = static_cast<FwSignedSizeType>(packetLen);
+ entry.packetOffset[pktEntry] = static_cast<I16>(packetLen);

packetLen += entry.channelSize;

diff --git a/Svc/TlmPacketizer/TlmPacketizer.hpp b/Svc/TlmPacketizer/TlmPacketizer.hpp
index 7f80d76d2..ffb58fc5d 100644
--- a/Svc/TlmPacketizer/TlmPacketizer.hpp
+++ b/Svc/TlmPacketizer/TlmPacketizer.hpp
@@ -172,7 +172,7 @@ class TlmPacketizer final : public TlmPacketizerComponentBase, public Fw::ParamE
FwChanIdType id; //!< telemetry id stored in slot
// Offsets into packet buffers.
// -1 means that channel is not in that packet
- FwSignedSizeType packetOffset[MAX_PACKETIZER_PACKETS];
+ I16 packetOffset[MAX_PACKETIZER_PACKETS];
FwSizeType channelSize; //!< max serialized size of the channel in bytes
bool ignored; //!< ignored channel id
bool hasValue; //!< if the entry has received a value at least once
Loading