Assembly Programming With FreeRTOS

joandunning wrote on Saturday, March 13, 2010:

Does anyone have any experience or links to assembly programming with freertos?

I’m developing a BASIC compiler that generates assembly code, and I was wondering if it is possible to somehow link my assembly code with FreeRtos “C” code? I haven’t looked too closely at the C code yet, I thought I’d just bounce the idea off people here first.

The goal would be for BASIC programmers to be able to use the features available in freertos for multitasking. If anyone knows if it is possible or has a link to a simple example of someone doing assembly programming / rtos then that would be a great start for me to get digging deeper into this.

My existing compiler supports procedures/functions/stack-frames and such, so maybe that will help with “mixing” the two different methods, I don’t know, but VERY interested in trying this!!

richard_damon wrote on Saturday, March 13, 2010:

Since a C compiler (at least internally) converts the C code to assembly, it should be possible. There are a few issues along the way to deal with. One is that if you are going to assume that the users of your BASIC compiler are not going to have a C compiler, then FreeRTOS will need to be provided already compiled as a object file, and the options configured with FreeRTOSConfig.h will need to be fixed ahead of time. Also, since FreeRTOS calls a few functions from the C run time library, you will need to distribute at least part of that (and may need to get permission depending on which C compiler you use). One other issue is that C code tends to require some startup code to be run at the beginning, the simplest way to do this in general is to make the “mainline” of the program a C function (main) and have that call your assembly function. Actually calling the FreeeRTOS is the easy part, as the C compiler should come with instructions on interfacing assembly to C.

All this assumes that you are able to distribute a linker to combine your code with FreeRTOS. If you use an open source C compiler, you should be able to distribute what you need.

rtel wrote on Saturday, March 13, 2010:

Keep in mind that I’m coming at this from a point of complete ignorance, but…

Presumably the BASIC interpreter is going to be resident on whatever which the BASIC program will be loaded.  Is it possible to build FreeRTOS into the BASIC interpreter, then have FreeRTOS functions called through a jump table, in the same way that the ROMed versions of SafeRTOS work?


joandunning wrote on Saturday, March 13, 2010:

Thanks for that, it sounds like it’s worth digging deeper…

Richard_Damon: I’ll take a closer look at the C code and see what I need to build/link this…

RichardBarry: I’ll have a look at SafeRTOS and the jump table, my BASIC system isn’t interpreter based, its assembly code, but I think the principle should still apply.

I think I’ll try a simple “hello world” example, just two assembly routines that toggle, really simple, and see what needs to be done to get these two routines “hooked in” to RTOS. From there I should be able to see how to widen the scope. It sounds like it’s worth attempting so fingers crossed…

joandunning wrote on Saturday, March 13, 2010:

Hi again,

I tried to download SafeRtos in order to evaluate the jump table principle but can’t seem to find a download link for it? Maybe it’s protected by license agreement, not sure, but would like to evaluate it, please help…

rtel wrote on Saturday, March 13, 2010:

Search for the StellarisWare package for the 9b96 (just search for 9B06) on this page: .  You will need to create an account to download it.  The package contains a demo application (using lwIP I think) that runs on top of SafeRTOS.  SafeRTOS itself is in the ROM of the LM3S9B96 so you will not find its source code, but you will find some header files (under “third party” of the files you download) that contain a jump table to allow you to link (sort of) with the RTOS code that is in ROM.