Is freeRTOS900 broken?

Working libraries, libraries being ported and related hardware
Post Reply
User avatar
Mangy_Dog
Posts: 92
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Is freeRTOS900 broken?

Post by Mangy_Dog »

Im having real trouble getting this working on my project.

Its really strange that at one point I got one of the tasks working, but then it stopped and never worked again. Even though nothing has really changed.
When i call xTaskCreate the program hangs.

Code: Select all

TaskHandle_t checkButtons =NULL;
is in global scope I have also tried without "=NULL"

In setup

Code: Select all

xTaskCreate (buttonCheck, "buttons",
	configMINIMAL_STACK_SIZE,
					NULL,
					tskIDLE_PRIORITY + 2,
					&checkButtons);
					
					
vTaskStartScheduler ();
and I have the task

Code: Select all

static void buttonCheck (void *pvParameters)
{
	while (true)
		{
			inputCheck();
			reedCheck ();

			vTaskDelay (5);
		}
}

What am i doing wrong? or is the library broken?
Just a dogs body developer, mostly making props and stuff...
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Is freeRTOS900 broken?

Post by mrburnette »

You provide little to no background info and I am not inclined to backtrack your posts to determine the board and uC model you are using. It is most helpful to repeat basic information with new post.
Mangy_Dog wrote: Mon Nov 09, 2020 7:13 pm ...What am i doing wrong? or is the library broken?
viewtopic.php?f=2&t=673

https://github.com/stm32duino/STM32Free ... ertos-v90x
The above link shows that not all boards passed all test examples.

Have you tried one or more basic examples?


Ray
STM32duino_FreeRTos.jpg
STM32duino_FreeRTos.jpg (20.55 KiB) Viewed 8085 times
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Is freeRTOS900 broken?

Post by fpiSTM »

I guess @Mangy_Dog talk about this one:
https://github.com/rogerclarkmelbourne/ ... reeRTOS900

using libmaple core.
User avatar
Mangy_Dog
Posts: 92
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: Is freeRTOS900 broken?

Post by Mangy_Dog »

Im sorry, yes the libmaple core freertos900.... And for f103

Also basic examples are working...

Also im having a strange issue... I can get 1 task working, but tasks created after it dont work and the code actually just gets stuck inside the task, and not making it to vTaskStartScheduler ();

Ive placed a blink just before the vTaskStartScheduler ();, and that doesnt activate but 1 task would run. At least for a while...
Just a dogs body developer, mostly making props and stuff...
User avatar
Mangy_Dog
Posts: 92
Joined: Sat May 02, 2020 11:45 pm
Answers: 1

Re: Is freeRTOS900 broken?

Post by Mangy_Dog »

Ok small update,
All my tasks are running as they should. as is suspending and resuming....

I found what was blocking the tasks that weren't working (forgot a while loop)

But i do have 1 very strange issue, which what was confusing me tons before and lead to me making this thread.

Im placing the bulk of my xcreatetask calls in the setup portion of the program.

The really strange thing is, any code i place after a xcreatetask, doesnt execute... UNLESS its another xcreatetask, and i assume vTaskStartScheduler, as the tasks seem to run.

Literally If I place a LED GPIO to turn the led on. The led wont turn on but the subsequent xtaskcreates would create their task.

Is this normal behavior?
Just a dogs body developer, mostly making props and stuff...
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Is freeRTOS900 broken?

Post by stevestrong »

Sorry but I have no experience with RTOSs.
Victor was using it a lot, but he is not active anymore in this forum.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Is freeRTOS900 broken?

Post by mrburnette »

I use FreeRTOS but under the Espressif ESP32 multicore architecture.

I took a quick look at some online examples for Arduino and it appears that there is a lot of wiggle-room in how authors set things up. From what I can tell without getting too deep into a rabbit hole is that once the scheduler is started, you can add tasks but single line code that is in the setup{} no longer runs. Some implementations (flavors) pin the loop(){} block to the idle queue, so code in loop() may execute, but unscheduled and at the lowest priority.

So IMO, "yes" what you are witnessing is normal behavior. (For the way the Maple RTOS library is configured.) But I would not rely upon the behavior crossing into another flavor or FreeRTOS, say on the ESP32.

My honest opinion is that using FreeRTOS on a single core uC is simply resource wasteful. Everything can generally be done without the overhead; however, FreeRTOS does have a legitimate use when forcing tic allocation between competing code segments, maybe updating two displays that have different backend functions.

From an example in the Roger's core under the FreeRTOS library. It appears that putting Arduino commands at the end of setup() does not work because the scheduler has already been activated. In loop() the word "background" is meant to be the sum of all free time allocated by the scheduler (technically, unallocated time.)

Code: Select all

#include <MapleFreeRTOS900.h>

static void vLEDFlashTask(void *pvParameters) {
    for (;;) {
        vTaskDelay(1000);
        digitalWrite(BOARD_LED_PIN, HIGH);
        vTaskDelay(50);
        digitalWrite(BOARD_LED_PIN, LOW);
    }
}

void setup() {
    // initialize the digital pin as an output:
    pinMode(BOARD_LED_PIN, OUTPUT);

    xTaskCreate(vLEDFlashTask,
                "Task1",
                configMINIMAL_STACK_SIZE,
                NULL,
                tskIDLE_PRIORITY + 2,
                NULL);
    vTaskStartScheduler();
}

void loop() {
    // Insert background code here
}
As Steve stated, victorpv was the more knowledgeable FreeRTOS individual when considering Roger's (libmaple) core and I have not seen him around the forum in a while ( Last active:Thu Jan 23, 2020 10:42 am)

For readers that may wonder what an appropriate use-case may be for FreeRTOS on the Arduino microcontroller platform, I have found this article to be enlightening: https://microcontrollerslab.com/arduino ... resources/

Here is the key quote of why the RTOS is useful:
Receiver Task

“TaskLcd” is a receiver task that reads structure data from struct_queue. The receiving task has the highest priority. Therefore, at the start of program execution, it will run first, but it will enter the blocking state. Because the queue will be empty. Hence, it will execute as soon as when one of the senders will write data to the queue.
Using an ESP32 and the already linked FreeRTOS, I think just publishing the results to a web-server page would be more fun than to a serial console.

Allow me to briefly elaborate on the above statement for context. ESP32 using Arduino already binds the FreeRTOS services into the Arduino code. Therefore, using these services does not significantly affect the size of the user binary / flash usage. And, if one is not using the RF section and dedicated processing core, you can easily direct Arduino functions to process on both cores. Even using WiFi, there is generally unused capacity on core_0 (RF section) with core_1 dedicated to Arduino.


Ray
Post Reply

Return to “Libraries & Hardware”