STM32 code works in Arduino IDE but not PIO

logs in github - build.log and arduino_build.log

You still have build_type = debug in the platformio.ini causing a debug build, please use the platformio.ini from above

Another cause might be that PlatformIO is using

 - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)

While the Arduino IDE uses

tools\\xpack-arm-none-eabi-gcc\\10.3.1-2.3/bin/arm-none-eabi-g++" 

Please add

platform_packages = 
   toolchain-gccarmnoneeabi@~1.100301.0

and retry if that helps + reupload log for PlatformIO.

I discovered that earlier. Your suggested minimal config doesn’t build. This is what I’ve got which generates a working release build. A debug build is still broken. I’ll upload the build log in a minute.

[env:electrosmith_daisy]

platform = ststm32

board = electrosmith_daisy

framework = arduino

lib_deps =

    Wire

    adafruit/Adafruit ILI9341@^1.5.7

    adafruit/Adafruit BusIO@^1.8.2

    adafruit/Adafruit seesaw Library@^1.6.1

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_tool = stlink

platform_packages =

    platformio/toolchain-gccarmnoneeabi@^1.100301.220327

Incidentally I found that all the files like .platformio/platforms/stm32/boards/electrosmith_daisy.json have the flash and ram sizes swapped. I.e. they read

"name": "Electrosmith Daisy",

  "upload": {

    "maximum_ram_size": 131072,

    "maximum_size": 524288,

where they should read

"name": "Electrosmith Daisy",

  "upload": {

    "maximum_ram_size": 524288,

    "maximum_size": 131072,

Apologies if my replies are a little short. I have a broken arm so trying to type as little as possible.

That’s definitely a bug one can report.

But then besides the debug optimization flags (which should be gone by now) I notice that the PlatformIO variant seems to hvae the USB CDC flags enabled while in the Arduino build it is not. Do you use the USB in the Arduino IDE example?

Otherwise I would suggest to take a small step back and use the Dhrystone benchmark code in the Arduino IDE and in PlatformIO and compare the numbers. If they’re significantly different there’s something wrong in the CPU optimization flags. Whetstone can also be done (checks floating point unit performance)

I’ve tried with and without USB CDC - makes no difference. If I could get the debugger to work I wouldn’t need it :slight_smile:

I’ll see what Dhrystone tells me. It’s got to be be a clock config or optimization flag but I just can’t see it.

And the results are… no significant difference in speed between debug and release build and build in the Arduino IDE (all about 1M Dhrystones)

The sketch needed some tweaking to work - include Arduino.h and then add the USB/CDC definitions to platformio.ini

And what about Whetstone?

100% The same library versions used?

Solution!


debug_build_flags =

    -Os -ggdb2 -g2

Thanks so much for your help Max!

Where should I report the issues in the boards files?

But that just gets used when build_type = debug or when you start debugging – was the regular release build working all the time?

That goes to Issues Ā· platformio/platform-ststm32 Ā· GitHub

Thanks again! I’ll post there.

1 Like