Forum Discussion
Altera_Forum
Honored Contributor
20 years agoThe 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.