Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12600 Discussions

Integrate RTOS into NIOS II HAL

Altera_Forum
Honored Contributor II
1,044 Views

Hi, 

I need to use an RTOS for my development with NIOS II. 

I found on Internet a very interresting little RTOS called FreeRTOS (www.freertos.org) and I want to port it to NIOS II HAL. 

Porting the OS to NIOS II core (CPU) is not a issu. 

But I don't know what I have to do to integrate it into the system library of my design and also into the NIOS II HAL. 

 

Does some one have information about how to do this ? 

 

Thanks for any help 

 

Fabrice Mousset
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
313 Views

The simplest way is to follow the following steps: 

 

1. Create a standard HAL project (e.g. using the hello world template). 

2. Add the source for your operating system to the system library project. 

3. Compile/test/debug until it works. 

 

This will give you a basic port of your RTOS. While the RTOS will be working, many of the HAL system calls will not be thread safe. You can fix this by providing macros that tell the HAL how to create and use semaphores etc.  

 

This is done by adding a directory named "os" to your system library project, and then placing within it headers named "alt_flag.h", "alt_sem.h" and "alt_hooks.h". You can look at the versions of these files provided for the microC/OS-II port to see what macros these files should provide. Documentation can be found in the section "Thread-Safe HAL Drivers" in the Nios II Software Developers manual. 

 

Finally, if you want malloc and env to be thread safe, then you will also need to add the files alt_malloc_lock.c and alt_env_lock.c to your system library. Again you can look at the files provided for the microC/OS-II port to see what functions these files need to provide. Additional documentation for these lock functions can be found in the Newlib porting guide.
0 Kudos
Altera_Forum
Honored Contributor II
313 Views

Hi monkeyboy, 

Thank you for your suggestions. 

I will try this. It seems very easy :-) 

 

I will give you later information about my port of freeRTOS.
0 Kudos
Altera_Forum
Honored Contributor II
313 Views

Hi all there, 

So finally it works, I have ported the FreeRTOS to NIOS II http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/cool.gif  

Now I am testing it. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/blink.gif  

 

Is there some one there who like to help me to debug the port of FreeRTOS to NIOS II ? 

 

To have more details about FreeRTOS, take a look at the homepage. (http://www.freertos.org)
0 Kudos
Reply