FunkOS - yet another RTOS for AVR

Go To Last Post
33 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've spent the last several months working on various personal hobby projects using AVRs, so I thought I'd write something that I could share with the community.

FunkOS is an RTOS written from the grounds up in C, with AVR as the primary target (although support for MSP430 is in there, too, with other targets pending).

Even though it just hit a first release, it's got most of the goodies you'd expect from a reasonably-capable RTOS:

-Fully preemptive kernel
-Multi-priority scheduling
-Synchronization and protection objects
-Driver interface
-Task-monitoring watchdog module
-Scalable - you only build the features you need
-Open-source, no restrictive terms for commercial use.

I've also tried to make the source easy to read and understand, keeping the API as simple as possible (and well documented).

At the moment I'm developing using SimulatorV2 for 644 and 323 parts, but haven't tested on real hardware.

You can download the latest version from the project page at:

http://www.avrfreaks.net/index.p...

Feedback is always welcome - let me know what you think!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Downloaded it today and yes the documentation is nicely done. Very readable had a look though the code and is quite clearly laid out so nice work.

I will have to build a test rig now to see how it performs.

Thanks for your efforts

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The documentation is very clear, and this seems to be a very easy-to-use SMALL OS. Great job, especially on the docs.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey all, I've put out a new release of FunkOS with a bunch of new features and drivers for AVR, mainly for graphics and user input. Check out the project page for more.

Cheers!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, it surely is a well-documented project, i just had a first glance at the download package. But i don't quite get how to actually build FunkOS, there's no makefiles, no build descriptions. Do i just code my application, include the right include files and that's it? Or is it supposed to be compiled separately and finally linked against my code?

Einstein was right: "Two things are unlimited: the universe and the human stupidity. But i'm not quite sure about the former..."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

(I'm pretty sure I just sent you this response over email, but this might be helpful for others)

The kernel has been designed to be built into the project - no separate build or linking steps required.

All you should have to do is copy the contents of the "kernel", "drivers" ,"config", and the appropriate "ports\AVR_GCC" folders into your project source. Be sure to either add a global define for "ARCH_AVR" in your project or somewhere in "types.h". Modify "kernelcfg.h" for the features you need in your project, and you should be good to compile.

If you want to use the device drivers or services, you copy them into your project folder the same way.

I'm sure you could also configure include directories to avoid having to copy out the source, but for my personal projects I haven't really found that necessary.

Good luck!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Might have been an idea to mention that in the .PDF perhaps? It's all very well documenting the API if no one know how to build/link it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've probably set up FunkOS projects a hundred times in WinAVR, so those steps are more of a reflex to me at this point. As much documentation as I've put into the project, there are still some glaring omissions. Too bad writing documentation isn't quite as much fun as writing the code behind it ;)

I'll definitely update the docs and put up a sample project.

Thanks for the feedback.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yo Mo... trying to compile myfirstapp.c for mega32 using iccv7avr... it keeps asking for taskcfg.h... all I can find is taskport.h.... where's taskcfg??

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey Bob. Find all references to taskcfg.h and replace with kernelcfg.h - that should get you moving. Lucky for you - only the mega323 port looks like it has that typo ;) I also haven't tried icc with FunkOS, so let me know how that works out.

Cheers!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh, and also taking a quick look at the mega323 port, in KernelTimer.c, replace line 11:
OCR1A = (USHORT)((4000000 / ( 10 << 6)));
with :
OCR1A = (USHORT)((SYSTEM_FREQ / TICK_FREQ) / 64) - 1;

I guess I also had the tick interval hard-coded for 10Hz w/a 4MHz crystal. Doh!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, I'll do you one better. Since I'm bored, stuck in a hotel on business, and wired on coffee, I downloaded the ICCv7 demo and put together a quick port. Since the file manager isn't working for me at the moment, I've put it on my sourceforge:

http://sourceforge.net/projects/funkos/files/

While it's a port of the 328p code, it should at least get you on the right track and you should only need to cut and paste the kerneltimer/kernelswi functions from the WinAVR port).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On closer inspection, I need to change some more things because of the different runtime model used in ICCv7 (two stacks vs. one used by GCC)... the port won't work until I fix that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay - ICC port for Mega323 and Mega328p parts has been tested successfully in the simulator. Download from my sourceforge and let me know if you have any problems.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yay! I converted the mega328 port to mega32 and copied mytask to mtask2 and made each one flash a port pin and it works!

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Great! I've added the latest version of the 328p MyFirstApp demo to the download page.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just for fun, I've ported FunkOS to C++ (WinAVR) as part of the R3 release, which is due out in a month or so.

A quick search around the tubes shows that this is the *only* multi-threaded C++ RTOS for AVR.

Surprisingly, the kernel is only about 20% larger than the vanilla C version, and the main portions like the scheduler/task modules are almost exactly the same size... in fact the only modules that end up taking up significantly more space are the mutex, semaphore, and timer classes.

While there is a bit of a hit in code size, I'm quite impressed at how much easier to read and easier to use the kernel ends up being in C++.

Since the project file upload seems to not be working at the moment, I'm adding it here (as well as on my sourceforge at https://sourceforge.net/projects/funkos/files/funkos/kernel%2B%2B.zip/download)

Anywho, it's still in Beta, but maybe someone here will get a kick out of it ;)

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

What exactly can a RTOS do for a microcontroller? Any examples or webpage links??

Thanks,

Alan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To ease the transition, for the developer, to embedded platforms where you really need a RTOS.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

What exactly can a RTOS do for a microcontroller? Any examples or webpage links??

It lets you write the various tasks in a program as what appear to be separate programs running completely independently. It's not quite the case that each has it's own main() but each will have something like TaskMain() and in each there can be the usual structure of initialisation and then infinite loop. Of course the tasks often need to interact with one another - one waits until another has done it's job, one flips the state of a variable in another, one passes a data stream to another. These things are achieved by semaphores, mutexes, queues, pipes and so on.

Whether the use of RTOS on something as resource limited as an AVR is another question. I always think there's a complexity boundary perhaps around the 32K..64K of code mark where maybe the cross interactions between various things being done by main and the various interrupt handlers becomes so complex that use of an RTOS is justified.

One of the "costs" of an RTOS is that various state information and local stacks must be maintained for each task (then the rest of RAM is free for use by all tasks using malloc()s off the heap). The per task cost can really "eat" through your RAM. In a mega168 for example I did an experiment using FreeRTOS and I think I managed to get a maximum of 5 simple tasks running.

For an explanation I always think this is very good (even if the web page layout is utter crap):

http://www.freertos.org/implemen...

Just keep following Next: at the bottom of each page to read through. What's nice is that the explanation is about the AVR (and, if you are familiar with it, avr-gcc in particular)

PS Sorry that this is a bit off topic for this FunkOS thread but I guess all RTOS are pretty similar in what they finally deliver - task scheduling/switching, sem4's, mutex, Q's, |'s etc.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No worries about hijacking the FunkOS thread - why not dust the cobwebs off?

Anyways, the "finished" version of R3 is out and is available for download from the projects page and sourceforge. New features:

-C++ port of the kernel (FunkOS++)
-Minimum round-robin kernel (Pipsqueak)
-Extensible GUI library (Fooey GUI)
-Buffered UART driver for AVR
-New AVR toolchain ports (IAR, ICCv7, codevision - Thanks, A. Shawqy)
-Enhanced documentation
-Updated demos
-Fixed a kernel initialization race condition
-FAT16/32 driver (requires an underlying SPI driver)

I hope you enjoy it, since this is probably going to be the last release. I start a new job in a couple of weeks where I'll be working on an RTOS kernel - so it's a bit of a conflict of interest now. If anyone's interested in picking up where I'm leaving off, they're more than welcome.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
I am a newbie I want to learn about RTOS RTOS on ATMEGA 2560 .. with FunkRTOS there anything you can give me a sample code with examples led blinky

embedded

Last Edited: Tue. Jun 2, 2015 - 02:39 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to point out that FunkOS is not the only RTOS for AVR - there a few. I have a (non-exhaustive and possibly slightly out of date) list here:

 

http://www.avrfreaks.net/forum/t...

 

BTW FreeRTOS is a very popular choice and because of that you will find a lot of threads and articles about it.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Indeed, FreeRTOS is very widely used indeed - and not just on AVRs.

 

http://www.freertos.org/

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DeniSafarani wrote:
I am a newbie

New to what, exactly?

 

If you're new to microcontrollers in general, then an RTOS is probably not the best place to start...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

If you're new to microcontrollers in general, then an RTOS is probably not the best place to start...

+10

 

On most AVRs there's almost no justification for wasting resources on an OS. Most AVR embedded applications simply consist of a main() loop and a handful of ISR()s handling the fast reaction stuff.

 

It's also not a particularly good environment for learning (RT)OS either. A desktop and a copy of pthreads (Linux/POSIX) or similar is probably a much better place to learn about the fundamentals of multi-threading. Widows has _beginthread()

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you sir clawson, lately I often open the site you send http://www.avrfreaks.net/forum/t... but I got the job using multiple RTOS RTOS in the list that you send in the forum avr freak , The following assignment of my lecturers, namely: FunkRTOS, NuttX RTOS, and picoOS. all RTOS should I apply on atmega 2560 with blinky LED example only .. I very difficult compile it, there's always an error and I do not see an example of how to write blinky LED or examples of other programs, there I felt unbelievably difficult. indeed many other RTOS that can be used on the AVR as FreeRTOS, YAVrtos, and AVR rtos .. but I have not got an assignment from my lecture about it ,,, may RTOS are already many examples. This task is long I was working and still unfinished as well .. I really hope somebody can help me give an example of the full with the blinky LEDs. in this work I am using AVR GCC application ECLIPSE

thanks to friends in this forum already responding to my questions and helped .. hehehe thanks .

embedded

Last Edited: Thu. Jun 4, 2015 - 01:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In other words, you want someone else to do your homework for you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sorry sir .. I mean not like that .. my homework instead of blinky LED .. maybe I can get inspiration from a blinky LED on avr .. sorry if I offended question ..wink

embedded

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I very difficult compile it, there's always an error

So this isn't about blinking LEDs at all is it? If you are saying you have taken the FunkOS distribution but can't compile it then show what you have attempted and what errors you get.

 

EDIT: I assume you are downloading FunkOS form this page...

 

http://www.avrfreaks.net/project...

 

That includes several demo .zip files - have you tried those? They are Stduio4 (+WinAVR) projects so I would start by loading them into that environment then, once a Makefile has been created, take that and the other files to whatever environment you actually want to use.

Last Edited: Thu. Jun 4, 2015 - 08:35 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DeniSafarani wrote:
The following assignment of my lecturers, namely: FunkRTOS, NuttX RTOS, and picoOS. all RTOS should I apply on atmega 2560 with blinky LED example only .. I very difficult...

Well, if your lecturers have given you this assignment, that means they expect that you should be able to do it!

 

If you are struggling to keep up with your course, you really should be discussing that with your tutors!

 

compile it there's always an error

This is certainly something you should be discussing with your lecturers!

 

Building an RTOS from source is rather different from just using it - if your assignment is just about using the RTOS, then you should be seeking help from your lecturers with the building!

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Andy,

 

I can kind of see where he's coming from. Not everyone has Windows and, of those that do, not everyone has a copy of the old AS4 so may not have a mechanism to handle .aps / .aws files found in the .zip downloads. I suppose one could ask AS6 to try and "import" it but personally my experience of import in AS6 has not been great and would likely bamboozle a beginner.

 

It does seem a real shame that when the author was using avr-gcc they didn't see fit to simply include a Makefile, even if it's just the auto-generated one from AS4. make works pretty much everywhere and once you've seen the code build successfully and the commands involved you can then work on getting the same to happen in one's chosen IDE.

 

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

thank you all who have helped to finally blinky with rtos can Funkos way too hehe 

thanks mr clawson

 

embedded