UClinux
From Hamsterworks Wiki!
If you follow these steps through, you will be well on your way with uClinux. You will have
- installed the complete tool chain
- created a system from source
- tested it
- added a custom I/O port
- added a custom executable to the boot image
- successfully interfaced to the outside world
The system genreated will have approximately these attributes
- 100MHz CPU, no floating point, no hardware divide, no MMU
- 32MB RAM, with about 29MB free
- The console running over the JTAG cable
- No persistent storage
- A little under 20% of the FPGA resources dedicated to the processor, leaving 80% for your own logic.
Contents |
The use-case for a DE0-nano + uClinux
Let me start by saying that running Linux on your DE0-nano doesn't make much sense - but don't let that stop you.
Why does it not make sense?
- You will need to license a full NIOS II processor core to allow it to run untethered.
- You will need to configure the device every time power is applied or develop a boot loader to load the boot from the EPCS flash
- The development environment is very heavy
- The big benefit is networking, and the DE0 doesn't have any Ethernet connectivity out of the box.
- Writing Linux device drivers is a big undertaking (but you don't really need to).
- Without a MMU to keep things in check bugs cause the system to fall to bits really quick.
- Offchip SDRAM is a lot slower than using embedded RAM blocks
- If you what o use Linux as you are super-committed to open source, using the closed-source FPGA tools might be not to your liking.
When does it make sense?
- If your device needs a good reliable TCP/IP stack
- If you need a multitasking OS
- If you want to use this as a development platform for custom hardware
- If your development team are Linux bigots, or want to develop a complex applications on PCs before moving to the FPGA platform
- If you are trying to remain platform agnostic - today NIOS II, tomorrow ARM or PowerPC. For example, proof of concepts or if the hardware platform doesn't yet exist
- In a R&D or lab environment, where time and ease of implementation is more important than creating a marketable product
What is the alternative?
If you are committed to the Altera/NIOS II platform then the better option is using the standard Altera "Eclipse for NIOS II" environment.
- You can use on-chip memory for your code, which is configured on startup - no boot loader required
- You can still use the SDRAM for data
- It is fully integrate into the IDE workflow
- It is very compact, with only the features you need.
- Provides enough hardware abstraction, but not too much.
With that said, running uClinux on a DE0-nano isn't too hard, especially with a bit of guidance.
Building the base uClinux environment
See UClinux/Building for the Terasic DE0-nano on Fedora 14
Creating custom hardware on NIOS2 based systems
See uClinux/Expanding your DE0-NIOS2 system for how to add a simple parallel output port to the base system. This example drives LEDs on the DE0-nano, which isn't configured in the 'simple' hardware build.
Hacking a custom program into the distribution
See uClinux/Hacking a app for a program to drive the LEDs added above.