Personal tools
You are here: Home Members jbutanowicz Tango on ML403
Document Actions

Tango on ML403

by jbutanowicz last modified 2007-05-25 15:20

Recipe on running Tango device servers on Xilinx ML403 FPGA board.

Project description


The aim of the project is embedding Tango device server on the FPGA board. The device server is intended to do signal processing. In order to use TANGO on the FPGA we need to cross-compile OmniORB (TANGO is based on CORBA) and TANGO on the host machine. Host machine is an i686 architecture while FPGA is a powerPC. The project main steps are as follow:


ML403 development board description


In the project we use:

PowerPC and MicroBlaze Development Kit - Virtex-4 FX12 Edition


Kit contents:

  • Virtex-4 FX12 FX12 ML403 board
  • Compact Flash Card - 512 MB
  • EDK/Xilinx Platform Studio Software
  • development Kit Reference CD
  • ISE WebPack Software
  • Power supply
  • Download cable (PCIV or USB)
  • Serial cable
  • Cross-over ethernet cable


Cross-compilation tools

For the cross-compilation of the OmniORB as well as TANGO crosstool was used. It is a free set of scripts to build and test several versions of gcc and glibc for most architectures supported by glibc. The crosstool was choosen instead of the cross-compiler attached with Virtex-4 board because of it is a powerful and yet simple to install and use. After installation of the cross-compiler on the i686 machine, the simple "Hello world" program in C and C++ was compiled and tested on a target powerPC host. Both tests succeeded.

Crosstool howto


OmniORB cross-compiled for powerPC

Cross-compilation of omniORB on machine with i686 processor for the powerPC architecture as a target machine is painful due to the fact that the standard Linux-style installation(./configure, make, make install) is not provided for cross-compilation. Man needs to create own make files for compilation.
Another problem is caused by a difference in architectures. The i686 is little-endian architecture while the powerPC is a big-endian. When cross-compiling problem arises with compilation of '''omniidl'''. Omniidl seems to stumble over the fact that host and target have different endianess.

  • Cross-compilation was conducted using modificated scripts from here.

Scripts are quite old and obsolete but the method for cross-compilation presented by them works. Scripts have been updated in order to cross-compile omniORB-4.1.0 on i686 machine for powerPC target architecture.

OmniORB for powerPC cross-compilation

Packet of scripts for cross-compilation of omniORB for PowerPC architecture consists:
  •   omniorb-ppc-install.sh
  •   host-build.sh
  •   host-install.sh
  •   ppc-build.sh    
  •   ppc-install.sh
  •   ppc_linux_2.0_glibc2.1.mk

These scripts build and install omniorb 4 on your system, in both x86 and
ppc 405 flavors. For the cross-compilation crosstools were used.

-------------------------------------------------------------------------------
OmniOrb 4 build procedure:

 1. Download current omniORB release from here
 
 2. Get the install scripts pack from here.

 3. Edit omniorb-ppc-install.sh and adapt variables:
  •  OMNIORB_VERSION - to reflect the version of omniORB going to be installed
  •  OMNIORB_TAR - to indicate a path to the omniORB tar archive

 4. Edit ppc_linux_2.0_glibc2.1.mk and adapt variables:
  •  PYTHON - to path of the python bin installed on the host machine
  •  CROSS_TOOLDIR - path to cross-compilation tools (bin)
  •  CROSS_TOOL_PREFIX - prefix in the name of standard compilation tools

 5. sh sudo omniorb-ppc-install.sh

The script unpacks omniORB, builds the native platform version (i586_linux_2.0_glibc2.1)
using sh host-build.sh, and installs it in /opt/omniorb4/native via
sudo sh host-install.sh.

It then builds the cross-version by running sh ppc-build.sh.
This uses some of the files installed by host-install.sh.

Finally, omni-install-405.sh is run using sudo, installing the 405 cross stuff into /opt/omniorb4/.

Cross-compilation of TANGO for the PowerPC

After OmniORB-4.0.7 was cross-compiled for the PowerPC, download and untar TANGO. Before running ./configure script export flags for cross-compiler tools.

 export CC=/your_path_to/crosstool/gcc-4.1.0-glibc-2.3.6/powerpc-405-linux-gnu/bin/powerpc-405-linux-gnu-gcc
 export CXX=/your_path_to/crosstool/gcc-4.1.0-glibc-2.3.6/powerpc-405-linux-gnu/bin/powerpc-405-linux-gnu-g++


After that create build folder for TANGO in the untared TANGO directory
 
 mkdir build-ppc
 cd build-ppc


and run configure script(assuming that you have MySQL installed according to TANGO requirements)
 
 ../configure -host=powerpc-unknown-linux-gnu -build=i686-linux --prefix=/path-to-your-installation/tango-ppc --enable-static --disable-shared
 --with-omni=/path-to-omniORB-4.0.7/omniORB-4.0.7/ --without-java CXXFLAGS="-static -static-libgcc" LDFLAGS="-static -static-libgcc
 -L/path-to-omniORB-4.0.7/omniORB-4.0.7/lib" build_alias=i686-linux host_alias=powerpc-unknown-linux-gnu --without-zlib


As soon as the TANGO was compiled go to lib and run make followed by make install. We do not need anything on the ppc apart of libraries.
 
 cd lib
 make
 sudo make install


TANGO libraries were successfuly cross-compiled if following libraries were created:

  • liblog4tango.a
  • liblog4tango.la
  • libtango.a
  • libtango.la

GPIO registers access

The board will be used for processing of a signal coming from an external device. The device is going to be connected  via J5 and J6 connectors. We can access them using differential expansion header GPIO registers. Addresses are described in a document accessible from Xilinx webpage.

To be able to read/write onto these addresses mapping from CPU address space into physical address needs to be done. To access arbitrary addresses under Linux from userspace the /dev/mem file is used. This file allows a process to use the mmap call to obtain a user space pointer to a physical address. Although writing simple test program for that purpose is pretty straight forward, a free, simple and yet powerfull devmem2 program was used.

The c++ source code was cross-compiled and uploaded onto Virtex board. Few tests were conducted with general purpose LEDs. On the address 0x90000000 bit words were put. It caused switching these LEDs on and off, for example command:

 ./devmem2 2415919104 w 15

switched 4 general purpose LEDS on.

Using demo version of MontaVista Linux shipped together with Virtex-4 FX12 on a flash card the full control over hardware is possible.


Testing Tango device server on FPGA

Very simple Tango device server has been generated using POGO. After that the server was cross-compiled on the host machine running Ubuntu Linux. Binary executables were uploaded on the FPGA using serial cable and minicom program. In order to test the device following settings have had to be adapted:

  • setting local network between Ubuntu-host and FPGA

 Ubuntu-host address: 192.168.0.1 hostname:  amandla
 FPGA address: 192.168.0.2 hostname:  ml403


  • all libaries from cross-compiled omniORB and TANGO have been stored in one directory /home/butanowi/sharedORB

  • the directory with libraries have been exported in local network using nfs, entry in /etc/exports:

 /home/butanowi/sharedORB 192.168.0.2/24(rw,sync,no_root_squash)

  • on ml403 libraries mounted:

 entry in /etc/fstab-> 192.168.0.1:/home/butanowi/sharedORB    /mnt/nfs        nfs     tcp,noauto    0    0
 mount /mnt/nfs


  • on FPGA path to shared libraries and tango host variables were added to environment

 export TANGO_HOST=localhost:10000
 export LD_LIBRARY_PATH=/mnt/nfs


  • on the host machine tango has started

 /opt/tango/bin/tango start

  • using a jive application new server with a device has been added to the database

 Tester_ppc/ml403    test/ppc/1

With all steps successfully acomplished tang device server has been able to start on the FPGA.
Using a simple client application measurements of performance speed were verified with results as follow:

 invoking ping command: 3 ms
 reading attribute: 5 ms


Paris by Night Server

For a complete test of a Tango device server running on ML-403 the leds device server was written. Source code and binaries can be downloaded from here. User can switch on and off LEDs on the board(GPIO addresses access) via tango server from host machine having access to the board.



Linux-2.6.20 Kernel for ML403 board

Preparation of linux-2.6.20 kernel


1. Download the linus tree for 2.6 linux from kernel.org:

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git $ cd linux-2.6

Note: you need to have git installed.

2. Get virtex development tree from Secret Lab.

$ echo git://git.secretlab.ca/git/linux-2.6.git#virtex-dev > .git/branches/virtex-dev $ git fetch virtex-dev $ git checkout virtex-dev

Note: you can get the tree more easily if you have access to segfs. Download tree from: /segfs/dserver/tmp/linux-2.6

3. Prepare Makefile.

edit linux-2.6.20/Makefile
change cross-compiling flags (around 185 line in the 2.6.20 kernel)

ARCH :=ppc
CROSS_COMPILE :=/your/cross-compiler/directory/powerpc-405-linux-gnu-

Note: For installation of cross-compilator for PowerPC please refer here


PowerPC architecture design on FPGA

1. In XPS from EDK-8.2.02i with Service Pack 2.4+0 create new project. 2. Use following components using a wizard:


  • Board vendor: Xilinx

    Board name: Virtex 4 ML403 Evaluation Platform Board revision: 1

    Note: if you do not have a Xilinx vendor provided use repository path.




  • Use PowerPC architecture




  • Reference clock frequency: 100.00 MHz

    Processor clock frequency: 100.00 MHz
    Bus clock frequency: 100.00 MHz
    Debug I/F: FPGA JTAG
    No debug
    Cache disabled
    On chip memory: none




  • RS232_Uart: OPB UART16550

    Configure as UART: 16550
    Use interrupt: yes
    LEDs_4Bit: OPB GPIO
    Use interrupt: no
    LEDs_Positions: OPB GPIO
    Use interrupt: no




  • Push_Buttons_Position: OPB GPIO

    Use interrupt: no
    IIC_EPROM: no
    SysAce_CompactFlash: OPB SYSACE
    Use interrupt: yes
    Cypress_USB: no




  • DDR_SDRAM_64Mx32: PLB DDR

    Use interrupt: yes
    Ethernet_MAC: no
    TriMode_MAC_GMII: PLB TEMAC
    DMA: Scather gather DMA
    Use interrupt: yes




  • SRAM_256Kx32: PLB EMC

    FLASH_2Mx32: no




  • plb_bram_if_cntlr_1: 16 KB




  • Base System Details


3. Generate the system files. 4. In xps edit .mhs file and change hard_temac driver version from 3.00.a to 3.00.b:

BEGIN hard_temac
.
.
PARAMETER HW_VER = 3.00.a
.
.
END

Note: BSB defaults to hard_temac_v3_00_b, which doesn't work well for PHY communication on the ML403 board

5. Generate bitstream.

In XPS: Hardware menu --> Generate Bitstream

Note: Take a coffee break. Generating a bitstream is very time and CPU resource consuming.


Libraries and BSP's generation in XPS

1. Prepare Software Platform Settings for Linux 2.6

  • In XPS open: Software menu --> Software Platform Settings
  • In Software Platform menu set OS to linux_2_6
  • In OS and Libraries add connected peripherals
  • In OS and Libraries set uart16550 bus clock freq to 100000000
  • In OS and Libraries set memory size to 0x4000000

2. Generate libraries and BSPs

In XPS: Software menu --> Generate Libraries and BSPs

Note: For more datails concerning generation of Linux 2.6 Board Support Packages(BSP) refer here

Linux 2.6.20 libraries/drivers update

Note: After the libraries and BSP was created, our kernel source tree needs to be adjusted with few files from Linux 2.6 Board Support Package.

Following Glenn G. Hart's notes:

1. From EDK 8.2.02i SP2.4+0 copy the files from the BSP to the kernel using the following steps.

  • Copy the file from /MyDesign/ppc405_0/libsrc/linux_2_6_v1_00_a/linux/arch/ppc/platforms/4xx/xparameters/xparameters_ml40x.h of the BSP to /linux-2.6/arch/ppc/platforms/4xx/xparameters/
  • Rename the file from xparameters_ml40x.h to xparameters_ml403.

Kernel image

1. Configuring the Linux Kernel.

invoke: make menuconfig in linux-2.6.20 directory
set all needed features of the intended system

Note: You can refer to my .config file and skip manual configuration. Copy the .config file into linux-2.6.20 directory under the .config name.

2. Compile kernel image.

After the kernel has been configured, run
make zImage

Now you are in possession of a freshly squeezed, embedded linux-2.6.20 kernel image.




Root File System using BusyBox


1. Create your own embedded Root File System using Busybox

Follow steps from the link.

2. Use Root File System from Montavista Preview Kit



Root File System on Compact Flash


Creating an ACE file

An Ace file is a file constructed from the FPGA bit file which implements PowerPC architecture and from Kernel image.
The file is used by SystemAce in order to architecture on FPGA and boot linux.

1. Launch EDK shell.

In XPS: Project menu --> Launch EDK shell

2. Go to your BSP project directory. 3. In your BSP project directory create a file with options - xupGenace.opt.

xupGenace.opt contents:
-jprog
-board user
-target ppc_hw
-board ml403
-hw implementation/system.bit
-elf /your_directory/linux-2.6.20/arch/ppc/boot/images/zImage.elf
-ace OutputLinuxAceFile.ace

4. Create the Ace file:

In EDK shell run:
xmd -tcl genace.tcl -opt xupGenace.opt

Note: On the board be sure to set the switches so that it will boot from JTAG (this causes it to try to boot from the SystemACE controller).

Compact Flash card preparation

1. Format Compact Flash card.

In order to make 3 partitions on the CF card do:
  • plug in your CF reader and the CF card,
  • assuming that your reader device is /dev/sdb on your Linux host machine, run
   fdisk /dev/sdb
  • delete the existing partition,
  • make the following partitions: Partition 1 FAT16 (6), Partition 2 Linux Swap (82), and Partition 3 Linux (83).

Note: The first partition only needs to be large enough to hold the system.ace file. The 3rd partition is where the root file system will go. The 2nd partition is for SWAP.

  • write out changes into partition table,
  • format partition 3 with a Linux file system invoking:
   mke2fs /dev/sdb3
  • copy the root file system created in the previous step over,


Note: The first partition (the SystemACE partition) needs a special format for SystemACE to recognize it.

  • create FAT16 partition runing,
   mkdosfs -s 64 -F 16 -R 1 /dev/sdb1


  • put a system.ace on partition 1 and you are ready to boot
  • create swap file system on second partition,
   mkswap /dev/sdb2


2. Set default bootloader parameters.

Check if your bootloader parameters are set like that (in Platform optionsmenu):
console=tty0,9600 root=/dev/xsa3 rw init=/sbin/init
if not set it, recompile the kernel Image, and recreate ACE file.

3. Create block and character devices.

In your created Root File System:
# cd /dev
# mknod -m 660 console c 5 1
# mknod -m 660 xsa b 254 0
# mknod -m 660 xsa1 b 254 1
# mknod -m 660 xsa2 b 254 2
# mknod -m 660 xsa3 b 254 3
# mkdir tts
# cd tts
# mknod -m 660 0 c 4 64



Root File System via NFS


To export the precompiled root filesystem via NFS, you must:

  • edit the /etc/exports file on your host machine,
  • add an entry for that filesystem - <rfs_dir> 192.168.0.2(rw,no_root_squash),
  • re-read the /etc/exports file: $sudo exportfs -ra
  • configure the linux-2.6 kernel with:
console=ttyS0,38400 root=/dev/nfs nfsaddrs=client:server:gateway:netmask rw nfsroot=<rfs_dir>

for example:
console=ttyS0,38400 root=/dev/nfs nfsaddrs=192.168.0.2:192.168.0.1:192.168.0.1:255.255.255.0 rw nfsroot=/opt/ml403_rootfs


Note: To a be able to access GPIO memory you need /dev/mem file. Use MAKEDEV on your host machine in order to get go into /dev directory of your embedded root file system, and invoke:

  • $ /dev/MAKEDEV -v generic console


Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: