Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

Integrate RTOS into NIOS II HAL

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

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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.