Board bring up with PetaLinux SDK

2012-05-11Publicerad av Sven-Åke Andersson


Up to now we have been using a pre-built PetaLinux image that was downloaded to the SP605 board. Now it is time to build our own image from scratch. We will follow the instructions in the document Board Bring Up with PetaLinux SDK.

Modifying the hardware platform

We will modify our original MicroBlaze design for running Linux. Let's start XPS and right-click the microblaze_0 entry and select Configure IP.

We select the configuration Linux with MMU and click OK. (We will also change the name of the QSPI_FLASH to primary_flash which is the name PetaLinux is expecting to see).

To rerun to complete design flow click: Export to SDK. When the export has finished we are ready to start SDK.

Starting SDK

We have to setup the PetaLinux environment before we start SDK.

--> cd /opt/home/svan/PetaLinux/petalinux-v2.1-final-full
--> source
--> xsdk &

Select workspace

Select the new workspace in the Workspace Launcher. We will use one workspace per hardware project, since each hardware project will have its own BSP configuration. The workspace must reside inside the PetaLinux installation.


Configuring software settings

After designing the hardware system, it is now necessary to configure a Linux BSP for our project. This is required to automate the Linux board bringup. The Xilinx SDK workflow is used to configure the Linux BSP. The steps required for the workflow is described in the following sections.

Add PetaLinux repository

  1. Click Xilinx Tools menu and select Repositories.
  2. Click the New button in the upper left corner.
  3. Browse to the edk_user_repository and click OK


First stage boot loader

FS-Boot is a simple bootloader developed by PetaLogix, intended to serve as the primary bootstrap mechanism when the MicroBlaze CPU first boots. It is  recommended for most applications that require a ready-to-run boot solution. In a typical system runtime scenario, FS-Boot's primary purpose is to bootstrap the main system bootloader (such as U-Boot) from flash memory. In the board bringup phase, FS-Boot may also be used to download an initial bootloader image (e.g. U-Boot), for first-time boot.

Adding FS-boot

To add fs-boot to our system click the File menu and select <New> and select <Xilinx C Project>. Select FS-BOOT from <Select Project template> and click next.

No hardware platform

The first time we start SDK with a new workspace we have to add the hardware platform.



We find the system.xml file in the SDK export directory.


Here is the New Project window.


Click Finish. This will create PetaLinux BSP fs-boot-bsp_0 and fs-boot_0 application.



Nine months later

The compilation fails because we are missing the file auto-config.h. This file should be automatically generated during the build process. I have no idea why it is not found in this directory: ....../petalinux-v12.12-final-full/hardware/user-platforms/SP605_MB/workspace/fs-boot_0_bsp/microblaze_0/include

Universal Bootloader

U-Boot (Universal Bootloader) is an open source bootloader targeted for embedded system platform across multiple architectures including ARM, PPC, M68K, MIPS and MicroBlaze. The U-Boot project is maintained by DENX Software Engineering and is hosted at Sourceforge. U-Boot bootloader supports a wide range of tools and facilities targetted for embedded systems.

Configure PetaLinux BSP for U-boot

Right click on the fs_boot_bsp_0 project in the Project Explorer. Select Board Support Package Settings. Make sure PetaLinux is selected.



Configure fs-boot settings

The fs-bootloader (fs-boot_0) is used to fetch U-Boot image from the U-Boot partition in the flash memory to main memory and will run the U-Boot from main memory when system boots up. To do this the start address of U-Boot in flash memory must be given:
  1. Right click on the fs-boot_0 project in the Project Explorer
  2. Select C/C++ Build settings
  3. Select the Tool Settings tab
  4. Set configuration profile at the top of the page to [All configurations]
  5. Click Symbols under MicroBlaze gcc compiler
  6. In the Defined symbols box click the Add button (with the plus sign)
  7. In the Enter Value window, enter CONFIG_FS_BOOT_OFFSET=<value>. This value must match the offset from the start of the flash memory to the boot partition as set in the PetaLinux system configuration menu, under <System Settings->Flash Partition Table>. If we haven't changed anything the value will be 0x200000.



No vector table needed

As fs-boot is a simple bootloader it does not require setting up vector tables. This can be done in the following steps:
  1. Click Miscellaneous under MicroBlaze gcc linker
  2. Enter <-Zxl-mode-novectors> in the Linker field.
  3. Click Apply


Set fs-boot to Release profile

  1. Right click on the <fs-boot_0> project in the Project Explorer
  2. Select Build Configurations
  3. Choose Set Active and select <Release>

Build the fs-boot project

When we build the fs-boot project SDK also runs PetaLinux BSP generation tools. These tools automatically generate the software platform configuration files required in the sebsequent board bringup stages.
  1. Right click on the fs-boot_0 project in the Project Explorer
  2. Select Build project
  3. Wait for the build to finish

Finalizing the FPGA bitstream

At this stage, the hardware platform is ready and properly configured and the fs-boot executable binary is ready, but not initialise to BRAM yet. This following section documents how to initialise the fs-boot to BRAM and create the bitstream.
  1. Start XPS if not already running.
  2. In the Project tab of the project information area, expand the <Elf Files> option.
  3. Double click on the microblaze_0 item.
  4. A Select Elf file window will pop up and allows us to select which Elf file to be used to initialize the BRAM.
  5.  Find the fs-boot executable created by SDK.
  6. Click OK to close the Elf file window.
  7.  Select Device Configuration menu and select <Download Bitstream> to create the download.bit file which has the fs-boot initialised to BRAM and program the FPGA.


First stage bootloader starting

The FS-Boot will start automatically after we downloaded the bitstream. Here is the print out on the console.


We are ready to download the Linux image. But before we can download it we have to build it. See next chapter. While we are waiting we can read the FPGA from scratch blog.