How to define which exactly framework is used?

Hello Everyone!

I’m using STM32-Nucleo board with an “Arduino”. But I can’t understand which framework exactly I use. I see that there are two Arduino frameworks for STM32 are installed into PlatformIO dir. One just arduinostm32 and the second one is arduinostm32-maple. Which one is used? How to understand?

And if under ArduinoSMT32 STM32Duino framework is used then where can I get its API description? Their site doesn’t work.

As can be seen in the documentation the core choice is controlled by the core entry in either the board’s JSON definition file (example) or a per-environment override board_build.core. Possible values are maple or stm32.

Open an issue in their repository Issues · stm32duino/Arduino_Core_STM32 · GitHub then.

1 Like

It is strange… I’ve managed to define that the default and used is STM32Duino. I’ve managed to find some API at their GitHub… Also some examples… For example, they use HardwareTimer library very broadly. This library is located at .platformio\packages\framework-arduinoststm32\cores\arduino
But this dir is not included into the compile path. I’m guessing why? I think that it should be…

This file was added 12 days ago and there was no new stable version released that PlatformIO could have picked up.

Latest 1.6.1 release is also what PlatformIO is using. And in this version, it’s not there.

On your own risk you may try to clone GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino yourself and just overwrite all your files in the framework-arduinoststm32 folder. No idea if that will work though.

I can be wrong, but it seems that 1.6.1 that is at their GitHub has this library:
But it is not at stm32 folder. And this file is at the PlatfromIO framework dir:

But it is not at the compile path.

Easy question: how to add this dir to platfromio.ini in order to make it independent from absolute path (eg I need relative path). Because I do this development at several computers and synchronize sources via GitHub.
Or it will be better jsut to copy this lib to Project/include dir?

As you can see in the upper left corner, you are on the master branch. Switch to 1.6.1 tag.


1 Like

Ehm, I don’t think this “library” will work when you just copy its files in a custom library. Doesn’t it depend on other files too? Or maybe on different behaviours of functions than what 1.6.1. has? I would advise to attempt a full framework upgrade to this current github bleeding-edge master version if you really need it, or otherwise look for APIs which are supported in the current stable (1.6.1) which help you do the same thing.

OK, it is already there:
And it is at my hard drive installed by PlatformIO

What is there? HardwareTimer? No there’s HardwareSerial. Or did I not understand you right?

1 Like

Yes, now I see. Thank you!

I have the same opinion according to that :slight_smile: Just copying shouldn’t work…

Well I got it to work. Just download, go to the framework-arduinoststm32 folder, delete the cores and libraries folder, then extract the entire content of the ZIP file into the folder and overwrite all existing files.

Example code compiles (probably won’t work though since it’s using random pins and channels)

#include <Arduino.h>
#include <Servo.h>
#include <HardwareTimer.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  int pin = PA_5;
  int channel = 1;
  HardwareTimer *MyTim = new HardwareTimer(TIM3);  // TIM3 is MCU hardware peripheral instance, its definition is provided in CMSIS
  MyTim->setPWM(channel, pin, 5, 10); // 5 Hertz, 10% dutycycle

  myservo.attach(9);  // attaches the servo on pin 9 to the servo object

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position


platform = ststm32
board = black_f407zg
framework = arduino
DATA:    [          ]   1.0% (used 1328 bytes from 131072 bytes)
PROGRAM: [          ]   1.8% (used 18724 bytes from 1048576 bytes)
 [SUCCESS] Took 5.73 seconds 

So it does work. Just a little bit hacky. You would usually want to create your own framework-arduinoststm32 package in your own repository and use platform_packages as in like

platform_packages =
  framework-arduinoststm32 @ <fixed git repo here>

Just checked - HardwireTimer alone doesn’t work. Requires also timer and it seems that it won’t be able to trace the whole tree.
Anyway thanks for the clarification.

Checked solution with platform_packages. Something is not good with:
platform_packages = framework-arduinoststm32 @ GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino

The source above gives 18 problems during compiling. The system can’t find any standard arduino include…

You cannot just take the Arduino_Core_STM32 git and use it as framework-arduinoststm32 package because it’s missing the package.json and CMSIS and tools directory from PlatformIO. You should take the current framework-arduinoststm32, upgrade the core files as I have described above, and then push it in a new repository, that should work.