STM32FreeRTOS on Platformio - not working

Post here first, or if you can't find a relevant section!
Post Reply
cagz
Posts: 6
Joined: Thu Aug 03, 2023 12:26 pm

STM32FreeRTOS on Platformio - not working

Post by cagz »

Hello,

Working on a project that requires FreeRTOS and decided to give Platformio a go. Mainly because I need a file hierarchy, rather than a single ino file. Any other suggestions are more than welcome.

The board is an STM32L502K6T6 custom board, nothing special about it.

Code is attached at the bottom of this message.

Situation:
On Arduino IDE this code compiles and works just fine, LEDs flash at different periods.
On Platformio, it compiles fine but upon uploading nothing happens.
If I remove the lines related to thread creation and scheduler start, loop() starts as expected and LEDs blink, so not an issue related to pin mappings etc.
If I put task creations back but leave scheduler start out, then loop() works only one and hangs. LEDs stay lit. ???

I am trying to understand what platformio is doing differently stopping the code from working as intended. I found one similar issue recommending addition of `lib_achive = no` to platformio.ini but it didn't make a difference. I also hopelessly been trying relevant looking compiler and linker options but no success.

I appreciate if you can suggest how can I troubleshoot this issue, unless there is something obvious I am missing.

Code: Select all

#include <Arduino.h>
#include <STM32FreeRTOS.h>

#define LED1 PB0
#define LED2 PB1
 
static void task1(void *pvParameters) {
  for (;;) {
      vTaskDelay(1000);
      digitalWrite(LED1, HIGH);
      vTaskDelay(1000);
      digitalWrite(LED1, LOW);
  }
}
 
static void task2(void *pvParameters) {
  for (;;) {
      vTaskDelay(200);
      digitalWrite(LED2, HIGH);
      vTaskDelay(200);
      digitalWrite(LED2, LOW);
  }
}
 
void setup() 
{
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  xTaskCreate(task1,"Task1",
              1000,NULL,tskIDLE_PRIORITY + 2,NULL);
  xTaskCreate(task2,"Task2",
              1000,NULL,tskIDLE_PRIORITY + 2,NULL);
  vTaskStartScheduler();
}
 
void loop() 
{
  digitalWrite(PB1, !digitalRead(PB1));
  digitalWrite(PB0, !digitalRead(PB0));
  delay(1000);
}
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32FreeRTOS on Platformio - not working

Post by fpiSTM »

I do not use PIO, but my first gess is that you have someting misaligned. PIO is not up 2 date compared to Arduino environnement.
Post Reply

Return to “General discussion”