Coder Social home page Coder Social logo

stm32freertos's People

Contributors

abostm avatar danyhm avatar fpistm avatar ivankravets avatar maxgerhardt avatar per1234 avatar ramboerik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stm32freertos's Issues

version of freertos is not clear

in library.json library.properties and README.md the freertos version is 10.0.1 but
inside avery source code files like task.c I found:
FreeRTOS Kernel V10.3.0

Including STM32FreeRTOS Crashes Board

I am very new to stm32duino ecosystem and also new to FreeRTOS, but am an experienced Arduino user. I'm using an Adafruit Feather STM32F405 on Arduino 1.8.13 and used the library manager to download STM32FreeRTOS v10.3.1. I was unable to use any of the simple examples for this library without the USB CDC driver crashing and the device locking up. I modified the basic Arduino blink sketch to include just the following line and a similar problem is happening:

#include <STM32FreeRTOS.h>

I'm using Ubuntu 22.04.2 LTS (kernel 5.19.0-35-generic) and here is some of the typical dmesg output:

[ 9166.881885] usb 1-6: USB disconnect, device number 40
[ 9167.431336] usb 1-6: new full-speed USB device number 41 using xhci_hcd
[ 9167.581006] usb 1-6: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 0.00
[ 9167.581022] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 9167.581029] usb 1-6: Product: FEATHER_F405 CDC in FS Mode
[ 9167.581035] usb 1-6: Manufacturer: STMicroelectronics
[ 9167.581040] usb 1-6: SerialNumber: 2078326B4D31
[ 9169.435126] usb 1-6: can't set config #1, error -71

and trying again

[ 9169.435328] usb 1-6: USB disconnect, device number 41
[ 9169.955274] usb 1-6: new full-speed USB device number 42 using xhci_hcd
[ 9170.105547] usb 1-6: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 0.00
[ 9170.105561] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 9170.105567] usb 1-6: Product: FEATHER_F405 CDC in FS Mode
[ 9170.105572] usb 1-6: Manufacturer: STMicroelectronics
[ 9170.105577] usb 1-6: SerialNumber: 2078326B4D31
[ 9175.232019] usb 1-6: can't set config #1, error -110
[ 9177.519498] usb 1-6: USB disconnect, device number 42
[ 9177.983322] usb 1-6: new full-speed USB device number 43 using xhci_hcd
[ 9178.133660] usb 1-6: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 0.00
[ 9178.133675] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 9178.133683] usb 1-6: Product: FEATHER_F405 CDC in FS Mode
[ 9178.133688] usb 1-6: Manufacturer: STMicroelectronics
[ 9178.133693] usb 1-6: SerialNumber: 2078326B4D31

With the frBlink sketch the LED flashes twice and then stays on. Here is the Arduino 1.8.13 debugging output:

Sketch uses 32472 bytes (3%) of program storage space. Maximum is 1048576 bytes.
Global variables use 4644 bytes (3%) of dynamic memory, leaving 126428 bytes for local variables. Maximum is 131072 bytes.
      -------------------------------------------------------------------
                        STM32CubeProgrammer v2.13.0                  
      -------------------------------------------------------------------



USB speed   : Full Speed (12MBit/s)
Manuf. ID   : STMicroelectronics
Product ID  : STM32  BOOTLOADER
SN          : 2078326B4D31
DFU protocol: 1.1
Board       : --
Device ID   : 0x0413
Device name : STM32F405xx/F407xx/F415xx/F417xx
Flash size  : 1 MBytes (default)
Device type : MCU
Revision ID : --  
Device CPU  : Cortex-M4


Memory Programming ...
Opening and parsing file: frBlink.ino.bin
  File          : frBlink.ino.bin
  Size          : 32.14 KB 
  Address       : 0x08000000 


Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 2]
erasing sector 0000 @: 0x08000000 done
erasing sector 0001 @: 0x08004000 done
erasing sector 0002 @: 0x08008000 done
Download in Progress:


File download complete
Time elapsed during download operation: 00:00:01.735

RUNNING Program ... 
  Address:      : 0x8000000
Start operation achieved successfully
Board at /dev/ttyACM0 is not available
Board at /dev/ttyACM0 is not available
Board at /dev/ttyACM0 is not available

Thanks.

build error

hello, i use vscode + platformio + arduino + stm32f103 to dev and i am a new fish.
i can add other libs like ArduinoJson by the platformio libraries tool, everthing is ok.
but when i add stm32duino/STM32FreeRTOS, i get some error.
image

i modify config_default.h #define __CORTEX_M 0x03U

i have no ways...

Any way to use serialEvent or something similar?

Hello, I was trying to use SerialEvent() but seems like it is not going to work with FreeRTOS. I may be doing something wrong.

I need to receive long burst of data over a serial port. Until now I was suspending other tasks as soon as I know that the data was about to be (or being) transmitted. Then I recall that Arduino has this SerialEvent() mechnism, and I thought that this could be handy. Is there any way to make SerialEvent() work or is there something similar that I can use with FreeRTOS?

A minimal working example (well, it's not working 😄 ) was added below. It has this two lines in setup():

    vTaskStartScheduler();
    while(1);

if both are commented, then SerialEvent() works, but the scheduler is not running. If those are left uncommented, then the scheduler working but serialEvent() is not.

I'm using this flags (put this in a file called build_opt.h in the same folder of the .ino code):
-DENABLE_HWSERIAL5 -DPIN_SERIAL5_RX=PD2 -DPIN_SERIAL5_TX=PC12

This is the code:


#include <STM32FreeRTOS.h>

String inputString = "";
bool stringComplete = false;

void Task1( void *pvParameters );

HardwareSerial Serial5(PD2, PC12);


void setup() 
{
    Serial5.begin(115200);
    inputString.reserve(200);

    xTaskCreate(Task1, (const portCHAR *)"task1", 128, NULL, 2, NULL);
  
    vTaskStartScheduler();
    while(1);
}


void loop() {
    if (stringComplete) 
    {
        Serial5.print("\nrecv: ");
        Serial5.println(inputString);

        inputString = "";
        stringComplete = false;
    }
}


void serialEvent5() 
{
    while (Serial5.available()) 
    {
        char inChar = (char)Serial5.read();
        inputString += inChar;
  
        if (inChar == '\n' || inChar == '\r') 
        {
            stringComplete = true;
        }
    }
}


void serialEventRun(void)
{
    #if defined(HAVE_HWSERIAL5)
        if (serialEvent5 && Serial5.available()) 
        {
            serialEvent5();
        }
    #endif
}


void Task1(void *pvParameters)
{
    for (;;) 
    {
        Serial5.println("task1");
        vTaskDelay(1000); 
    }
}

fatal error: stm32_def.h: No such file or directory

Hi there! Really excited to use this library in PlatformIO. However, with a simple project I'm not able to build. Here's my platformio.ini

[env:bluepill_f103c8]
platform = ststm32
board = bluepill_f103c8
framework = arduino
debug_tool = stlink-v2
build_flags = -std=gnu++11 -MMD -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB 
build_unflags = -lc -lstdc++ -lnosys

lib_deps =
  Nanopb
  PacketSerial
  STM32duino FreeRTOS

When I try to build, I get this error while building FreeRTOS

Compiling .pioenvs/bluepill_f103c8/lib823/STM32duino FreeRTOS_ID2093/FreeRTOS/Source/event_groups.o
In file included from .piolibdeps/STM32duino FreeRTOS_ID2093/src/FreeRTOS/Source/include/portable.h:94:0,
from .piolibdeps/STM32duino FreeRTOS_ID2093/src/FreeRTOS/Source/include/FreeRTOS.h:104,
from .piolibdeps/STM32duino FreeRTOS_ID2093/src/FreeRTOS.h:9,
from .piolibdeps/STM32duino FreeRTOS_ID2093/src/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.h:101,
from .piolibdeps/STM32duino FreeRTOS_ID2093/src/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c:100:
.piolibdeps/STM32duino FreeRTOS_ID2093/src/portmacro.h:9:23: fatal error: stm32_def.h: No such file or directory

Would this lib work with libopencm3 as well?

I currently have some projects set-up in PlatformIO, using libopencm3. I would like to add FreeRTOS using this library. However, right now it is defined only for framework "Arduino".

error: #5: cannot open source input file "cmsis_gcc.h"

I've just started using mdk5, created a new project and the first example compiles with an error """... ... \Drivers\CMSIS\Include\cmsis_compiler.h(41): error: #5: cannot open source input file "cmsis_gcc.h": No such file or directory" "", but I see the same file in the official routine as in the "cmsis_compiler.h" file I imported
I'm not sure how to solve this error

vApplicationGetIdleTaskMemory not present if static allocation is on

Hello,

the vApplicationGetIdleTaskMemory function is not present if configSUPPORT_STATIC_ALLOCATION is 1. It seems it needs to be supplied manually. from CubeMX we have:

/* GetIdleTaskMemory prototype (linked to static allocation support) */
void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize );

static StaticTask_t xIdleTaskTCBBuffer;
static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];
  
void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
{
  *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
  *ppxIdleTaskStackBuffer = &xIdleStack[0];
  *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}

which needs to be supplied in the sketch.

maybe update the docs ? or provide examples for configSUPPORT_STATIC_ALLOCATION

Error when compiling programs for CMSIS-RTOS V2, as well as examples

Normal compilation and work in the Arduino environment, but a compilation error in the Platformio environment, like this:

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

const uint8_t LED_PIN = PE0;

osThreadId_t tid_blinky_led;

void blinky_led_thread(void *startArg)
{
  (void)startArg;
  while (true){
    digitalWrite(LED_PIN, HIGH);
    osDelay(500);
    digitalWrite(LED_PIN, LOW);
    osDelay(500);
  }
}

void setup() {
  pinMode(LED_PIN, OUTPUT);
  //
  osKernelInitialize();
  tid_blinky_led = osThreadNew(blinky_led_thread, NULL, NULL);
  if (osKernelGetState() == osKernelReady){
    osKernelStart();
  }
  while (true);
}

void loop() {
  //
}
rocessing genericSTM32F407VET6 (platform: ststm32; board: genericSTM32F407VET6; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F407VET6.html
PLATFORM: ST STM32 (15.4.1) > STM32F407VE (192k RAM. 512k Flash)
HARDWARE: STM32F407VET6 168MHz, 128KB RAM, 502.23KB Flash
DEBUG: Current (stlink) External (jlink, stlink)
PACKAGES:
 - framework-arduinoststm32 @ 4.20200.221104 (2.2.0)
 - framework-cmsis @ 2.50700.210515 (5.7.0)
 - toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
Dependency Graph
|-- STM32duino FreeRTOS @ 10.3.1
Building in release mode
Linking .pio\build\genericSTM32F407VET6\firmware.elf
c:/users/kep/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/genericSTM32F407VET6/src/main.cpp.o: in function `setup':
main.cpp:(.text.setup+0xa): undefined reference to `osKernelInitialize'
c:/users/kep/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: main.cpp:(.text.setup+0x14): undefined reference to `osThreadNew'
c:/users/kep/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: main.cpp:(.text.setup+0x1c): undefined reference to `osKernelGetState'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\genericSTM32F407VET6\firmware.elf] Error 1

STM32duino [email protected] and other

FreeRTOS: vTaskDelay() and vTaskDelayUntil() not working correctly after calling vTaskStartScheduler()

Hi all,

I'm new in FreeRTOS. I'm uing some STM32 boards to build some projects, but after noticing that CMSIS-RTOS v2 is not working on my STM32F411CE board, I tried the FreeRTOS API directly.
Seems that is working to create tasks and I was able to run the tasks.
But, for my suprise, the when the tasks are create they starts and run at full speed. vTaskDelayUntil() is not working until a certain time pass.

For example:

SemaphoreHandle_t sem;

void vLEDFlashTask(void *pvParameters);
void vSerialUSB(void *pvParameters);

//Thread 1
void vLEDFlashTask(void */*argument*/) {
  TickType_t xLastWakeTime;
  const TickType_t xPeriod = pdMS_TO_TICKS( 500 ); 
  
  for (;;) {
    digitalToggle(LED_BUILTIN);
    vTaskDelayUntil(&xLastWakeTime, xPeriod);
  }
   vTaskDelete( NULL );
}

//Thread 2
void vSerialUSB(void */*argument*/) {
  TickType_t xLastWakeTime;
  const TickType_t xPeriod = pdMS_TO_TICKS( 2000 ); 
  
  for (;;) {
    //digitalToggle(LED_BUILTIN);
    SerialUSB.println("Task 2 is working..");
    vTaskDelayUntil(&xLastWakeTime, xPeriod);
  }
   vTaskDelete( NULL );
}

void setup() {

  portBASE_TYPE tid_vLEDFlashTask, tid_vSerialUSB;
  
  pinMode(LED_BUILTIN, OUTPUT);

  // flash LED for booting

  uint8_t i;
  
  for (i = 0; i <= 5; i++) {
    digitalToggle(LED_BUILTIN);
    delay(500);
  }
  
  SerialUSB.begin(115200);
  SerialUSB.println("USB Serial Port init done ..");

  sem = xSemaphoreCreateCounting(1, 0);
  if (sem == NULL ) {
    SerialUSB.println(F("Sempahore Creation problem"));
    while(1);
  }

  vSemaphoreCreateBinary(sem);

  // create task at priority one
  tid_vLEDFlashTask = xTaskCreate(vLEDFlashTask, "vLEDFlashTask", configMINIMAL_STACK_SIZE, NULL, 2, NULL);  

  // check for creation errors
  if (tid_vLEDFlashTask != pdPASS ) {
    Serial.println(F("Task vLEDFlashTask creation problem"));
    //while(1);
  }

  tid_vSerialUSB = xTaskCreate(vSerialUSB, "vSerialUSB", configMINIMAL_STACK_SIZE, NULL, 1, NULL);  

  // check for creation errors
  if (tid_vSerialUSB != pdPASS ) {
    Serial.println(F("Task vSerialUSB creation problem"));
    //while(1);
  }


  SerialUSB.println("Starting vTaskStartScheduler..");
  vTaskStartScheduler();

  SerialUSB.println("Insufficient RAM");

  while (1);
}

void loop() {
    // Not used.
}

This is a very-very simple code I wrote. The USB serial port is flooded with message "Task 2 is working.." completley insane and not from 2 to 2 seconds as it is in the code.
The LED is flashing at a very high rate.
After a while (about 10 seconds) everything is settled and is working fine.
What I'm doing wrong? Why vTaskDelay() or vTaskDelayUntil() not working as they suppose to work?
I'm trying to find in RTOS manual an answer, but without any success.

Kind regards.

Memory manager to safely use malloc() from other libraries

The current options in the portable/MemMang directory cannot provide thread safety for those Arduino libraries that directly call malloc() family of functions (e.g. STM32SD, String).

I have ported some code here: RoboTech-srl@897009a

Before making a PR, I was wondering if configMEMMANG_HEAP_NB == -1 was a good choice. I thought the number of heap implementations might grow in future versions, so I went negative. What do you think @fpistm ?

I also think that the default _sbrk() provided by the core must be defined as a "weak" symbol for this to work. See fortebit/fortebit-openiot-stm32-core@169ced0

How to set the value heap and stack in the .ld file?

OK, Here is my problem, and I was confused.
I use five tasks in my main.cpp like this:

	xTaskCreate(periphRunTask, 		(const portCHAR *)"PeriphRun", 		512, 	NULL, 	6,	NULL);
	xTaskCreate(sensorSampleTask, 	(const portCHAR *)"Sensor", 		256, 	NULL, 	5, 	NULL);
	xTaskCreate(dataHandleTask, 	(const portCHAR *)"DataHandle", 	512, 	NULL, 	4, 	NULL);
	xTaskCreate(socketLTERunTask, 	(const portCHAR *)"LTESocket",		1024, 	NULL, 	3, 	NULL);
	xTaskCreate(socketWaterRunTask, (const portCHAR *)"WaterSocket",	1024, 	NULL, 	2, 	NULL);

and in my ldscript.ld file , I set the heap size like this:

/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size  = 0x200;;       /* 0x400 1KB 一般由程序员分配和释放,分配方式类似于数据结构中的链表     */
_Min_Stack_Size = 0x800;; 	    /* 0x800 2KB 由编译器自动分配和释放,如存放函数的参数值,局部变量的值等	 */

and default use #define configUSE_NEWLIB_REENTRANT 1

but I dont know how to set them with right value, my problem often run to hardfault,
When I use tasklist to see the statck size, it is useless.

Could you help me?

L073RZ support

Hello,

It seems like Cortex M0+ are supported, so I would basically assume that STM32L073RZ would be too, but I can't find this entry in your validated list.

Before I lose time with trying anything stupid, may I get a confirmation of L073RZ support ?

Thanks

Parameters at task startup

My envronment

I'm using STM32duino FreeRTOS for Platform IO.
stm32duino/STM32duino FreeRTOS@^10.2.1
https://registry.platformio.org/libraries/stm32duino/STM32duino%20FreeRTOS

Content of the problem

The xTaskCreate function allows you to specify parameters for the task.
The same address(=0x2001FFDC) is passed to the task.
However, the contents of the structure are not displayed correctly on the task side.

serial (same as 4)
*****
param address is 0x2001FFDC
Start Scheduler.....
task_parameter address is 0x2001FFDC
task_parameter->ivalue is -3
task_parameter->cvalue is []
task is running
task is running

My code:

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

#define BAUDRATE 115200

struct PARAMETER_t{
  int ivalue;
  char cvalue[16];
};

void task(void *pvParameters)
{
  PARAMETER_t *task_parameter = (PARAMETER_t *)pvParameters;
  Serial.print ("task_parameter address is 0x");
  Serial.println ((unsigned int)task_parameter, HEX);
  Serial.print ("task_parameter->ivalue is ");
  Serial.println(task_parameter->ivalue);
  Serial.print ("task_parameter->cvalue is [");
  Serial.print(task_parameter->cvalue);
  Serial.println("]");

  while(1) {
    Serial.println("task is running");
    delay(1000);
  }
}

void setup() {
  Serial.begin(BAUDRATE);
  Serial.println("serial (same as 4)");
  Serial.println("*****");

  PARAMETER_t param;
  param.ivalue = 6;
  strcpy(param.cvalue, "serail 6");
  Serial.print("param address is 0x");
  Serial.println ((unsigned int)&param, HEX);
  portBASE_TYPE xTask = xTaskCreate(task, "TASK", configMINIMAL_STACK_SIZE, (void *)&param, 2, NULL);
  configASSERT( xTask );

  // start scheduler
  Serial.println("Start Scheduler.....");
  vTaskStartScheduler();

  Serial.println("Insufficient RAM");
  while(1);
}

void loop() {

}

(EDIT1)
If it is not a structure, it works correctly.

#include <STM32FreeRTOS.h>

#define BAUDRATE 115200

void task(void *pvParameters)
{
  int index = (int)pvParameters;
  Serial.print ("task_parameter is ");
  Serial.println(index);
  char * task = pcTaskGetName(NULL);

  while(1) {
    Serial.print(task);
    Serial.print(" is running:index is ");
    Serial.print(index);
    Serial.println();
    delay(1000);
  }
}

void setup() {
  Serial.begin(BAUDRATE);
  Serial.println("serial (same as 4)");
  Serial.println("*****");

  int index;
  index = 0;
  portBASE_TYPE xTask0 = xTaskCreate(task, "TASK0", configMINIMAL_STACK_SIZE, (void*)index, 2, NULL);
  configASSERT( xTask0 );

  index = 1;
  portBASE_TYPE xTask1 = xTaskCreate(task, "TASK1", configMINIMAL_STACK_SIZE, (void*)index, 2, NULL);
  configASSERT( xTask1 );

  // start scheduler
  Serial.println("Start Scheduler.....");
  vTaskStartScheduler();

  Serial.println("Insufficient RAM");
  while(1);
}

void loop() {
  // Empty. Things are done in Tasks.
}

Library needs to include Arduino.h to compile OK

Hi,

I have a library that adds the option to use functional callbacks to the FreeRTOS timers.
That uses no Arduino functionality at all so I did not include "Arduino.h"

#include <functional>
#include "STM32FreeRTOS.h"
#include "timers.h"

That causes compile time errors : error: template with C linkage

Compiling library "RTOSTicker"
"C:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\tools\\xpack-arm-none-eabi-gcc\\9.2.1-1.1/bin/arm-none-eabi-g++" -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb "@C:\\Users\\Herman\\AppData\\Local\\Temp\\arduino_build_22616/sketch/build_opt.h" -c -Os -w -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -fno-use-cxa-atexit -MMD "-IC:\\Users\\Herman\\Documents\\Arduino\\sketch_oct20b" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\cores\\arduino/avr" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\cores\\arduino/stm32" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\cores\\arduino/stm32/LL" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\cores\\arduino/stm32/usb" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\cores\\arduino/stm32/OpenAMP" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\cores\\arduino/stm32/usb/hid" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\cores\\arduino/stm32/usb/cdc" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\system/Drivers/STM32F4xx_HAL_Driver/Inc" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\system/Drivers/STM32F4xx_HAL_Driver/Src" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\system/STM32F4xx" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\system/Middlewares/ST/STM32_USB_Device_Library/Core/Src" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\system/Middlewares/OpenAMP" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\system/Middlewares/OpenAMP/open-amp/lib/include" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\system/Middlewares/OpenAMP/libmetal/lib/include" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\system/Middlewares/OpenAMP/virtual_driver" -DSTM32F4xx -DARDUINO=10808 -DARDUINO_GENERIC_F411CE -DARDUINO_ARCH_STM32 "-DBOARD_NAME=\"GENERIC_F411CE\"" -DSTM32F411xE -DHAL_UART_MODULE_ENABLED "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\tools\\CMSIS\\5.5.1/CMSIS/Core/Include/" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\system/Drivers/CMSIS/Device/ST/STM32F4xx/Include/" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\system/Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc/" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\tools\\CMSIS\\5.5.1/CMSIS/DSP/Include" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\cores\\arduino" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\variants\\Generic_F411Cx" "-IC:\\Users\\Herman\\Documents\\Arduino\\libraries\\RTOSTicker\\src" "-IC:\\Users\\Herman\\Documents\\Arduino\\libraries\\STM32FreeRTOS\\src" "-IC:\\Users\\Herman\\AppData\\Local\\Arduino15\\packages\\STM32\\hardware\\stm32\\1.9.0\\libraries\\SrcWrapper\\src" "C:\\Users\\Herman\\Documents\\Arduino\\libraries\\RTOSTicker\\src\\RTOSTicker.cpp" -o "C:\\Users\\Herman\\AppData\\Local\\Temp\\arduino_build_22616\\libraries\\RTOSTicker\\RTOSTicker.cpp.o"
In file included from c:\users\herman\appdata\local\arduino15\packages\stm32\tools\xpack-arm-none-eabi-gcc\9.2.1-1.1\arm-none-eabi\include\c++\9.2.1\bits\stl_algo.h:60,
                 from c:\users\herman\appdata\local\arduino15\packages\stm32\tools\xpack-arm-none-eabi-gcc\9.2.1-1.1\arm-none-eabi\include\c++\9.2.1\algorithm:62,
                 from C:\Users\Herman\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/wiring_constants.h:26,
                 from C:\Users\Herman\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/wiring.h:34,
                 from C:\Users\Herman\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0\cores\arduino/Arduino.h:36,
                 from C:\Users\Herman\Documents\Arduino\libraries\STM32FreeRTOS\src/portmacro.h:9,
                 from C:\Users\Herman\Documents\Arduino\libraries\STM32FreeRTOS\src/FreeRTOS/Source/include/portable.h:52,
                 from C:\Users\Herman\Documents\Arduino\libraries\STM32FreeRTOS\src/FreeRTOS/Source/include/FreeRTOS.h:62,
                 from C:\Users\Herman\Documents\Arduino\libraries\STM32FreeRTOS\src/FreeRTOS.h:9,
                 from C:\Users\Herman\Documents\Arduino\libraries\STM32FreeRTOS\src/STM32FreeRTOS.h:9,
                 from C:\Users\Herman\Documents\Arduino\libraries\RTOSTicker\src\RTOSTicker.h:31,
                 from C:\Users\Herman\Documents\Arduino\libraries\RTOSTicker\src\RTOSTicker.cpp:25:
c:\users\herman\appdata\local\arduino15\packages\stm32\tools\xpack-arm-none-eabi-gcc\9.2.1-1.1\arm-none-eabi\include\c++\9.2.1\bits\algorithmfwd.h:195:3: error: template with C linkage
  195 |   template<typename _IIter, typename _Predicate>
      |   ^~~~~~~~
In file included from C:\Users\Herman\Documents\Arduino\libraries\STM32FreeRTOS\src/FreeRTOS.h:9,
                 from C:\Users\Herman\Documents\Arduino\libraries\STM32FreeRTOS\src/STM32FreeRTOS.h:9,
                 from C:\Users\Herman\Documents\Arduino\libraries\RTOSTicker\src\RTOSTicker.h:31,
                 from C:\Users\Herman\Documents\Arduino\libraries\RTOSTicker\src\RTOSTicker.cpp:25:
C:\Users\Herman\Documents\Arduino\libraries\STM32FreeRTOS\src/FreeRTOS/Source/include/FreeRTOS.h:52:1: note: 'extern "C"' linkage started here
   52 | extern "C" {
      | ^~~~~~~~~~

It compiles OK with :

#include <functional>
#include "Arduino.h"
#include "STM32FreeRTOS.h"
#include "timers.h"

I can't build blink.cpp using platformio.

My environment.

$ uname -a
Linux HP-Laptop 4.15.0-46-generic #49-Ubuntu SMP Wed Feb 6 09:33:07 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

platformio.ini

$ cat platformio.ini
; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:nucleo_f103rb]
platform = ststm32
board = nucleo_f103rb
framework = arduino
board_build.core = stm

src/main.cpp

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

#define LED PB12

void setup()
{
  // initialize LED digital pin as an output.
  Serial.begin(115200);
  Serial.println("Serial start");
  pinMode(LED, OUTPUT);
}

void loop()
{
  digitalWrite(LED, HIGH);
  delay(1000);
  digitalWrite(LED, LOW);
  delay(1000);
}

pio run

$ pio run
Processing nucleo_f103rb (platform: ststm32; board: nucleo_f103rb; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_f103rb.html
PLATFORM: ST STM32 > ST Nucleo F103RB
HARDWARE: STM32F103RBT6 72MHz 20KB RAM (128KB Flash)
DEBUG: CURRENT(stlink) ON-BOARD(stlink) EXTERNAL(blackmagic, jlink)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 8 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <STM32duino FreeRTOS> 9.0.3
Compiling .pioenvs/nucleo_f103rb/src/main.cpp.o
Linking .pioenvs/nucleo_f103rb/firmware.elf
.pioenvs/nucleo_f103rb/lib6d3/libSTM32duino FreeRTOS_ID2093.a(heap.c.o): In function `__malloc_lock':
heap.c:(.text.__malloc_lock+0x0): multiple definition of `__malloc_lock'
/home/nop/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-m/libc_nano.a(lib_a-mlock.o):mlock.c:(.text.__malloc_lock+0x0): first defined here
.pioenvs/nucleo_f103rb/lib6d3/libSTM32duino FreeRTOS_ID2093.a(heap.c.o): In function `__malloc_unlock':
heap.c:(.text.__malloc_unlock+0x0): multiple definition of `__malloc_unlock'
/home/nop/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7-m/libc_nano.a(lib_a-mlock.o):mlock.c:(.text.__malloc_unlock+0x0): first defined here
collect2: error: ld returned 1 exit status
*** [.pioenvs/nucleo_f103rb/firmware.elf] Error 1
========================== [ERROR] Took 4.22 seconds ==========================

Can not use HID bootloader while using STM32FreeRTOS

Hi,
I was using the HID bootloader for USB for Arduino IDE for several months. But when I inserted the FreeRTOS I lost the com port for the blue pill. And look like the program does not work, though the program is uploaded. I mean I tried to use pc13 to blink1 and PA4 to blink2 program (blink 1 & 2 are for different time delays). How can I solve this?

HID will not work if STM32FreeRTOS.h is included.

env: Arduino 1.8.9 + Arduino_Core_STM32 + RobotDyn STM32 MINI
code:

// It does not work if there is this line.
// #include <STM32FreeRTOS.h>
#include "Keyboard.h"

void setup()
{
  Keyboard.begin();
  delay(1000);
  Keyboard.print("test");
  while (1);
}

void loop()
{
}

compilation time is too long

My arduino ide compilation time is too long, each compilation takes 8 minutes or more, is there any way to solve it? Thank you very much.

Request printf() to multitask environment

My environment:
Arduino-IDE(Ver1.8.5) + stm32duino + nucleo F103RB

Source code:

	#include <STM32FreeRTOS.h>
	#include <stdarg.h>

	SemaphoreHandle_t xSemaphore;

	void _printf(const char *format, ...) {
	    xSemaphoreTake(xSemaphore, portMAX_DELAY);
	    va_list va;
	    va_start(va, format);
	//    TickType_t _nowTick = xTaskGetTickCount();
	//    char * _taskName = pcTaskGetTaskName( NULL );
	//    printf("[%s:%d] ",_taskName, _nowTick);    
	    vprintf(format, va); 
	    va_end(va);
	    xSemaphoreGive(xSemaphore);
	}

	// 時間稼ぎ(Gain time)
	void ConsumptionTick(int delay) {
	    TickType_t startTick;
	    TickType_t endTick;
	    TickType_t nowTick;
	    startTick = xTaskGetTickCount();
	    endTick = startTick + delay;
	    //printf("startTick=%d endTick=%d\n",startTick,endTick);
	    while(1) {
	      nowTick = xTaskGetTickCount();
	      if (nowTick > endTick) break;
	    }
	}

	// Task Body
	void task(void *pvParameters)
	{
	    UBaseType_t prio;
	    TickType_t nowTick;

	    prio = uxTaskPriorityGet( NULL );
	    nowTick = xTaskGetTickCount();
	    printf("[%s:%d] start Priority=%d\n",pcTaskGetName(0),nowTick,(int)prio);
	//    _printf("[%s:%d] start Priority=%d\n",pcTaskGetName(0),nowTick,(int)prio);
	    ConsumptionTick(200);
	    nowTick = xTaskGetTickCount();
	    printf("[%s:%d] end\n",pcTaskGetName(0),nowTick);
	//    _printf("[%s:%d] end\n",pcTaskGetName(0),nowTick);
	    vTaskDelete( NULL );
	}


	//------------------------------------------------------------------------------
	void setup() {
	  portBASE_TYPE xTask1, xTask2, xTask3, xTask4;

	  Serial.begin(115200);
	  Serial.println("setup() start");
	  Serial.print("configTICK_RATE_HZ:");
	  Serial.println(configTICK_RATE_HZ);
	  Serial.print("portTICK_PERIOD_MS:");
	  Serial.println(portTICK_PERIOD_MS);
	  Serial.print("freeRTOS version:");
	  Serial.println(tskKERNEL_VERSION_NUMBER);

	#if 1
	// Task1 is started in priority=2
	// Task2 is started in priority=2
	// Task3 is started in priority=2
	// Task4 is started in priority=2
	  xTask1 = xTaskCreate(task, "Task1", configMINIMAL_STACK_SIZE, NULL, 2, NULL);
	  xTask2 = xTaskCreate(task, "Task2", configMINIMAL_STACK_SIZE, NULL, 2, NULL);
	  xTask3 = xTaskCreate(task, "Task3", configMINIMAL_STACK_SIZE, NULL, 2, NULL);
	  xTask4 = xTaskCreate(task, "Task4", configMINIMAL_STACK_SIZE, NULL, 2, NULL);
	#endif

	#if 0
	// Task1 is started in priority=2
	// Task2 is started in priority=3
	// Task3 is started in priority=4
	// Task4 is started in priority=5
	  xTask1 = xTaskCreate(task, "Task1", configMINIMAL_STACK_SIZE, NULL, 2, NULL);
	  xTask2 = xTaskCreate(task, "Task2", configMINIMAL_STACK_SIZE, NULL, 3, NULL);
	  xTask3 = xTaskCreate(task, "Task3", configMINIMAL_STACK_SIZE, NULL, 4, NULL);
	  xTask4 = xTaskCreate(task, "Task4", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
	#endif

	  /* Check everything was created. */
	  configASSERT( xTask1 );
	  configASSERT( xTask2 );
	  configASSERT( xTask3 );
	  configASSERT( xTask4 );

	  /* Create Mutex for printf */
	  xSemaphore = xSemaphoreCreateMutex();
	  /* Check everything was created. */
	  configASSERT( xSemaphore );
	  
	  // start scheduler
	  Serial.println("Start Scheduler.....");
	  vTaskStartScheduler();

	#if 1
	  while (1) {
	    Serial.println("setup alive...");
	    delay(1000);
	  }
	#endif
	}

	//------------------------------------------------------------------------------
	// WARNING loop() called from vApplicationIdleHook(), so don't use this function.
	// loop must never block
	void loop() {
	  // Not used.
	}

When i used prinf(),Indication is confused.

setup() start
configTICK_RATE_HZ:1000
portTICK_PERIOD_MS:1
freeRTOS version:V9.0.0
Start Scheduler.....
0] start Priority=2
rity=2
0] start Priority=2
rity=2
0] start Priority=2
0] start Priority=2
rity=2
rity=2
[Task3:218] end
[Task4:225] end
[Task1:230] end
[Task2:238] end

When i used _print(),Indication is not confused.

setup() start
configTICK_RATE_HZ=1000
portTICK_PERIOD_MS=1
Start Scheduler.....
[Task1:0] start Priority=2
[Task2:1] start Priority=2
[Task3:1] start Priority=2
[Task4:1] start Priority=2
[Task1:211] end
[Task2:214] end
[Task3:222] end
[Task4:233] end

Add support of STM32WL

A call for help. I guess I am just missing some setting somewhere.

I am trying to use FreeRTOS with the Arduino_Core_STM32 and the newly added variant WL54CCU_WL55CCU_WLE4C(8-B-C)U_WLE5C(8-B-C)U

But compilation fails (even with empty sketch) with

C:\Users\RAKWIR~1\AppData\Local\Temp\cci0Ndhb.s: Assembler messages:
C:\Users\RAKWIR~1\AppData\Local\Temp\cci0Ndhb.s:334: Error: selected FPU does not support instruction -- `vstmdbeq r0!,{s16-s31}'
C:\Users\RAKWIR~1\AppData\Local\Temp\cci0Ndhb.s:356: Error: selected FPU does not support instruction -- `vldmiaeq r0!,{s16-s31}'

Example sketch:

#include <STM32FreeRTOS.h>

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

vTaskDelay Don't seem to be working

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

#define LED PC13

void task(void *pvParameters)
{
  Serial.println("task start");
  for (;;)
  {

    digitalWrite(LED, HIGH);
    vTaskDelay(100);
    digitalWrite(LED, LOW);
    vTaskDelay(100);
  }
}

void setup()
{
  Serial.begin(115200);
  Serial.println("Serial start");
  pinMode(LED, OUTPUT);
  xTaskCreate(task, "task", 128, NULL, 2, NULL);
  vTaskStartScheduler();
}

void loop()
{
  for (int i = 65; i < 91; i++)
  {
    Serial.println((char)i);
    delay(1000);
  }
}

nucleo-l432kc

After wondering why it linked and loaded onto the board, but then crashed on the first freertos call, I just realized that the nucleo-l432kc isn't in the table showing that it's a tested device.

Not understanding the constraints of the port - is the 432kc something that should work even if not tested, or is this a bridge too far?

thanks.

Will not compile

Nothing I can do will make this compile.
`Compiling debug version of 'frBlink' for 'Maple Mini'

The STM32duino_FreeRTOS library encountered an unknown path resolve error.In file included from D*: Users\jfitter\Documents\Arduino\libraries\STM32duino_FreeRTOS\src/FreeRTOS/Source/include/portable.h:94:0
FreeRTOS.h:104: from
FreeRTOS.h:9: from
cmsis_os.h:101: from
cmsis_os.c:100: from

portmacro.h: 12:20: error: no "__CORTEX_M" definition
#pragma GCC error "no "__CORTEX_M" definition"

cmsis_os.c: 122:25: fatal error: cmsis_gcc.h: No such file or directory
#include "cmsis_gcc.h"
compilation terminated
Debug build failed for project 'frBlink'`

FreeRTOS CPU HSE Clock Configuration

Hello everyone,
I'm using an STM32F303CCT6 to control a TMC5160, a W5500 and some other stuffs. I'm using the STM32Duino FreeRTOS lib with the Arduino frameworks (In Platform IO, I'm not sure if it's a bug from PIO nor the lib ...). Everything is working fine except the clock system ... The max CPU frequency achievable is 72 MHz. I have a 32 MHz HSE on my board (homemade), I have generated my SystemClockConfig function with STM32CubeMX.

void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI
                              |RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV4;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.LSIState = RCC_LSI_ON;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  {
    Error_Handler();
  }
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB|RCC_PERIPHCLK_USART1
                              |RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_I2C1
                              |RCC_PERIPHCLK_RTC;
  PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_SYSCLK;
  PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_SYSCLK;
  PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_HSI;
  PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
  PeriphClkInit.USBClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  {
    Error_Handler();
  }
}

If I check HSE_IN with an oscilloscope I have my 32MHz, as soon as I remove the code above, my crystal stops running as expected. I would say that my clock hardware is fine.

Now, I have just created a dummy sketch to test things:

static void vTask( void * pvParameters)
{
  vTaskDelay(1);

  while (true)
  {
    SerialUSB.println(millis());
    SerialUSB.println(HAL_RCC_GetHCLKFreq()); // return 180 000 000, but should be 72 000 000 ?
    vTaskDelay(1000 / portTICK_PERIOD_MS); // should be a 1 sec delay, but it is rather a 100ms one ...
  }
  
}

void setup()
{
  SystemCoreClock = 72000000; // it has the same behavior with or without this.
  SystemCoreClockUpdate();

  SerialUSB.begin(115200);
  while (!SerialUSB);

  delay(1000);

  xTaskCreate(vTask, "task1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL);

  vTaskStartScheduler();
  
}

void loop()
{
  ;
}

This is the first time I'm playing with CPU clocks frequencies. I'm pretty sure I missed something in the documentation.

I tried:

  • Put board_build.f_cpu = 72000000 in the platformio.ini but I read that it's reserved for esp, isn't it ? And it doesn't work anyway, The task is still running 10 times a second;
  • Modify system_stm32f3xx.h to write SystemCoreClock = 72000000;
  • Re-write configCPU_CLOCK_HZ in my STM32FreeRTOSConfig_extra.h;
  • Re-write configTICK_RATE_HZ in my STM32FreeRTOSConfig_extra.h;

Nothing worked for now. If anyone has any idea, or documentation that I might have missed ...
Thanks for your help !

I've posted this on PIO forum too

Cannot build for STM32L552ZE-Q

I tried building for STM32L552ZE-Q but failed with the following message.

/tmp/ccjgv9nE.s: Assembler messages:
/tmp/ccjgv9nE.s:224: Error: selected processor does not support `vstmdbeq r0!,{s16-s31}' in Thumb mode
/tmp/ccjgv9nE.s:225: Error: instruction not allowed in IT block -- `mrs r2,psplim'
/tmp/ccjgv9nE.s:250: Error: selected processor does not support `vldmiaeq r0!,{s16-s31}' in Thumb mode
/tmp/ccjgv9nE.s:252: Error: instruction not allowed in IT block -- `msr psplim,r2'
*** [.pio/build/nucleo_l552ze_q/lib67e/STM32duino FreeRTOS/portasm.c.o] Error 1

It seems similar to #44 but STM32L5 is supported bu adba678 so I report this.

My environment

platformio 5.2.5
platform-ststm32 15.3.0

platformio.ini

[env:nucleo_l552ze_q]
platform = ststm32
board = nucleo_l552ze_q
framework = arduino
monitor_speed = 115200
lib_deps =
  STM32duino FreeRTOS

Is there any idea to avoid this error?

Thank you for sharing the useful library.

Hardfault on CMSIS OS v2

Hello,

I installed the library via Arduino library manager and tried running the examples on an STM32 blue pill.

all examples except the ones in CMSIS-RTOSv2 run fine. if I try to run the examples in CMSIS-RTOSv2 the MCU enters a hardfault with 3 (or 4) blinks immediately.

I narrowed the problem down to be from the CMSIS-RTOSv2 configurations because whenever I enable configUSE_CMSIS_RTOS_V2 the hardfault happens otherwise it runs fine.

I hope it helps.

Documentation suggestion for configCHECK_FOR_STACK_OVERFLOW and for LED_BUILTIN

The FreeRTOS web site says that one must implement function vApplicationStackOverflowHook when enabling configCHECK_FOR_STACK_OVERFLOW . This is not the case for STM32FreeRTOS as it is defined in STM32FreeRTOS.c and there is no option to override. Suggest to document this and to clarify that the user must ensure that LED_BUILTIN is defined in their variant.h for their board as vApplicationStackOverflowHook will hang (while 1) when stack overflow detected and flash the LED. At the very least of not documented, hopefully this post will be found by users through google and will be helpful.

Perhaps vApplicationStackOverflowHook and other error functions could be defined as weak in STM32FreeRTOS.c so that the user can override.

my task just run once

Hello, i have a problem..
i use this library in platformio for stm32l476 - nucleo..
i create 2 task just like example shown in Analogread_digitalread.
but all task just run once...
please help me.

xTaskGetTickCount and uxTaskPriorityGet don't work

environment:
Arduino-IDE(Ver1.8.5) + stm32duino + nucleo F103RB

code:

#include <STM32FreeRTOS.h>

void setup() {
  Serial.begin(115200);
  while(!Serial);
  Serial.println("Serial Start");
}

void loop() {
  static int counter=0;
  TickType_t nowTick;
  UBaseType_t Priority;
  
  Serial.print("counter="); 
  Serial.println(counter);

  nowTick = xTaskGetTickCount();
  Serial.print("nowTick=");
  Serial.println(nowTick);

  Priority = uxTaskPriorityGet(NULL);
  Serial.print("Priority=");
  Serial.println(Priority);
  
  counter++;
  delay(1000);
}

result:

nowTick=0
Priority=134218401
counter=101
nowTick=0
Priority=134218401
counter=102
nowTick=0
Priority=134218401
counter=103
nowTick=0
Priority=134218401
counter=104

Custom STM32FreeRTOSConfig.h usage with platform io

Hello,
I am using platform io with STM32FreeRTOS.
I am trying to modify some setting of the FreeRTOS, but the setting don't take effect and it always uses the STM32FreeRTOSConfig_Default(I think).
I have create a file named 'STM32FreeRTOSConfig.h' in my include directory and copied the setting form STM32FreeRTOSConfig_Default, and modified it.
I am using 'stm32duino/STM32duino FreeRTOS @ ^10.2.1' to add the library.

Message buffer is not supported

My envronment

I'm using STM32duino FreeRTOS for Platform IO.
stm32duino/STM32duino FreeRTOS@^10.2.1
https://registry.platformio.org/libraries/stm32duino/STM32duino%20FreeRTOS

Content of the problem

FreeRTOS Message Buufer feature is not supported.
A compile error will occur.

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

#define BAUDRATE 115200

MessageBufferHandle_t xMessageBufferTrans;
MessageBufferHandle_t xMessageBufferRecv;

void task(void *pvParameters)
{
  while(1) {
    Serial.println("task is running");
    delay(1000);
  }
}

void setup() {
  Serial.begin(BAUDRATE);
  Serial.println("serial (same as 4)");
  Serial.println("*****");

  portBASE_TYPE xTask = xTaskCreate(task, "TASK", configMINIMAL_STACK_SIZE, NULL, 2, NULL);
  configASSERT( xTask );

  // start scheduler
  Serial.println("Start Scheduler.....");
  vTaskStartScheduler();

  Serial.println("Insufficient RAM");
  while(1);
}

void loop() {
  // Empty. Things are done in Tasks.
}

Is it a good practice to change HAL time base to timer and free SysTick for FreeRTOS?

Hello all, I am starting playing with stm32duino + freertos + cmake + CLION and everything is working fine but I have doubt.
In my previous work with stm32cubeide + stm32cubemx + freeRTOS it was recomended to change HAL time base to any available timer and free the Systick for FreeRTOS, I have tried to do so but it looks no ovbious to redefine HAL_TIM_PeriodElapsedCallback function.

It has sense what I am trying to do, is it possible?
I will appreciate any hint on that matter.
Thank you very much.

Interrupts and Multiple Tasks Causing Usage Fault INVPC

Hi, this problem has been plaguing me for a while now and it is very hard for me to pin down the root cause.
My board is an Adafruit STM32F405 Feather. The symptom is a Hard Fault/Usage Fault with INVPC bit set to 1 (found out using J-Link/Ozone debugger).

In my setup, I can cause the fault to happen with the following conditions: there is at least one external interrupt triggering at a rate > 200 Hz (not a hard bound but a typical rate), and there are at least two tasks running at the same time. The interrupt handler can be dead simple (just incrementing its own counter) with no interaction with the FreeRTOS API. The tasks don't need to interact directly and no other primitives are needed to cause instability. The interrupt is triggered by another chip pulling the line down - it has its own clock and its on a custom board. The fault usually occurs within a few minutes time, if the tasks are switching context faster, then the fault tends to happen sooner.

Strangely, I cannot reproduce this fault by using the microcontroller to drive its own interrupt pin directly - this seems pretty stable. Later I will try to drive the interrupt from another microcontroller to see if having independent clocks will cause the fault.

I'm pretty desperate to get this working, any advice would help.

STM32FreeRTOS breaks I2C

Not a super detailed bug report, but just wanted to raise this issue.

Seems like if the FreeRTOS is included in the project (no FreeRTOS code is even in the binary), I2C or something lower-level than it breaks.

In particular, execution gets stuck in the first call to i2c_master_write() because HAL_GetTick() doesn’t get updated once inside the function, so:

delta = (HAL_GetTick() - tickstart) is stuck at 0.

Screenshot 2021-04-06 141235

I'm using platformio with Nucleo-64 G071 board.
Simply removing stm32duino/STM32duino FreeRTOS@^10.2.1 from library dependencies in platformio.ini fixes the problem.

Missing include file for message_buffer.h

Hi,

I'm trying to use FreeRTOS' message buffer implementation but there seems to be one file missing. All FreeRTOS' types have a include wrapper in src but the wrapper for message_buffer.h is missing. Could you add it 😃?

Calling vTaskDelay in loop() leads to infamous vListInsert death spiral

This problem took me a long time to figure out which line of code was responsible for my sketch hanging at a distant call.
Symptoms:

  • calling xQueueReceive on an empty queue with a finite timeout would cause a hanging of the kernel
  • debugging pointed to a forever loop in the function vListInsert (which is surprisingly common and can be caused by lots of things!)

Eventually I tracked it down to a line in the loop() function calling vTaskDelay

Now, since I thought loop is iterated by the Idle Task, shouldn't this be allowed?

I'm using an Adafruit STM32F405 Feather board, with setting:

#define configMEMMANG_HEAP_NB             3

Anyway, here is a simple sketch to reproduce the issue:

#include <STM32FreeRTOS.h>

QueueHandle_t  mQueue = NULL;

// HeartBeatTask, pulse the LED every couple of seconds
static void vHeartBeatTask(void* arg) {
  UNUSED(arg);
  pinMode(LED_BUILTIN, OUTPUT);

  while (1) {
    // Sleep for 2000 milliseconds.
    vTaskDelay((2000L * configTICK_RATE_HZ) / 1000L);
    // Turn LED on.
    digitalWrite(LED_BUILTIN, HIGH);
    // Sleep for 200 milliseconds.
    vTaskDelay((200L * configTICK_RATE_HZ) / 1000L);
    // Turn LED off.
    digitalWrite(LED_BUILTIN, LOW);
  }
}

static void vQueueRecvTask(void* arg) {
  UNUSED(arg);
  uint8_t pkt;

  // Sleep for 5000 milliseconds.
  vTaskDelay(pdMS_TO_TICKS(5000));

  while (1) {
    // attempt to receive from queue
    Serial.println(F("# trying xQueueReceive"));
    if (xQueueReceive(mQueue,&pkt,pdMS_TO_TICKS(5000)) == pdTRUE){
      Serial.print(F("# recvd pkt: "));
      Serial.println(pkt);
    } else{ //xQueueReceive timed-out
      Serial.println(F("# xQueueReceive empty"));      
    }
    
  }
}

void setup() {
  Serial.begin(115200);
  while (!Serial){}; //WAIT FOR SERIAL CONNECTION TO OPEN, DEBUG ONLY!

  // queues
  mQueue = xQueueCreate(1,1);

  xTaskCreate(vHeartBeatTask,NULL,configMINIMAL_STACK_SIZE+50,NULL,1,NULL);
  xTaskCreate(vQueueRecvTask,NULL,configMINIMAL_STACK_SIZE+50,NULL,1,NULL);

  // start FreeRTOS
  vTaskStartScheduler();

  // should never return
  Serial.println(F("Die"));
  assert_param(false);
}

void loop() {
  // WARNING this seems to cause sketch to hang after xQueueReceive blocks
  vTaskDelay(pdMS_TO_TICKS(10));
}

How to use other timebase for HAL, cause the freeRTOS use the Systick?

As we all know it, When using FreeRTOS, the CubeMX suggests not to use SysTick as timebase for the HAL. I believe this is because there is conflict between the HAL and RTOS use of the SysTick timer?
I found a bug that when I use stm32g070 with STM32FreeRTOS, I use the delay(10) in my setup() function before the osKernalStart, and my program will always in the delay(10) and never jump out, the HAL_Tick never increase cause they use the same timebase?

How to make the HAL use other timebase as TIM1, TIM2 or other to avoid the conflict?

I think it's a bug in freeRTOS config file?

Please look the L102
https://github.com/stm32duino/STM32FreeRTOS/blob/master/src/FreeRTOSConfig_Default.h

here is my result I think it should change to
#define configTOTAL_HEAP_SIZE ((size_t)(&_estack - (uint32_t)&_Min_Stack_Size - &_end))

I use printf to print the value of _Min_Stack_Size it always wrong, but I add the & as &_Min_Stack_Size , it will be the right value that I set in the ld file.

SO I the heap size shoud minus the _Min_Stack_Size set to 0x400?

STM32duino vTaskStartScheduler() problem

I have a STM32F103C86T with PL2303 to communicate over Serial. I have to implement STM32FreeRTOS but I’m having issues after I call vTaskStartScheduler() in my code. Whenever I call vTaskStartScheduler() after creating my tasks, onboard led of the STM blinks faster than I decided and stays ON for about 3 seconds then starts to blink again. While this happening, my tasks aren’t working at all.

I was trying to test the original example blink code right from GitHub but I couldn’t find a proper solution. Also, even I remove all the led codes from the example (including pinMode()), led still blinks.

/*
 * Based on Blink_AnalogRead example from: https://github.com/feilipu/Arduino_FreeRTOS_Library
 * Modified by: Frederic Pillon <frederic.pillon (at) st.com>
 */
#include <STM32FreeRTOS.h>

// define two tasks for Blink & AnalogRead
void TaskBlink( void *pvParameters );
void TaskAnalogRead( void *pvParameters );

// the setup function runs once when you press reset or power the board
void setup() {

  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);

  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB, on LEONARDO, MICRO, YUN, and other 32u4 based boards.
  }

  // Now set up two tasks to run independently.
  xTaskCreate(
    TaskBlink
    ,  (const portCHAR *)"Blink"   // A name just for humans
    ,  128  // This stack size can be checked & adjusted by reading the Stack Highwater
    ,  NULL
    ,  2  // Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
    ,  NULL );

  xTaskCreate(
    TaskAnalogRead
    ,  (const portCHAR *) "AnalogRead"
    ,  128  // Stack size
    ,  NULL
    ,  1  // Priority
    ,  NULL );

  // start scheduler
  vTaskStartScheduler();
  Serial.println("Insufficient RAM");
  while(1);
}

void loop()
{
  // Empty. Things are done in Tasks.
}

/*--------------------------------------------------*/
/*---------------------- Tasks ---------------------*/
/*--------------------------------------------------*/

void TaskBlink(void *pvParameters)  // This is a task.
{
  (void) pvParameters;

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
  Most Arduinos have an on-board LED you can control. On the UNO, LEONARDO, MEGA, and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN takes care
  of use the correct LED pin whatever is the board used.
  The MICRO does not have a LED_BUILTIN available. For the MICRO board please substitute
  the LED_BUILTIN definition with either LED_BUILTIN_RX or LED_BUILTIN_TX.
  e.g. pinMode(LED_BUILTIN_RX, OUTPUT); etc.
  If you want to know what pin the on-board LED is connected to on your Arduino model, check
  the Technical Specs of your board  at https://www.arduino.cc/en/Main/Products
  This example code is in the public domain.
  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
*/

  // initialize digital LED_BUILTIN on pin 13 as an output.
  pinMode(LED_BUILTIN, OUTPUT);

  for (;;) // A Task shall never return or exit.
  {
    digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
    vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second
  }
}

void TaskAnalogRead(void *pvParameters)  // This is a task.
{
  (void) pvParameters;

/*
  AnalogReadSerial
  Reads an analog input on pin 0, prints the result to the serial monitor.
  Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
  This example code is in the public domain.
*/

  for (;;)
  {
    // read the input on analog pin 0:
    int sensorValue = analogRead(A0);
    // print out the value you read:
    Serial.println(sensorValue);
    vTaskDelay(1);  // one tick delay (15ms) in between reads for stability
  }
}

I’d like to hear some ideas about it.
Thank you in advance,
Emre

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.