You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Teensy 4: Channel API costs ~72 KB RAM1 because ChannelManager::instance() registers every driver #4708
It looks like ChannelManager::instance() calls initChannelDrivers(), which now registers all drivers unconditionally on Teensy 4 and bloats the ITCM memory used? If I switch from the legacy addLeds() approach to the channels API, it costs me ~72KB of RAM1 in my current project. Let me know if you want any help investigating this one.
The user offered to help investigate.
What the code does
ChannelManager::instance() (src/fl/channels/manager.cpp.hpp) calls platforms::initChannelDrivers() the first time it runs.
On Teensy 4.x, initChannelDrivers() (src/platforms/arm/teensy/teensy4_common/init_channel_driver_mxrt1062.cpp.hpp) always registers three engines:
FlexIO, through BusTraits<Bus::FLEX_IO, 1>
ObjectFLED DMA, through BusTraits<Bus::FLEX_IO, 0>
unified SPI hardware
Any sketch that uses the Channel API therefore links in every engine, whether or not it uses them. On Teensy 4, code goes into ITCM by default (FASTRUN/RAM1), so that dead code also takes up RAM1.
The legacy addLeds<> slim bridge goes through ChannelManager::registry(), which only registers the bus that is actually used. That is why it doesn't pay this cost.
Expected
Using the Channel API should only link (and spend RAM1 on) the engines the sketch actually uses, the same way the registry() / enableDrivers<> opt-in path already does.
Next steps
Measure RAM1/ITCM with bash bloat teensy41 for a sketch using addLeds<> and the same sketch using the Channel API.
Options:
Make the Teensy 4 registration opt-in or demand-driven, keyed on the requested bus.
Keep any engine not selected for the sketch out of .text in ITCM by placing it in flash (FLASHMEM).
Activity
fix: post-3.10.6 Teensy RAM1/RAM2 trimming and host example slowdown (#…