kolja waschk
haubachstraße 39
D-22765 hamburg


This document describes my efforts to add support for the Altera NIOS II processor to the RTEMS realtime operating system. At this time it is is more a request for cross-checking and review than a production-ready code package. If you're interested to use the results at this time, prepare yourself to dive into RTEMS and NIOS2 internals...

Current State

Toolchain (Binutils, Compiler etc.)

Using Altera's nios2-elf-tools (NIOS2 EDS 6.0, gcc 3.4.1), including GDB and Insight over JTAG connection, with wrapper scripts that turn them into nios2-rtems-tools. No C++ yet!


Using CVS Newlib (1.14), compiled with the interim nios2-rtems-tools (outside the gcc tree).


Using CVS RTEMS. Most sptests, most psxtests, all tmtests pass. A sample BSP for use in Altera's instruction set simulator with a simulated JTAG UART and two timers is included and has been successfully used on a real system as well (only memory layout and IO addresses need to be changed).

There are a number of things to do before this can be considered production quality, so please keep reading further down where the To-Do list is located.

Source Code / Downloads

On August 10th, 2006, the RTEMS patches below all have been committed to the RTEMS CVS repository. To ensure that you're up to date, please check out current sources from there instead of using the files from here. The Newlib patches are still needed though.

Archive containing newlib patches (for 1.14.0) and RTEMS patches for CVS HEAD as of 2006-08-07. I replaced the old nios2_eb2_1 BSP with a nios2_iss BSP that can be used with Altera's nios2-iss instruction set simulator and the included PTF description.. Additionally, a first version of a tools/cpu/nios2/nios2gen is there, not finished yet. It will hopefully become a good tool to configure a BSP from a PTF file from SOPC Builder. This represents my current state of development and obsoletes all downloads below.
I provide my personal build script here as a hint. It shows how to wrap nios2-elf-gcc so that it can be used to compile Newlib for RTEMS and RTEMS itself. There are absolute paths inside; you have to edit it before using it!

Obsolete Downloads

Patch for CVS Newlib (as of 2006-01-17). It adds nios2 as a target where required and a newlib/libc/machine/nios2 subdirectory. It doesn't contain the configure and other files that could be created automatically.
Additional files for CVS Newlib (not needed if you create your configure and such files yourself)
Patch for CVS RTEMS (as of 2006-01-24), adding nios2 targets where appropriate
Content for NIOS2 cpukit, libcpu, and libbsp containing a simple nios2_eb2_1 BSP. To be unpacked in rtems/ top level directory.


I've prepared an archive with the actual output of the tests on nios2-iss, reports-20060809.tar.gz.


stackchk fails, otherwise everything looks good. ticker runs without problems.

Single Processor Test Suite (sptests)

Rate monotonic manager and some things related to the region manager fail.

POSIX Test Suite (psxtests)

All tests pass except for psx03. Maybe I haven't allocated enough ressources.

Time Test Suite (tmtests)

All tests pass.


In rtems/tools/cpu/nios2 I added a nios2gen tool. Somewhen in the future it will be able to derive linkcmds and bsp.h from Altera system description files (*.PTF) to simplify customization of NIOS2 BSPs for your specific configuration. The parsing code is working, some intelligent decisions are made about the devices, but it doesn't do usable output yet.

To Do

Tool Hints

You can get Altera's Quartus (their logic design software) and the the NIOS2 Tool Evaluation Kit from their website free of charge, but only for Windows. It should be possible to use the Cygwin-based tools, but I haven't tried.

If you purchased a NIOS Evaluation Kit, you should have access to the toolchain source code and binaries for Linux as well. I used these for my work. The CDs contain the sourcecode as well.

NIOS2-enhanced toolchain sourcecode is also available from Altera's FTP server, but up to version 6.0 some NIOS-specific files in the GCC source tree are missing. These can only be found in the gnusrc.tgz distributed on the CDs. In the very next release after I filed a support request (in niosii-gnutools-src-6.1.tgz), all the missing files are now included.

It is advisable to have a USB Blaster (an USB JTAG adapter made by Altera) for debugging. But, if you don't have Quartus for Linux, you also probably don't have the USB Blaster drivers and JTAG software. You can still use Linux as your primary development platform, but you'll have to run the JTAG server with remote access enabled on a separate Windows PC (or run Linux in a virtual machine on the Windows PC).

I'm currently working on an alternative USB JTAG adapter. The hardware is working in principle and with some tweaking it can be used instead of an USB-Blaster.