Nios II: Building your first kernel
From Crashcourse Wiki
This page documents the basic steps to configuring, building and testing your first kernel.
Contents |
The checklist
Before you get started, ensure you have all of the following:
- a uClinux-dist tree, with the branch of your choice checked out
- a Nios II toolchain somewhere on your search path
- a PTF file to use as the basis for the vendor H/W selection step
make menuconfig
Starting in the top directory of the uClinux-dist tree, run
$ make menuconfig
and select the following:
- Vendor/target: Altera/nios2nommu
- Kernel version: 2.6.x
- Libc version: None
- "Default all settings (lose changes)"
Note that it's important to select the Libc version of "None" since we have no need for a C library. And you can see the results of the configuration in the top-level .config file.
vendor_hwselect
Next, do the vendor hardware selection step by running:
$ make vendor_hwselect SYSPTF=<pathname to your PTF file here>
and answer any questions appropriately.
If you're curious, you can examine the resulting generated makefile with:
$ cat linux-2.6.x/arch/nios2nommu/hardware.mk SYSPTF = <PTF filename> CPU = cpu_0 UPLMEM = cfi_flash_0 EXEMEM = sdram_0 $
Building the kernel
Finally, build the kernel by running:
$ make
at which point the resulting kernel image should be in the file images/zImage.
The default config file for the 2.6 kernel that will be used for this build can be found at vendors/Altera/nios2nommu/config.linux-2.6.x.
For much more detail, see the Nios wiki page [here] and the wiki page for testing your new image [here].
What's in that initramfs, anyway?
Even if you're building a completely default kernel image, it will still have an embedded initramfs image to be used as the root filesystem. We'll discuss the mechanics of the initramfs creation on a later page but, if you truly want to see the initramfs image contents, you can always gunzip and examine the contents of linux-2.6.x/usr/initramfs_data.cpio.gz once the kernel build is complete.
Return to Altera_Nios_II home page.

