Skip to content

Heaps named by their tags; the STM32F746's DTCM is fast memory too - #137

Draft
JaxCalder wants to merge 1 commit into
masterfrom
perf/heap-tags
Draft

JaxCalder wants to merge 1 commit into
masterfrom
perf/heap-tags

Conversation

@JaxCalder

@JaxCalder JaxCalder commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What

  • Heaps named by their tags (dmheap's tags: a heap's name is the list of its kinds of memory). DMBOOT_DMA_HEAP_TAGS / DMBOOT_MAIN_HEAP_TAGS name the DMA and the main heap - "dma", "main" by default, as before.
  • The STM32F746's DMA heap - the DTCM - is "dma,fast,dtcm" (configs/mcu/STM32F746xG.cmake, STM32F746ZG.cmake): drivers still find it as "dma" (dmheap_get_context_by_name() matches a tag), and modules asking for fast memory (Dmod_MallocTagged("fast", ...)) get it.
  • The STM32F746G Discovery's flash modules get dmimg_jpeg and dmimg_png: the decoders of carhmi's album covers, which dmimg loads by name (not in carhmi's .dmd).
  • README: "Heaps and their tags".

Why

Every module's allocation lands in the SDRAM - the newest default heap - behind a 4 kB data cache. Measured on the board while carhmi-demo plays an MP3 (debugger sampling the PC):

dmmp3's decoder state (23 kB) player thread the views
SDRAM 35 % (70 % on another file) 10 - 16 frames/s
DTCM ("fast") 10 - 12 % 19 - 23 frames/s, 26 - 29 when the covers are all made

Before merging - draft

This needs, in this order:

  1. Dmod_MallocTagged: memory of a kind, else the default memory dmod#332 (Dmod_MallocTagged) and Heaps tagged by their names, memory of a kind dmheap#22 (tags) merged, and the submodules lib/dmod, lib/dmheap bumped here. Without the dmheap bump the old dmheap_get_context_by_name("dma") would not find a heap named "dma,fast,dtcm" and the DMA drivers would lose their heap - so not before.
  2. New releases of dmimg, dmimg_jpeg, dmimg_png (their cortex-m7 packages held x86_64 modules: dmimg#3, dmimg_jpeg#2, dmimg_png#2, todmvi#4), dmmp3 (Add CMake build system with full Make parity #2, cmake monitor nie dziala #3), and carhmi-demo with the covers.

Tested on the board with those built locally: the DTCM heap named dma,fast,dtcm; dmeth, dmsai, dmsdio, dmuart allocate in it as before; dmmp3's state there (memory -m -H fast); the SD card, the audio and the display work. Ethernet: the link is up and frames come in, but DHCP got no address - as all day on this board before this change too (the clock showed --:--), so not checked further.

🤖 Generated with Claude Code

A heap's name is now the list of its tags (dmheap): DMBOOT_DMA_HEAP_TAGS and
DMBOOT_MAIN_HEAP_TAGS name the DMA and the main heap ("dma", "main" by
default). The STM32F746's DMA heap - the DTCM, never cached, no wait states -
is "dma,fast,dtcm": drivers still find it as "dma", and modules asking for
"fast" memory (Dmod_MallocTagged) get it - dmmp3's decoder state took 70 %
of the CPU in the SDRAM, 15 % there.

The STM32F746G Discovery's flash modules get the decoders of carhmi's album
covers (dmimg_jpeg, dmimg_png): loaded by name, not in carhmi's .dmd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants