libstdc++ for eCos Nios2
This is a work-in-progress intended only for testing and discussion purposes.
Download binaries
Precompiled CygWin nios2-elf toolchain is available for downloading here:
| POSIX multithreaded exception handling |
nios2gccbin-20060811.tar.bz2 |
NIOS2 GCC toolchain source. These files are modified somewhat from what is provided with Nios 5.0. Also note that the GCC source provided with Nios 5.0 is incomplete, so some of the files were copied over from the Nios 6.0 beta.
Altera has since I cobbled together the source for the GCC toolchain made efforts to provide
complete and tidy source for the GCC Nios2 toolchain. Not investigated
http://www.altera.com/support/ip/
processors/nios2/ide/ips-
nios2-ide-tutorial.html |
nios2gccsrc.tar.bz2 |
Background
These instructions are based on
libstdc++.
Building GCC
These instructions are incomplete. Consider them working
notes. Once all the problems have been solved, the idea is to write
a build script that can be used by mortals.
You should know how to compile a basic GCC toolchain before
attempting this.
Cygwin time machine
Altera has included a partial, old version of Cygwin with Nios 5.0/6.0 that
will not run binaries created by the latest Cygwin.
The solution is to install a Cygwin via the "Cygwin Time Machine." Which version?
Altera includes several cygwin1.dll (double shame on them!) and there is no snapshot for 1.3.23.
The toolchain above was created using:
ftp://www.fruitbat.org/pub/cygwin/circa/2003/05/14/200002/index.html.
Building
- Compile binutils
$ mkdir build
$ cd build
$ ../GnuSRC/gcc/src/binutils/configure --target=nios2-elf --prefix=`pwd`/../install
$ make
$ make install
$ cd ..
- Add the fresh binutils to the FRONT of the path
$ export PATH=`pwd`/install/bin:$PATH
- Create eCos header files
$ mkdir ecos
$ cd ecos
$ ecosconfig new nios2_dev_board default
$ ecosconfig add posix
$ ecosconfig add fileio
- Also change ecos.ecc to:
cdl_option CYGPKG_LIBC_I18N_NEWLIB_CTYPE {
user_value 1
};
- Build eCos headers:
$ ecosconfig tree
$ make headers
$ cd ..
- Build GCC
$ mkdir gccbuild
$ cd gccbuild
$ ../GnuSRC/gcc/src/gcc/configure --target=nios2-elf --prefix=`pwd`/../install --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-newlib --enable-threads=posix --without-headers --enable-libstdcxx-allocator=malloc --enable-cstdio=stdio --disable-shared --disable-libstdcxx-pch
$ make
$ make install
$ cd ..
- GCC will fail to compile libstdc++ as configured above, because it can not find the
POSIX pthreads include files. The solution is to replace
the newlib include files with the eCos include files when compiling libstdc++.
$ mkdir ../install/nios2-elf/include
$ cp -r ../ecos/install/include/* ../install/nios2-elf/include
# remove reference to in the file below, lest compilation fails.
# ../install/nios2-elf/include/pkgconf/hal_nios2.h
- _NEWLIB_VERSION have not been defined by the eCos include files and hence
testsuite_hooks.cc fails. Modify testsuite_hooks.cc and continue.
Known problems
Tips