Code runs in Arduino IDE but not Platformio

I have made this work, and in the process discovered a few things. Now sure where to report them so I’ll put everything here (@shensley anywhere else I should post this?)

  1. The default configuration when a new arduino project is created with PlatformIO does not work. It is necessary to add some configuration to platformio.ini. The key to getting debugging working was adjusting the level of optimization in a debug build.

  2. PlatformIO itself packages a very old version of the toolchain by default. This is no addressed by following the Daisy Wiki instructions to install the Daisy toolchain - more configuration in platformio.ini is needed.

  3. The board definition files are incorrect - the sizes of RAM and Flash are swapped. E.g. see .platformio/platforms/stm32/boards/electrosmith_daisy.json
    I’ll post an issue in Issues · platformio/platform-ststm32 · GitHub to cover this

For 1. and 2. your platformio.ini should look like the following

  • remove the USB lines if you don’t need USB serial suport
  • check the latest toolchain at PlatformIO Registry for version

---- platformio.ini ----

[env:electrosmith_daisy]

platform = ststm32

board = electrosmith_daisy

framework = arduino

lib_deps =

    Wire

build_flags = -w

    -D HAL_SDRAM_MODULE_ENABLED

    -D HAL_MDMA_MODULE_ENABLED

    -D HAL_DMA_MODULE_ENABLED

    -D INSTRUCTION_CACHE_ENABLE

    -D USBD_USE_CDC

    -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC

debug_build_flags =

    -Os -ggdb2 -g2

platform_packages =

    platformio/toolchain-gccarmnoneeabi@^1.100301.220327
1 Like