embedded-memory-constraints
/embedded-memory-constraints
Fit firmware into kilobytes with static allocation, measured stack sizing, and linker-map budgeting. Use when developing on microcontrollers or debugging overflows and fragmentation on-device.
- Author
- Amey-Thakur ↗
- Repository
- AI-SKILLS ↗
- Licence
- MIT
- Last repository change
- 05.09.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Fit firmware into kilobytes with static allocation, measured stack sizing, and linker-map budgeting. Use when developing on microcontrollers or debugging overflows and fragmentation on-device.
Original author description
Fit firmware into kilobytes with static allocation, measured stack sizing, and linker-map budgeting. Use when developing on microcontrollers or debugging overflows and fragmentation on-device.
How it works
- Method
- Boundaries
SKILL.md preview
--- name: embedded-memory-constraints description: Fit firmware into kilobytes with static allocation, measured stack sizing, and linker-map budgeting. Use when developing on microcontrollers or debugging overflows and fragmentation on-device. --- # Embedded memory constraints A microcontroller gives you kilobytes, no MMU, and no swap: memory bugs do not throw, they corrupt. The discipline is knowing where every byte lives at link time and proving the stack fits before the field proves it does not. ## Method 1. **Allocate statically; ban or bound the heap.** Fixed-size pools, static buffers, and compile-time arrays for everything long-lived: heap use after init is where fragmentation slowly kills month-uptime devices. Where dynamic-ish behavior is needed, fixed-block pools (same-size chunks per object type) fragment nothing and fail loudly on exhaustion (the c-memory-safety arena idea, sized for kilobytes). 2. **Read the linker map as a budget.** Per-section (.text, .data, .bss, per-module) sizes tracked in CI with diffs per PR (see bundle-size's twin): flash and RAM budgets with headroom targets (~15-20% for growth and stack). The map also catches the classics: accidental stdlib pull-ins (printf's float support doubling .text), debug strings shipping to production, duplicated const tables missing `PROGMEM`/flash placement. 3. **Size stacks by measurement, not vibes.** Fill stacks with a pattern at boot, measure high-water marks under worst-case load (deep call paths, nested interrupts: see interrupt-safe-code) per task (see rtos-task-design); static analysis (`-fstack-usage`, call-graph tools) bounds what tests miss. Enable hardware protection where available (MPU guard regions, stack canaries): a silent stack overflow into .bss is the least debuggable bug on a device (see embedded-debugging). 4. **Choose data representations for the platform.** Right-sized integer types, packed flags, indices instead of pointers (2 bytes vs 4/8, and serializable: see entity-component-system's handle logic), lookup tables in flash not RAM, strings as IDs resolved off-device where a log pipeline exists (see sensor-data-handling's batching). Alignment padding audit on structs (`-Wpadded` spot checks) recovers surprising bytes in arrays of thousands. 5. **Make exhaustion behavior explicit.** Every pool and queue has a stated full policy (drop-oldest for telemetry, reject-and-flag for commands: see backpressure's policy table, message-queues) and a counter observable in the field; out-of-memory in an embedded system must be a designed state, never a surprise, because there is no OOM-killer to blame. 6. **Keep debug and release honest.** Asserts and logging cost RAM/flash: use link-time-removable levels (see log-levels), but keep the *safety* checks (bounds, pool exhaustion, watchdog kicks) in release; a build that only asserts in the lab ships its bugs silently (see defensive-programming's release-assert stance). ## Boundaries - Linux-class embedded (Pi-grade, with MMU) relaxes these rules toward ordinary systems programming (see c-memory-safety); this skill is for the MCU world beneath it. - Rust-on-embedded moves several disciplines into the compiler (no-heap enforced by no_std, ownership: see rust-ownership) but stack sizing and linker budgeting remain manual. - Ultra-low-power sleep states interact with RAM retention (which banks survive sleep); memory layout and power design are coupled decisions (see low-power-design).
Versions
The database has no other skills named embedded-memory-constraints.
Database snapshot: 13.11.2026 · package version 0aa73d0acd09 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 90esp32-linker-map-review
Use when designing, reviewing, debugging or validating linker map review for ESP32 firmware; apply target-specific constraints, failure analysis and measurable verification before release. - 100memory-audit
Audit embedded code for stack overflow risks, heap fragmentation, static allocation patterns, and memory leaks. Use when investigating OOM crashes, optimizing memory usage, or reviewing memory-critical code on constrained devices. - 100embedded-firmware-engineer
Use when a task needs the judgment of an Embedded/Firmware Engineer — analyzing worst-case execution time for a hard real-time deadline, choosing static over dynamic memory allocation to avoid fragmentation on a long-uptime device, keeping an interrupt service routine minimal… - 100c-cpp-patterns
Use this skill when the user says 'embedded C', 'embedded C++', 'firmware', 'register access', 'volatile', 'memory-mapped IO', 'ISR', 'ring buffer', 'struct packing', 'alignment', 'MISRA', 'RAII on microcontroller', 'linker script'. Writes and reviews C/C++ firmware for… - 100resource-optimization-lowend
Resource optimization skill for constrained embedded targets. Use when reducing flash/RAM usage, analyzing stack depth, reading linker map files, or tuning size vs speed on MCUs. Activates on queries about firmware size optimization, linker map, stack usage, -Os, flash RAM budget, or bloat analysis. - 90esp32-linker-script-change-review
Use when designing, reviewing, debugging or validating linker script change review for ESP32 firmware; apply target-specific constraints, failure analysis and measurable verification before release.