Go Down

Topic: DuinOS: small and simple rtos (Read 84291 times) previous topic - next topic


Sorry, but it is not a memory issue.
I moved the HEAP size down to as low as 200 and still no difference.
WiShield SimpleServer works until I choose the ATmega328 + DuinOS board in the IDE.

The only feature of FreeRTOS that I found was uxTaskGetStackHighWaterMark() which returns STACK information, not HEAP info.

I'll continue my quest for a software conflict.


You will still need to lower the default heap size for FreeRTOS in order to use the SimpleServer example of WiShield.  When I compiled that app with FreeRTOS and using the default 1200 byte heap size it was using 2352 bytes of SRAM which is obviously too much.


Thanks for all of your help. I am new to the Arduino platform and have not been able to find the info that I need without asking.

So, how did you determine that it required 2352 bytes of RAM?


Dec 09, 2009, 04:16 am Last Edit: Dec 09, 2009, 04:17 am by chumbud Reason: 1
See the post here on how to manually calculate the static memory usage:

There is also a binary called avr-size that is available on some platforms that will do this for you.  It is something the Arduino IDE probably should be doing automatically for you but doesn't.


Hi, is there a repository (svn, git, whatever) of this project?
The forum isn't really comfortable to keep track of changes.


Dec 09, 2009, 03:40 pm Last Edit: Dec 10, 2009, 02:02 am by juliandasilva Reason: 1
We will put online it as soon as possible. I think it will be a wiki, as chumbud suggested. We released the v0.1 Alpha as soon as it was ready (or something similar to ready), and are working on the project, which is part of a bigger project. We have finished this week a lot of things (but not directly related to DuinOS) and I hope will have news soon.

Regards, and thanks!

Mark G.


Good stuff.  Thanks for doing this.  I'm an old embedded systems programmer who's been away from it for about 20+ years.  I cut my teeth with preemptive multitasking systems so it's good to have something familiar in the Arduino environment.

I've been reading on the FreeRTOS site and others and it looks like the taskENTER_CRITICAL() just disables interrupts.  Help me connect the stale synapses in my brain on the matter.  If I am updating data in an interrupt routine then I'm pretty safe but in tasks I need the critical sections to ensure nothing gets changed by an interrupt.  

What about println() functions?  Are they thread safe?  I got the impression they are not.

Anyway, keep up the good work.  Can't wait until your next rev.  Let us know if there's an area you'd like us to work on.


Hi Mark, thanks for your comments. The critical sections are not necessary in most cases. Just when you are making something very time-critical (for example emulating by software bus protocols, like OneWire, wich is not working yet with DuinOS).

The taskENTER_CRITICAL() disables the interrupts and saves the SREG, but because the FreeRTOS kernel is portable, it may be doing something else in other MCUs.

Regarding the println functions, they seem to be working. Looking at the code, I do not expect problems with them (did you see something wrong?), please tell me if if there is any issue.

One open issue where it's possible to do something is the mentioned OneWire library.  Another possibilites are writing examples.

Many thanks! and regards,


Your comment about the OneWire interface makes me want to ask about the other interfaces.
Do you have the SPI and Two Wire systems working with DuinOS?


We did not test them yet, but:

- According to other users previous posts in this forum, the I2C is working.

- The main problem with OneWire is that it uses a lot of delayMicroseconds, and that it emulates by sofware the bus. By other hand, I2C (well TWI here) and SPI are mostly done by the AVR's hardware, so I expect them to work, just like the serial works,



Dec 27, 2009, 07:01 pm Last Edit: Dec 27, 2009, 07:05 pm by juliandasilva Reason: 1
Hi, we have the DuinOS wiki on line! It's a small wiki yet, but please make it grow!

The main page URL is:


And here is the Tracker page, where everyone can comment which Arduino libraries are working, which are not, and report bugs:


Many thanks in advance for your contributtions here!




This is just great!.  I've been looking at FreeRTOS and other OSes for microprocessors like Micrium's. I'm working on my first robot and pre-emptive multitasking seems such a natural fit for robot software.

Now to find a JavaVM for the Arduino. Perhaps the Mega.

The only thing about these small OSes, though,  is there is no memory management/protection which can make debugging a real beast.



Hi Dennis, thanks for your comments!

Regarding the VM, I think one of the biggest advantages of Arduino over other platforms (like stamps, or the ones based on Java) is that it executes native code. But, if you really want a VM, you can try this one  (I did not test it and it's not Java, it's Python):


and yes, for the Mega, as you said, cause the M328 is too small to fit it.

Well, good luck with your robot! Please feel free to contribute to the wiki, or if you have sample code running with DuinOS it's welcome too!


Mark G.


I'm having trouble with Serial.println() locking up my Seeeduino Mega.  I have a simple PIR on the pin 3 interrupt that toggles a state value when changed.  It gives a binary semaphore that the task loop is waiting on.  The Loop() routine is just spitting out text to let me know it's alive.

The task prints out a string followed by a byte hex value (eg. Serial.print(PIR_state, HEX) ).  Seems if I just spit out text is fine, but any value stops things up good.

To simplify things, I had the loop() function give the semaphore and the same thing happened - text worked, values did not.

I added the #ifdef statements you suggested for SerialHardware.cpp and .h.  Any thoughts?

Let me know if you'd like me to post on the bug tracker.


Hi Mark, could you upload the whole code here so we can test it? Then if it still does not work, you can add it to the Tracker.

Of course, as the documentation is a wiki, you can add it there directly, but I think by the moment more people will read the code here first and may suggest a solution.



Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131