Simulating uC/OS-II inside the
OpenRISC simulator
In order to run uC/OS-II applications inside the OpenRISC simulator you bascially need three things: a hardware simulator, a compiler for the simulator and a uC/OS-II port for the simulator.
The OpenCores project provides a complete GNU toolchain, contianing a hardware simulator and the corresponding compiler tools based on GNU GCC.
In order to save compilation time and space, we offer a precompiled toolchain. The installation procedure is tested on Linux, Ubuntu 8.04 and 9.04 (32 bit). Our precompiled toolchain provides the following complier tools and simulator versions:
- GNU binutils-2.18.50
- GNU GCC-4.2.2
- GNU GDB-6.8
- or1ksim-0.3.0


Installing the precompiled OpenRISC toolchain for Linux
- Download the precompiled toolchain.
- Extract the archive anywhere you like.
- Add the <toolchain>/or32-elf/bin directory to your path.
If you are working with bash you can type (or add the PATH to your .bashrc):
$ PATH=$PATH:<toolchain>/or32-elf/bin $ export PATH
Running uC/OS-II inside the OpenRISC simulator
- Obtain a copy of the uC/OS-II version 2.86 source code from the Micrium website.
- Downlaod the uC/OS-II port for OpenRISC. Note that this port was made specifically for uC/OS-II version 2.86.
- Extract the archive anywhere you like
- Go to the extracted port directory.
- Follow the instructions in the README file to apply a patch to the original uC/OS-II sources.
- Compile the example application:
$ make all
- Run the simulation:
$ or32-elf-sim -f sim.cfg ucos-test.or32
Note: you may need to install qmake for the make command to work. Under Ubuntu you can install it using:
$ sudo apt-get install qt4-qmake
Using the GDB debugger
The OpenRISC toolchain comes with a GDB debugger, named or32-elf-gdb. We can connect it to a running simulation compiled with debug information using a (simulated) JTAG interface. Note that future versions of the OpenRISC toolchain plan to depricate the JTAG interface.-
To compile the uC/OS-II application with debug information, add -ggdb to the CFLAGS defines in the file config.mk, or type:
$ CFLAGS="-ggdb"; make distclean all
- In order to use a graphical debugger interface, install the programm ddd from your Linux distribution's package manager.
- Start the simulation and connect the debugger to the target platform:
$ ddd --debugger or32-elf-gdb
-
Within the gdb console load the simulated executable and the remote target:
file ucos-test.or32 target jtag jtag://localhost:9999
Various extensions
We have extended the above uC/OS-II distribution with the following features:- RELTEQ, a simple timing mechanism, which improves on the standard uC/OS-II timer management
- Stack Resource Policy (SRP) implementation of mutexes. A setting in the os_cfg.h configuration file allows to chose between the original priority inversion protocol implemented by uC/OS-II and the SRP.
- Logging functionality, allowing to produce traces of various events, e.g. task arrival, task execution, aquiring of mutexes and server replenishment and depletion.
- Plotting application, which accepts a before mentioned trace as input and represents it graphically as a traditional task graph.