This page provides the latest information of the Linux kernel and components, specific to Nios II.

For how to run Nios II Linux on Altera boards, please refer to the following links: Note:
  • This package will work only on Linux. You will need a virtual Linux to run it on Windows.
  • This package has been tested with the CentOS 6.3 distribution.
  • This package does not fully apply to Altera MAX10 board. Hence, please refer to Altera MAX10 10M50 Rev C Development Kit Linux Setup for MAX10 Nios II Linux package setup.

Setting up toolchain

Go to link below, select Altera Nios II Processor GNU/Linux release, download and install Sourcery CodeBench Lite , you may need to refer to Sourcery CodeBenchGettingStartedGuide. There are two type of toolchains, generic syscall ABI compatible toolchain and non-generic syscall ABI compatible toolchain and each only work for the targeted kernel (generic or non-generic syscall ABI compatible kernel). These two toolchains are not binary compatible, this means you need to recompile all the source files if you switching toolchain between them (e.g: kernel, bootloader, rootfs, applications and etc)

v2013.05-43 version is worked with non-generic syscall ABI compatible kernel, v2014.05.47 or above is worked with generic syscall ABI campatible kernel.
Sourcery CodeBench Lite 2014.05-47 and above
This toolchain is with generic syscall ABI.
Example supported kernel: linux-socfpga/github (kernel v4.0 and above), master/ (kernel v3.19 and above)

Sourcery CodeBench Lite 2013.05-43
This toolchain is with non generic syscall ABI
Example supported kernel: socfpga-3.18 and version prior 3.18 in linux-socfpga.git

/bin/sh <Nios II Linux GNU installer>.bin

The toolchain is located in the CodeSourceryfolder, add the toolchain to your PATH.
export PATH=/<your path>/CodeSourcery/Sourcery_CodeBench_Lite_for_Nios_II_GNU_Linux/bin/:$PATH
export ARCH=nios2
export CROSS_COMPILE=nios2-linux-gnu-

To confirm the toolchain is added properly , type echo $PATH.

Kernel v3.19 and above

Few things need to be noted if using kernel 3.19 and above:
  • Toolchain: Sourcery CondeBench Lite 2014.05-47 and above
  • Hardware: 2 timers in nios2 system
  • DTS: Small letter for altr prefix in dts file, eg: altr,has-mmu; compatible = "altr,juart-1.0";

Building root filesystem

Buildroot is used to build the root filesystem for Nios II Linux. Download Buildroot source files from Buildroot GIT.
git clone
cd buildroot
git tag -l (to check for latest remote version)
git checkout -t -b <version> tags/<version> (eg. 2013.11)

Download Nios II config file for Buildroot: nios2_config file for Buildroot. Add this file to <buildroot_top_directory>/configs.

Go to Buildroot top directory and configure Buildroot for Nios II:
make nios2_defconfig

To customize Buildroot configuration:
make menuconfig

For the toolchain configuration, please make sure to add the complete path to the toolchain in the buildroot configuration. Optionally, you can pass this as a variable during make. The parameter is BR2_TOOLCHAIN_EXTERNAL_PATH. This should be set to the fully qualified path to the toolchain install, and not the bin directory.

To build:
  • You need to be connected to the network before make as the script must download and install packages.

Output file name : rootfs.jffs2, rootfs.cpio, rootfs.tar
Output directory : <Buildroot_top_directory>/output/images

Building U-Boot

Download the latest U-Boot source files from using git.
git clone
cd u-boot-socfpga
git branch -a (to check for latest remote version)
git checkout -t -b <version> origin/<version> (eg. socfpga_2013.01.01)

For U-boot config files, refer to respective board BSP page: " 3C120 U-boot config files" or " 4SGX230 U-boot config files"

In U-Boot top directory, configure U-Boot for Nios II and compile.
make <boardname>_config (eg. 3c120 or 4sgx230)

Output file name : u-boot
Output directory : U-Boot_top_directory

Building Nios II Linux kernel

Download the latest Linux kernel source files from using git.
git clone
cd linux-socfpga
git branch -a (to check for latest remote branches)
git checkout -t -b <branch-name> origin/<branch-name> (eg. socfpga-3.15, socfpga-3.10-ltsi)

Go to Linux top directory and configure Linux kernel for Nios II.
For 4sgx230 desing, download 4sgx230_defconfig hereand store in <Linux_kernel_top_directory>/arch/nios2/configs.
make <boardname>_defconfig (eg. 3c120 or 4sgx230)

To build:
make vmImage

  • To create vmImage , you will need to use U-Boot utility, mkimage. Point to mkimage path with "export PATH=/<your_path>/uboot-socfpga/tools/:$PATH"
  • Refer " building U-boot" on how to setup U-Boot utility.
Output file name : vmImage
Output directory : <Linux_kernel_top_directory>/arch/nios2/boot
Output file name : vmlinux
Output directory : <Linux_kernel_top_directory>

Building Device Tree Blob(DTB)

The device tree in this example is provided in the Linux kernel sources in <Linux_kernel_top_directory>/arch/nios2/boot/dts. To create/modify your own device tree, refer to [ [1]].

For 4sgx230 design, download 4sgx230_devboard.dts here and store in <Linux_kernel_top_directory>/arch/nios2/boot/dts.

To build the DTB, go to Linux top directory:
make <boardname>_devboard.dtb (eg. 3c120 or 4sgx230)

Output file name : <boardname>_devboard.dtb
Output directory : <Linux_kernel_top_directory>/arch/nios2/boot

Give us your feedback

© 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors. Privacy.