Embedded Linux

Galatea, Microblaze And Linux – How To Run Linux On Galatea PCI Express Spartan 6 FPGA Board

1694 views March 19, 2018 admin 3


FPGAs are best known for their flexibility and versatility. Such flexibility allows FPGAs not only to be used for custom logic circuits but also implement a processor on it and even run Linux (or other operating system) on the processor. The possibilities are only limited by imagination, and also by FPGA speed grade and size. This article will discuss how to create/implement Microblaze processor and run Linux on Galatea PCI Express Spartan6 FPGA Module. This is based on our previous article series for Saturn Spartan 6 FPGA Module. So we highly recommend that you read the series for Saturn and get yourself familiar with the steps. So let’s dive right in.


This article is structured into 4 sections.

  • Section I:Creating the Microblaze based design for Galatea
  • Section II:Generating Device Tree
  • Section III:Building Linux Image
  • Section IV:Running Linux on Galatea


For following this article, you would require:

  • Hardware
  • Software:
    • Xilinx Platform Studio installed on either Windows or Linux system
    • Linux system (author used Ubuntu 14.04 64-bit)

Section I: Creating the Microblaze based design for Galatea

For this section we are building Microblaze based embedded platform for Linux using Xilinx EDK. Now let’s get started. We will need to use XPS Base System Builder (BSB) to create a new project. To make the process easier, download BSB Wizard files from here and copy to the folder “C:\Xilinx\xx.xx\ISE_DS\EDK\board”. Once extracted, the complete path to the file should look like C:\Xilinx\xx.xx\ISE_DS\EDK\board\NumatoLab\ipxact\GalateaPCIeDevBoardLX45T_V1\data”. Now go to All Programs > Xilinx Design Tools > EDK and start Xilinx Platform Studio. Once XPS is loaded, click on “New BSB Project” under File menu or press Ctrl + Shift + B to invoke the BSB wizard. If everything went fine, you should be presented with BSB wizard window as shown below.

Enter path to a folder where you want to store the project and a project name (Here the project name is Galatea_Linux in the image above). Select AXI System in the interconnect Type section and click OK. In the next page of the wizard, select “Numato Lab” from the Board Vendor combo box (This option should be available if you have placed the BSB wizard support files for Galatea properly as mentioned earlier). Select GalateaPCIeDevBoardLX45T and 1.0 from Board Name and Board version combo boxes respectively and click “Next” to go to the next page:

Leave the Optimization Strategy to its default value and click Next.

By default, FT232_UARTand DDR3_MCB_BANK3 will be selected. Select memory size, I-cache size and D-cache size as 16KB. Then select FT232_UART peripheral and set the baud rate to 115200 and check the “Use Interrupt” check box. Then select “axi_timer” in the “Available Peripherals” list and add that to the system. Select the timer and check the “Use Interrupt” check box. Make sure everything is setup as shown in the image below and click “Finish” button.

Now Xilinx Platform Studio will generate a project for you based on the selections you made in the BSB wizard. If everything went well, you will be presented with a window as shown below

There is a bug in XPS where it fails to load valid parameters for DDR3_MCB_BANK3 from BSB Wizard files. This will result in failure in generating netlist. Workaround for this bug is to just regenerate the files for this IP core. Its not a difficult task. Just double click the “DDR3_MCB_BANK3” IP and click “Next” at every step and finally click “Finish”. There is no need to modify anything, just leave everything as is and click “Finish”.

Add “axi_spi” IP from IP Catalog. Right click on axi_spi_0 in the “System Assembly View > Bus Interfaces” tab and select “Configure IP” from the pop up menu. The AXI SPI Configuration Wizard will open. Set “Include both Receiver and Transmitter FIFOs” as “FALSE” and “Ratio of AXI Clock Frequency To SCK Frequency” as 2 and click “OK”.

Now we will configure the peripheral IPs. Right click on microblaze_0 in the “System Assembly View > Bus Interfaces” tab and select “Configure IP” from the pop up menu. The Microblaze Configuration Wizard will pop up. Select “Linux with MMU” under the “Select Configuration” options (Please see image below). 

At this point, we have finished configuring Microblaze CPU and all peripherals. The next step is to route all peripheral interrupts to the microblaze CPU through the interrupt controller. To configure interrupts, go to the “Ports” tab in “System Assembly View” and locate the “Open interrupt Control Dialog” button. This button is a little tricky to locate. Please see the image below for help.

In the interrupt control dialog box, make sure that both  FT232_UART and axi_timer_0 are connected to the interrupt controller and debug_module and axi_spi_0 are not connected to the interrupt controller as shown in the image below.

Now go to the “System Assembly View” and select “Addresses” tab and make sure all peripherals have a base address assigned (XPS will take care of this automatically, but just in case). Note the base address of DDR3 memory, we will need it when building Linux kernel. At this point, we are ready to build the project. Click on the “generate bitstream” button the left side pane to start build process. If build fails due to timing closure issues, go to project menu in XPS, select Project Options and uncheck “Treat timing failures as errors”. This should help the build complete without errors.

Now we recommend that you create a SDK application project for this hardware platform and test its basic functionality by creating a “Hello world” application. Please follow the steps similar to the section “Creating Application program for Microblaze based Embedded Platform” in the article Creating Xilinx EDK test project for Saturn – Your first Microblaze processor based embedded design to create a SDK project(creating SDK project for Galatea is similar to creating a SDK project for Saturn). Choose “Hello world” SDK application template when generating the application. Run the application on the board to make sure that everything so far works as expected.

Assuming you were able to build the hardware platform using XPS and test it using SDK successfully, let us move on to the discussion about how to build Linux kernel. There are different ways to do this depending on how much time and effort you would like to invest. The easiest of all is to use a tool such as Buildroot. In this example, we will use Buildroot to build our kernel. Buildroot, when properly configured, can download Linux kernel source, build cross compilation tools and build the kernel itself all with a single command.

Please note that we will continue using Windows for running Xilinx tools (and of course Linux for building kernel). Author has used Ubuntu 14.04 LTS 64 bit desktop version while putting together this article. We will do the following steps one by one to build the Linux Kernel.

Section II: Generating Device Tree

On many platforms, Linux kernel depends on a data structure called Device Tree to discover and configure different hardware components available on the board. Kernel uses the device tree in binary format which is generated by using device tree compiler. The input to the device tree compiler is a text file (with extension .dts) that describes all the hardware and dependencies. This file can be edited manually by hand if necessary. But fortunately, there are tools available that can help us generate device tree from our XPS/SDK projects.

Having completed all the steps before, now download the device-tree repository from Xilinx’s github account: https://github.com/Xilinx/device-tree-xlnx.git . If you have downloaded the zip, extract it in the same location as your SDK workspace. In case of the author, the directory structure was D:\XPS_PROJECTS\GALATEA_DEVP_BOARD\Galatea_Linux\SDK\device-tree-xlnx-master

Step 1: In XPS, select Project -> Export Hardware Design to SDK -> Export & Launch SDK. This opens the Xilinx SDK

Step 2: In SDK, go to Xilinx Tools -> Repositories.

Step 3: In the Dialog window, we have a section named “Local Repositories”.  Select “New” and select the device tree folder which you had downloaded and extracted to SDK workspace. Final result should look like in the below image.

Step 4: Go to File -> New -> Board Support Package. In the Dialog window, select “device_tree” under “Board Support Package OS” and press “Finish” and then “OK” in another dialog that opens.

This should generate a system.dts file along with a .dtsi file. We need both of them

Step 5: We have to merge the ‘.dtsi’ and ‘.dts’ files. So open both of them in some text editor (Notepad++ etc) and copy the contents of system.dts and paste them in the .dtsi file just after the line ” model = “Xilinx MicroBlaze” .  Don’t forget to add “/dts-v1/;” at the top of .dtsi file also. The final content should look like this


At this point, we will need to make some changes to the dts file manually. Open galatealx45t.dts in your favorite text editor and replace the bootargs = “” line with the following

linux,stdout-path = &ft232_uart;
stdout-path = &ft232_uart;

Now, save this modified file as “galatealx45t.dts”. And copy “galatealx45t.dts” file to your Linux System.

Section III: Building Linux Image

Step 1: Login to your Linux workstation to download and setup buildroot. On a Ubuntu 14.04 desktop clean installation you will need to install a few packages to make Buildroot work. Run the following command to install those.

cmd> sudo apt-get install build-essential bison flex gettext libncurses5-dev texinfo autoconf automake libtool

You may need to install Qt lib if you prefer to use xconfig instead of menuconfig while configuring Buildroot (please note that we will not use xconfig or menuconfig in the article rather load a default configuration that is known to be working).

Step 2: Now create a convenient folder on your Linux machine and move to that folder on the command line.The author created “Galatea_Linux” directory inside the “home” directory.  Download buildroot to that folder. You can download buildroot manually from Buildroot download page or by running the following command.

cmd> wget http://buildroot.uclibc.org/downloads/buildroot-2015.11.tar.gz

You can use latest buildroot release instead of the above. Now, extract the downloaded tarball archive using following command:

cmd> tar -xvf buildroot-2015.11.tar.gz

All files should be extracted to the folder “buildroot-2015.11”.

Step 3: We need the Linux Kernel defconfig files for Galatea. Download them from here.

1. galatea_defconfig file: place it under the directory “buildroot-2015.11/board/numato/galatea/” You will need to create respective directories named “numato” and “galatea”. Please note the kernel base address is set to 0xc0000000 in the Linux kernel defconfig file. Please change it appropriately if the DDR3 base address is different in your XPS project.  Now copy the “galatealx45t.dts” to the same folder as well.

2. Now, buildroot defconfig file “numato_galatea_defconfig” : copy it to the “configs” folder inside buildroot root directory (ie. “buildroot-2015.11/” )

After setting up buildroot as mentioned above, execute the following commands at the buildroot root directory:

cmd> make numato_galatea_defconfig

This will create a .config file for buildroot. Next, type:

cmd> make

This command will build the kernel and its file system. This downloads the kernel sources and lots of other tools from internet. It will take some time to finish building the kernel image, from 30 minutes to over an hour, or even more, depending on your machine’s capabilities and your internet speed.

Upon completion, this step creates a “simpleImage.galatealx45t” linux image in the directory “buildroot-2015.11/output/images/”. This is the Linux kernel with a root file system (initramfs) attached to it. We will use this file to boot Linux on Galatea PCI Express Spartan 6 FPGA Board.

Section IV: Running Linux on Galatea

Step 1: Connect the Xilinx Platform Cable to the Galatea board and power it up. Open any Serial terminal program (Putty, TeraTerm etc) and connect to Opsis  at 115200 baudrate.  First run the Hello World program and memory tests again to make sure everything is connected properly and works.

Step 2: Once FPGA programming is finished, we can now communicate with the Microblaze processor through XMD. It is possible to invoke XMD within SDK but I found it very easy and convenient to invoke XMD in a standalone commandline (DOS) window. Before starting XMD, copy “simpleImage.galatealx45t” in the folder /output/images under buildroot directory on Linux build machine to the Windows machine. Open a new commandline window (in Windows) where the kernel image is copied and run the following commands.

cmd> c:\Xilinx\14.7\ISE_DS\settings64.bat
cmd> xmd

Make sure to replace 14.7 with your ISE version and to choose settings32.bat if your system is 32 bit. These commands will start XMD within the commandline window. Now type the following command at the XMD command line to connect to the Microblaze processor running on the FPGA.

cmd> connect mb mdm

If everything went well, you should see XMD spit out some information as shown below.

Step 3: Now we are connected to the Microblaze processor and we can download Linux kernel image. To download the image, run the below command at XMD command line.

dow simpleImage.galatealx45t

This command should start downloading the image to the DDR memory. Since simpleImage.galatealx45t is in ELF format, it already contains the DDR address where it should be copied to. If download fails, chances are that you have not updated the Linux kernel base address with the starting address of the DDR3 memory assigned by EDK before building Linux kernel. It can take a few minutes to download the kernel image to DDR. Below image shows the download process.

Step 4: Now we are ready to boot Linux. Open your favourite serial terminal emulation software (hyperterminal, PuTTY, Teraterm etcc..) and open the serial port corresponding to Galatea’s UART. Set baud rate to 115200 and set any handshaking to off/none. Once the terminal software is setup, run the following command at XMD commandline to boot the kernel.

cmd>con 0xc0000000

Make sure to replace 0xc0000000 with the DDR base address/Kernel base address of your system if it is different. If all steps so far went as planned, you should see Linux booting in the serial terminal software as shown below.

You can login to Linux with username “root” and password as “galatea”. We have a successfully running Linux kernel in Galatea PCI Express Spartan6 FPGA Board! Congratulations!  Those who could not successfully boot, please don’t give up and keep trying. You should be able to tackle this without much difficulties.

Was this helpful?

  • Gaston says:

    Hi, im using spartan 6 with ISE 14.7 and following your tutorial and Im having trouble with SDK repository. SDK dont have the device tree option. I Add the xilinx_device_tree_master from github to SDK repository. In Xilinx forums mentions the bsptop folder inside xilinx_device_tree_master but not luck.
    I want to ask you also about the defconfig from your board if could be used for other board (generic one in my case thinking in my custom board).
    Your tutorial help a lot. Thanks

    November 18, 2018 at 2:11 pm
Leave A Comment