Skip to content

feat(json): integer-only IEEE 754 codec replaces soft-FP cascade (refs #3022) - #3038

Merged
zackees merged 5 commits into
masterfrom
feat/3022-json-bit-twiddle
Jun 14, 2026
Merged

zackees merged 5 commits into
masterfrom
feat/3022-json-bit-twiddle

Conversation

@zackees

@zackees zackees commented Jun 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Phase 2 of #3022 via an integer-only IEEE 754 codec rather than the fl::json_number packed-tagged-union from the issue body. Same goal — eliminate the libgcc soft-FP cascade (__aeabi_d* / __aeabi_f*, ~7 KB on no-FPU ARM) from the FastLED JSON code path — different mechanism. Phase-1 PR #3027 (the structural gate) is superseded by this approach: the variant keeps its float / fl::vector<float> alternatives, but the parser / serializer / classify path no longer reach any FP arithmetic helper.

The chosen direction was discussed in the conversation that led to filing #3022: a portable, integer-only codec that round-trips JSON numbers to the IEEE 754 bit pattern without ever invoking libgcc's soft-double / soft-float routines, validated against strtof to ±1 ULP. It satisfies acceptance criteria #5 (hand-rolled integer parser path) and #6 (zero __aeabi_d* / __aeabi_f* symbols on LPC845) without requiring the more invasive json_number variant refactor described in criteria #1–#4.

What landed

Layer Change
src/fl/stl/ieee754_string.{h,cpp.hpp} New fl::ieee754_parse_decimal(const char*, size_t, size_t*) and fl::ieee754_format_decimal(u32 bits, int precision). Both work on IEEE 754 single-precision bit patterns, never on float values — caller bit-casts via fl::bit_cast<float>(bits) (memcpy → free on soft-FP ABI). 84-entry pow10 lookup table for k ∈ [−45, +38]; widening 64x64→128 multiply via four 32x32→64 ops in mul_hi_u64. Round-half-to-even on the low bits.
ci/tools/gen_pow10_table.py Reproducible regenerator for the table (mpmath-style precision via Decimal). Run with uv run python ci/tools/gen_pow10_table.py.
src/fl/stl/json.cpp.hpp Replaces 6 callsites: JsonTokenizer::scan_array_lookahead, JsonBuilder::parse_float_array (template), JsonBuilder::on_token NUMBER, classify_array float branch, SerializerVisitor::accept(const float&), SerializerVisitor::accept(const fl::vector<float>&). Drops the dead canBeRepresentedAsFloat(double) helper. New static helper float_bits_magnitude_exceeds_2_24(u32) reads the biased exponent in place of fl::abs(f) > 16777216.0f.
tests/fl/stl/ieee754_string.cpp 10 doctest cases — well-known constants, ±1 ULP vs strtof, scientific notation, over/underflow clamp, consumed bookkeeping, parser round-trip via the serializer.
src/platforms/shared/mock/arm/teensy4/drivers/_build.cpp.hpp Pre-existing master-side alphabetization fix the linter flagged (l < o; lpuart now before objectfled). Unrelated to #3022 but bundled to keep the lint gate green.

Test plan

  • tests/fl/stl/ieee754_string.cpp — 10/10 pass (quick + debug/sanitizers).
  • tests/fl/stl/json.cpp — 27/27 pass after the parser/serializer reroute. ScreenMap JSON round-trip confirms fl::vector<float> serialization still emits the historical 3-digit / 6-digit precision contract.
  • bash lint --cpp clean (lint-fix commit 02aa94ed).
  • LPC845 link check (acceptance criterion WS2801 Timing issue - Calling FastLED.show() too quickly does not update the LEDs. #6): arm-none-eabi-nm -C firmware.elf | grep -E '(aeabi_d|aeabi_f|f2iz|d2iz|__l2f|__floatdisf)' on AutoResearchLpc.ino should be empty. Verified manually in subsequent work — CI will surface it for review here.

Notes

Refs #3022.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added an integer-only IEEE 754 single-precision decimal codec to accurately parse and format floating-point values from/to decimal strings.
    • Upgraded JSON parsing and serialization to use the new codec for improved numeric fidelity, including better handling of float representation boundaries.
  • Tests
    • Added a comprehensive unit test suite covering decimal parse/format correctness, special values (inf, -inf, nan), overflow/underflow clamping, and format↔parse round-trip behavior.

zackees and others added 4 commits June 14, 2026 12:34
Adds `fl::ieee754_parse_decimal` (and stubs the serializer side) plus a
84-entry pow10 lookup table generated by `ci/tools/gen_pow10_table.py`.
The parser:

  * Reads decimal digits into a u64 mantissa with a decimal-exponent
    accumulator (handles fractional + scientific notation).
  * Normalizes the mantissa so its top bit is set.
  * Multiplies against a precomputed (mantissa, binary_exp) pair for
    10**k using a portable 4-way 32x32->64 widening multiply
    (`mul_hi_u64`) — no `__aeabi_d*` / `__aeabi_f*` helpers ever reached.
  * Packs into IEEE 754 single-precision bits with round-half-to-even.

Caller bit-casts the returned u32 to `float` via `fl::bit_cast<float>`
(which is `memcpy` — no FP arithmetic). Out-of-range exponents clamp to
±0 / ±inf bit patterns.

Embedded-grade precision target: ~6 significant decimal digits with at
most ±1 ULP drift from `strtof`. Sufficient for the JSON-RPC use case
that motivates the no-soft-FP mandate (FastLED #3022 / #3029).

`tests/fl/stl/ieee754_string.cpp` exercises well-known constants,
±1 ULP tolerance against the host strtof, scientific notation,
over/underflow clamping, and the `consumed` bookkeeping path. Passes
under both quick mode and debug mode (ASAN/LSAN/UBSAN).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds fl::ieee754_format_decimal. Reuses the same pow10 lookup table
already in the TU for the parser, plus a small kPow10IntExact[] table
(10^0..10^9 as exact u32 values) for the integer/fractional split.

  * Unpacks sign / biased exponent / mantissa from the IEEE 754 bit
    pattern via shifts and masks.
  * Lifts the 24-bit mantissa to u64 with the top bit set, multiplies by
    the normalized 10^precision via mul_hi_u64 (shared with the parser),
    and rounds-half-to-even at the bit-shift step.
  * Splits the resulting integer by 10^precision and formats via the
    existing fl::utoa64 helper — no FP arithmetic anywhere.
  * Inf / NaN / zero / underflow / overflow all return the appropriate
    literal (inf / -inf / nan / 0.000000 / clamp).

tests/fl/stl/ieee754_string.cpp extends to cover the serializer: known
constants (0, 1, 0.5, 10, 100), special values, parser round-trip on
exact powers of two and within 1 ULP on pi / e, and precision clamping.

Verified by building the test DLL directly and invoking the runner:
10/10 doctest cases pass. The bash test wrapper hits an unrelated
meson_native.txt lifecycle bug on this build dir, tracked separately.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…phase 2)

Replaces the four direct callers of libgcc soft-FP-anchored helpers in
src/fl/stl/json.cpp.hpp with the integer-only fl::ieee754_string codec:

  * JsonTokenizer::scan_array_lookahead — fl::parseFloat + fl::abs check
    -> fl::ieee754_parse_decimal + biased-exp comparison.
  * JsonBuilder::parse_float_array (template) — same swap; the static_cast
    on the outbound value type is left to the caller, matching the
    "user opts into float math, library does not" mandate.
  * JsonBuilder::on_token NUMBER arm — fl::parseFloat -> bit-twiddling
    parse + fl::bit_cast<float> at the variant boundary (memcpy, free).
  * SerializerVisitor::accept(const float&) and accept(const fl::vector
    <float>&) — fl::string::append(f, prec) -> fl::ieee754_format_decimal
    (bit_cast<u32>(f), prec). Output precision contract preserved
    (3 digits scalar / 6 digits vector).
  * classify_array float branch — fl::abs(f) > 16777216.0f -> integer
    biased-exp comparison via the shared float_bits_magnitude_exceeds_2_24
    helper.
  * Removed the unused-since-#3027 canBeRepresentedAsFloat(double) dead
    helper (it pulled __aeabi_d* via fl::abs(double) for callers that no
    longer exist).

Verified:
  * tests/fl/stl/ieee754_string.cpp — 10/10 pass.
  * tests/fl/stl/json.cpp           — 27/27 pass (ScreenMap round-trip
    confirms the new fl::vector<float> serializer reproduces 0.000-style
    output the previous fl::string::append(f, 3) emitted).

Next phase will verify the LPC845 ELF link is free of __aeabi_d* /
__aeabi_f* symbols even with FL_JSON_HAS_FLOAT=1 (task #5).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Three follow-up linter fixes spotted by `bash lint --cpp`:

  * `src/fl/stl/ieee754_string.cpp.hpp`: rename local `m_full` -> `mantissa_full`
    so MemberStyleChecker (which treats `m_*` as a member-variable prefix)
    stays quiet. The variable is a function-local in `ieee754_format_decimal`;
    the rename is purely cosmetic.
  * `src/fl/stl/json.cpp.hpp`: wrap the newly-added `#include "fl/stl/bit_cast.h"`
    in an `// IWYU pragma: begin_keep` / `end_keep` block so
    IwyuPragmaBlockChecker keeps it pinned (the include is reachable transitively
    but we want explicit intent for the `fl::bit_cast<float|u32>` calls).
  * `src/platforms/shared/mock/arm/teensy4/drivers/_build.cpp.hpp`: alphabetize
    the LPUART / ObjectFLED / FlexIO _build.cpp.hpp includes (UnityBuildChecker).
    Pre-existing master-side ordering bug from PR #3032 — fixing here per the
    project's "all encountered lint errors get addressed" policy.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5efbbfb7-c55b-4342-bc52-0efce77dee99

📥 Commits

Reviewing files that changed from the base of the PR and between 02aa94e and b957230.

📒 Files selected for processing (5)
  • ci/tools/gen_pow10_table.py
  • src/fl/stl/ieee754_string.cpp.hpp
  • src/fl/stl/ieee754_string.h
  • src/fl/stl/json.cpp.hpp
  • tests/fl/stl/ieee754_string.cpp

📝 Walkthrough

Walkthrough

Adds a new integer-only IEEE 754 single-precision decimal codec (ieee754_parse_decimal, ieee754_format_decimal) backed by a precomputed 10^k lookup table generated by a Python script. The JSON codec is updated to replace all float-arithmetic parse and format calls with the new bit-pattern routines. A Teensy4 driver include order is also corrected.

Changes

IEEE 754 Integer-Only Codec and JSON Integration

Layer / File(s) Summary
Pow10 table generator
ci/tools/gen_pow10_table.py
Python script that computes normalized (mantissa, binary_exp) pairs for 10^k across [-64, 38] using high-precision Decimal arithmetic and emits them as C++ constexpr arrays.
Public header and API contract
src/fl/stl/ieee754_string.h
Declares ieee754_parse_decimal and ieee754_format_decimal in namespace fl with documented integer-only guarantee, sentinel on malformed input, overflow/underflow clamping, and precision clamping to [0, 9].
Lookup tables and mul_hi_u64
src/fl/stl/ieee754_string.cpp.hpp (lines 1–237)
Embeds kPow10Mant (u64 hex) and kPow10BExp (i16) arrays for exponents −64 to 38, and implements mul_hi_u64 via 32×32 widening multiplies plus IEEE-754 bitmask constants.
ieee754_parse_decimal implementation
src/fl/stl/ieee754_string.cpp.hpp (lines 261–438)
Sign/whitespace, decimal digit accumulation capped at 19 significant digits, optional e/E, mantissa normalization, table-driven scaling via mul_hi_u64, exponent derivation, ±inf clamping, subnormal collapse, and round-half-to-even for the 23-bit mantissa.
ieee754_format_decimal implementation and build wiring
src/fl/stl/ieee754_string.cpp.hpp (lines 439–553), src/fl/stl/_build.cpp.hpp
Precision clamping, special-value early returns, fixed-point scaling, round-half-to-even, digit formatting, and unity build include.
JSON codec integration
src/fl/stl/json.cpp.hpp
Adds float_bits_magnitude_exceeds_2_24 helper; replaces abs(float) lookahead and classifier, parseFloat in array/scalar parse, and direct float serialization with ieee754_parse_decimal + bit_cast / ieee754_format_decimal.
Unit and integration tests
tests/fl/stl/ieee754_string.cpp
Exact bit-pattern parsing, ±1 ULP accuracy, scientific notation, overflow/underflow clamping, consumed bookkeeping, format for well-known values and special cases, round-trip fidelity, and precision clamping.

Teensy4 Driver Include Order Fix

Layer / File(s) Summary
Include reorder
src/platforms/shared/mock/arm/teensy4/drivers/_build.cpp.hpp
Swaps lpuart and objectfled driver include order; no logic change.

Sequence Diagram(s)

sequenceDiagram
  participant JSONCodec as fl::json codec
  participant ieee754_parse as ieee754_parse_decimal
  participant ieee754_format as ieee754_format_decimal
  participant kPow10Tables as kPow10Mant / kPow10BExp
  participant mul_hi_u64

  rect rgba(70, 130, 180, 0.5)
    note over JSONCodec,mul_hi_u64: Parse path (was: parseFloat / strtod)
    JSONCodec->>ieee754_parse: s, len, &consumed
    ieee754_parse->>kPow10Tables: lookup mant/bexp for decimal exponent k
    kPow10Tables-->>ieee754_parse: kPow10Mant[k], kPow10BExp[k]
    ieee754_parse->>mul_hi_u64: top-64 of mantissa × kPow10Mant[k]
    mul_hi_u64-->>ieee754_parse: scaled u64
    ieee754_parse-->>JSONCodec: u32 IEEE-754 bits
    JSONCodec->>JSONCodec: bit_cast<float>(bits)
  end

  rect rgba(34, 139, 34, 0.5)
    note over JSONCodec,mul_hi_u64: Format path (was: fl::string::append(float))
    JSONCodec->>JSONCodec: bit_cast<u32>(float_value)
    JSONCodec->>ieee754_format: bits, precision (3 or 6)
    ieee754_format->>kPow10Tables: lookup mant/bexp for precision exponent
    kPow10Tables-->>ieee754_format: scale factors
    ieee754_format->>mul_hi_u64: fixed-point scale
    mul_hi_u64-->>ieee754_format: scaled integer
    ieee754_format-->>JSONCodec: fl::string decimal text
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Poem

🐇 Hoppity-hop through bits of ten,
No soft-float helpers needed, then!
A table of powers, neat and tight,
Mul-hi keeps the mantissa right.
JSON sings in integers now—
The rabbit grins and takes a bow! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.84% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: introducing an integer-only IEEE 754 codec to replace soft-FP cascade in JSON handling, directly matching the PR's primary objective.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/3022-json-bit-twiddle

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (1)
tests/fl/stl/ieee754_string.cpp (1)

94-109: ⚡ Quick win

Add regressions for the parser floor/validation edges.

The suite never exercises the two cases this parser is most likely to miss: a bare decimal point with no digits, and a 19-digit mantissa below the current pow10 floor (for example 1234567890123456789e-46, which should not underflow to zero). Locking those down here will keep the public contract from drifting again.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/fl/stl/ieee754_string.cpp` around lines 94 - 109, Add two additional
regression test cases to the FL_TEST_CASE("ieee754_parse_decimal — consumed
bookkeeping") test function to cover edge cases that are currently not
exercised: first, add a test that calls ieee754_parse_decimal with a bare
decimal point (such as "." or ".xyz") to validate it handles this validation
edge correctly, and second, add a test that calls ieee754_parse_decimal with a
19-digit mantissa below the pow10 floor (such as "1234567890123456789e-46") to
ensure it does not incorrectly underflow to zero. For each case, verify the
returned bits value and consumed count (n) match the expected behavior by adding
appropriate FL_CHECK assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ci/tools/gen_pow10_table.py`:
- Around line 67-68: The codebase requires 7-bit ASCII characters in all new
Python/C++ sources, but several files contain Unicode punctuation that violates
this rule. Fix the following locations: In ci/tools/gen_pow10_table.py lines
67-68, replace the Unicode dash (–) in the print statement with an ASCII hyphen
or double hyphen. In src/fl/stl/ieee754_string.h lines 22-30, replace any
Unicode dashes, arrows, and other non-ASCII punctuation in the public API
docstring with their ASCII equivalents (use `--` instead of em-dash, use `+/-`
or plain text instead of Unicode operators, etc.). In
src/fl/stl/ieee754_string.cpp.hpp lines 201-203, replace Unicode punctuation in
the implementation comments with ASCII equivalents. In src/fl/stl/json.cpp.hpp
lines 41-49, replace Unicode arrows and dashes in the helper function comments
with ASCII alternatives. In tests/fl/stl/ieee754_string.cpp lines 1-6, replace
Unicode punctuation in the test banner and comments with 7-bit ASCII characters.
- Around line 69-71: The print statement in the gen_pow10_table.py file contains
an unnecessary f-string prefix on a string literal that has no placeholder
expressions. Remove the f prefix from the string in the print function call
(starting around line 69) since the multi-line string literal contains no curly
brace placeholders and does not require f-string formatting. This will resolve
the Ruff F541 linting error.

In `@src/fl/stl/ieee754_string.cpp.hpp`:
- Around line 323-328: In src/fl/stl/ieee754_string.cpp.hpp#L323-L328, the early
underflow check that returns sign_bit when decimal_exp < kPow10KMin is incorrect
because decimal_exp applies to the full retained 19-digit mantissa rather than a
normalized scientific mantissa in [1, 10). Either renormalize the mantissa to
[1, 10) before performing the lookup or extend the pow10 table to cover the
extra decades contributed by the 19-digit mantissa; do not return immediately
based solely on the kPow10KMin comparison. In
ci/tools/gen_pow10_table.py#L26-L30, lower the K_MIN constant value and
regenerate the pow10 table so that the lookup range covers the extended range
needed for the full 19-digit retained mantissa, allowing the parser to correctly
represent small-but-normal values instead of underflowing them to zero.
- Around line 251-283: The current validation in the while loop that processes
digits and the decimal point is insufficient. A string like "." or "-." can pass
because while the `i == mantissa_start` check correctly identifies when no
characters were consumed, it fails to catch the case where the decimal point was
consumed but no actual digits follow. Add an additional check after the while
loop to ensure that at least one significant digit was actually parsed by
verifying `significant_digits > 0` in addition to the existing `i ==
mantissa_start` condition, so that strings containing only a decimal point
without any digits are properly rejected.

In `@src/fl/stl/json.cpp.hpp`:
- Around line 41-53: The function `float_bits_magnitude_exceeds_2_24` only
checks if the biased exponent exceeds 151, but misses values in the range
(2**24, 2**25) that have exponent equal to 151 with non-zero mantissa bits.
These values like 16777217.0 actually exceed the 2**24 integer-precision
boundary but incorrectly pass through. Fix the return statement to check not
only if biased_exp is greater than 151, but also if biased_exp equals 151 while
the mantissa bits (the lower 23 bits extracted from the bits parameter) are
non-zero, which indicates the value truly exceeds the precision boundary.

---

Nitpick comments:
In `@tests/fl/stl/ieee754_string.cpp`:
- Around line 94-109: Add two additional regression test cases to the
FL_TEST_CASE("ieee754_parse_decimal — consumed bookkeeping") test function to
cover edge cases that are currently not exercised: first, add a test that calls
ieee754_parse_decimal with a bare decimal point (such as "." or ".xyz") to
validate it handles this validation edge correctly, and second, add a test that
calls ieee754_parse_decimal with a 19-digit mantissa below the pow10 floor (such
as "1234567890123456789e-46") to ensure it does not incorrectly underflow to
zero. For each case, verify the returned bits value and consumed count (n) match
the expected behavior by adding appropriate FL_CHECK assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5695cd56-6980-4f24-926f-c5db1299a7a0

📥 Commits

Reviewing files that changed from the base of the PR and between 952cbea and 02aa94e.

📒 Files selected for processing (7)
  • ci/tools/gen_pow10_table.py
  • src/fl/stl/_build.cpp.hpp
  • src/fl/stl/ieee754_string.cpp.hpp
  • src/fl/stl/ieee754_string.h
  • src/fl/stl/json.cpp.hpp
  • src/platforms/shared/mock/arm/teensy4/drivers/_build.cpp.hpp
  • tests/fl/stl/ieee754_string.cpp

Comment thread ci/tools/gen_pow10_table.py Resolved
Comment thread ci/tools/gen_pow10_table.py Resolved
Comment thread src/fl/stl/ieee754_string.cpp.hpp Resolved
Comment thread src/fl/stl/ieee754_string.cpp.hpp Resolved
Comment thread src/fl/stl/json.cpp.hpp Resolved
- Reject decimals with no digits (".", "-.") via explicit seen_digit guard;
  the existing i == mantissa_start check skipped past a consumed decimal point.
- Extend pow10 table down to K_MIN=-64 so the parser's raw 19-digit mantissa
  reaches IEEE 754 single-precision underflow without prematurely flushing to
  zero (e.g. 1234567890123456789e-46 ~= 1.23e-28 now decodes correctly).
- Fix float_bits_magnitude_exceeds_2_24 to include the (2**24, 2**25) decade
  (biased_exp == 151 with non-zero mantissa) and inf/NaN; the prior strict
  > 151 check leaked literals like 16777217.0 onto the optimized vector<float>
  path past the exact-integer boundary.
- Strip non-ASCII punctuation (em-dash, plus-minus, arrows) from generator
  output and from the new ieee754_string / json comments + test banners to
  satisfy the 7-bit-ASCII repo guideline.
- Drop F541 f-string prefix in gen_pow10_table.py print().

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@zackees
zackees merged commit 76fe5e1 into master Jun 14, 2026
26 of 27 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 14, 2026
zackees added a commit that referenced this pull request Jun 14, 2026
…h.ino low-memory mode (closes #3030) (#3041)

Phase 2 of FastLED #3022 (integer-only IEEE 754 codec, PR #3038) freed up
enough flash on LPC845-BRK that the soft-FP cascade no longer blocks the
main AutoResearch sketch. Per #3030 we consolidate so we do not maintain
two bring-up harnesses that drift apart.

Layout:

  * `examples/AutoResearch/AutoResearchLowMemory.h` -- new header that holds
    the JSON-RPC echo + SCT-RX bring-up surface inherited from the retired
    LPC sketch (echo, pinToggleRx, ws2812SctTest). Same RPC contract; CSV
    column order preserved so the Python orchestrator (test_lpc_pin_toggle_rx
    and test_lpc_ws2812_loopback) keeps working as-is.
  * `examples/AutoResearch/AutoResearch.ino` -- gated at the top with
    `FASTLED_AUTORESEARCH_LOW_MEMORY`. Auto-defines to 1 when
    `FL_PLATFORM_HAS_LARGE_MEMORY == 0` (covers LPC8xx + classic Low-tier
    parts per FastLED #3000). In low-memory mode the main body is
    short-circuited and we just call `autoResearchLowMemorySetup()` /
    `autoResearchLowMemoryLoop()`.
  * `examples/AutoResearchLpc/` -- deleted. The board filter for
    `lpc845brk` / `lpcxpresso845max` / `lpcxpresso804` moves onto the
    consolidated `AutoResearch.ino`'s `@filter` directive.
  * `ci/autoresearch/phases.py` -- removes the bring-up-env sketch
    dispatch; always points at `examples/AutoResearch/`.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 14, 2026
…sign-off checklist (closes #2880) (#3042)

Stage 3.6 of #2845 is no longer hardware-gated -- PR #3041 retired
AutoResearchLpc.ino into the main AutoResearch.ino low-memory mode
(auto-engaged on LPC8xx via FL_PLATFORM_HAS_LARGE_MEMORY == 0). The
JSON-RPC contract (echo / pinToggleRx / ws2812SctTest) is identical
to what the standalone sketch shipped.

Stage 3.5 (linker memory-layout verification on real silicon) still
needs hardware sign-off, but every code-side prerequisite has shipped
and the no-soft-FP invariant from #3038 puts the LPC845 flash budget
back inside 64 KB. Adds a five-bullet sign-off checklist a community
maintainer can walk to close out #2880 with field evidence.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 14, 2026
…intainer sign-off) (#3049)

Drops the "needs maintainer with scope" framing from the LPC bring-up
checklist. The AutoResearch harness + TX<->RX jumper loopback is the
verification: the Python orchestrator asserts pass/fail from JSON-RPC
results that come back over the same serial link the device echoes on.

Three harness workloads do the work:

  * `--bring-up`        -- echo + FL_WARN literal round-trip (Serial + RPC +
                           log pipeline intact)
  * `--pin-toggle-rx`   -- SCT input-capture latches a bit-banged square
                           wave; mean +/- 2% and sigma thresholds across
                           1/10/100 kHz (FastLED #3035 Phase 1)
  * `--ws2812-loopback` -- FastLED.show() through the bit-bang driver;
                           SCT-RX latches the wire; decoder asserts
                           mismatched == 0 (FastLED #3035 Phase 2b)

Plus the link-symbol check (no `__aeabi_d*` / `__aeabi_f*` after FastLED
#3038) folded into the harness reporting path so the no-soft-FP invariant
is asserted on every run.

Status column on the LPC845 / LPC804 / LPC11Uxx / LPC11xx-legacy /
LPC15xx rows updated to say "AutoResearch loopback verification pending"
instead of "hardware sign-off pending" -- accurate to the new framing.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 19, 2026
…r scaffold (#3294)

Phase 1 toward closing #3022 / #3002. Two changes:

1. NEW `src/fl/math/soft_float.h` -- integer-only IEEE-754 float<->double
   bit-codec. Moved out of `fl/stl/json/types_impl.h` (which now reads as
   a thin shim around the new home) so non-JSON callers (audio timing,
   animation curves, anyone else who needs FP on a no-FPU target without
   the libgcc soft-FP tax) can use it directly. Public API:

     fl::soft_float_to_double(float) -> double         (NEW widening path)
     fl::soft_double_to_float(double) -> float         (existing, renamed)
     fl::soft_double_bits_from_float_bits(u32) -> u64  (NEW widening bits)
     fl::soft_float_bits_from_double_bits(u64) -> u32  (existing, renamed)

   The widening path is the new piece. The narrowing path moved unchanged
   from `json_double_to_float` (#3038). Both paths use only integer
   shift/mask/add, emit zero soft-FP symbols on no-FPU targets, and
   handle subnormals, NaN canonicalization, and +/-inf bit-exactly.

   Symmetric round-trip: `soft_double_to_float(soft_float_to_double(f))`
   is bit-exact identity for any finite float (and inf/qNaN/zero).

2. NEW `src/fl/math/number.h` -- 64-bit packed tagged numeric value
   (scaffold for the #3022 design). Lays down the type, the 8-tag enum
   (SIGNED_INT, UNSIGNED_INT, FLOAT_60, RESERVED_3..7), and basic
   factory/accessor methods for the integer tags. The FLOAT_60 tag is
   reserved (no parser/serializer yet -- those follow in a phase-2 PR
   alongside JSON adoption). Storage footprint is exactly 64 bits so it
   slots into the JSON value variant without padding overhead.

3. JSON wiring: `float_conversion_visitor` (`as_float` / `as_double`
   visitor used on extraction) routes the residual float<->double
   `static_cast` paths through the new soft_float codec. Was the last
   path that could anchor `__aeabi_f2d` / `__aeabi_d2f` on no-FPU
   targets even if `as_double()` survived DCE. Now structurally
   impossible -- the soft_float helpers compile to integer-only ops.

Verification:
- bash test --cpp -- 327 / 327 pass (incl. 7 new soft_float tests and
  5 new fl::number tests).
- bash lint --cpp -- clean (FL_STATIC_ASSERT used per banned-macro
  checker; only warn-only PlatformIO-internal-usage findings remain).
- bash compile lpc845brk -- could not verify locally due to zccache
  daemon flake (fbuild infrastructure issue, see soldr#710); CI will
  catch any LPC regression. No source change touches LPC-specific paths.

Refs #3022, #3002, #3208 (LPC burn-down meta).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the feat/3022-json-bit-twiddle branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant