I am trying to leverage the CMake flow in my project, and I am running some side by side comparisons to identify gaps w.r.t. Make.
The list of defines created by the CMake build does not match the one created by the Makefile: DATA_IN_D2_SRAM is missing.
DATA_IN_D2_SRAM gates the only code in the repo that enables the D2 AHB SRAM blocks — the RCC->AHB2ENR write in SystemInit() (src/sys/system_stm32h7xx.c). Those blocks are disabled out of reset, and .sram1_bss / DMA_BUFFER_MEM_SECTION (src/daisy_core.h) is
where the audio, ADC, MIDI and USB-host DMA buffers live.
So a CMake build programmed to internal flash never turns that memory on. Confirmed by disassembling SystemInit in both builds of examples/AudioPassthru — AHB2ENR |= 0xE0000000 is present under Make, absent under CMake.
When introduced
The gap dates to #390 (b2b8943, 2021-09-28), which added -DDATA_IN_D2_SRAM to Makefile only. The CMake build had been added three months earlier in #332 (e52d37f, 2021-06-15), and #390 did touch CMakeLists.txt, but only its source list, not its defines.
How to fix
system_stm32h7xx.c is built by CMSIS_DEVICE_H7 (Drivers/CMakeLists.txt), so the define belongs on that target:
target_compile_definitions(CMSIS_DEVICE_H7 PRIVATE
DATA_IN_D2_SRAM
)
I will open a PR with this patch.
Disclaimer: I identified the gap and when it was introduced using Claude Code
I am trying to leverage the CMake flow in my project, and I am running some side by side comparisons to identify gaps w.r.t. Make.
The list of defines created by the CMake build does not match the one created by the Makefile:
DATA_IN_D2_SRAMis missing.DATA_IN_D2_SRAMgates the only code in the repo that enables the D2 AHB SRAM blocks — theRCC->AHB2ENRwrite inSystemInit()(src/sys/system_stm32h7xx.c). Those blocks are disabled out of reset, and.sram1_bss/DMA_BUFFER_MEM_SECTION(src/daisy_core.h) iswhere the audio, ADC, MIDI and USB-host DMA buffers live.
So a CMake build programmed to internal flash never turns that memory on. Confirmed by disassembling
SystemInitin both builds ofexamples/AudioPassthru—AHB2ENR |= 0xE0000000is present under Make, absent under CMake.When introduced
The gap dates to #390 (b2b8943, 2021-09-28), which added
-DDATA_IN_D2_SRAMtoMakefileonly. The CMake build had been added three months earlier in #332 (e52d37f, 2021-06-15), and #390 did touchCMakeLists.txt, but only its source list, not its defines.How to fix
system_stm32h7xx.cis built byCMSIS_DEVICE_H7(Drivers/CMakeLists.txt), so the define belongs on that target:I will open a PR with this patch.
Disclaimer: I identified the gap and when it was introduced using Claude Code