Repository navigation
feat(memory-tier): add tiny tier for <=1KB SRAM ATtiny parts - #2267
Conversation
Introduces a fourth memory tier ('tiny') below 'low' for MCUs with <=1KB
SRAM that cannot fit standard FastLED example sketches. Fixes ATtiny1604
CI build failures where ArrayOfLedArrays, MultipleStripsInOneArray, and
PerfDisc overflowed .bss after library growth (FL_NOEXCEPT rollout, PMR,
singleton refactors between Feb-Mar 2026).
- src/platforms/avr/is_avr.h: new FL_IS_AVR_ATTINY_TINY_MEMORY macro
covering classic ATtiny13/25/45/85/etc., ATtiny88, ATtiny4313, and
modern ATtinyxy2/xy4 parts up to ATtiny1604 (1KB).
- src/fl/system/sketch_macros.h: new SKETCH_HAS_TINY_MEMORY macro with
invariant TINY=1 implies LARGE=0.
- ci/boards.py: memory_class returns 'tiny' for attiny85/88/4313/1604;
attiny1616 (2KB) stays 'low'.
- ci/compiler/sketch_filter.py: MEMORY_TIERS ordered tiny<low<large<huge;
unknown-board default preserved at 'large' so existing filters behave
identically.
- Three failing examples tagged '// @filter: (memory is low)' to skip
tiny boards while still building on Uno (2KB) and larger.
- ci/tests/test_sketch_filter.py: 5 new tests for tiny tier semantics.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a new "tiny" memory classification for specific ATtiny boards and propagates it through board classification, sketch-filter semantics, platform detection macros, compile-time sketch macros, tests, and example build filters to support tiny < low < large < huge. Changes
Sequence Diagram(s)sequenceDiagram
participant Builder as Build System
participant Platform as Platform Detection
participant Board as Board Classifier
participant Filter as Sketch Filter
participant Compiler as Compiler Macros
Builder->>Platform: Detect AVR target chip
Platform->>Platform: Evaluate FL_IS_AVR_ATTINY_TINY_MEMORY
Platform-->>Builder: Return platform capabilities
Builder->>Board: Query board.memory_class
Board->>Board: Determine "tiny"/"low"/"large"/"huge"
Board-->>Builder: Return memory_class
Builder->>Filter: Evaluate sketch filter expressions
Filter->>Filter: Match using updated MEMORY_TIERS rules
Filter-->>Builder: Include or skip examples
Builder->>Compiler: Set SKETCH_HAS_TINY_MEMORY if applicable
Compiler->>Compiler: Validate exclusivity with LARGE/HUGE macros
Compiler-->>Builder: Final compile configuration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
📊 Header Compilation PerformanceTotal Time: 1014.85ms Top 5 Slowest Headers
Warnings
Full Report |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
ci/compiler/sketch_filter.py (1)
319-319: Update docstring to mention the newtinytier.The
_memory_tier_matchesdocstring still saysboard_memory: Board's memory class ("low", "large", or "huge"), omittingtiny.📝 Proposed fix
- board_memory: Board's memory class ("low", "large", or "huge") + board_memory: Board's memory class ("tiny", "low", "large", or "huge")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ci/compiler/sketch_filter.py` at line 319, Update the _memory_tier_matches docstring to include the new "tiny" tier in the description of board_memory (e.g., "tiny", "low", "large", or "huge") and adjust any example or parameter text to reflect the added tier; locate the docstring for the _memory_tier_matches function and change the board_memory line accordingly so the docs match the implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ci/boards.py`:
- Around line 239-246: The tiny-vs-low misclassification is caused by
case-sensitive membership check: tiny_memory_boards contains lowercase names but
Board.memory_class uses self.board_name with mixed case (e.g., "ATtiny1604");
normalize before comparison by comparing self.board_name.lower() against
tiny_memory_boards (or store normalized names in tiny_memory_boards and use a
lowercased lookup), update the check in memory_class that references
tiny_memory_boards to use the normalized form, and apply the same
lowercase-normalization to the subsequent low_memory_boards and
huge_memory_boards checks so mixed-case board_name values (like
ATtiny1604/ATtiny1616) are classified correctly; also add a regression test that
instantiates the real Board for "ATtiny1604" and asserts memory_class == "tiny".
In `@ci/compiler/sketch_filter.py`:
- Around line 325-326: The current assignment of board_tier uses
MEMORY_TIERS.get(board_memory.lower(), MEMORY_TIERS["large"]) which silently
upgrades unknown board_memory to the "large" tier; change this to fail fast or
at least warn: look up board_memory.lower() in MEMORY_TIERS explicitly, and if
missing call process_logger.warning(...) (or raise a ValueError) and either
fallback to an "unknown" sentinel that triggers exact-match-only behavior or
raise so callers must handle it; update the code paths that read board_tier
accordingly (reference symbols: MEMORY_TIERS, board_memory, board_tier) so
unknown/misconfigured values do not silently map to "large".
In `@src/platforms/avr/is_avr.h`:
- Around line 139-140: The macro list using __AVR_ATtinyxy4__ /
ARDUINO_attinyxy4 incorrectly claims to cover only ≤1KB SRAM parts for
SKETCH_HAS_TINY_MEMORY=1; either replace the wildcard with an explicit list of
the ≤1KB parts (e.g., ATtiny414, ATtiny814, ATtiny424) in the is_avr.h condition
that sets SKETCH_HAS_TINY_MEMORY, or update the surrounding comment to reflect
that the wildcard also matches 2-series devices (ATtiny1624, ATtiny3224) and
ensure those larger devices are excluded by adding their own macro check or a
separate macro path so SKETCH_HAS_TINY_MEMORY is only set for true ≤1KB devices.
---
Nitpick comments:
In `@ci/compiler/sketch_filter.py`:
- Line 319: Update the _memory_tier_matches docstring to include the new "tiny"
tier in the description of board_memory (e.g., "tiny", "low", "large", or
"huge") and adjust any example or parameter text to reflect the added tier;
locate the docstring for the _memory_tier_matches function and change the
board_memory line accordingly so the docs match the implementation.
🪄 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: 8b34681a-8e30-41b7-900f-77678499f329
📒 Files selected for processing (8)
ci/boards.pyci/compiler/sketch_filter.pyci/tests/test_sketch_filter.pyexamples/Multiple/ArrayOfLedArrays/ArrayOfLedArrays.inoexamples/Multiple/MultipleStripsInOneArray/MultipleStripsInOneArray.inoexamples/PerfDisc/PerfDisc.inosrc/fl/system/sketch_macros.hsrc/platforms/avr/is_avr.h
| # Unknown board memory defaults to "large" tier (capable, non-tiny, non-low). | ||
| board_tier = MEMORY_TIERS.get(board_memory.lower(), MEMORY_TIERS["large"]) |
There was a problem hiding this comment.
Behavior change: unknown board_memory now silently defaults to large.
Previously unknown memory classes used a distinct default; now they are coerced to large, which means an unknown/misconfigured board will pass (memory is low) and (memory is large) filters without any diagnostic. Given the new tiny tier — where misclassification risks OOM on hardware — consider logging a warning or falling back to exact-match-only instead of silently upgrading. As per coding guidelines, "Never use silent fallbacks for missing critical resources - always fail fast with descriptive errors."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@ci/compiler/sketch_filter.py` around lines 325 - 326, The current assignment
of board_tier uses MEMORY_TIERS.get(board_memory.lower(), MEMORY_TIERS["large"])
which silently upgrades unknown board_memory to the "large" tier; change this to
fail fast or at least warn: look up board_memory.lower() in MEMORY_TIERS
explicitly, and if missing call process_logger.warning(...) (or raise a
ValueError) and either fallback to an "unknown" sentinel that triggers
exact-match-only behavior or raise so callers must handle it; update the code
paths that read board_tier accordingly (reference symbols: MEMORY_TIERS,
board_memory, board_tier) so unknown/misconfigured values do not silently map to
"large".
Board 'ATtiny1604' has a capital A in PlatformIO's canonical name, so the exact lowercase match against the tiny_memory_boards set missed it and fell through to the atmelmegaavr platform check returning 'low'. Lower-case the board_name before the membership test.
📊 Header Compilation PerformanceTotal Time: 1206.34ms Top 5 Slowest Headers
Warnings
Full Report |
The memory-tier filter '(memory is low)' only takes effect with the new tiny-tier ci/boards.py from this PR, but CI runs with the trusted master branch's ci/ code + this PR's src/examples. Switching to an explicit board exclusion so the filter works on master's unchanged memory_class logic (which classifies ATtiny1604 as 'low' and thus matches 'memory is low'). The tiny-tier infrastructure in this PR is still useful for future PRs once merged to master.
📊 Header Compilation PerformanceTotal Time: 1222.48ms Top 5 Slowest Headers
Warnings
Full Report |
XYMatrix's static arrays + FastLED internals push .bss past 1KB on ATtiny1604 (same root cause as ArrayOfLedArrays/MultipleStripsInOneArray /PerfDisc). Verified locally: 'compile ATtiny1604 all' now succeeds on all examples after this filter.
📊 Header Compilation PerformanceTotal Time: 1220.31ms Top 5 Slowest Headers
Warnings
Full Report |
… parts CodeRabbit review flagged that __AVR_ATtinyxy4__ and __AVR_ATtinyxy6__ wildcards span parts with up to 3KB SRAM (ATtiny1624=2KB, ATtiny3224= 3KB), which would incorrectly trip SKETCH_HAS_TINY_MEMORY=1 on parts that fit standard sketches. Drop the xy4/xy6 wildcards and rely on explicit per-part defines plus the ATtinyxy2 wildcard (which only spans <=256B parts). ATtiny1604 (1KB) is the largest tiny-memory part — larger 1-series/2-series xy4 variants (ATtiny1614/1624 @ 2KB, ATtiny3214/3224 @ 2-3KB) are now correctly classified as 'low'. Updated sketch_macros.h comments to match.
📊 Header Compilation PerformanceTotal Time: 1151.80ms Top 5 Slowest Headers
Warnings
Full Report |
Summary
tiny(belowlow) for MCUs with ≤1KB SRAM that cannot fit standard FastLED example sketchesArrayOfLedArrays,MultipleStripsInOneArray, andPerfDiscoverflowed.bssafter library growth between Feb-Mar 2026FL_IS_AVR_ATTINY_TINY_MEMORYmacro inis_avr.handSKETCH_HAS_TINY_MEMORYinsketch_macros.hwith invariantTINY=1 implies LARGE=0// @filter: (memory is low)— they continue to build on Uno (2KB) and largerWhy
The toolchain is unchanged —
platform-atmelmegaavr 1.9.0,framework-arduino-megaavr-megatinycore 2.6.7,toolchain-atmelavr 7.3.0. The regression was purely library footprint growth:ArrayOfLedArrays&MultipleStripsInOneArraybuilt finePerfDisc(added 2026-03-11) was born broken on ATtiny1604 — its comment says "fits AVR 2KB RAM" but ATtiny1604 has 1KB.Memory tier ordering
tiny < low < large < huge—(memory is X)means>= X. Existing filters behave identically; unknown-board default kept atlarge.Test plan
uv run pytest ci/tests/test_sketch_filter.py— 67 passed (5 new tiny-tier tests)bash lint --cpp— clean (noNativePlatformDefinesCheckerviolations)bash test --cpp— 298/298 passeduv run ci/tools/validate_sketch_filters.py— 106/106 sketches valid🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Chores
Tests