Skip to content

Compile fails with PlatformIO under Windows #3042

Description

@gicking

Describe the bug
(Any) Arduino sketch fails to compile with Arduino Core STM32 v3.0.0 under Windows

Due to recent enhancements, I need Arduino Core STM32 v3.0.0 for a PlatformIO project. Under Linux the project compiles, under Windows I get this error

Processing nucleo_l432kc (platform: ststm32; board: nucleo_l432kc; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_l432kc.html
PLATFORM: ST STM32 (19.7.1) > ST Nucleo L432KC
HARDWARE: STM32L432KCU6 80MHz, 64KB RAM, 256KB Flash
DEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-arduinoststm32 @ 0.0.0+sha.7698174
 - framework-cmsis @ 2.60300.0 (6.3.0)
 - framework-cmsis-dsp @ 1.16.2
 - toolchain-gccarmnoneeabi @ 1.120301.0 (12.3.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 15 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\nucleo_l432kc\FrameworkArduinoVariant\PeripheralPins.c.o
Compiling .pio\build\nucleo_l432kc\FrameworkArduinoVariant\generic_clock.c.o
...
Compiling .pio\build\nucleo_l432kc\SrcWrapper\src\LL\stm32yyxx_ll_ucpd.c.o
In file included from C:\Users\ICK2BUE\.platformio\packages\framework-arduinoststm32@src-d84578b36232bb5f951e2e3754949218\cores\arduino/api/ArduinoAPI.h:31,
                 from C:\Users\ICK2BUE\.platformio\packages\framework-arduinoststm32@src-d84578b36232bb5f951e2e3754949218\cores\arduino/Arduino.h:36,
                 from C:\Users\ICK2BUE\.platformio\packages\framework-arduinoststm32@src-d84578b36232bb5f951e2e3754949218\libraries\SrcWrapper\src\HardwareTimer.cpp:26:
C:\Users\ICK2BUE\.platformio\packages\framework-arduinoststm32@src-d84578b36232bb5f951e2e3754949218\cores\arduino/api/Print.h: In member function 'size_t arduino::Print::write(const char*)':
C:\Users\ICK2BUE\.platformio\packages\framework-arduinoststm32@src-d84578b36232bb5f951e2e3754949218\cores\arduino/api/Print.h:54:42: error: 'strlen' was not declared in this scope
   54 |       return write((const uint8_t *)str, strlen(str));
      |                                          ^~~~~~
C:\Users\ICK2BUE\.platformio\packages\framework-arduinoststm32@src-d84578b36232bb5f951e2e3754949218\cores\arduino/api/Print.h:27:1: note: 'strlen' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
   26 | #include "String.h"
  +++ |+#include <cstring>
   27 | #include "Printable.h"
Compiling .pio\build\nucleo_l432kc\SrcWrapper\src\LL\stm32yyxx_ll_usart.c.o
...
Compiling .pio\build\nucleo_l432kc\SrcWrapper\src\stm32\clock.c.o
*** [.pio\build\nucleo_l432kc\SrcWrapper\src\HardwareTimer.cpp.o] Error 1

================================================== [FAILED] Took 22.36 seconds ==================================================

 *  The terminal process "C:\Users\ICK2BUE\.platformio\penv\Scripts\platformio.exe 'run'" terminated with exit code: 1.
*  Terminal will be reused by tasks, press any key to close it.

Compiling the attached dummy PlatformIO project STM32_bug.zip shows the same error. I tried with Linux and Arduino IDE also and get the following results

  • Linux
    • PlatformIO: ok
    • Arduino IDE: ok
  • Windows
    • PlatformIO / Arduino Core STM32 v3.0.0: fails
    • Arduino IDE: ok

Note that the project compiles without error with previous v2.12.0 of Arduino Core STM32, so this was newly introduced with v3.0.0.

To Reproduce

Steps to reproduce the behavior:

  1. Under Windows, open the attached project STM32_bug.zip in VSCode / PlatformIO
  2. Press compile
  3. See error

Expected behavior
Project should build without error.

Screenshots
See above error message

Desktop (please complete the following information):

  • OS: Windows 11
  • STM32 core version: 3.0.0

Board (please complete the following information):

  • Name: Nucleo L432KC

Additional context
ChatGPT suspects that this is due to Windows file system not being case sensitive, i.e. #include "String.h" and #include <string.h> are not distinguished. This would explain why Linux has no issue, as it's file system is case sensitive.

I tried to fix the problem and issue a pull request, but I failed. Also, I figured that this should be easy to fix, as v2.12.0 of Arduino Core STM32 did not have this issue

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