Sunteți pe pagina 1din 10

Porting Linux to a Xilinx Microblaze Processor on the Virtex 6 ML605 FPGA Evaluation Board

Robin Coxe Close Haul Circuits, LLC (www.close haul.com/circuits) 31 August 2011 (revised 7 December 2011)

Prerequisites:

Xilinx ISE/EDK/SDK version 13.2 (either Linux or Windows). If installing the Xilinx tools on a Linux machine, please refer to the Appendix for workarounds to potential installation issues.

Linux workstation (I used a netbook running Ubuntu 10.10) with git installed

Xilinx ML605 Virtex6 FPGA evaluation board and 12V power adapter

Two (2) USB A to USB mini B cables

Procedure:

1)

Download the AXI4 interconnectbased ML605 reference design for ISE Design Suite 13.2

2)

from http://www.xilinx.com/products/boa rds/v6embd/reference_designs.htm (You'll need a Xilinx account and will be asked to agree to a license prior to downloading.) Extract the ISE project to a directory of your choice.

3) Open up the project in Xilinx ISE by double clicking on:

<ise_project_dir>/ug668_13_2_AXI4_PRODN/ML605_Embedded_Kit/ML605_System/HW/ise_proj.xise

on: <ise_project_dir>/ug668_13_2_AXI4_PRODN/ML605_Embedded_Kit/ML605_System/HW/ise_proj.xise Page 1 of 10

4) Fire up XPS by double clicking on system.xmp .

Fire up XPS by double ‐ clicking on system.xmp . 5) Click on the Project tab.

5) Click on the Project tab. 6) Click on the Bus Interfaces tab and double click on microblaze_0 . 7) In the XPS Core Config microblaze_0 window, select Linux with MMU (click on Tux the Penguin) and then click Next. 8) Make sure the Barrel Shifter is enabled, enable the Extended FPU, select a MUL64 integer multiplier, enable the Integer Divider , the Additional Machine Status Register Instructions, and the Pattern Comparator . Click OK .

9) Go back to the ISE Project Navigator window. Right click on Export Hardware Design

9) Go back to the ISE Project Navigator window. Right click on Export Hardware Design to SDK with Bitstream and select Run from the pulldown. Go get a cup of coffee.

select Run from the pulldown. Go get a cup of coffee. 10) Eventually, SDK will launch.

10) Eventually, SDK will launch. The next steps involve the creation of the Xilinx Device Tree. 11) Follow the directions at http://xilinx.wikidot.com/device treegenerator .

12) Set the bootargs field in Board Support Package Settings to: console=ttyS0 root=/dev/ram ip=on (In

12) Set the bootargs field in Board Support Package Settings to:

console=ttyS0 root=/dev/ram ip=on (In this particular configuration, the Linux file system will be stored in volatile RAM). 13) Enter RS232_Uart_1 as the console device .

RAM). 13) Enter RS232_Uart_1 as the console device . 14) In the main SDK window, navigate

14) In the main SDK window, navigate to Project > Build All . 15) Navigate to <SDK_workdir>/devicetree_bsp_0/microblaze_0/libsrc/device tree_v0_00_x and locate the file xilinx.dts .

16) The next steps involve cross compilation of the Linux kernel for the Microblaze on a Linux workstation. Follow the directions at the bottom of the following page to install the Little Endian Tools and Ramdisk Image: http://xilinx.wikidot.com/mb gnutools 17) Note that <dir where tools are untarred> MUST begin with a forward slash or the cross compiler will get confused. (e.g., /home/yourhomedir/microblaze, NOT home/yourhomedir/microblaze ). On Ubuntu, you can add the PATH and CROSS_COMPILE settings to your .bashrc file. Exit your terminal window and open up a new one for the settings to take. 18) Get the Linux kernel from the Xilinx git archive:

git clone git://git.xilinx.com/linux 2.6 xlnx.git master

19) Referring back to Step #15, copy the Xilinx Device Tree file generated by SDK (xilinx.dts ) to <kernel_dir>/arch/microblaze/boot/dts/xilinx.dts . 20) Copy the Linux filesystem gzip archive downloaded in Step #16 (initramfs_minimal_le.cpio.gz ) to <kernel_dir>. 21) Now for the configuration of the kernel… Make sure you're in <kernel_dir>. Start with the default kernel configuration file provided with the kernel for the SP605 AXI reference design.

> make ARCH=microblaze sp605_le_defconfig

22) To customize the kernel for use with the Microblaze core defined in XPS on the Virtex6 FPGA on the ML605 board:

> make ARCH=microblaze menuconfig

23) Go to Platform Options . Make sure the Definitions for MICROBLAZE0 look like this picture:

Definitions for MICROBLAZE0 look like this picture: 24) Build the kernel: > make ARCH=microblaze

24) Build the kernel:

> make ARCH=microblaze simpleImage.xilinx 25) Get another cup of coffee. 26) Find the kernel image <kernel_dir>/arch/microblaze/boot/simpleImage.xilinx and copy it to someplace convenient. 27) Find the FPGA bitstream

<ise_project_dir>/ug668_13_2_AXI4_PRODN/ML605_Embedded_Kit/ML605_System/HW/ise_top.bit and

copy it into the same directory as the kernel image. 28) Start Xilinx SDK and Launch a Xilinx shell: Xilinx Tools > Launch Shell . You can exit SDK if you'd like. 29) In the Xilinx shell, navigate to the location where the FPGA bitstream and the Linux Kernel image live.

30) Make sure the 2 USB cables are connected from the host PC to the front panel of the ML605 board and power on the ML605 board. 31) Open up a serial console connection. For Windows machines, follow the directions on p. 11 15 of http://www.xilinx.com/support/docum entation/boards_and_kits/ug533.pdf to install the USB to UART driver and configure the RS232 serial connection. 32) Start up a serial console (e.g. TeraTerm or screen /dev/ttyUSB0 9600 from a Linux terminal). Serial connection settings: 9600 baud, 8 bits, 1 stop bit, no parity, no flow control. The ML605 will by default boot up to a test project. Fear not! 33) From the Xilinx shell, start up the Xilinx Microprocessor Debugger:

> xmd

34) Load the FPGA and the Linux kernel image:

XMD% fpga f ise_top.bit XMD% connect mb mdm XMD% dow simpleImage.xilinx (Spewage on the screen. Wait for a minute or two ) XMD% con 35) Linux should now boot in the serial console window. Wait for a command prompt. It can't do all that much, but you can navigate around the directory tree and top works. Voila!

Creation of a Compact Flash Image (New!)

1)

In the Xilinx shell, navigate to the location where the FPGA bitstream and the Linux Kernel

2)

image live. Copy the file genace.tcl from %XILINX%/ISE_DS/EDK/data/xmd

3)

Launch a Xilinx shell (see step #28 above).

4)

Create the file linuxmb.ace file by typing:

xmd tcl genace.tcl –hw ise_top.bit –elf simpleImage.xilinx –ace linuxmb.ace –board ml605 –target mdm

5)

If you don’t have a Compact Flash card formatted with a FAT16 filesystem, follow the

directions here: http://billauer.co.il/ blog/2011/07/systemacebitstreammicroblazeprocessorcompact flash/

6)

Delete all of the files and folders from the Compact Flash card.

7)

Copy linuxmb.ace to the CompactFlash card and insert it into the slot on the ML605 board.

8)

Power up the ML605 board and open a serial console as in step #32 above. Linux will boot.

Mounting an NFS Filesystem (New!)

1)

Create a new directory called nfsboot in a convenient location on the Linux workstation that

2)

will act as the NFS server and cd to it. Uncompress the Linux filesystem to the nfsboot directory:

>zcat <kernel path>/initramfs_minimal_le.cpio.gz | sudo cpio –i –d –H newc ‐‐no absolute filenames

3)

Ensure that NFS server is installed on the Linux workstation:

>

sudo aptget install nfskernelserver portmap nfscommon

4)

Create an export filesystem: sudo mkdir /export/nfsroot

5)

Mount the Linux filesystem extracted in step 1:

>

sudo mount ‐‐ bind <path to nfsroot>/nfsroot /export/nfsroot

6)

Add an entry to /etc/fstab to avoid having to issue the mount command on system restart

7)

(sudo gedit /etc/fstab): <path to nfsroot>/nfsroot /export/nfsroot none bind 0 0 Add the following lines to /etc/exports ( sudo gedit /etc/exports):

/export/ 192.168.1.0/255.255.255.0(rw,fsid=0,in secure,no_subtree_check,sync) /export/nfsroot 192.168.1.0/255.255.255.0(rw,nohide,insecure,no_subtree_check,sync)

8)

9)

If not connected to a LAN , replace 192.168.1.0 with the IP address or IP address range of the ML605 client. Start the NFS server: sudo /etc/init.d/nfs kernelserver start Some tweaks to the Linux kernel configured in Steps 23 and 24 are necessary for NFS to work properly. You can either manually edit the .config file in <linux kernelpath> or repeat Step 22 and navigate through the menuconfig.

#

# Boot options

#

CONFIG_CMDLINE_BOOL=y CONFIG_CMDLINE="console=ttyS0 ip=dhcp rootfstype=nfs root=/dev/nfs rw

nfsroot=192.168.1.2:/export/nfsroot,tcp,nolock,wsize=4096,rsize=4096"

CONFIG_CMDLINE_FORCE=y

CONFIG_SECCOMP=y

Replace 192.168.1.2 with the NFS server IP address.

#

#

Networking options

#

CONFIG_PACKET=y

CONFIG_UNIX=y

CONFIG_XFRM=y

CONFIG_INET=y

CONFIG_IP_FIB_HASH=y

CONFIG_IP_PNP=y

CONFIG_IP_PNP_DHCP=y

CONFIG_IP_PNP_BOOTP=y

CONFIG_INET_XFRM_MODE_TRANSPORT=y

CONFIG_INET_XFRM_MODE_TUNNEL=y

CONFIG_INET_XFRM_MODE_BEET=y

CONFIG_INET_LRO=y

CONFIG_INET_DIAG=y

CONFIG_INET_TCP_DIAG=y

CONFIG_TCP_CONG_CUBIC=y

CONFIG_DEFAULT_TCP_CONG="cubic"

CONFIG_DNS_RESOLVER=y

Make sure that CONFIG_IP_PNP_DHCP=y.

10) Rebuild the kernel: > make ARCH=microblaze simpleImage.xilinx 11) Get another cup of coffee. 12) Find the kernel image <kernel_dir>/arch/microbla ze/boot/simpleImage.xilinx and copy it to someplace convenient. 13) Download the kernel to the ML605 board by repeating Steps 30 35 or create a System Ace Compact Flash image. Success!

Next steps:

Get Microblaze u boot working: http://xilinx.wikidot.com/u bootnew

Build a C application program in SDK and run it on the Microblaze.

Connect custom IP to the AXI4 bus in the Virtex6 FPGA.

World domination.

 Connect custom IP to the AXI4 bus in the Virtex ‐ 6 FPGA.  World

Page 8 of 10

Tux the Polyester Penguin approves of this message. Thank you to Analog Devices Lyric Labs

Tux the Polyester Penguin approves of this message.

Thank you to Analog Devices Lyric Labs ( www.lyricsemi.com ) for sponsoring this exercise.

Appendix: Ubuntu Linux Installation Hiccups

Thanks to Andy Schweitzer for uncovering these issues.

To get the Xilinx tools to run correctly on a Linux machine, add the following lines to .bashrc:

source /opt/Xilinx/13.2/ISE_DS/settings32.sh > /dev/null

To work around other ISE and EDK path issues, it may be necessary to create some soft links and move some files around:

sudo ln /usr/bin/make /usr/bin/gmake

cd /opt/Xilinx/13.2/ISE_DS/ISE/lib/lin/

sudo mkdir orig

sudo mv libstdc++* orig

cd /opt/Xilinx/13.2/ISE_DS/common/lib/lin/

sudo mkdir orig sudo mv libstdc++* orig

References:

http://forums.xilinx.com/t5/EDK andPlatformStudio/Synthesis problemof EDKprojectattachedin theISE12 4/tdp/135438

http://forums.xilinx.com/t5/Installation andLicensing/ISE 13 1 on kubuntu 11 04/td p/151626

USB cable driver problems:

Download this alternative Xilinx USB cable driver (requires libusb):

http://rmdir.de/~michael/xilinx/

Copy the following files (as sudo) to /etc/udev/rules.d

50 xilinx usbpav.rules:

ACTION=="add", BUS=="usb", SYSFS{idVendor}=="03fd", MODE="666"

xusbdfwu.rules:

# version 0003 ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0008", MODE="666" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0007", RUN+="/sbin/fxload v t fx2 I /usr/share/xusbdfwu.hex D $tempnode" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0009", RUN+="/sbin/fxload v t fx2 I /usr/share/xusb_xup.hex D $tempnode" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="000d", RUN+="/sbin/fxload v t fx2 I /usr/share/xusb_emb.hex D $tempnode" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="000f", RUN+="/sbin/fxload v t fx2 I /usr/share/xusb_xlp.hex D $tempnode" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0013", RUN+="/sbin/fxload v t fx2 I /usr/share/xusb_xp2.hex D $tempnode" SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="03fd", ATTRS{idProduct}=="0015", RUN+="/sbin/fxload v t fx2 I /usr/share/xusb_xse.hex D $tempnode"