Skip to content

Parse driver config files only while their drivers are configured - #66

Merged
JohnAmadis merged 1 commit into
mainfrom
feature/lazy-config-parsing
Oct 2, 2026
Merged

JohnAmadis merged 1 commit into
mainfrom
feature/lazy-config-parsing

Conversation

@JohnAmadis

Copy link
Copy Markdown
Contributor

The config tree walk parsed every file in /configs and kept its parsed INI until the last driver it declares was created. A parsed INI costs several times the file size in small heap blocks (three allocations per key), and the walk happens before any driver runs - before dmfmc brings up external RAM. On the STM32F746G-DISCO the board's driver configs come to ~54 KB of parsed INI in ~600 blocks of at most 32 bytes; measured when dmeth failed, the main heap had 16 KB free in 1444 pieces, the largest 136 bytes. Every module loaded meanwhile (dmtty, dmclk, dmfmc, ...) spilled into the 64 KB "dma" heap, and dmeth then found no room for its 12 KB descriptor rings ("Out of memory allocating ETH descriptor rings from the 'dma' heap") - adding any driver configuration (a display, a touch panel) tipped it over.

Now the walk parses a file only to queue its drivers (section, driver name, driver_order) and releases it right away, keeping just the path. The file is parsed again when the first of its drivers is created, stays parsed while the following drivers come from the same file, and is released as soon as a driver of another file is configured or its last driver is done - at most one file is parsed at a time.

Verified on the STM32F746G-DISCO with the LCD (dmlcdtft), I2C3 (dmi2c) and touch panel (dmft5336) configs added: Ethernet comes up again (DHCP) next to the LCD, the microSD and the touch panel; boot time unchanged. In Renode the board boots and the touch panel test passes.

The config tree walk parsed every file in /configs and kept its parsed INI
until the last driver it declares was created. A parsed INI costs several
times the file size in small heap blocks (three allocations per key), and
the walk happens before any driver runs - before dmfmc brings up external
RAM. On the STM32F746G-DISCO the board's driver configs come to ~54 KB of
parsed INI in ~600 blocks of at most 32 bytes; measured when dmeth failed,
the main heap had 16 KB free in 1444 pieces, the largest 136 bytes. Every
module loaded meanwhile (dmtty, dmclk, dmfmc, ...) spilled into the 64 KB
"dma" heap, and dmeth then found no room for its 12 KB descriptor rings
("Out of memory allocating ETH descriptor rings from the 'dma' heap") -
adding any driver configuration (a display, a touch panel) tipped it over.

Now the walk parses a file only to queue its drivers (section, driver
name, driver_order) and releases it right away, keeping just the path.
The file is parsed again when the first of its drivers is created, stays
parsed while the following drivers come from the same file, and is
released as soon as a driver of another file is configured or its last
driver is done - at most one file is parsed at a time.

Verified on the STM32F746G-DISCO with the LCD (dmlcdtft), I2C3 (dmi2c)
and touch panel (dmft5336) configs added: Ethernet comes up again (DHCP)
next to the LCD, the microSD and the touch panel; boot time unchanged. In
Renode the board boots and the touch panel test passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JohnAmadis
JohnAmadis merged commit 0240cdc into main Oct 2, 2026
1 check passed
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