Porting FreeRTOS from Atmel Studio to Arduino Due

Hi,
I was wondering if somebody here have tried to port freeRTOS to Arduino Due using Atmel Studio.
I have seen in Atmel Studio that they have an extension called FreeRTOS but I don't know how to use it.
Have anybody else tried it?

Hi,

cool, i am also working with FreeRTOS on Arduino Due
See http://www.freertos.org/Atmel_SAM3_SAM3X-EK_SAM3S-EK2_RTOS_Demo.html

Hi,

I just got freeRTOS running on my Due. I use the version that is included in Atmel Software Framework (in Atmel Studio).

What i have done so far using freeRTOS:

  • Create two tasks. One that executes every x ms and one that executes as soon there is something in the queue.
  • Create a queue to communicate between tasks.
  • Use TWI and USART (no UART yet though, the freeRTOS port does not seem to support that)

A note on using Atmel Studio and the Arduino Due. The TWI implementation in Atmel Studio has a bug that causes it to always return successes when writing just one byte to the slave, even when there is no slave connected to the bus. This is no problem when using the freeRTOS implementation in ASF since it is using the PDC, but instead there is a different problem. The freeRTOS TWI implementation require that an internal address for the slave is used and will return an error message if it is not. Both of these problems are quite easy to fix, and if anyone is interested I will post my solutions.

Is your port able to work on the Mega 2560 and does it have Ethernet Support?

I am working on a port using the Mega and Wiznet 5100 support, have not yet worked out where/how to support the TCP/IP stack in it yet.

Sid

My setup would not work on the mega, and it does not have Ethernet support. FreeRTOS does have a TCP/IP library, but it is unfortunately not free.

I ported FreeRTOS to AVR boards, Due, and Teensy 3.0. The current version is FreeRTOS20130208.zip Google Code Archive - Long-term storage for Google Code Project Hosting..

I ported FreeRTOS as an Arduino library so the Arduino IDE is used.

I will be updating the various RTOS libraries when Arduino 1.05/1.53 is released since yet another fix for malloc will break the AVR versions of the RTOS libraries.

@fat16lib: I am using your library in Arduino IDE over Arduino Megs 2560 R3. I have written a simple program to blink two LEDS. But only one of them blinks. Following is my code:

// Simple demo of three threads
// LED blink thread, print thread, and idle loop
#include <FreeRTOS_AVR.h>

const uint8_t LED_PIN = 13;
const uint8_t LED_PIN_2 = 2;

volatile uint32_t count = 0;

// handle for blink task
TaskHandle_t blink;
TaskHandle_t blink2;

//------------------------------------------------------------------------------
// high priority for blinking LED
void vLEDFlashTask(void *pvParameters) {
pinMode(LED_PIN, OUTPUT);

// Flash led every 200 ms.
while(1) {
// Turn LED on.
digitalWrite(LED_PIN, HIGH);

// Sleep for 50 milliseconds.
vTaskDelay((50L * configTICK_RATE_HZ) / 1000L);

// Turn LED off.
digitalWrite(LED_PIN, LOW);

// Sleep for 150 milliseconds.
vTaskDelay((150L * configTICK_RATE_HZ) / 1000L);
}
}
//------------------------------------------------------------------------------
void vLEDFlashTask2(void *pvParameters) {
pinMode(LED_PIN_2, OUTPUT);

// Flash led every 200 ms.
while(1) {
// Turn LED on.
digitalWrite(LED_PIN_2, HIGH);

// Sleep for 50 milliseconds.
vTaskDelay((50L * configTICK_RATE_HZ) / 1000L);

// Turn LED off.
digitalWrite(LED_PIN_2, LOW);

// Sleep for 150 milliseconds.
vTaskDelay((150L * configTICK_RATE_HZ) / 1000L);
}
}
//------------------------------------------------------------------------------
void setup() {
Serial.begin(9600);
// wait for Leonardo
// while(!Serial) {}

// create print task
xTaskCreate(vLEDFlashTask2,
"Task1",
configMINIMAL_STACK_SIZE + 100,
NULL,
tskIDLE_PRIORITY + 3,
&blink2);

// create blink task
xTaskCreate(vLEDFlashTask,
"Task2",
configMINIMAL_STACK_SIZE + 50,
NULL,
tskIDLE_PRIORITY + 4,
&blink);

// start FreeRTOS
vTaskStartScheduler();

// should never return
Serial.println(F("Die"));
while(1);
}
//------------------------------------------------------------------------------
// WARNING idle loop has a very small stack (configMINIMAL_STACK_SIZE)
// loop must never block
void loop() {
// while(1) {
// // must insure increment is atomic
// // in case of context switch for print
// noInterrupts();
// count++;
// interrupts();
// }
}