Labels

[nios2]uClinux on NOIS2

reference on \url http://www.nioswiki.com/OperatingSystems/UClinux

µClinux
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.3, which is free and binary compatible with RHEL5. You may find step by step guide on Linux installation and usage from Redhat's doc . You may install it to a (20+GB suggested) partition on your PC along with 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 sof, download image, debug and program flash using 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 QuartusforLinux for details. You can find links to major linux distributions here. Don't use Redhat9, for 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 Linux PC, so that it can share files with 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 Linux shell to program JTAG on coLinux under Windows. You must use 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 , 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 be not available for a new custom board. You can mount other devices or filesystem later,eg jffs2, in user space.


Hardware requirements

You should start with a minimal system with only,

  • Nios II f or s core, with 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 hardware multiplier, but you will need some hack.


Let's start it step by step

  1. TryOutuClinux with pre-built binary images if you have Altera Nios dev boards.
  2. InstallNios2Linux install the source and build tools. Or you can use prebuild BinaryToolchain .
  3. UClinuxDist build uClinux kernel and a collection of user applications.


Linux Articles in the Wiki:

Supported devices,

NET: dm9000,smc91111,opencore eth,mtip1000
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

Support Forum

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

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.

nios2-dev mailing list for Nios II specific topics.
uclinux-dev mailing list for uClinux topics.

Wish List and To Do

ToDo list 

Tutorial and Projects




No comments:

Post a Comment