Trying to setup SKR-PRO 1.2, not getting my variants right?

Hello, I hope you’re doing well today.

I’m trying to setup a BIGTREE SKR-PRO 1.2 with arduino framework in vscode+platformio.
When I compile I get a lot of “fatal error: variant.h: No such file or directory

I know Marlin supports the board so I copied some of their config settings.
My project root has

/platformio/boards/BigTree_SKR_Pro.json (from marlin)
/platformio/variants/BIGTREE_SKR_PRO_1v1/(from marlin, many files including variant.h)

platformio.ini is

[platformio]
boards_dir = platformio/boards

[env:BIGTREE_SKR_PRO]
framework = arduino
platform = ststm32
board = BigTree_SKR_Pro
build_unflags = -std=gnu11
lib_ignore =
    SoftwareSerial
    SPI
build_flags =
    -std=gnu++14
    -DUSBCON -DUSBD_USE_CDC
    -DUSBD_VID=0x0483
    -DTIM_IRQ_PRIO=13
    -DUSB_PRODUCT=\"STM32F407ZG\"
    -DTARGET_STM32F4
    -DSTM32F407_5ZX
    -DVECT_TAB_OFFSET=0x8000
    -fmax-errors=5
    -g
    -fmerge-all-constants
upload_port = anything

I saw another forum post that mentioned a variants_dir but I can’t find it in the documentation.
How do I correctly tell platformio where the variants file is located?

Thank you and stay well!

Well the magic in Marlin is done with the Python extra script

You see that it dynamically copies the folder buildroot/share/PlatformIO/variants/<variant> to the Arduino STM32 core framework folder (C:\Users\<user>\.platformio\packages\framework-ststm32\variants on Windows).

But it can also be done more elegantly with, as you mentioned,

The request for proper documentation is already open. Until then, the information that adding

board_build.variants_dir = <path to new folder with variants>
board_build.variant = <selected variant>

is a valid build option of the Arduino STM32 core is enough. There’s also an example available.

So you should try adding

board_build.variants_dir = platformio/variants
board_build.variant = BIGTREE_SKR_PRO_1v1

to the platformio.ini and retry.

1 Like

Thanks for the great reply, that was a huge help! LED works, motors all work…

But one hiccup: I can’t seem to get HardwareTimer to attach.

HardwareTimer *MyTim;

void UpdateLED(HardwareTimer *htim) {
  digitalWrite(LED_BUILTIN,!digitalRead(LED_BUILTIN));
}

void setup() {
  Serial.begin(57600);
  pinMode(LED_BUILTIN,OUTPUT);
  MyTim = new HardwareTimer(TIM6);
  MyTim->setOverflow(10,HERTZ_FORMAT);
  MyTim->attachInterrupt(UpdateLED);
  MyTim->refresh();
  MyTim->resume();
}

void loop() {}

I don’t know if I’m using Maple or Core. I see ST STM32 — PlatformIO latest documentation mentions board_build.core… is this another undocumented feature? The header file mentions “Daniel Fekete” so it’s probably STM32Generic?

If anyone has a hint how to make the hardware timer work it would be the best!

Thank you,

Given that the board JSON definition says

It uses https://github.com/stm32duino/Arduino_Core_STM32, not maple (https://github.com/rogerclarkmelbourne/Arduino_STM32/). Otherwise the value of core would have been maple, as documented in your link above already.

One has to be careful with the versions here. If you look at the the wiki it will refer to the latest bleeding-edge version. The last PlatformIO update of the STM32Duino core contains 1.9.0, not the freshly (11 days) released 2.0.0 version.

Compared to the example code

You’re missing a call to setMode().

Otherwise, have you verified that it works in a normal-style blocking blinky before doing it with a timer?

You may also try different timers or different versions of the above referenced example (click on the upper left “1.2.0” version icon to see more versions / tags).

Yes! setMode() was the magic sauce. Thank you!

1 Like