Xcell Journal Home
  Xcell Journal Article
  Partner Yellow Pages
   
  Xcell Archives
  Subscription
  Comments & Suggestions
  Write Articles for Xcell

 

Home : Documentation : Xcell Journal Online : Article

(NOTE: For faster downloading, all online articles are TEXT ONLY versions with no graphics. To view the complete article with graphics, download the PDF version at the end of the article.)

Unleash Your Creativity with Embedded Linux on Virtex-II Pro FPGAs

by Milan Saini, Technical Marketing Manager, Xilinx, Inc.
milan.saini@xilinx.com (10/13/03)

Xilinx has partnered with MontaVista Software to provide a customized embedded Linux solution for Virtex-II Pro FPGAs.

The open-source Linux® kernel with realtime extensions now provides most real-time operating system (RTOS) functionality and is rapidly emerging as a viable alternative to other commercial offerings. An RTOS is typically used to operate the majority of today’s high-performance embedded systems.

The development of embedded applications on a single chip has reached new levels of integration, performance, flexibility, and ease of use with the introduction of Virtex-II Pro™ Platform FPGAs, which have up to four IBM™ PowerPC™ 405 32-bit RISC processors woven into the programmable fabric. The platform’s sophisticated technology, however, typically requires newer tools and methodologies to address the unique characteristics of the device.

For those new to embedded Linux applications or Virtex-II Pro devices, this article explains some key concepts and answers commonly asked questions.

Key Linux Features
The open-source, royalty-free, and POSIX-compliant nature of Linux helps developers build highly customized and highly portable applications. Linux derives much of its value from gradually accumulating functionality through the combined contributions of its worldwide base of users. Similar to Unix in many ways, Linux offers a range of powerful operating system capabilities, including memory protection, processes, threads, and extensive networking facilities. It is generally considered to be a mature and robust technology.

The Linux kernel is licensed under the terms of the GPL (General Public License) with an important clarification: Code that employs the normal services of the Linux kernel via system calls or dynamic (module) linkage is considered normal use of the kernel and does not fall under the heading of “derived work.” This means that dynamically linked device drivers may not be covered by the GPL and their source code need not be disclosed to recipients of binary versions of the drivers.

In Linux space, “glibc,” or the GNU C Library, is an important system call library used by most applications to provide an interface to the kernel. Glibc is distributed under the Lesser GPL (LGPL) license. Most applications link dynamically to this shared library to access the functionality of the kernel. Linking to glibc is not considered to be linking directly to the Linux kernel – having glibc under LGPL frees applications linked to glibc from the GPL licensing requirements.

This flexible licensing model enables the mixing of proprietary drivers and application code with the Linux kernel and libraries, opening up a wider set of applications for use on Linux.

What Is Embedded Linux?
Embedded Linux distributions such as MontaVista® Linux® are usually configurable versions of standard Linux that make it more suitable for embedded systems development. Among the notable changes are the addition of a real-time scheduler and a preemptable kernel. These features make the interrupt and task response times shorter and more predictable. As a result, interrupt and task responses are more in line with the requirements of typical embedded applications. MontaVista Linux is currently the primary development environment for Virtex-II Pro-based embedded systems.

Strengths of Combining Linux and Virtex-II Pro
The configurable nature of Linux combined with the high versatility of Virtex-II Pro architecture offers designers unprecedented system flexibility and unique HW/SW codesign possibilities.

Because the platform is completely programmable, a design function can be implemented in either hardware (programmable logic) or software (PPC405) depending on the real-time design constraints and tradeoffs between performance and flexibility, as shown in Figure 1.

Combining Linux and its reloadable modules with the partial reconfiguration feature of Virtex-II Pro FPGAs allows for features such as run-time device “hot-swapping,” as shown in Figure 2.

For example, based on environmental factors, a design can swap a 10/100 Ethernet MAC with a faster 1 Gb MAC in the FPGA. Linux can reload the corresponding new device driver dynamically and at run time. This allows a design to adapt to its environment without the need for redesign and redeployment, which is a significant advantage.

Typical Design Flow
Development of embedded applications on Virtex-II Pro devices typically involves the following:

  • Assembling a hardware platform
  • Configuring the Linux kernel
  • Developing the firmware (device drivers) and software application code
  • Downloading the design into the FPGA device or board.
The Xilinx Embedded Development Toolkit (EDK) and integrated software environment (ISE) software help a hardware engineer assemble a reference hardware platform. This process involves the instantiation, initialization, and configuration of the processor, bus, and peripheral components. The EDK tools (platgen, libgen) write both the hardware implementation netlists and the software header file. The header file named “xparameters.h” captures and stores customized information such as device ID, base address, and so forth for all peripherals in a single location. The information contained in this file is referenced by the kernel and drivers and is essential to building the Linux application.

Using one of several Linux configuration tools (such as the MontaVista Target Configuration Tool [TCT]™ GUI-based utility), the Linux kernel is configured by making appropriate selections of drivers and services required by the application software. In general, the idea is to keep the kernel image size as small as possible by excluding features not needed by the application. (Linux kernel configurations typically require between 2 and 8 Mb of memory.)

Application software for Linux can be developed and debugged with GNU C and C++ compiler tool chains to create binary “elf ” images that can be deployed onto a Virtex-II Pro board.

Various methods for debugging applications and downloading into the FPGA are discussed later in this article.

Embedded Linux Environment for Virtex-II Pro
Xilinx has partnered with embedded Linux pioneer MontaVista Software to provide a customized embedded Linux solution for Virtex-II Pro devices. Users receive the embedded Linux kernel, Virtex-II Pro device drivers, host and target tools, applications, utilities, and product support. Support includes updates, enhancements, defect corrections, training, and technical assistance. Some of the development tools are shown diagrammatically in Figure 3 and include:

  • Cross-compiler tool chain. To increase efficiency, developers use cross-development tools that run on faster and friendlier host machines. The code is compiled to run on the actual target CPU. MontaVista provides these tools for multiple Linux and Solaris hosts.
  • Libraries. Glibc and glibc-linux threads are the most commonly used set of libraries for Linux application development. These libraries contain the core set of functions to which most utility and application code links.
  • Kernel and drivers. The kernel provides core functionality such as memory management, threads, and I/O behavior. A “makefile” included in the distribution package is used to assemble the Linux kernel per the user and application requirements.
  • The target Linux file system. A kernel without programs to run is not useful, so a set of programs and utilities have been developed to run on Linux for the target PPC405 CPU. Examples of such programs include bash, tcsh, perl, awk, sed, grep, make, gcc compilers, a vi clone, emacs, and X Windows.
The above tools and utilities are packaged and distributed by MontaVista in its Professional Edition. MontaVista also provides a Preview Kit, a free evaluation version of this product.

The Linux kernel, libraries, and tools can also be compiled from the open source, but this configuration is not supported by Xilinx.

Prototyping Boards and Design Availability
Xilinx and its partners have made several Virtex-II Pro evaluation boards available, including the ML300 (V2P7) from Xilinx and the Insight V2P4/7 from Insight Electronics. The boards differ mostly in external-to-FPGA component configuration, with the ML300 offering, in general, a richer set of processor companion devices. These boards can be used for evaluation, demonstration, or development. Full details can be found by following the links at the end of this article.

The MontaVista Linux kernel and drivers have been tested with the ML300 Reference Design using EDK (Design Source: http://www.xilinx.com/ise/embedded/edk_examples.htm). This development platform provides a reasonable starting point for designing custom applications. The same design should run on other Virtex-II Pro boards without modifications.

Linux/Virtex-II Pro Device Drivers
A device driver is code that provides an abstraction layer for hardware I/O devices so that higher levels of software can access the devices in a uniform and hardwareindependent fashion. Since Virtex-II Pro FPGAs allow processor peripherals to be uniquely customized, the corresponding device-driver code must match the userselectable configuration of the device.

The custom and dynamic nature of the embedded platform assembly is an important difference between Virtex-II Pro development and traditional embedded development on boards and processors with static peripheral configurations. To speed development, Xilinx EDK tools have been designed to create custom software device drivers for all relevant hardware peripheral IP blocks Xilinx provides. The driver code is modular and generic and is designed to be easily adapted to higherlevel OS functions, as shown in Figure 4.

Several of the Xilinx-provided device drivers have been adapted for Linux and released as open source. Among them are: 16450/16550 UARTs, 10/100 Ethernet, PS/2 for mouse and keyboard, the System ACE™ CF configuration storage device, GPIO, PCI, TFT display, and touchscreen. The drivers can either be built directly into the kernel or dynamically linked as loadable modules.

Loading the Application into the Target FPGA
A typical boot sequence after power up is as follows:

  1. Load FPGA bitstream
  2. PPC boot
  3. Load Linux kernel from Flash memory
  4. Start application.
While an application is in active development, a software debugger like GDB can be used to load the application to the target CPU through the JTAG pins of the processor.

On production boards, several methods can be used:

  • Recommended method – use the Xilinx System ACE CF companion chip that can read the combined FPGA bitstream and Linux kernel image from a CompactFlash™ mass storage device or MicroDrive™ compact storage device. The System ACE CF chip configures the FPGA, boots the CPU, and then loads the kernel image into processor memory, as shown in Figure 5. The PowerPC 405 program counter is advanced to the starting address of the Linux kernel. After the system is up and running, the processor can use the CompactFlash/MicroDrive as its secondary storage device. Other benefits of this process include the flexibility to store multiple boot configurations on the FAT file system and eliminating the need for memory at the reset vector.
  • PPCBoot™/bootloader – a bootloader is a program that runs just before the operating system really starts to work; in fact, it loads the kernel of the operating system. PPCBoot is a general-purpose bootloader for embedded PowerPC boards, supporting more than 80, including boards based on Xilinx Virtex-II Pro FPGAs. It offers many features, including hardware initialization, loading kernel image, trivial file transfer protocol (TFTP) download, flash write access, and low-level diagnostics. PPCBoot is available from ppcboot.sourceforge.net.
Debugging Tools
For initializing the board, a host-based debugger such as GNU gdb with its graphical front end ddd (or products from emacs, Insight, and others) can nonintrusively control the PPC405 CPU. The processor’s JTAG pins are connected through a debugging interface such as Abatron’s BDI2000 or Lauterbach’s Trace32™ debugger, as shown in Figure 6. Connection can also be made through a Xilinx-provided resident host program called “xmd” in series with the Xilinx Parallel Cable IV. GDB has full visibility and control of the processor memory, caches, and TLB entries.

Using a Parallel IV cable, the ChipScope™ Pro Logic Analyzer tool from Xilinx helps provide visibility and debug features for corresponding hardware logic where most of the processor peripherals reside. Using a single cable to control and observe both the hardware and software not only simplifies the lab setup but also provides a comprehensive, powerful, and efficient system-debug methodology.

Conclusion
For data sheets, application briefs, and additional information on the ML 300 evaluation board, visit Xilinx online at www.xilinx.com/ml300, or for information on Virtex-II Pro FPGAs, visit www.xilinx.com/virtex2pro. For similar information on the Insight V2B evaluation board, visit www.insight-electronics.com/virtex2pro.

Additional information on MontaVista’s Professional Edition 3.0 can be obtained by visiting MontaVista online at www.mvista.com.

Related article:
MonteVista Linux and Virtex-II Pro Speed Your Design Cycles

Printable PDF version of this article with graphics. PDF logo (10/13/03) 457 KB

 
Jobs Events Webcasts News Investors Feedback Legal Privacy Trademarks Sitemap
© 1994-2008 Xilinx, Inc. All Rights Reserved.