Configure FPGA/SPI Flash to Run Linux on LX9 MicroBoard, Part 1 – Preparation

This is Part 1 for the topic, to prepare configuration data for LX9 MicroBoard.

The FPGA design is done with ISE 13.2 based on AXI/Little Endian MicroBlaze 8.20a. The details were presented here at Run Linux on Avnet Spartan-6 LX9 MicroBoard.

The Linux kernel is built with Petalinux SDK 2.1. You may contact PetaLogix to obtain a license and SDK to try out. If you prefer Xilinx’s embedded Linux solution, you can find useful information from its Open Source Wiki. From configuration point of view, it makes no difference which one is used.

The keys to prepare the configuration data are:

  • understand how SPI Flash is partitioned
  • understand how each partition is used
  • make sure proper sizes for partitions, especially for the partition where Linux is at

You may need build kernel more than once, if you don’t know the kernel size beforehand. For example in the second build, you can adjust partitions to fit Linux into flash.

Here’s Flash partitions used by Petalinux, and sizes are modified because of 11MB kernel. Note SPI Flash on the MicroBoard has 256 64KB blocks, total space is 16MB.

Partition Name Size (blocks) Flash Address Usage
0 fpga 2MB (32) 0x0 bitstream and fs-boot
1 boot 256KB (4) 0x200000 u-boot
2 bootenv 128KB (2) 0x240000 u-boot environment variables (not used here)
3 config 128KB (2) 0x260000 used by flatfsd to store persistent data, required but not used by configuration
4 image 12.5MB (200) 0x280000 Linux kernel and filesystem
5 spare 1MB (16) 0xf00000 remaining space (not used here)

Here’s how partitions are specified in kernel configuration (System Settings -> Flash Partition Table -> Image Partition Size).

System Settings

Flash Partition Table

Image Partition Size

Once the kernel is rebuilt, along with the outputs of FPGA bitstream from ISE/EDK, and U-Boot from XSDK, the following files are used to construct configuration data, and/or bootstrap Linux:

File Description Built by Usage
system_bd.bmm BRAM memory map ISE/XPS to generate download.bit by script d2m
mb_system_top.bit design bitstream
fs-boot_0.elf fs-boot XSDK
u-boot.elf u-boot executable Petalinux SDK not used by configuration, but useful to transfer images to Flash
u-boot-s.bin u-boot relocatable binary to generate sopc_lx9.mcs by script pgen.ub
image.ub Linux kernel and filesystem binary

This is the script d2m, a wrapper of data2mem:

data2mem \
  -bm mb_system_bd.bmm \
  -p xc6slx9csg324-2 \
  -bt mb_system_top.bit \
  -bd fs-boot_0.elf \
  tag microblaze_0 \
  -o b download.bit

This is the script pgen.ub, an wrapper of promgen:

promgen -w \
  -p mcs \
  -c FF \
  -o sopc_lx9 \
  -s 16384 \
  -u 0000 download.bit \
  -data_file up 200000 u-boot-s.bin \
  -data_file up 280000 image.ub \

The following capture summarizes the procedure to generate configuration data.

Generate Configuration Data

If you would rather prepare PROM from iMPACT GUI, here’re the steps (Note, the files could be at any folder).
Launch iMPACT and select “Prepare a PROM File”.

Prepare PROM File

Select and Enter as following (highlighted).

Prepare PROM Steps

Add device bitstream.

Add Device Bitstream

Add 2 data files.
The first one is U-Boot, and make sure it is at proper address on Flash, in this case it is 0x200000.

U-Boot Flash Address

Add U-Boot

The second data file is Linux kernel and filesystem. Make sure the Flash address is set to 0x280000.

Kernel Flash Address

Add Kernel

Here’s the resulting data file assignment.

Data File Assignment

Proceed to generate configuration data.

Generate File

You can find scripts and source data files from here.

As a side note, when people move to high end FPGA solutions with processor integration, as Xilinx calls Zynq as EPP (Extensible Processing Platform), and Altera calls SoC FPGA with HPS (Hard Processor System), there is less or no need, in a sense, to configure FPGA from persistent storage such as Flash. The processor can easily make bitstreams and software images available to FPGA.
For large volume and low cost applications, soft-cores such as MicroBlaze and Nios are good solutions, and configuration is still needed.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: