Skip to content

CMake: define mismatch with Make flow (missing DATA_IN_D2_SRAM) #712

Description

@zeroisnan

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions