STM32 Arduino wont compile

Hi,

I’ve a project wich does not compile with PIO but with Arduino IDE so I’m looking for the right platformio.ini settings.

Arduino IDE:

I’ve tried various combinations with
platform = ststm32
framework = arduino
board = bluepill_f103c8
board = genericSTM32F103CB
board_build.core = maple
board_build.core = stm32

But I always get some or more compile errors for this sketch

You can get it to compile with three changes:

  1. Rename the .ino file to main.cpp (optional but recommended)
  2. Insert #include <Arduino.h> at the top of the file
  3. Use the below platformio.ini file:
[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino

lib_deps =
    https://github.com/pa-pa/AskSinPP.git
2 Likes

Thx for your fast answer!

Sadly there is still a problem with LowPower:

   .pio/libdeps/genericSTM32F103C8/AskSinPP_ID2900/AlarmClock.h:204:4: warning: #warning "RTC not supported" [-Wcpp]
  #warning "RTC not supported"
    ^~~~~~~
Compiling .pio/build/genericSTM32F103C8/lib197/EEPROM/EEPROM.cpp.o
In file included from ~/.platformio/lib/Low-Power_ID38/LowPower.cpp:47:0:
~/.platformio/lib/Low-Power_ID38/LowPower.h:162:6: error: #error "Please ensure chosen MCU is ATSAMD21G18A."
    #error "Please ensure chosen MCU is ATSAMD21G18A."
      ^~~~~
~/.platformio/lib/Low-Power_ID38/LowPower.cpp:1189:3: error: #error "Please ensure chosen MCU is ATSAMD21G18A."
  #error "Please ensure chosen MCU is ATSAMD21G18A."
  ^~~~~

The program you have described intially does not use the Lower Power library. So it looks as if we are talking about a different program now. Can you add the source code incl. platformio.ini?

You’re right, I’ve pasted the errors from the wrong Sketch but the linked one HM-DW-WM.ino is the same.

[platformio]
src_dir = .

[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino

lib_deps =
  AskSinPP

and the main.cpp is same as the one from the github repo with ´#include <Arduino.h>´ inserted.

// #define USE_OTA_BOOTLOADER
#include <Arduino.h>

#define STORAGEDRIVER at24cX<0x50,128,32>
#define TICKS_PER_SECOND 500UL
#define USE_HW_SERIAL
...

Here is the full log: https://pastebin.com/RBBKitZB

I’m afraid I can’t reprodcue the problem.

For reasons that I don’t understand PlatformIO identifies Low-Power as a dependency. However, the library is not compatible with the STM32 architecture and not needed for this Arduino sketch. And it shouldn’t be included because the AskSinPP library only includes it for compatible architectures.

In my environment, it’s not identified as a dependency and therefore works.

Have you installed the library manually before? Can you delete the directory /home/psi/.platformio/lib/Low-Power_ID38 and try building again (and run the Clean task first)?

1 Like

Yay! I removed the ~/.platformio and ./.pio and now it compiles flawlessly!

Thank you very much!

1 Like