Linux Bring-Up on SoPC

System-on-Programmable-Chip is an emerging trend in the embedded world.
Here’s what I did to bring-up Petalinux on Xilinx Spartan-6 devkit SP605/SP601.
Petalinux is an embedded Linux distribution for Xilinx FPGA’s MicroBlaze softcore. Since SDK v1.3, the current release as of early 2011, Petalinux supports PowerPC440 hardcore.
Once you have the right hardware and software tools, such as devkit (SP605 or SP601), Xilinx ISE (12.4, 12.3 is fine), Petalinux SDK (v1.3) and a Linux host (a Xubuntu 10.4 VM on Macbook), it is surprising easy to bring-up Linux on FPGA. The idea is the same if you have a different hardware and software combination.

1. Install Xilinx ISE 12.4 for Linux. Petalinux SDK depends on Xilinx design suite to run.

I installed ISE (Embedded Edition) to a CIFS network share, which is a Journaled HFS+ external portable USB2 hard drive connected to Macbook (it is worth for another article to cover the topic, may be some other time). If ISE is installed on a virtual disk, it takes about 12G space for ISE, EDK, PlanAhead, LabTools and SDK (not all are necessary for our purpose).
Here’s how ISE 12.4 is setup.

ISE 12.4

Xilinx JTAG Platform Cable drive needs to be installed too. I installed CP210x USB/UART driver on Macbook host.

2. Install Petalinux SDK 1.3

The SDK should be installed on a Linux file system, because of some Linux specific symbolic links. I installed it to my Xubuntu’s second ext4 virtual disk.

Here’s how Xilinx and Petalinux (/media/users) are mounted:

Mounts

Here’s how SDK is setup. I installed it to /software/target/ because of the specific need for the projects I am working on.

SDK 1.3

3. Treakin Ubuntu
The following first two changes are needed for SDK under Ubuntu.

  • SDK scripts are using pushd/popd, so replace /bin/sh (link to /bin/dash) and point it to /bin/bash.
  • Create symbolic link /usr/bin/gmake, pointing to /usr/bin/make.
  • I also found a weird thing about SDK 1.3. It looks for some files from ISE 12.3, so create a symbolic link 12.3 and points it to 12.4 (See Picture ISE 12.4).
  • 4. Design hardware
    PetaLogix’s Board Bringup Guide is extremely useful, but not all that clear. To bring up Linux, it needs UART, system timer, DDR and MicroBlaze hardware, Ethernet and Flash are optional. UART, system timer and Ethernet must be interrupt driven.
    Create a folder, say sopc, under $PETALINUX/hardware/user-platforms.
    Launch Xilinx Platform Studio (enter $xps &) and choose Base System Builder wizard.

    Base System Builder wizard

    Create New XPS Project by specifying project file name, say sopc.xmp under $PETALINUX/hardware/user-platforms/sopc, and search path at $PETALINUX/hardware/edk_user_repository.

    XMP Project

    Keep “PLB system” as the default interconnect type, and move BSB wizard forward to “Board Select”. Choose “Spartan-6 SP605 Evaluation Platform” as the “Board Name”.

    SP605

    Move BSB wizard forward by using all default selections till “Peripheral Configuration”. Add xps_timer, check “Use Interrupt” option and choose “Two timers are present” for “Configuration Mode”.

    xps timer

    Check “Use Interrupt” option for Ethernet_MAC.

    Ethernet

    For RS232_Uart, select 115200 for “Baud Rate”, and check “Use Interrupt” option.

    UART

    Move to “Cache Configuration”, and check both “Instruction Cache” and “Data Cache”.

    Cache

    Move the wizard to the end to finish BSB, and go back to XPS. In “System Assembly View” tab, double click MicroBlaze instance to launch “MicroBlaze Configuration Wizard”. Select “Linux with MMU” configuration, and then “OK” button to finish the wizard.

    Select “Software Platform Settings” from XPS “Software” menu. For “Software Platform” tab, select “petalinux” as “OS” under “OS & Library Settings” section.

    Software Platform Petalinux

    For “OS and Lib Configuration” tab, make the selections for peripheral as highlighted in the following screenshot. If FLASH is used in the design, make sure its value is properly set.

    OS and Lib Configuration

    Now the hardware design is done, time to build bitstream by selecting “Generate Bitstream” from “Hardware” menu.
    Before doing that, and if FLASH is used, make sure FLASH’s base address must be after DDR3. It can be changed and verified from XPS “System Assembly View” tab under “Address”.
    In my environment, it takes about 22 minutes to finish the build process. The generated bit file is located at: $PETALINUX/hardware/user-platforms/sopc/implementation/sopc.bit. It will be used to configure Spartan-6 FPGA on SP605 later.

    5. Design software

  • Create software platform by using: petalinux-new-platform:
    petalinux-new-platform -c <cpu-arch> -v <VENDOR> -p <PLATFORM> 

    Create Software Platform

    Architecture configuration, Linux kernel configuration, and DTS file, etc., are generated at: $PETALINUX/software/petalinux-dist/vendors/tcao/sopc.

  • Configure Software Platform:
    petalinux-copy-autoconfig -v <VENDOR> -p <PLATFORM> PROJECT_FILE 

    Configure Software Platform

    FPGA configuration files and drivers are copied to proper folders in $PETALINUX/software/petalinux-dist/linux-2.6.x.

  • Configure Kernel and Applications.
    petalinux-config-kernel
    petalinux-config-apps 

    Configure Kernel and Apps

  • Build Linux Kernel
    cd $PETALINUX/software/petalinux-dist
    make 

    Build Kernel

    It takes about 21 minutes to build the kernel. Kernel image is at:
    $PETALINUX/software/petalinux-dist/images/image.elf.

    6. Upload configuration and application
    Now comes the fun part to configure FPGA and unload Linux kernel. Connect JTAG USB and USB/UART cables to the host, power on SP605 or SP601 board. I forward the JTAG USB connection to VM, and keep USB/UART connection to host (baud rate is 115200).

  • Configure FPGA
    Navigate to the hardware project folder and launch XMD:
    $xmd
    XMD% fpga -f xxx.bit

    FPGA Programming

  • Upload Linux Image
    Within XMD, connect to Microblaze core, upload the Linux image and boot Linux:
    XMD% connect mb mdm
    XMD% dow xxx.elf
    XMD% run

    Linux Upload

    From serial console, login as root.

    Petalinux Console

  • 3 Responses to “Linux Bring-Up on SoPC”

    1. Ali Says:

      Interesting. More interesting will be seeing real-world applications using this combination of xilinx (spartan 6?) and petalinux.

      Thanks for the post, helfull indeed.

    2. tingcao Says:

      The solution is being used for commercial equipments in mass production.

    3. Muhammad Ilyas Says:

      Thanks.
      Helpful solutions.

    Leave a comment