The original uClinux was a derivative of Linux 2.0 kernel intended for microcontrollers without Memory Management Units (MMUs). Later the patches of uClinux were merged back to the mainstream Linux 2.6 kernel. Today's uClinux as an operating system includes Linux kernel releases for 2.0 2.4 and 2.6 as well as a collection of user applications, libraries and tool chains. If you are new to uClinux, it is very helpful to read the uClinux FAQ and uClinux-dist Developers Guide. There is a very helpful uClinux wiki site for blackfin, and it apply to Nios II as well.
Why develop on Linux when you have the IDE on Windows?
The IDE on Windows is not good for uClinux kernel/apps development,
- The IDE's compiler defaults to newlib, while we prefer to use uClibc in uClinux. Software building and porting will be much easier with the compiler created from buildroot.
- The tools run much faster, and with less trouble on Linux. After using Linux, you will feel the IDE on Windows moves like turtles.
- If you want to develop Nios II uClinux, you should work on Linux and learn Linux. You can learn a lot when working on Linux, and the "Linux know how" is the key to success on Nios II uClinux.
Advantages over the Microtronix's release 1.4
The kernel code for Nios II was developed by Microtronix. But they didn't release update for a long time. We based on the code, and improve it.
- It is ported in uClinux-dist, which is the build enviroment most familiar to uClinux developers. There are richer set of libraries and user apps. Microtronix picked only some of them to make their release.
- It is synced up to the latest Linux kernel release, which means improvements, bugfixes and more drivers supported. If you will develope drivers, it is important to keep up.
- we add support of compressed kernel image, which can save around 50% flash usage.
- we use initramfs, which is easier to use than romfs, especially for custom boards.
- we add drivers for EPCS,PCI,VGA,PS/2 etc.
Quartus for Linux - recommended
- You will need to add a PC, to run Linux. If you are new to Linux, you can try CentOS 5.5 i386 32bits distro, which is free and binary compatible with RHEL5. You can find a step by step guide on the Linux installation and usage from Redhat"s doc . You may install it to a (20+GB suggested) partition on your PC along with an other OS, eg, Windows XP. Though it is not necessary, it is very useful to install Quartus for Linux. You will be able to configure the .sof, download the image, debug and program the flash using the USB Blaster, all on your Linux PC. Even if you don't have a license (to generate hardware programming files), you can still install it and use it to develope software. Please refer to Quartus for Linux for details. You can find links to major Linux distributions here. Don't use Redhat9, as its make is too old.
- If you didn't install Quartus for Linux or you don't have a license to compile hardware, you can setup a samba server or client on a Linux PC, so that it can share files with a Windows PC. You can use Quartus II and Nios II on Windows to design hardware, then build software on Linux. But you must install and develop software on a native Linux filesystem, not a Windows shared drive. You may copy the kernel image to Windows for download and testing.
- If you have only a Windows PC, you can still construct a Linux environment using coLinux , which will run under Windows, see Nios2Colinux. You may use VMWare, too. But they may be difficult for a Linux newbie. Note, you cannot use the Linux shell to program JTAG on coLinux under Windows. You must use the Nios II command shell for Windows to program JTAG in this case.
Before you start
- Always update your tools to the latest version: ie, Altera Design suite v9.0 (including Quartus,Nios2eds) at this moment.
- The Nios II kernel image is configured with a SOPC builder PTF file, and it will only run on the same hardware generated SOF file.
- Remember, the current version of uClinux does not use an MMU, starwebsoft, so no virtual memory, no shared objs/libs, no fork, and stack size is fixed. As such, do not include the MMU in your Nios II build.
- The application executable format on uClinux is not ELF, but (compressed) binary flat format, FLT.
- We will use initramfs (which is quite new to uClinux), instead of romfs. The initramfs is compressed. The rootfs (initrd) image can be linked into the kernel, and make the booting easier. You don't need other devices, such as MTD, CF/IDE, NFS for rootfs to start up your uClinux. As they may not be available for a new custom board. You can mount other devices or filesystem later, eg jffs2, in user space.
You should start with a minimal system with only,
- Nios II f or s core, with a hardware multiplier, (f-core suggested, s-core is slower).
- sdram (minimum requirement 8MB),
- one full featured timer,
- a jtag/serial uart
Note in Linux, irq 0 means auto-detected, so you must not use irq 0 for ANY devices, except for timer.
It is possible to use e-core, but it will be very very slow.
It is possible to run without a hardware multiplier, but you will need some hack.
Let's start it step by step
- Try Out uClinux with pre-built binary images if you have Altera Nios dev boards.
- Install Nios II Linux install the source and build tools. Or you can use prebuild Binary Tool chain.
- UClinux Dist build uClinux kernel and a collection of user applications.
Linux Articles in the Wiki
- Accessing your own hardware from userland programs
- Accessing hardware registers from user space programs shows how to manage a device via an mmap'ed file
- How to use a Flash file system to save configuration data:
- command line and scrips
using haserl scripts for runtime configuration
- Upload files using boa and cgihtml
- DebugKernel using insight gdb GUI to debug kernel.
- DebugApps debug user space applications using gdb, gdbtui, insight or ddd.
- EclipseCDT install and develop/debug with CDT IDE. ( Eclipse IDE outdated)
- Nios2IDE import uClinux-dist to Nios2 IDE, and debug.
- Altera NIOS Studio (Beta, no support for uCLinux yet)
- Adding you own stuff
- LinuxConfig basic kernel config .
- EPCSGuide Document outlining various uses for EPCS Configuration device
- EtherNet Ethernet device drivers and kernel network configuration
- NFSFileSytem NFS support and Root NFS.
- CompactFlash CF drive and IDE hard disk, CD/DVD reader/writer .
- AlteraPCI example design and driver for Altera PCI compiler in host bridge mode.
- UsbHost USB host drivers and device drivers.
- ModuleProgramming example hello kernel module.
- BuildrootGuide guide to build the cross compiler, uClibc and rootfs.
- BusyBox use busybox alone, without buildroot.
- KernelPatches Nios II kernel from linux-2.6.11 to 2.6.23 .
- CustomBootLoader boot from onchip memory instead of cfi or epcs flash.
- Mpeg2Dec mpeg2 decoder library.
- MmcSd mmc sd driver .
- WiFi wireless LAN 802.11 b/g .
- Running Java on uclinux-niosII board
- FrameBuffer VGA, PS/2, USB mouse kbd
- Video i2c, cmos camera sensor (how to do I²C)
- lcd_16207 kernel driver and example for the 2x16 LCD Display
- loginHOWTO How to set up a login prompt
- GitServer mini howto setup a git server to publish projects.
- ContributingCode mini howto commit patches to git uClinux-dist repository.
- BinaryToolchain install binary of Nios II cross-gcc compiler.
- CGI and Boa demo for DE2 using CGI in C and boa
- RootDevice boot kernel from device instead of initramfs
- NetSnmp build net-snmp.
- PortingApps add new packages to uClinux.
- Nios2 mmu linux
- GPIO simple gpio interface and driver
Board support package
When you do "make vendor_hwselect", it will extract the parameters of your custom hardware (address, irq, freq etc) from your sopc PTF file into
nios2-linux/uClinux-dist/linux-2.6.x/include/asm-nios2/nios2.h. Then they are used by kernel through the file
nios2-linux/linux-2.6/arch/nios2/kernel/config.c. You might need to modify the config.c file to match the component instant name.
NET: dm9000,smc91111,opencore eth,mtip1000, altera_tse IDE: altcf USB: isp116x,isp1362, isp1760/1761 CHAR: uart,watchdog,pio/button,spi,ps/2 keyboard mouse. MMC: mmc core MTD: EPCS I2C: opencore i2c, ds1307, i2c-gpio PCI: altpci VIDEO: altfb
Nios uClinux forum is the place to post questions. Don't post questions or comments on this wiki. If you have good suggestions or successful experiences to share, please update the wiki directly.
Before you post any questions, check the wiki and search previous posts first. If you can't find answer, then post as a new topic on the forum. When your questions got answered or resolved, it is suggested that you should update the wiki. It will be helpful to others and avoid repeated questions.
Mailing lists are the prime communication between developers.
You must adjust your mail client to send "plain text" format e-mail to the lists. Don't send "HTML" format e-mail.
You should not send "test" mail.
If you want to reply a post, you should quote only the minimum necessary part of previous post. And reply AFTER the quote. Reply to the "list", not the sender.
Tutorial and Projects
- uClinux on DE2-115, This document describes how to set up uClinux on NIOSII on an DE2-115 board. Including how to add custom hardware and kernel driver.
- Tutorial Video There is a Tutorial video available base on the above document that demonstrate how to boot uclinux on Nios II processor with mmu on DE2-115 board but you can apply these configuration to any custom board in order to boot uclinux, Qsys and Kernel configuration is described in the video
- custom hardware and driver, The project was to create a custom piece of hardware which we had to add to the standard Nios II core and write a linux driver to drive this hardware under uClinux. By piie.
- "Device drivers and Test application for a SOPC solution with Nios II softcore processor and μClinux", a excellent guide to DE1/DE2 projects from hans_wurst.
- The document about implementing and testing is located at: http://www.hs-augsburg.de/~carcass/nios2-uClinux/uClinux_Nios2_Devicedrivers_and_Testapplication_Documentation.pdf
- The project-files are located here http://www.hs-augsburg.de/~carcass/nios2-uClinux/
- Redhat's doc] , linux installation guide and gnu tools usage, Must-Read for newbie.
- RPJday's wiki on Nios2 uClinux, step by step guide.
- Nacide's linux tutorial, in-depth technical notes.
- blackfin uClinux guide,
- GNU gcc,make,...
- Jdhar's site with Nios II kernel svn and many drivers
- Linux Tutorial
- the coldfire uclinux note
- books about kernel
- Nios II uClinux guide in Chinese by Alex Liu
- Linux Hardware Compatibility Lists & Linux Drivers
- Tips for planning an embedded Linux project
- Embedded Linux best practices
- Books on Embedded Linux
- http://trac.cross-lfs.org/, very detailed e-book available here called "Cross-Compiled Linux From Scratch".