uCLinux on LEON3

MicroController Linux (uCLinux) is a Linux operating system for embedded hardware systems without a memory management unit (MMU).

The LEON3 is a 32-bit VHDL processor core based on the SPARCV8 RISC instruction set architecture.

This project will involve synthesis and placement of a LEON3 processor onto a commercial off the shelf (COTS) field programmable gate array (FPGA), uCLinux will then be loaded to the FPGA.

Hardware Used:

Xilinx Virtex-5 ML-505 Board.
Xilinx Platform Cable USB
Host Computer. x86-64 machine (AMD Phenom x4 9950 Black (AMD64))

System:

  • Ubuntu 8.10/9.10 running Sun VirtualBox Version 2.2.2 r46594/Version 3.1.2 r56127.
  • Virtual Machine running CentOS 5.3 i386.
  • Download:
    • CentOS-5.3-i386-bin-1of6.iso
    • CentOS-5.3-i386-bin-2of6.iso
    • CentOS-5.3-i386-bin-3of6.iso
    • CentOS-5.3-i386-bin-4of6.iso
  • Procedure:
    1. Obtain a desktop computer. Any desktop machine with a USB port, serial port, and internet connection should suffice. Install the host Operating System of Ubuntu 8.10, as well as the specified VirtualBox.
    2. Download the CentOS distribution, specific .iso files listed above.
    3. (VirtualBox is used here, however, CentOS could of course be used as the machine’s primary operating system). In VirtualBox, create a new virtual machine. Specific options used are described in CentOS_5.3_i386.xml
    4. With the new virtual machine, mount and boot to CentOS-5.3-i386-bin-1of6.iso.
    5. When installing CentOS, install the following extras: “Development Libraries”,”Development Tools”,”Java Development”,”Legacy Software Development”.
    6. Login-name: ‘centos’ sans single quotes.
    7. Once CentOS is installed: a. Applications->System Tools->Software Updater
    8. We know have a fresh, updated operating system to begin the project.

Building uCLinux:

Cross Compiler
The cross compiler is necessary to compile uCLinux using LEON3 as the target architecture.
In the CentOS virtual machine, open a terminal.

$ cd
$ pwd
/home/centos
$ mkdir uCLinux
$ cd uCLinux/
$ mkdir crosscompiler
$ cd crosscompiler/
$ wget ftp://gaisler.com/gaisler.com/linux/linux-2.0/toolchains/sparc-linux-3.2.2/sparc-linux-3.2.2-1.0.1.tar.bz2
$ tar xjf sparc-linux-3.2.2-1.0.1.tar.bz2 
$ su
Password: 
$root cp -R ./sparc-linux /opt
$root exit
exit
$ export PATH=$PATH:/opt/sparc-linux/bin
			

uCLinux Source
We’re going to use an instance of uCLinux that is safely ensconced within SnapGear Linux provided by Gaisler. The mainline distribution of uCLinux is rife with ‘paper cuts’.

$ cd
$ cd uCLinux
$ mkdir uCLinux_source
$ cd uCLinux_source
$ wget ftp://gaisler.com/gaisler.com/linux/linux-2.0/snapgear/snapgear-2.0-p36.tar.bz2
$ tar xjf snapgear-2.0-p36.tar.bz2
$ cd snapgear-2.0-p36
$ make xconfig
         Kernel/Library/Defaults Selection, Libc Version: uClibc, Customize Vendor/User Settings: Y,
         'Save and Exit'.
         Set Kernel Command Line: n
         boa 0.94.14rc21: n
         hdparm: n
         SnapGear Embedded Linux Application Configuration -> Network Applications, telnetd: n,
         'Save and Exit'.
$ make dep
$ make
			

Built images will be found at: /home/centos/uCLinux/uCLinux_source/snapgear-2.0-p36/images/

TSIM
Validate the built image by using a LEON3 emulator from Gaisler.

$ cd
$ cd uCLinux
$ mkdir TSIM
$ cd TSIM
$ wget ftp://ftp.gaisler.com/gaisler.com/tsim/tsim-eval-2.0.14.tar.gz
$ tar xfz tsim-eval-2.0.14.tar.gz
$ export PATH=$PATH:/home/centos/uCLinux/TSIM/tsim-eval/tsim/linux/
$ cd /home/centos/uCLinux/uCLinux_source/snapgear-2.0-p36/images/
$ tsim-leon3
$ tsim> load image-2.0.x.tsim
$ tsim> run
			

Building the LEON3:

Download Xilinx ISE WebPACK. Make an account and log in. The product you want is: “SW, ISE WebPACK 11.1 Single File Download Image” and the name of the file is “Xilinx_11.1_WebPack_SFD.tar”.

$ cd
$ cd uCLinux
$ mkdir Xilinx_ISE_11
$ cd Xilinx_ISE_11
$ #Place the downloaded Xilinx_11.1_WebPack_SFD.tar into this directory.#
$ tar xf Xilinx_11.1_WebPack_SFD.tar
$ cd Xilinx_11.1_WebPack_SFD
$ su
Password: 
$root echo 0 >/selinux/enforce #to turn off secure linux
$root ./xsetup #Keep defaults, except: unselect 'Acquire or Manage a License Key', unselect 'Launch XilinxUpdate'.
$root chmod -R 755 /opt/Xilinx/11.1
$root exit
exit
$ cd /opt/Xilinx/11.1
$ ./settings32.sh
$ export PATH=$PATH:/opt/Xilinx/11.1/ISE/bin/lin
			

With the Xilinx account, request a 30 day trial license, or purchase a license. When the process is complete, you will have a file called ‘Xilinx.lic’. Place the file in ‘/home/centos/.Xilinx/’, chmod the permissions to 755.

Now that Xilinx ISE is installed, we’ll pull down the LEON3 from Gaisler, and compile.

$ cd
$ cd uCLinux
$ mkdir LEON3
$ cd LEON3
$ wget http://www.gaisler.com/products/grlib/grlib-gpl-1.0.21-b3848.tar.gz
$ gzip -rd grlib-gpl-1.0.21-b3848.tar.gz
$ tar xf grlib-gpl-1.0.21-b3848.tar
$ cd grlib-gpl-1.0.21-b3848/designs/leon3-xilinx-ml505
$ make xconfig #Tested with enabling and disabling the MMU, both work. OK.
$ make ise-map
$ make ise #The resulting file is 'leon3mp.bit'.
			

Program ML505 with uCLinux and LEON3:

Install Windows XP SP2 (32-bit) to a computer, install Xilinx ISE 11.1 Design Suite. ‘Xilinx_11.1_ISE_DS_SFD.tar’ can be downloaded from Xilinx. Disable ‘Acquire or Manage a License Key’ and disable ‘Launch XilinxUpdate’. XP is used to program the board instead of CentOS due to time constraints, everything works without much trouble on XP. A good follow on project would be to program the board using CentOS.

Attach a serial cable from the ML505 to the XP machine. Connect the Xilinx Platform Cable USB from the XP host machine to the ML505. Attach the ML505 to a power source, and turn on. Do not connect to Windows Update to find a driver, allow the driver to be installed automatically.

Use Xilinx iMPACT to download the leon3mp.bit file to the FPGA.
1. Start Xilinx iMPACT, automatically create and save a project->Yes. select ‘Configure devices using Boundary-Scan(JTAG)’->OK.
2. ‘Do you want to continue and assign configuration file(s)?’->No. ‘Device Programming Properties’->Cancel.
3. On the xc5vlx50t chip, right click ‘Assign New Configuration File’. Select the leon3mp.bit. ‘Attach SPI or BPI PROM’->No.
4. On the xc5vlx50t chip, right click ‘Program’. ‘Device Programming Properties’->OK.
5. Xilinx iMPACT should report ‘Program Succeeded’.

Download GRMON from Gaisler to debug and program the ML505 board.
1. ftp://gaisler.com/gaisler.com/grmon/grmon-eval-1.1.37.tar.gz
2. Extract to suitable directory.

C:\Xilinx\Tutorials\grmon-eval\win32> grmon-eval.exe -u
  grlib> info sys
			

Load the built image file to execute Linux on the FPGA.

C:\Xilinx\Tutorials\grmon-eval\win32> grmon-eval.exe nb -u
  grlib> load image-2.0.x.dsu
  grlib> run
			

Output: http://www.samueltoepke.com/projects/LEON3_support/grmon-output.txt.

Follow On Work

  • Benchmarks. SPECint. Compile the core with/without the hardware FPU, and see how much worse SPECfp would be.
  • Troubleshoot the ?CLinux Official Distribution. Fixing the ‘paper cuts’, as well as diff-ing the code between official and SnapGear. After fixing and gratuitous documentation, re-committing to the official site.
  • SystemACE. Using a CF card to combine the LEON3 bit file as well as the Linux image into a SystemACE file and install onto the CF card that came with the ML505.
  • Xilinx ISE Installation to CentOS. There are a myriad of tutorials and papers that touch on various parts of getting the ISE to work. Putting together a single source document with precise steps for Xilinx ISE installation would be useful.

References

Building and Loading U-boot On A Virtex Board. 29 November 2009 &#60http://xilinx.wikidot.com/u-boot#toc8&#62.

Casey Cain. Using and Creating Flash Files for the MicroBlaze Development Kit – Spartan-3E Edition. Gaisler Research, 1.0 edition, Nov 2006. &#60http://www.xilinx.com/support/documentation/application_notes/xapp963.pdf&#62.

CMPE 202. 29 November 2009 &#60http://www.soe.ucsc.edu/classes/cmpe202/Fall09/classwork.html&#62.

Daniel Hellström. SnapGear Linux for LEON. Gaisler Research, 1.37.0 edition, Nov 2008. &#60ftp://gaisler.com/gaisler.com/linux/linux-2.6/snapgear/snapgear-manual-1.0.37.pdf&#62.

EDK Concepts, Tools, and Techniques. Xilinx, 11.2 edition, Jun 2009. &#60http://www.xilinx.com/support/documentation/sw_manuals/xilinx11/edk_ctt.pdf&#62.

EEMBC–The Embedded Microprocessor Benchmark Consortium. 29 November 2009 &#60http://www.eembc.org/home.php&#62.

Embedded Linux/Microcontroller Project. 29 November 2009 &#60http://www.uCLinux.org/&#62.

Embedded Processor Block in Virtex-5 FPGAs. Xilinx, 1.7 edition, Oct 2009. &#60http://www.xilinx.com/support/documentation/user_guides/ug200.pdf&#62.

Embedded System Tools Reference Guide. Xilinx, 11.3.1 edition, Sep 2009. &#60http://www.xilinx.com/support/documentation/sw_manuals/xilinx11/est_rm.pdf&#62.

FPGA design from scratch. 29 November 2009 &#60http://svenand.blogdrive.com/archive/40.html&#62.

FPGA Developer: ML505 Tutorials and Examples. 29 November 2009 &#60http://www.fpgadeveloper.com/2008/10/ml505-tutorials-and-examples.html&#62.

GRMON User’s Manual. Gaisler Research, 1.1.36 edition, Sept 2009. &#60http://www.gaisler.com/doc/grmon.pdf&#62.

GRLIB IP Core User’s Manual. Gaisler Research, 1.0.21 edition, Aug 2009. &#60http://gaisler.com/products/grlib/grip.pdf&#62.

GRLIB IP Library. 29 November 2009 &#60http://www.gaisler.com/cms/index.php?option=com_content&task=section&id=13&Itemid=125&#62.

Jiri Gaisler, Marko Isomaki. LEON3 GR-XC3S-1500 Template Design. Gaisler Research, Oct 2006. &#60http://gaisler.com/doc/leon3-gr-xc3s-1500.pdf&#62.

Jiri Gaisler, Sandi Habinc, Edvin Catovic. GRLIB IP Library User’s Manual. Gaisler Research, 1.0.21 edition, Aug 2009. &#60http://gaisler.com/products/grlib/grlib.pdf&#62.

LEON. 29 November 2009 &#60http://en.wikipedia.org/wiki/LEON&#62.

LEON3/GRLIB SOC IP Library. Gaisler Research,. &#60http://www.gaisler.com/doc/Leon3%20Grlib%20folder.pdf&#62.

LEON3MP. 29 November 2009 &#60http://www.gaisler.com/cms/index.php?option=com_content&task=view&id=167&Itemid=125&#62.

LEOX.org – Free Hardware and Software Resources for System on Chip. 29 November 2009 &#60http://www.leox.org/resources/sw.html&#62.

ML505/506/507 Overview and Setup. Xilinx, May 2009. &#60http://www.xilinx.com/products/boards/ml505/ml505_10.1_2/docs/ml505_overview_setup.pdf&#62.

ML505/ML506/ML507 Evaluation Platform. Xilinx, 3.1.1 edition, Oct 2009. &#60http://www.xilinx.com/support/documentation/boards_and_kits/ug347.pdf&#62.

ML505/ML506/ML507 Getting Started Tutorial. Xilinx, 3.0.3 edition, Jun 2009. &#60http://www.xilinx.com/support/documentation/boards_and_kits/ug348.pdf&#62.

ML505/ML506/ML507 Reference Design. Xilinx, 3.0.3 edition, Jun 2009. &#60http://www.xilinx.com/support/documentation/boards_and_kits/ug349.pdf&#62.

Micro Architecture Santa Cruz Group (MASC). 29 November 2009 &#60http://masc.soe.ucsc.edu/&#62.

Muthuswamy, Bharathwaj. FPGA TOOLS-HOW TO. Berkeley EECS, Spring 2007. &#60http://myweb.msoe.edu/~muthuswamy/pubs/FPGA-Tools_HOWTO.pdf&#62.

Publications. 2009. 20 November 2009 &#60http://users.soe.ucsc.edu/~elkaim/elkaim/Publications.html&#62.

Running Xilinx ISE and EDK 10.1 in Ubuntu 8.10. 29 November 2009 &#60http://www.aclevername.com/articles/linux-xilinx-tutorial/edk101-ubuntu810.html&#62.

SPEC-Standard Performance Evaluation Corporation. 29 November 2009 &#60http://www.spec.org/&#62.

Tutorials for Running Linux on Xilinx FPGAs. 29 November 2009 &#60http://www.aclevername.com/articles/linux-xilinx-tutorial/index.html&#62.

Virtex-5 Family Overview. Xilinx, 1.0 edition, Feb 2009. &#60http://www.xilinx.com/support/documentation/data_sheets/ds100.pdf&#62.

Virtex-5 FPGA Configuration User Guide. Xilinx, 3.8 edition, Aug 2009. &#60http://www.xilinx.com/support/documentation/user_guides/ug191.pdf&#62.

Virtex-5 FPGA User Guide. Xilinx, 5.2 edition, Nov 2009. &#60http://www.xilinx.com/support/documentation/user_guides/ug190.pdf&#62.

Virtex-5 FPGA Packaging and Pinout Specification. Xilinx, 4.6 edition, May 2009. &#60http://www.xilinx.com/support/documentation/user_guides/ug195.pdf&#62.

Virtualbox and the Xilinx USB Platform Cable. 29 November 2009 &#60http://peeters-noppe.net/alcaic/2009/09/virtualbox-and-the-xilinx-usb-platform-cable/&#62.

XILINX JTAG tools on Linux without proprietary kernel modules. 29 November 2009 &#60http://www.rmdir.de/~michael/xilinx/&#62.

Leave a Reply