From a80c4f6481ee32df3d91112a0f65fababa924f63 Mon Sep 17 00:00:00 2001 From: Michael Pham <61564344+Mikefly123@users.noreply.github.com> Date: Thu, 23 Jul 2026 18:43:14 -0700 Subject: [PATCH] Svc::TlmPacketizer: shrink per-channel packetOffset storage from FwSignedSizeType to I16 TlmEntry stores FwSignedSizeType packetOffset[MAX_PACKETIZER_PACKETS] per channel. The value is a byte offset into a ComBuffer-sized packet (bounded by FW_COM_BUFFER_MAX_SIZE, typically a few hundred bytes) or the -1 'not in this packet' sentinel -- a 64-bit signed type per slot is 4-8x oversized. Shrink to I16 (keeps the -1 sentinel; supports packet offsets to 32 KB) with a config-time FW_ASSERT range guard at the single assignment site in setPacketList. Validated on a real CubeSat deployment (MAX_PACKETIZER_CHANNELS=202, MAX_PACKETIZER_PACKETS=22, RP2350/Zephyr, v5e flight board): - -27,472 B BSS (60,480 -> 33,008 B, -45%) in CdhCore::tlmSend - Svc/TlmPacketizer UTs: 12/12 passed (1 pre-existing skip) - HWIL-verified: clean boot, NO_OP round-trip, packetized telemetry decodes bit-correct, SEND_PKT works; live heap walk matches nm prediction exactly (free-at-boot 11,504 -> 38,976 B) Tracked by Open-Source-Space-Foundation/proves-core-reference#469. --- Svc/TlmPacketizer/TlmPacketizer.cpp | 6 +++--- Svc/TlmPacketizer/TlmPacketizer.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Svc/TlmPacketizer/TlmPacketizer.cpp b/Svc/TlmPacketizer/TlmPacketizer.cpp index 89af22e1d01..ba1c685558c 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(std::numeric_limits::max()), + // the offset must fit within I16 to allow for the -1 sentinel value + FW_ASSERT(packetLen <= static_cast(std::numeric_limits::max()), static_cast(packetLen)); - entry.packetOffset[pktEntry] = static_cast(packetLen); + entry.packetOffset[pktEntry] = static_cast(packetLen); packetLen += entry.channelSize; diff --git a/Svc/TlmPacketizer/TlmPacketizer.hpp b/Svc/TlmPacketizer/TlmPacketizer.hpp index 7f80d76d265..ffb58fc5d17 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