Excellent ) I would be grateful if you could post a link (to the FreeRTOS part) in the FreeRTOS Interactive site. Here is a link to the Atmel specific forum:http://interactive.freertos.org/forums/103473-atmel

...or do you think I should create an Arduino specific forum?

There is also a demo that uses Atmel Studio 6 with GCC in the latest Atmel Software Framework (ASF) distribution (http://asf.atmel.com)

Regards,Richard (http://www.FreeRTOS.org)

mcgski

Has anyone tried to use Memory Pools and Mailboxes in this port? Here's my two questions:

1) I'm seeing some odd behavior in the mailboxes, particularly in the first pull from the mailbox. The data of the object pulled seems corrupted though I suspect it's some header information. Likely pilot error.

2) Also seeing "junk" at the top of every memory pool item allocated. Again, I think from reading the ChibiOS forums and documentation I think this is the pool header though some examples on the ChibiOS forums do not show this needing to be exlicitly defined in the memory structure.

Here's the code in question. Two small tasks delaying a second each, posting to the mailbox a seconds counter, and a third task picking it up and displaying it on an LCD. Pretty simple stuff. Notice I do a bit of error checking on the content to weed out the first mailbox data error.

//------------------------------------------------------------------------------// LCD Thread - This thread waits on a Mailbox (FIFO Queue) and depending on who// sent the message, displays in the proper quadrant of the LCDstatic WORKING_AREA(waLCDThread, 64);

// Here we can muck with the LCD because nothing in the RTOS system is initialized clearDisplay(&mainLCD); setLCDCursor(&mainLCD, 2); // Set cursor to the 3rd spot, 1st line mainLCD.print("Initializing"); setLCDCursor(&mainLCD, 16); // Set the cursor to the beginning of the 2nd line mainLCD.print("RTOS System...");

// From here on, only the LCD thread should handle this hardware.

halInit(); chSysInit();

// add each element to the pool // this is the least obvious part of the process, as far as my experience went

I added a function, chBegin(), that calls these functions and fills the stack and never returns on AVR. On ARM chBegin() totally changes stack use and must be called.

I assume you are using the AVR version. You should be able to call these functions on AVR but you must not call any other ChibiOS functions before these calls and interrupts must be disabled when you call the functions. chSysInit will enable interrupts.

I did not enable memory pools and did not try this feature. I assume you enabled memory pools since your code compiles.

I didn't see a call to chPoolInit(). I believe the init call should replace this:

I have several other mysteries so I am planing to port the ChibiOS testsuite to the Arduino environment. That may take some time.

You might download ChibiOS and look at the testsuite functions as examples.

Sorry I can't be of more help. I am very interested in what you are doing so please don't worry about posting too much code. I will be happy to help find problems by writing or looking at example code.