In keeping with our theme of free stuff (see Embedded Technology Journal, January 27, 2009) we proudly chronicle the newest free alternative for embedded developers: a free Linux-compatible microprocessor. Never has so much been offered to so many for so little. Or something like that.
Here’s the deal. Altera, the world’s second-best-known FPGA company, has struck a deal with Wind River Systems, the world’s second-best-known embedded-software company, to port Linux to Altera’s NIOS II processor. And since NIOS is free, you’ve got yourself a free 32-bit microprocessor capable of running a genuine full-on multitasking Linux operating system.
Naturally, there’s a catch. In fact, there are two. First off, NIOS is free only if you’re already using Altera’s FPGA chips (more on this later). Second, the Linux itself isn’t free; Wind River charges a significant amount of money for access to the software, and even more money for annual support.
That’s right – the microprocessor is free but the open-source software costs money. One wonders how such a paradox came to be.
Let’s focus first on the hardware. If you’re a NIOS neophyte, you’re in for a treat. NIOS is a “soft core” processor design that Altera happily gives away for free to any customer using its FPGA chips. As an Altera customer, you’re able to put as many NIOS processors into an FPGA as you like, with the only limitation being the capacity of the chip itself.
Why NIOS and not, say, ARM or PowerPC or x86? For years, programmers and engineers have been trying to implement microprocessors in FPGA chips, but the results were always dismal. FPGAs, by their nature, don’t lend themselves to processor implementations. They don’t have the right mix of logic and interconnect that microprocessor architectures require, so it’s a bad fit. Although technically you can make an ARM or a PowerPC to work in an FPGA, it’ll be slow and awkward and expensive and power-hungry. It’s like making a pig dance: it’s not pretty and it annoys the pig.
Enter NIOS. Altera, like its arch-rival Xilinx, wanted to give developers the ability to implement CPUs in FPGAs. So rather than shoe-horn a standard processor into a fundamentally incompatible logic fabric, the company went the other direction and created its own CPU specifically tailored for its FPGAs. Xilinx came up with MicroBlaze and Altera did NIOS (the name doesn’t stand for anything).
Because NIOS (like MicroBlaze) is designed to suit FPGA logic structures, there are some compromises, but nothing that the average programmer would worry about. It’s a fully functional 32-bit processor complete with memory management, caches, branch prediction, and a rich instruction set. It’s even customizable. Like any self-respecting processor, NIOS comes with a C compiler and other basic software-development tools. The only downside is that NIOS works only in Altera-brand FPGA chips. If you’re not using Altera’s silicon you can’t use NIOS.
Which is, of course, precisely the point. That’s the reason Altera developed NIOS and gives it away for free (Xilinx does the same with MicroBlaze). It’s the sweet treat that keeps you coming back for more. But if you’re already committed to using Altera FPGAs in your design, then NIOS is a complete freebie. It doesn’t even take up a significant amount of space. About 4000 logic elements is all that’s required; wee enough to fit in even the smallest Cyclone III device. Giant Stratix IV chips can hold hundreds of NIOS II processors and still have room left over. It’s really a zero-cost processor – if you’re already using Altera FPGAs. You do have to pay a small, one-time license fee for NIOS – but even that is included in many of the development kits.
Software… and Support
A processor is only as good as its software. One problem with a specialty processor like NIOS is that there isn’t much software available for it. Oh, you can get Micrium’s MicroC/OS-II RTOS and a TCP/IP network stack, but most of NIOS’s sparse software library is self-supported open-source code. With the free hardware you mostly get free software. Some assembly required.
This is what makes Wind River’s Linux such a big deal. First, it’s remarkable that such a large and complex operating system would run on a small and simple FPGA-based processor. Second, it’s equally remarkable that a large company like Wind River would throw its weight behind NIOS II. The business case must have been compelling for the company to expend the effort required to port Linux and provide the support it will require for years into the future.
Wind River is no charity, however, and the company expects to be paid for its work. Unlike Altera’s NIOS, Wind River’s Linux isn’t free. The company doesn’t disclose the terms of its license agreements and has no published price list, but developers can expect to pay thousands of dollars for access to the Linux port, along with recurring payments for annual support. In short, this is anything but a cheap open-source alternative.
So the hardware might be free (or at least, mostly buried in the cost of the FPGA and/or the development kit) but the software cost is likely to be substantial. Is it worth it? Quite possibly, but the answer depends on your goals – and your philosophy.
To many programmers, the whole point of Linux – its raison d’être, if you like – is that it’s an open-source alternative to commercial operating systems. In short, that it’s free. Paying money for access to the software defeats the whole purpose of using Linux.
Some developers choose Linux for reasons of control. They like to tweak the code to suit their own purposes and don’t like the idea of being beholden to an outside commercial entity.
For either of these camps, Wind River’s Linux is anathema. (Presumably, the same would be true of Red Hat Linux, or any of the many other commercial distributions.) But to many department heads, program managers, and business executives, paying money for Linux makes perfect sense. It’s money well spent on a quality port with round-the-clock technical support. And it minimizes the distractions to the engineering team. Unless your company’s core competence is porting operating systems, there’s little to be gained by doing it yourself. Focus instead on your key value-add and leave the software plumbing to someone else. It’s modular programming at its best.
So then it boils down to the choice of Linux and its suitability to the task. Do you need such a big operating system? Many embedded systems do, and Linux has been growing in popularity for many years. It’s easy to find programmers with Linux experience (though not many will have NIOS experience), so staffing is easy. It even looks good on the resume.
Linux has a big memory footprint, however. So even though the processor uses very little of the FPGA, you’ll need to include a memory controller, plus several megabytes of DRAM outside the chip. Keeping NIOS fed will be a design task in itself; there’s no point in starving the processor once you’ve gone to all the trouble to include it. Fortunately, Altera provides plenty of design assistance and support here. Tens of thousands of its customers have used NIOS II in their designs, so there’s a ready source of support.
If Linux is right for you, and if you don’t have strong feelings about processor architecture, and if you can wrap your head around the idea of free hardware but expensive open-source software, this may be just the ticket. It’s certainly a milestone. Giveaway FPGA processors started out as pretty modest affairs, more science project than serious processor. That’s clearly changed, with real operating systems doing real work in real projects. Let’s hear it for progress.