Home News Features Examples Code FAQ License
AVR Webring
Prev Hub Join Rate Next
Femto OS: RTOS for small MCU's like AVR.

What is this?

The Femto OS is a very concise portable real time - preemptive operating system (RTOS) for embedded microcontrollers with minimal ram and flash, say 2KB .. 16KB flash and 128 .. 1024 bytes ram. The main target is the Atmel AVR architecture, such as the ATtiny or smaller ATmega series. The OS runs well on larger hardware also. The system is written in C with a separate port file. Porting has been done for 44 AVR devices.

The typical footprint is between 1K and 4K flash, depending on the functions used. Somewhere around 2K for the OS itself is realistic figure for normal applications. The OS takes between 10 and 20 bytes of ram, tasks can take as little as 6 bytes of ram, but approximately 20 to 40 bytes is more realistic for real applications. Figures are including the stack. It is perfectly possible to run 4 or more tasks on an ATtiny261. There is no separate idle task and most api function calls run in OS space. The OS is interruptible most of the time, if needed. There are tools to watch and protect the use of the stack of the tasks and the OS.

The code itself is heavily documented, and comes with a number of example applications, (which are minimally documented, but are intended to speak for themselves). Demo's run on all devices for which a port is available. Most of the demo's run directly on the STK500/STK501/STK503 boards, some require extra (but very simple) hardware. Femto OS is distributed under GPLv3 but a commercial license and support are available.

Femto OS basics in Figures

Maximum number of tasks: 16
Maximum number of priorities: 8
Maximum number of locks: 15
Minimum tcb size per task: 2 bytes
Minimum stack size per task: 4 bytes
Minimum OS stack size: 9 bytes
Minimum OS other ram usage: 3 bytes
Smallest application: 258 bytes
Ports (Atmel)
mega128 mega3250 mega88P
mega1280 mega3250P tiny2313
mega1281 mega325P tiny24
mega1284P mega48 tiny25
mega162 mega48P tiny261
mega164P mega64 tiny43U
mega168 mega640 tiny44
mega168P mega644 tiny45
mega16 mega644P tiny461
mega2560 mega645 tiny48
mega2561 mega6450 tiny84
mega324P mega8 tiny85
mega328P mega8515 tiny861
mega32 mega8535 tiny88
mega325 mega88  
OS Load
Checks on, 1KHz tick, 8MHz clock: 19%
Checks off, 1KHz tick, 8MHz clock: 9%
Checks off, 1KHz tick, 16MHz clock: 4%
Checks off, 100Hz tick, 16MHz clock: < 1%

Femto OS is specially made for small embedded devices. For example, the 'Smallest application' is the application called 'Bare' compiled for the ATmega8. It solely runs a 16 bit led counter on the idle task hook. It consumes 258 bytes of flash and 10 bytes of ram. Femto OS is specially designed for gcc, and the generated executeable depends on preprocessor processing of the source code. Therefore, Femto OS is bound to the limits given above. If you need to run more than 16 tasks, or more synchronization primitives, you need to use an other OS, such as the FreeRTOS for those applications.

Femto OS roadmap

The OS is fairly complete by now, although there is always room for more. I will however not add any code that increases the core code of the OS. Adding optional functionality (i.e. which can be left out depending on the configuration parameters) can be taken into consideration. I have some small wishes, like a simple heap manager.

Most important for me in the near future is making it rock stable. I have one implementation of version 0.82 on a ATtiny861 continuously running from april 2008 now! Then i will probably work on some kind of IPv2, to couple multiple avr's, and maybe a kind of IP stack (Femto IP).

Femto OS demo application in Figures

Below find the sizes of the code (in bytes) for several test applications (OS included, ready to run). This is to give an indication what we are talking about. Numbers are for the ATtiny861. More about these examples can be found on the page 'examples'.

Application FLASH RAM #tasks Short description
Bare 270 10 0 Counts with leds in the idle 'task'.
Minimal 590 29 2 Copies the switches to leds.
FlashLeds 1004 47 8 Runs eight leds independently flashing.
Watchdog 1762 184 10 Watchdog catching a crashed task.
Rendezvous 1366 210 9 Multiple rendez-vous synchronizing.
Queues 1866 116 3 Pumping data through a queue.
Sleep 1242 76 3 Low power sleep in between led blinking.
Hooks 794 35 1 Show how to use the system hooks.
Interrupt 2246 264 4 Show the different interrupt modes.
Shell 6874 373 10 Eight leds blinking controlled by a shell.
Passon 1914 293 10 Testing use of simultaneous mutexes.
Remember 2632 368 5 File system stress test.
HelloWorld 960 48 2 Displays Hello World in ascii.

Note that the numbers above may slightly differ depending on the port. Smaller devices usually produce smaller footprints. Apart from "Bare", "Minimal" and "FlashLeds" the applications above are not designed to be as small as possible. Note for example that FlashLeds uses almost the minimal ram. The tcb is 2 bytes larger than the minimum due to the delay information. This application uses a shared stack for all tasks, with the minimum size of 4 bytes. Calculation: 4 bytes per task, 8+3=11 bytes for the OS, 4 bytes for one stack, thus total 4x8+11+4=47 bytes.

Femto OS motivation

The Femto OS project (which is a total 'spare time' project) commenced in august 2007. The whole system was written from scratch. I was inspired by the FreeRTOS (who did a wonderful job, but was to large for the ATtiny devices for anything serious) but my OS is a totally different product.

The name Femto OS is meant to indicate that the OS is really small, significantly smaller than pico]OS, but that room is left for an even smaller OS (atto OS). An other nice point was that, at the moment i started writing, the keyword femtoos not only had a free domain, but that it was totally unused on the internet, see the google search. Truly amazing, a keyword of seven letters and no hits! Btw, Yahoo obtained the same result.

Contact: info@femtoos.org   CC-BY License: Ruud Vlaming.