Skip to content

fix(ram): carry TlmPacketizer I16 packetOffset patch (−27.5 KiB RAM Reduction) - #468

Draft
Mikefly123 wants to merge 1 commit into
mainfrom
fix/tlmpacketizer-i16-offset
Draft

fix(ram): carry TlmPacketizer I16 packetOffset patch (−27.5 KiB RAM Reduction)#468
Mikefly123 wants to merge 1 commit into
mainfrom
fix/tlmpacketizer-i16-offset

Conversation

@Mikefly123

@Mikefly123 Mikefly123 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What

Carries patches/fprime-tlmpacketizer-i16-offset.patch against lib/fprime, applied by make submodules with a reverse-apply idempotency check (same pattern as the existing fprime-yamcs patch step). The patch shrinks Svc::TlmPacketizer's per-channel packetOffset array from FwSignedSizeType (64-bit) to I16 — 3 functional lines:

  • TlmEntry::packetOffset[MAX_PACKETIZER_PACKETS]: FwSignedSizeTypeI16 (TlmPacketizer.hpp)
  • Range FW_ASSERT in setPacketList tightened to the I16 max + cast at the single assignment site (TlmPacketizer.cpp)

Also excludes patches/ from the trailing-whitespace / end-of-file pre-commit hooks — patch bytes must byte-match the upstream tree or git apply silently breaks.

Why

F Prime's 64-bit size-type migration leaked into a persistent dense channels × packets offset matrix. With this deployment's MAX_PACKETIZER_CHANNELS=202 and MAX_PACKETIZER_PACKETS=22, the offsets alone are 202×22×8 B ≈ 35.5 KB of BSS. Offsets index into ComBuffers ≤ 256 B, so I16 (which preserves the −1 "not in this packet" sentinel and supports packets up to 32 KiB) is ample. Since our malloc arena is the SRAM left over after static allocation (CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=-1) and boot margin was measured at 11,504 B with a hard BufferManager-assert boot-loop past it (background: #467), this flows 1:1 into heap headroom.

Measured (v5e reference deployment)

Metric Before After Delta
CdhCore::tlmSend bss 60,480 B 33,008 B −27,472 B
malloc arena 173,272 B 200,744 B +27,472 B
free heap at boot 11,504 B 38,976 B 3.4×

The −27,472 B was reproduced in this branch's build (nm: tlmSend = 0x80f0).

Validation

  • fprime Svc/TlmPacketizer UT: 12/12 pass (1 pre-existing skip)
  • make test-unit: 8/8 pass on this branch
  • HWIL on a v5e flight board: stable boot, 49 channels decode sane, NO_OP round-trip and SEND_PKT (Beacon + Health) pass, live sys_heap walk measured arena 200,744 B / free-at-boot 38,976 B — matching the nm-predicted numbers exactly
  • make submodules apply flow verified idempotent (reverse-apply check on second run)

Status

Carried patch, pending upstream acceptance in nasa/fprime — upstreaming proposal tracked in #469.

🤖 Generated with Claude Code

Carry patches/fprime-tlmpacketizer-i16-offset.patch, applied to lib/fprime
by `make submodules` with a reverse-apply idempotency check (same pattern
as the existing fprime-yamcs patch step). Also exclude patches/ from the
trailing-whitespace and end-of-file pre-commit hooks: patch bytes must
byte-match the upstream tree or `git apply` breaks.

TlmPacketizer::TlmEntry stores FwSignedSizeType packetOffset[MAX_PACKETIZER_PACKETS]
per channel — F Prime's 64-bit size-type migration leaked into a persistent dense
channels x packets offset matrix. The offsets index into ComBuffers <= 256 B, so
I16 is ample (keeps the -1 sentinel, supports offsets to 32 KiB; the range
FW_ASSERT in setPacketList is tightened to the I16 max). 3 functional lines.

Measured on this deployment (MAX_PACKETIZER_PACKETS=22, MAX_PACKETIZER_CHANNELS=202):
- CdhCore::tlmSend bss: 60,480 -> 33,008 B (-27,472 B; reproduced in this build, nm 0x80f0)
- malloc arena (CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=-1): 173,272 -> 200,744 B
- free heap at boot: 11,504 -> 38,976 B (3.4x; margin context in PR #467)

Validation: fprime Svc/TlmPacketizer UT 12/12 pass (1 pre-existing skip);
HWIL on v5e — stable boot, 49 channels decode sane, NO_OP and SEND_PKT pass,
live sys_heap walk matches predicted numbers exactly. Upstream candidate for
nasa/fprime; carried here until accepted.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c467cfd8-6b4a-4334-9a7b-5ce9877e1220

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Mikefly123 Mikefly123 changed the title fix(ram): carry TlmPacketizer I16 packetOffset patch (−27.5 KiB bss) fix(ram): carry TlmPacketizer I16 packetOffset patch (−27.5 KiB RAM Reduction) Jul 23, 2026
@Mikefly123 Mikefly123 self-assigned this Jul 23, 2026
@Mikefly123 Mikefly123 added the help wanted Extra attention is needed label Jul 23, 2026

@nateinaction nateinaction left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me.

@Lex-ari

Lex-ari commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

omg tlmpacketizer :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants