I have done some work on running uClinux and on a NIOS II from Altera. The biggest problem there is the constant obfuscation of the code and patches. Most of the code can be found (after long searches), but it is still quite some work to create decent patches. Just skip the introduction if you know what the Nios II is and just want to get on with hacking together some toolchain.
The NIOS II is a softcore RISC processor to embed in Altera FPGA's. There are a number of problems with this platform:
Of course, this approach is not without its advantages:
This section describes the approach taken to create a custom toolchain for the NIOS II. Support for the Nios II is (not yet, and not likely) to be in the main GCC distribution. In the following, we always start from the well established upstream sources and where needed, a patch is provided. A large part of the patches is extracted out of the GPL'd Nios port of Altera and Microtronix. The patches have been extracted from the code, generalised (most of it was done for Cygwin) and cleaned up.
You should use the snapshots and patches as described on this page. As far as I know, all the snapshots I used can be downloaded here and lots of people managed to build their own toolchain using this information. The official upstream sources are in a constant state of development and not all the required changes for Nios II have been done. Also, the priorities within my company have shifted, so I have much less time to improve and develop the toolchain :-(. If anyone has done improvements on the documentation and/or has additional patches, please return the information and I'll add it to this page (with the appropriate credits, of course).
The following sections have made it (together with work of other people) in buildroot. You should be able to download the latest nightly snapshot and compile a cross compilation toolchain with buildroot. The only things which might be interesting are the clean kernel patches and possibly busybox.
The following will provide a HOWTO to create your customised NIOS II (GNU/Linux) toolchain. It is still not as clean as I would want it to be, but it is IMHO very usable. More and cleaner patches will be provides as work progresses.
You need to build the following components to get a toolchain:
$ quilt push $(tail -1 patches/series)I noticed that the latest (20050602) uClibc snapshot was broken, just use this working snapshot of 20050517. Put in the 'dl' directory in buildroot. There are a number of changes in the uCLinux ABI that need to be changed (in the works).
[marc@scorpius nios2]$ gunzip linux-2.6.9-uc0-nios2-barco.diff.gz
[marc@scorpius nios2]$ gunzip linux-2.6.9-uc0.patch.gz
[marc@scorpius nios2]$ tar xvfj linux-2.6.9.tar.bz2
[marc@scorpius nios2]$ cd linux-2.6.9
[marc@scorpius linux-2.6.9]$ patch -p1 < ../linux-2.6.9-uc0.patch
[marc@scorpius linux-2.6.9]$ patch -p1 < ../linux-2.6.9-uc0-nios2-barco.diff
[marc@scorpius linux-2.6.11]$ make ARCH=nios2nommu CROSS_COMPILE=nios2-linux-uclibc- hwselect SYSPTF=std_1s10.ptfYou will need to find the std_1s10.ptf file from your Altera installation somewhere and place it in the kernel directory.
[marc@scorpius linux-2.6.11]$ make ARCH=nios2nommu CROSS_COMPILE=nios2-linux-uclibc- menuconfig
[marc@scorpius linux-2.6.11]$ make ARCH=nios2nommu CROSS_COMPILE=nios2-linux-uclibc-
[marc@scorpius linux-2.6.11]$ nios2-linux-objcopy -O binary vmlinux vmlinux.binThe -g option starts after uploading.
[marc@scorpius linux-2.6.11]$ nios2-download -g vmlinux.bin
As for the nios2-download and the *.ptf files, I'm afraid those are Altera proprietary, you'll need to contact Altera for those. They are included in the evaluation kits, if you are working on Nios II, you should have those anyway.
You can always get the binary snapshot of the toolchain we are using, if you don't want to go through the building process. It's not that big (34 MB uncompressed). See my contacts page for the details. Please use the subject Nios II toolchain, this way your mail will stick out in my inbox.
Some things I plan to upgrade in the following months/weeks, euhm, whenever I have time (see here).
As you can see from the screenshot, the entire environment is booting a working system :) The patches have been submitted to buildroot and are currently in the bug reporting system.
This research is done in Barco in the division Barco Control Rooms (combined with a lot of morning, evening and weekend hacking :), much to the despair of my lovely wife).
If you have more questions, just mail/IM me, it should be pretty easy to find me online.Happy Hacking!
Thanks to the following people for their feedback and work to improve this toolchain: