Skip to content

PlatformIO library, RTOS lock options, printf stats - #1

Merged
endurodave merged 1 commit into
masterfrom
feature/platformio
Nov 14, 2026
Merged

endurodave merged 1 commit into
masterfrom
feature/platformio

Conversation

@endurodave

Copy link
Copy Markdown
Owner

Summary

  • RTOS lock options: the lock is selected at compile time.
    • XALLOC_LOCK_FREERTOS uses taskENTER_CRITICAL, or the _FROM_ISR form inside an interrupt on Cortex-M. On ESP32 it uses a portENTER_CRITICAL_SAFE spinlock. It takes no lock until the scheduler starts.
    • XALLOC_LOCK_THREADX uses tx_interrupt_control.
    • XALLOC_LOCK_ZEPHYR uses irq_lock.
    • XALLOC_LOCK_CMSIS_RTOS2 uses Cortex-M PRIMASK.
    • XALLOC_LOCK_USER calls your own xalloc_lock()/xalloc_unlock(), and XALLOC_LOCK_NONE takes no lock.
    • Default: std::mutex where the C++ library provides it; no lock on bare-metal toolchains without thread support.
    • DelegateMQ's DMQ_THREAD_* options select the matching lock.
    • Each lock call returns the state it saved, so nested calls and calls from interrupts restore correctly.
  • Stats: xalloc_stats() now uses printf instead of <iostream>. The ESP32 example went from 481 KB to 273 KB of flash.
  • PlatformIO: adds library.json and the example examples/platformio/xallocator-demo. Boards: ESP32, ESP32-C3, Nucleo-F401RE, STM32F4 Discovery (two FreeRTOS tasks), Pico and native.
  • CI:
    • platformio.yml builds 6 boards and runs the native build.
    • rtos_locks.yml compiles the ThreadX, CMSIS-RTOS2, USER and NONE options against the vendor headers, in both heap blocks and static pools modes.
  • README: adds a PlatformIO section and a table of lock options under Porting Issues. Also fixes the license badge.

Testing

  • The STM32F4 Discovery passed the two-task FreeRTOS stress test with XALLOC_LOCK_FREERTOS.
  • The example builds for ESP32, ESP32-C3, Nucleo-F401RE and Pico.
  • The ThreadX, CMSIS-RTOS2, USER and NONE options compile for Cortex-M4 with -Werror.
  • The Windows MSVC unit tests pass.
  • A package packed from this branch installs and builds in a fresh project.
  • Not tested:
    • Zephyr was not compiled (needs the Zephyr SDK).
    • The interrupt-handler paths were never run from a real interrupt.

🤖 Generated with Claude Code

- Lock selected at compile time: XALLOC_LOCK_FREERTOS, _THREADX, _ZEPHYR,
  _CMSIS_RTOS2 (critical sections, ISR-safe), _USER, _NONE. Default is
  std::mutex where the C++ library provides it, otherwise no lock.
  DelegateMQ DMQ_THREAD_* options select the matching lock.
- xalloc_stats() uses printf instead of iostream (smaller on MCUs).
- library.json and examples/platformio/xallocator-demo (ESP32, ESP32-C3,
  Nucleo-F401RE, STM32F4 Discovery with FreeRTOS, Pico, native).
- CI: PlatformIO board builds and RTOS lock compile checks.
- README: PlatformIO section, lock options, license badge fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@endurodave
endurodave merged commit 1d446bb into master Nov 14, 2026
13 checks passed
@endurodave
endurodave deleted the feature/platformio branch November 15, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant