2

I have an AT90USB162 AVR chip which I want to run a multitasking RTOS, so I am evaluating possible RTOS for using with my AVR chip. Which multitasking RTOS's are supported by AVR? Maybe QNX? (Is it possible to run a QNX kernel on an AVR microchip?).

Thanks in advance.

Rego
  • 1,118
  • 1
  • 18
  • 40
  • Do you mean "RTOS" as in "Real Time..."? - Or are you just looking for preemptive scheduling? – JimmyB Oct 29 '11 at 14:03
  • I mean Real-Time Operating System. – Rego Oct 29 '11 at 17:07
  • 2
    @Hanno: Is there a pre-emptive scheduler for AVR that is not real-time!? – Clifford Dec 15 '11 at 10:29
  • Well, I once wrote one :) - But I seem to remember that there are quite some pre-emptive schedulers around for the AVR of which many lack any RT features for simplicity and/or resource usage. Most can easily be found in various AVR forums. – JimmyB Dec 23 '11 at 16:14
  • Since I come across a lot of confusion about alledged 'real time os-es', I think it should be noted what the term actually means: A real time os is in contrast to a -simpler- preemptively scheduling os; the aspect of real time and guaranteed, deterministic completion/response times is what makes the real time part, which can be found in any book on the subject aswell as on [Wikipedia](http://en.wikipedia.org/wiki/Real-time_operating_system). – JimmyB Jun 18 '12 at 21:00

5 Answers5

9

The Atmel AT90USB162 is an 8-bit AVR RISC-based microcontroller -- QNX would be a stretch, and AVR is not in their BSP directory

Micrium supports AVR with uC/OS-II

FreeRTOS also supports AVR

Doug Currie
  • 40,708
  • 1
  • 95
  • 119
  • Doug, do you know if uC/OS-II is opensource? (I assume FreeRTOS is opensource, isn't it?) – Rego Oct 25 '11 at 11:49
  • I'm not Doug, but uC/OS-II is open-source licensed software: http://micrium.com/page/downloads/source_code (you must register, create an account, and purchase a license if you want to use it in a commercial application.) – Kevin Vermeer Oct 25 '11 at 13:51
  • 2
    The ability to download the source is not the same as "Open Source", read the product's licence terms carefully rather than relying on anything stated here. The source for uC/OS-II is included with Jean Labrosse's book; that was previously the only way to get it. You cannot use it in a commercial product without purchasing a license. FreeRTOS is open source; it requires you to identify that FreeRTOS is used in any distributed product. If you do not want to do that OpenRTOS is identical, but commercially licensed and supported. – Clifford Dec 15 '11 at 10:36
  • I've tried running FreeRTOS on an AVR before, but it is severely limited due to the device memory... can only run a couple tasks, and it's easy to overflow the stack. – bobasaurus Mar 04 '16 at 23:16
4

When you say "RTOS", I presume you mean pre-emptive multi-tasking? I'm guessing (since this is an 8-bit AVR) you don't need a filesystem, network stack, etc.?

If you're looking for a tiny, pre-emptive multi-tasking kernel, you might want to check out the Quantum Platform - I've used it on very resource-constrained platforms like AVR & MSP430. Co-workers have used it on 8-bit 8051 and HC11 variants as well.

The QP's preemptive kernel (QK) is a run-to-completion kernel, which reduces its stack (RAM) requirements and makes context switching less resource-intensive (no TCBs, less context to save & restore).

There is a QP/C variant, which is "small", and a QP-nano variant, which is "tiny". Since those terms are absolutely meaningless without numbers, the QP-nano page has a comparison of kernel types & their typical sizes. For example (minimum figures provided): typical RTOS, 10K ROM, 10K RAM; QP/C - 8K ROM, 1K RAM; QP-nano - 2K ROM, 100 bytes of RAM.

The good thing is that all the code is available so you can download & try it & see for yourself.

Dan
  • 10,303
  • 5
  • 36
  • 53
  • 1
    The QP-nano link in the above answer has died; [link] About QP-nano™ (https://www.state-machine.com/qpn/) is another entry point. – HiTechHiTouch Apr 11 '18 at 06:49
  • @HiTechHiTouch -- thank you very much -- time flies! I've updated the URL in my answer thanks to your update. – Dan Apr 11 '18 at 20:34
3

QNX - not a chance! QNX is a relatively large and sophisticated OS for 32bit devices with MMU, providing not only kernel level scheduling but also file systems, fault-tolerant networking, POSIX API, GUI etc. Its most significant feature is its support for memory protection - each thread runs in its own virtual memory segment, so only runs on devices with appropriate hardware support.

What features do you want from your OS? On an 8 bit device it is only reasonable to expect basic priority based pre-emptive scheduling and IPC. Other services such as networking, filesystem, USB etc. are usually add-ons from the RTOS vendor or must be integrated yourself from third-party code.

The obvious choice if you want to spend no money is FreeRTOS. It is competent, though in some ways unconventional architecturally, even if fairly conventional at the API level. In my tests on ARM it had slower context switch times that other kernels I compared it with others I tested, but that may not be the case on AVR, and would only be an issue if you require real-time response times in order of a few microseconds. AVR has a rather large register set, so context switches are typically expensive in any case.

Atmel have a list of third-party support including RTOS at http://www.atmel.com/products/AVR/thirdparty.asp#. They list the following:

  • CMX Systems, Inc: CMX-RTX, CMX-Tiny+ (Add-ons: CMX-MicroNet, CMX-FFS)
  • FreeRTOS.org: FreeRTOS
  • Micriµm, Inc: µC/ OS-II
  • Nut/OS: RTOS and TCP/IP stack with a Posix-like API.
  • SEGGER: embOS

I have personal experience of CMX-Tiny+ (on dsPIC), embOS (on ARM), and FreeRTOS (on ARM), and uC/OS-II. They are all competent, uC-OS-II has the minor restriction of only allowing a single task at each priority level (no round-robin scheduling), but consequently probably faster context switches. In the case of embOS I have, successfully integrated third-party file-system and USB code, though the vendor has their own add-ons for these as well.

Clifford
  • 88,407
  • 13
  • 85
  • 165
0

Though not a direct answer to your question, being 8 bit controller with limited resource, think of the advantage before committing to an OS Layer, the advantage of an OS layer will be beneficiary only when the project has to handle major subsystems that are tedious to code and maintain ex. file system, graphics, audio, networking, etc.

Since most of the suppliers provide integrated development environment and standard libraries and more over you can write code with high level languages like C, C++, for simple controls task sticking to your own frame work will be much more manageable

Raj
  • 1,156
  • 11
  • 15
0

Athomthreads is a lightweight RTOS supported by AVR. It supports:

  • Preemptive scheduler with 255 priority levels
  • Round-robin at same priority level
  • Semaphore
  • Mutex
  • Message Queue
  • Timers

It is open source and has about 1k lines of code. By comparision, the demo project for AVR build with Eclipse produces a .bin file of 96 to 127 kb. Of course FreeRTOS has more features (like memory management, including dynamic memory) and better security. But if you only need multi-threading atomthreads is nice.

Here is a comprehensive comparison between multiple RTOSs.