Install Nios II Linux

cancel
Showing results for 
Search instead for 
Did you mean: 

Install Nios II Linux

Install Nios II Linux



Please refer to http://www.rocketboards.org/foswiki/Documentation/NiosIILinuxUserManual for latest updates on Nios II Linux !

Here we will setup the source to build Nios2 uClinux. branch "test-nios2", per 20090730.

(If you already have the toolchain and working git repos from 20080619 tarball, then you can pull updates without downloading the new tarball. There are copies of the update scipts and anonymous sshkey in the nios2-linux/toolchain-build/release_top/ dir. Copy them to nios2-linux dir.

cp -a nios2-linux/toolchain-build/release_top/* nios2-linux

You must get updates to build toolchain with host gcc 4.3 for 20080619 tarball.)

New install

You must have a Linux desktop with software development packages. Login as root or use sudo to install these packages.

On Fedora, RHEL, CentOS:

(for RHEL or CentOS, please add epel repository, How to use EPEL)

sudo rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm

sudo yum install git-all git-gui make gcc ncurses-devel bison byacc flex \

gawk gettext ccache zlib-devel gtk2-devel lzo-devel pax-utilslibglade2-devel uboot-tools

On Suse:

sudo zypper install git-core git-gui make gcc ncurses-devel bison byacc \

flex gawk gettext ccache zlib-devel lzo-devel pax-utilslibglade2-devel

On Debian/Ubuntu:

sudo apt-get update

sudo apt-get install git-core git-gui make gcc ncurses-dev bison flex gawk \

gettext ccache zlib1g-dev libx11-dev texinfo liblzo2-dev pax-utils uboot-mkimage corkscrew

(If Ubuntu/Debian can't find the liblzo2-dev package search for equivalent. This is needed for the MTD tools package.)

Please check your git version with "git --version". If it is older than 1.5.3.x, please update to the latest.

On Ubuntu, check if the default shell is "bash"

ls -l /bin/sh

This should give "/bin/sh -> bash", Otherwise, change it with,

sudo rm /bin/sh

sudo ln -s bash /bin/sh

followed by a logout and log back in again.

As root, check if you have "cc" which is a symlink to "gcc".

which gcc


gcc -v

which cc


cc -v

if not,

cd /usr/bin


ln -s gcc cc

GCC4.2

Before compiling the 20090703 toolchain on a linux ubuntu/kubuntu 9.04 you need to make sure to install gcc version 4.2 (older) and gcc's file system link is properly pointing to it:

sudo apt-get install gcc-4.2

sudo rm /usr/bin/gcc

sudo ln -s gcc-4.2 /usr/bin/gcc

If this isn't done tool chain compilation will buffer overflow on nios2-linux-uclibc-ar

Nios2 Linux Tarball

Make sure you have 6GB or more free disk space. Please use wget to download the tar file nios2-linux-20100621.tar , 1.6GB. Best thanks to Embedded System Lab., Electronic Engineering Department, National Taiwan University of Science and Technology kindly hosting these files. Please verify the sha1sum after download. (but don't use Windows ftp, it corrupts the files)

wget http://sopc.et.ntust.edu.tw/pub/linux/nios2-linux-20100621.tar

tar xf <path_to>nios2-linux-20100621.tar # untar the package

OR

#get the initial git files - This gets a bunch of tar files so they are not too big...

wget ftp://ftp.altera.com/outgoing/nios2-linux/20120802/* .


#This should download the following

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/files.md5sum

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-3c120_default-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-base-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-binutils-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-boards-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-elf2flt-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-gcc3-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-glibc-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-insight-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-linux-2.6-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-openip-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-toolchain-build-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-toolchain-mmu-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-tools-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-u-boot-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-uClibc-20120802.tgz

# ftp://ftp.altera.com/outgoing/nios2-linux/20120802/nios2-linux-uClinux-dist-20120802.tgz


#check that they are right

md5sum --check files.md5sum


#extract the files - they will extract into a directory called nios2-linux

for i in $(ls nios2-linux-*.tgz); do tar -xzvf $i;done


# For mmu-less nios2 uCLinux, download the precompiled toolchain as well

wget ftp://ftp.altera.com/outgoing/nios2-linux/nios2gcc-20080203.tar.bz2


#this extracts to nios2-linux/opt

tar -xvf nios2gcc-20080203.tar.bz2

We use "git" to keep the source. You make check out GitServer later. The git database inside the tar file was compressed, so we don't do compression on the tar file. 

You can build in any working directory as a user account, eg. in your home (say /home/hippo). The tar file contains a nios2-linux dir.

cd nios2-linux

ls # see what's in



binutils insight u-boot use_http_for_update

checkout linux-2.6 uClibc use_ssh443_for_update

elf2flt README uClinux-dist

gcc3 sshkey update

glibc toolchain-build use_git_for_update


# check out the source

./checkout

Now the source files for the Nios2 uClinux and gnutools are ready.

  • linux-2.6: the Linux kernel source, which is stock Linux kernel plus Nios2 specific patches. The current version is v2.6.30.
  • uClinux-dist: the uClinux userspace libraries and applications. We will build uClinux here.
  • binutils, gcc3, elf2flt, insight: the gnu tools source.
  • uClibc: the main userspace libraries, which is smaller that glibc. please note, newlib doesn't support Nios2 uClinux.
  • u-boot: a powerful boot loader and monitor, DasUBoot.

Toolchain

We will proceed to build the toolchain. If you don't want or fail to build it yourself, you may use the prebuild BinaryToolchain.

If you work on x86_64, 64 bits platform, you will need to change the arch to 32 bits , with "setarch i386" , to build gcc.

cd toolchain-build


gcc --version # this may need to be 4.2, other versions seem to fail (i.e. 4.1.2, 4.4)

git clean -f -x -d # clean on restart

make gcc elf2flt gdb-host # setarch i386 make gcc elf2flt gdb-host, if you work on x86_64 platform




# make -j6 gcc elf2flt gdb-host #if you have a multi-core machine, -j(number of cores +2) gives a nice parallel compilation speedup



cd ..


It might take hours to build.





~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Problems building toolchain... avanhorn 15:59, 14 January 2013 (CST)

When trying to build the toolchain with the above directions, I could not get the toolchain to build UNTIL I switched to the test-nios2 branch on linux-2.6

cd nios2-linux/linux-2.6

git fetch origin

git branch test-nios2 origin/test-nios2

git checkout -f test-nios2


cd nios2-linux/toolchain-build

git clean -f -x -d #clean on restart

make gcc

make elf2flt

#I still get errors trying to make gdb-host, so I'm skipping it for now...

#make gdb-host

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~





The default installation path is toolchain-build/build/nios2. Then setup the PATH for the tools, you can add a line at the end of file ~/.bash_profile (or ~/.bashrc on Debian/Ubuntu) ( the file is hidden, you have to use "ls -a" to find it . For "gedit" use open Location, and enter the file name), like this

PATH=$PATH:/home/hippo/nios2-linux/toolchain-build/build/nios2/bin

Logout and login again. You can use the tools now. Run this to verify that you have it in your command search path,

nios2-linux-uclibc-gcc -v

Try to compile a simple hello.c like this,

#include <stdio.h>


int main(void)

{

printf("hello world");

return 0;

}

nios2-linux-uclibc-gcc hello.c -o hello -elf2flt

The compiled object format is FLAT.

You may check it with,

nios2-linux-uclibc-flthdr hello

Now you can follow UClinuxDist to build the kernel. You should build in the new source tree, nios2-linux/uClinux-dist .

cd uClinux-dist


make menuconfig

*make vendor_hwselect SYSPTF=<path to your system ptf>


make

(EDIT: ccache links removed because it doesn't work well with blackfin uclinux-dist)

  • New Kernal do not support vendor_hwselect instead Devicetree


Release Notes:

Important changes in this release, nios2-linux-20090730,

  1. Add git+ssh tunneling update
  2. Add trunk branch from blackfin uclinux-dist

Important changes in this release, nios2-linux-20080619,

  1. The arch name is now "nios2", (but not nios2nommu). Use current development branch test-nios2 by default.
  2. The kernel source linux-2.6.x and uClibc are removed from uClinux-dist. the kernel source is now external linux-2.6 (from linux-2.6.git) at the same directory level as uClinux-dist.
  3. The previous nios2_system.h is relocated to include/asm-nios2/nios2.h, and now the port/memory address is physical address , without cache-bypass, ie no address bit 31 set.
  4. mtd partition maps file altera.c , microtronix.c and EPCS drivers are removed. Now they are in the platform device data of arch/nios2/kernel/config.c, using generic physical maps , m25p80 and altera spi driver.
  5. Many arch/drivers reworked/added, such as timer, interrupt handler, cache, ioremap, uart/jtaguart, framebuffer, spi, TSE.
  6. Adopt the Makefile from blackfin uclinux-dist, with many userspace libs/apps merged from blackfin. eg, ncurses, openssl, directfb, freetype..etc.
  7. Introduce the staging dir, with all libs and headers installed there. the previous include dir was removed.

The latest branch is "test-nios2". Despite the "test" in the name, this does not mean "unstable". All future works and support will base on this branch. I won&apos;t update those older branches with the limited time available. Please migrate to the new branch.

The uClinux-dist dose not contain the kernel now. It should stick with "test-nios2" branch. It will merge updates from uclinux.org and blackfin uclinux.

The development of nios2 kernel will stick with mainly the "test-nios2" branch, with proper tags follow Linus&apos; releases. eg "v2.6.26-nios2" tag when Linus release "v2.6.26" stable. Then it will move on to v2.6.27-rc1, but not with a new branch. It is still "test-nios2" branch.

Though there will be some experimental branches from time to time, but they will be merged into the main branch "test-nios2" at proper time. And then deleted.

If you need a "stable" branch, you can create local branch off the stable tags. You might apply patches from stable-queue git. Or you want to freeze. It is all up to you.

# patches for stable releases


git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git

Prepare to get update

After you have first successful boot, you can get updates from server. Change to the nios2-linux dir,


Normally you will use "git" protocol to get update from server if your PC is directly connected to the Internet. Then you should SKIP below and fetch update with git directly.

Tunneling ssh behind firewall

Only if you are behind a proxy firewall and cannot use git protocol, you can change the git to use ssh tunneling through port 443 to get updates from community server with this command once, "./use_ssh443_for_update" .

You should have ssh tunneling package installed, such as "corkscrew". Add the following 3 lines to your ~/.ssh/config, which should have no public access, "chmod og-rwx config". Replace <http_proxy_ip> <port> to that of your http proxy server.

IdentityFile ~/.ssh/id_rsa IdentityFile ~/nios2-linux/sshkey/id_rsa ProxyCommand corkscrew <http_proxy_ip> <port> %h %p


Dumb http proxy behind firewall

If you failed to use ssh tunnling as above, you may try dumb http protocol with this command, "./use_http_for_update" . But this is very slow and not recommended. You will need to add the setup of proxy to your login profile (.bash_profile or .profile),

export http_proxy=http://<http_proxy_ip>:<port>

Revert to git directly

You may revert to git protocol when there is no firewall blocking with this command, "./use_git_for_update".

Update

Now fetch updates from server with, "./update" .

Fetching updates the first time can be a long lasting process, as there might be lots of patches applied to the version that had been downloaded. This is especially true if you are sitting behind a firewall and are foreced to use the dumb http protocol.

You might see connecion problems (e.g. "error 503") in the "./update" output. This usually does not indicate a permanent problem (if you see other git status messages before the update stops) and git is perfectly able to recover from those errors with the next "./update" run. You just need to redo "./update" until you don&apos;t see any lines but "Already up-to-date"

(note) if the kernel couldn&apos;t start after update..

Please disable optimize for size, or start with default config again.

General setup -->

[ ] Optimize for size <== unselect

If you got such error in updating,

~/nios2-linux/uClinux-dist$ git pull .

vendors/Altera/nios2/config.vendor: needs update fatal: Entry &apos;vendors/Altera/nios2/config.vendor&apos; not uptodate. Cannot merge.

Please do a "git checkout -f" . Then "git pull" again.

Version history
Last update:
‎06-27-2019 05:20 PM
Updated by:
Contributors