http://www.nioswiki.com/linux

Nios Community Wiki > Linux for the Nios II Processor

Linux for the Nios II Processor

Table of contents
No headers

 

This is the community supported version of Nios II Linux with MMU. This is package will work only on Linux. You will need a virtual Linux to run it on Windows. This is GPL software, and come with absolutely NO warranty.

You may get support with the Nios forum, or the nios2-dev mailing list.

http://forum.niosforum.com/forum/ind...p?showforum=18
http://sopc.et.ntust.edu.tw/cgi-bin/...info/nios2-dev

 

Install the required development packages on your Linux desktop, as root or sudo,
For RHEL5/Centos5, enable EPEL at https://fedoraproject.org/wiki/EPEL.

# for RHEL5/Centos5 only
wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
rpm -Uvh epel-release-5-3.noarch.rpm

# for RHEL5/Centos5/Fedora11
yum install git-all git-gui tcsh make gcc ncurses-devel bison libglade2-devel \
byacc flex gawk gettext ccache zlib-devel gtk2-devel lzo-devel pax-utils

 

For new users who didn't used nios2 git before, please download the tarball (1.7GB) ,as a normal user,

wget http://www.niosftp.com/pub/linux/nios2-linux-20090825.tar

sha1sum nios2-linux-20090825.tar
c156d21b1b6adf1b47102a5f37c4d1d9acdb637f  nios2-linux-20090825.tar
tar xf nios2-linux-20090825.tar
cd nios2-linux
./checkout 


For existing nios2 git users, (with nios2-linux-20080619.tar or nios2-linux-20090730.tar) there is no need to download the tarball. You may add a new branch to track nios2 mmu kernel and clone to get the binary toolchain.

cd nios2-linux git clone git://sopc.et.ntust.edu.tw/git/toolchain-mmu.git cd linux-2.6 git fetch origin git branch nios2mmu origin/nios2mmu git checkout -f nios2mmu git clean -f -x -d cd .. cd uClinux-dist git fetch origin git branch trunk origin/trunk git checkout -f trunk git clean -f -x -d

In short, to build with MMU, use nios2mmu branch on linux-2.6, trunk branch on uClinux-dist. To build without MMU, use test-nios2 branch on linux-2.6, test-nios2 branch on uClinux-dist.


QUICK START

1. add the binary toolchain to your PATH in, .bash_profile or .profile , like
this,
PATH=$PATH:/home/hippo/nios2-linux/toolchain-mmu/x86-linux2/bin

2. Build the Linux image in uClinux-dist dir,

 

cd nios2-linux/uClinux-dist
make menuconfig   # or make xconfig

 

In the menuconfig, make sure it is selected as follows:

Vendor/Product Selection --->               # select
    --- Select the Vendor you wish to target
        Vendor (Altera)  --->               # select Altera 
    --- Select the Product you wish to target 
        Altera Products (nios2)   --->      # select nios2

Kernel/Library/Defaults Selection --->      # select
    --- Kernel is linux-2.6.x
        Libc Version (None)  --->           # should default to None - very important.
    [*] Default all settings (lose changes) # select
    [ ] Customize Kernel Settings 
    [ ] Customize Vendor/User Settings 
    [ ] Update Default Vendor Settings 
Then <exit> <exit> <yes>

(If you were asked option like this, "Build faac (LIB_FAAC) [N/y/?] (NEW)" just enter to use default. This will be fixed.)

 

Compile kernel and apps,

make

(this will take a while)


3. The images created are,

images/linux.initramfs.gz is the elf image with initramfs built-in

images/zImge.initramfs.gz is the compressed elf image with initramfs built-in

images/vmImage is compressed u-boot image

images/rootfs.initramfs.gz is compressed initramfs to be used as initrd by u-boot

images/rootfs.jffs2 is jffs2 image, eg, cp rootfs.jffs2 /dev/mtd0. This is available when jffs2 is selected in kernel. Please note the flash erase sector size on 3c120 dev board is 128KB, you will have to specify "MKFS_JFFS2_FLAGS = -l -p -e 128" at the beginning of your product Makefile.

Connect USB Blaster cable to 3C120 dev board, download the sof and elf.

nios2-configure-sof ../3c120_default/nios2_linux_3c120_125mhz_top.sof
nios2-download -g images/linux.initramfs.gz
nios2-terminal



There is a prebuild linux.initramfs.gz elf image in the 3c120_default
dir, which you may try out first.

4. Get source updates from community server.

Normally you will use "git" protocol to get update from server if your PC
is directly connected to the Internet. Then you may skip to step 5.

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, "./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. Change the nios2-linux path to yours.

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




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 may revert to git protocol when there is no firewall blocking with this
command, "./use_git_for_update" .

5. Now You can fetch updates from server with, "./update" .

 

Create a Nios II design with MMU

1. Add a 512B or 1KB dual-port tightly coupled memory. Connect one port to tightly_coupled_instruction_master, and the other port to tightly_coupled_data_master.

2. Include MMU to your Nios II processor using SOPC builder. Assign "Fast TLB Miss Exception Vector" to the tightly coupled memory. You may use default MMU setting.

You may find a golden reference design for 3C120 dev board, which is the default_mmu in kernel config.

Nios II Hardware Reference Design for Linux, Cyclone III (EP3C120) Edition Release R15 (download .zip file via FTP)

  • Quartus® II project file compatible with Quartus II version 9.0 software
  • Cyclone III FPGA development board design files
  • U-boot files


There is another example for NEEK at, (though the TSE doesn't work on this design). This is the custom_fpga in kernel config.
http://www.nioswiki.com/@api/deki/files/296/=neek_web_server_mmu.zip

The new kernel doesn't use hwselect script, it uses sopc generated header instead.

Run this in your quartus project dir (with quartus 8.1 or later),

sopc-create-header-files --single custom_fpga.h
cp custom_fpga.h nios2-linux/linux-2.6/arch/nios2/include/asm


You may fixup the defs in nios2-linux/linux-2.6/arch/nios2/include/asm/nios.h .

To build,

cd uClinux-dist
make menuconfig  # select Altera,nios2. kernel config your FPGA.

NiosII Configuration  --->NiosII FPGA configuration --->(X) CUSTOM_FPGA

make

 

Debug usespace


The jtag debugger is not working yet. So we will have to use printk to debug kernel. There is a gdbserver binary for userspace at nios2-linux/toolchain-mmu/nios2-linux/bin. (we will add the gdbserver source to uclinux-dist later) You may copy it to romfs/bin. To enable solib in gdb, you will need to run this command or add it to .gdbinit,


set solib-absolute-prefix ~/nios2-linux/toolchain-mmu/x86-linux2/nios2-wrs-linux-gnu/libc

 

 Please refer to the wiki about user space debugging,

  • DebugApps debug user space applications using gdb, gdbtui, insight or ddd.
  • EclipseCDT install and develop/debug with Eclipse CDT IDE.


Reply via email to