ChibiOS/RTand FreeRTOS for Teensy 3.0

Status
Not open for further replies.
For starters, here is my step one to get FreeRTOS on the Teensy3.1 : Getting and configuring the code. I took something already made by Erich Styger famous for is work MCU on Eclipse. I like the guy very much, he takes the time to reply on every comment or question post ed on the site : http://mcuoneclipse.com/.

All the golden stuff is on the github and has lots of exemples for the real deal K20DX50VLH5 or K20DX72VLH7 setup with CodeWarrior, etc. check it out if you want to get serious with coding on a freescale platform : https://github.com/ErichStyger/mcuoneclipse

If you download the ZIP youo can browse into the exemples because work as already been done to port FreeRTOS to ProcessorExpert (kinda GUI for the CodeWarrior that auto-magically generates code for the processor) and it was done with the version 8 of the RTOS. You can find it in the folder "\Examples\FreeRTOS_Ports\CodeWarrior\CW_FreeRTOS_FRDM-K20D50M\Sources". So the config file is mostly done but if anyone has some comments on configuring it for the Teensy, that would be much appreciated.

Next step is to follow the "recipe" on this blog : http://rishifranklin.blogspot.ca/2014/03/freertos-on-teensy-31.html and not fall into the many lurking pits... TBC

Mevon

EDIT : learning the hard way makes for better lessons :S Well turns out adding this library to arduino gives me success with the given exemples, for now the blinky print one works. Try this : https://code.google.com/p/rtoslibs/downloads/list?q=label:Arduino and get the FreeRTOS 7.4.2 update RTOS Arduino. Works just fine for a 1yo code. :D Happy FreeRTOSing!
 
Last edited:
Are you guys still struggling to get FreeRTOS running - more than just using the contributed port that uses Teensyduino + one software interrupt for task state saving?
I've used that - works OK.
 
stevech no I think i got it under control now, but yeah maybe it would be nice to have to the latest and greatest version 8.0.1.... To be continued.

Mevon
 
I'm really curious about this, are the advantages in scheduling and "multitasking" / "multithreading"?
Does it work?
I guess I am curious what is the objective of using rtos on a small micro controller,
would the advantages gained outweigh the memory cost?
 
In my opinion, It is completely about what you are trying to do and how you want your application to scale.

In a single threaded 'SuperLoop' style application the simple timing and rapid coding are great for simple things.. As soon as you have multiple independent operations being taken care of by the processor you will need to develop infrastructure that helps isolate and insulate the independent operations from each other. As this get's larger you get closer and closer to writing your own buggy RTOS...

The packaged RTOS is reasonably small and generally can be tailored down to a more minimal size.. It's already debugged and allows you to work on your programs purpose and not building and debugging infrastructure... One of the other benefits is that it allows you to write separate tasks for logically separate operations. Keeping a task bug free and reliable once written is easier than function n of a set or array of function pointers that all are called in turn.

I'm sure other folks have more valid opinions.. I've targeted 15 or 20 applications on Teensy processors and have yet to run out of memory, These days I always start out getting the OS up first.

Mil
 
I'm really curious about this, are the advantages in scheduling and "multitasking" / "multithreading"?
Does it work?
I guess I am curious what is the objective of using rtos on a small micro controller,
would the advantages gained outweigh the memory cost?
Does it work? Yes, millions of small embedded systems are in use with an RTOS.
Two kinds of RTOSes: preemptive scheduling and cooperative scheduling. For a beginner, the latter should be used to avoid races, deadlocks, etc.
A finite state machine can be used for most "tasking" and "threading", and is simpler.

The answer to your questions have to come from reading a book or on-line summary of RTOSes 101, then look at examples, then try it yourself.
FreeRTOS is very popular among many.
Read about finite state machine software too.
 
Hello Bill,

First of all, thanks for a huge work on porting those RTOSses to teensy! I wrote a small program using your port of ChiBios and it works great when I build it in Arduino IDE. However, my needs are exceeding capabilities of this small IDE so I tired moving to building and deploying my project using makefile and this template:
https://github.com/apmorton/teensy-template
Here is where I have a problem with ChiBios. When I copy your library to libraries folder it gets compiled when I run make. I get following error that I can't seem to work out:

<path_to_project>build/libraries/ChibiOS_ARM/ChibiOS_ARM.o: In function `chBegin':
<path_to_project>libraries/ChibiOS_ARM/ChibiOS_ARM.c:110: undefined reference to `halInit'
<path_to_project>libraries/ChibiOS_ARM/ChibiOS_ARM.c:111: undefined reference to `chSysInit'
<path_to_project>libraries/ChibiOS_ARM/ChibiOS_ARM.c:114: undefined reference to `loop'
<path_to_project>libraries/ChibiOS_ARM/ChibiOS_ARM.c:114: undefined reference to `sysTickEnabled'

Looks like something is not included, but being a beginner cpp developer I can not figure out what is going south. Again, when I try to build the project using Arduino IDE everything works OK.

Thanks in advance for any help on this

Regards,
Michal
 
If you just want multiple, cooperative co-routines that make for clean looking code, consider http://www.cocoos.net/. Trivial to port and there are no changes to existing libraries, no interrupts needed, no playing with the stack. It uses Duff's device.
 
Bill Greiman, thanks for your work to port FreeRTOS to Arduino.
Today I tested the following setup and get an error on every example.

Arduino 1.6.6 + Teensyduino 1.26 + FreeRTOS from your git (8.2.3)
Compile the example: "frBlink" gives the following error:

./arduino-1.6.6/libraries/FreeRTOS_ARM/examples/frBlink/frBlink.ino: In function 'void Thread1(void*)':
frBlink:16: error: 'void Thread1(void*)' was declared 'extern' and later 'static' [-fpermissive]
static void Thread1(void* arg) {
^
frBlink:16: error: previous declaration of 'void Thread1(void*)' [-fpermissive]
static void Thread1(void* arg) {

Sounds logically? You have any idea?
 
isn't this the normal C limitation that a static is local to the file - cannot be a global/extern.
Just remove the "static" attribute in the function definition if you want it to be used with extern
 
isn't this the normal C limitation that a static is local to the file - cannot be a global/extern.
Yes, in C correct. I was confused by the C++ Code in Arduino, this would be another story with static functions.

Just remove the "static" attribute in the function definition if you want it to be used with extern
I tried this before and it compiles. But I don't understand the intention of the author, because every example has this static functions.
In the end I try to understand the reasons.
 
I took a look at the frblink example... the function that is the task code is in the same file as where it is launched: within startup(). So no extern was used and the task's function is simply local to the file/module.

In C, I don't see a need to declare a function as static unless you are concerned about name conflicts in a multi-file project.
I have seen static functions used to try to restrict what is/isn'/t callable externally - for an embedded system, this (and C++ private) seems silly.
 
Last edited:
What do you have to do to 'Run ESP8266'? If you give details it might help get a better solution . . .

I'm bolting ESP8266 units from onehorse to my Teensy and they are pretty self sufficient - I transfer Serial data into T_3.2 with serialEvent#() for the serial port # - so that just happens under interrupt control. Are you using Arduino for the ESP8266, as I am, that allows the ESP8266 to run a webserver and be self sufficient - with chatter over serial and some shared I/O?
 
Hi,

I have to run esp8266 as mode 3 which is a station as well as access point mode.
After that, I have to take the request from N number of mobiles.
At the same time, my speaker is emitting 1.2s tone continuously.


2+ finite state machines????
 
I can't offer any help - that didn't tell me much about what the Teensy needs to respond for the ESP8266? Or how this Mode3 ESP module is programmed are you using AT commands or other and not the native processor on the ESP? All Feedback over Serial?

It is interesting to know the ESP can be an AP and a Station though.
 
Status
Not open for further replies.
Back
Top