Code runs in Arduino IDE but not Platformio

I have been able to get at least many of the DaisyDuino examples working in PlatformIO with this platform.ini which is a little bit simpler.

[env:electrosmith_daisy]
platform = ststm32
board = electrosmith_daisy
framework = arduino
; ----------
; Everything(?) below this needs to be added to use DaisyDuino in PlatformIO.
; Setting up a new project or importing from Arduino does not add any of this.
; ----------
lib_deps = electro-smith/DaisyDuino@^1.5.2
build_flags = 
    ; -w                            ; optional - to suppress redundant definition warnings
    -D HAL_SDRAM_MODULE_ENABLED     ; required? build fails without this one
    ; These flags enable serial monitor over USB UART
    -D USBD_USE_CDC                 ; Define USB Communications Device Class (for serial I/O)
    -D USBCON                       ; Enable USB connection in Arduino (?)
; This is not documented on PlatformIO website but
; enables the DFU firmware upload (over USB)
upload_protocol = dfu

The last two flags were both required for me to get the USB serial monitoring working. Without them, attempting to use Arduino Serial interface eventually causes the program to crash/hang.

I’m not totally sure about the necessity of some of the other HAL flags as well as the instruction cache flag. At least the examples I’ve tried so far from DaisyDuino’s built in examples seem to work :man_shrugging: