This is part I of my HOWTO on running Linux on Microblaze. The outline is as follows:
- Part I: Introduction and setting up the Microblaze processor (this page)
- Part II: Compiling the kernel
- Part III: Preparing for boot and booting
- Part IV: Compiling user space applications
This HOWTO goes through the procedures for getting a simple Linux system running on a Xilinx Microblaze processor. The examples are given for an SP605 evaluation board, but almost everything here applies for other FPGAs and boards as well. The Xilinx software version used here is 13.2.
There are quite a few variants on how to get the bitstream and Linux kernel into their right places in the FPGA. The approach taken here is to boot up from the Compact Flash alone by writing a file to it. No bootloader is used in this howto; the SystemACE chip is responsible for loading both the FPGA bitstream and Linux kernel image, and it will do so reading one single (.ace) file. The main advantage of this approach is that there’s no need to set up a boot loader, which is yet another piece of software that can go wrong. The main disadvantage is that a bootloader allows some tweaking of the kernel configuration at boot time, which has to be done by recompiling the kernel otherwise.
The root filesystem is mounted from network (NFS) in this HOWTO.
I’m assuming the following prerequisites:
- You have the Xilinx tools set up properly, and have managed to compile and run a simple standalone “Hello, World” application with the EDK/SDK (having loaded the code to the FPGA in any way, we’ll get to that)
- You’ve actually seen the RS-232 console data on a terminal, and feel confident about it (otherwise you may work hard to figure out why everything is stuck, when it’s actually your terminal window’s problem).
- You’re running on one of the evaluation boards, or know how to set up the processor to work with your own (and have that tested already)
- Your board has a systemACE flash chip (recent evaluation boards usually do)
- You have access to a machine running Linux on a computer. Compiling the kernel will require this. The Xilinx tools can be run on whatever’s your cup of tea.
- You have the ability to read and write files to a Compact Flash. This is most easily done with a simple adapter to a PC computer, which should be available in camera or computer accessories shops. Chances are you have one without necessarily being aware of it.
An outline of the steps
So this is what we’ll do:
- Set up a Microblaze processor in the Xilinx EDK so it can run Linux.
- Generate the processor, so an FPGA bitstream is at hand.
- Export the processor to the Xilinx SDK and compile a dummy C application, so that necessary metadata files are generated
- Generate a Device Tree file (.dts) based upon files created by EDK/SDK, and copy it into the Linux kernel sources, so Linux is in sync with the EDK regarding what it’s running on.
- Configure the kernel and compile it.
- Create a .ace file from the FPGA bitstream and kernel image just compiled.
- Set up the Compact Flash card.
- Boot and hope for good
And of course, certain software tools will need to be downloaded for this. We’ll come to this.
Setting up the processor
If you’re really lazy about this, you can use the minimal processor I’ve generated for the SP605 board. Unzip, double-click system.xmp, and skip to after the bullets below. It will work on that board only, of course.
Otherwise: Start Platform Studio (EDK) and create a new platform, based upon the Wizard’s defaults.
Following a Microblaze on Linux guide, in particular the part regarding minimal hardware requirements, there a need to make sure that the hardware has an MMU with two regions, a timer, an interrupt controller and a UART with an interrupt line. In the platform studio it goes like this:
Starting off with the Wizard’s defaults,
- Double click “microblaze_0″ on the Ports tab, and set the Linux with MMU preset on the Configuration wizard showing up. This will take care of most settings.
- Still in the ports view, add an AXI Interrupt Controller (under Clock, Reset and Interrupt in the IP Catalog). Accept default settings. Make a new connection for its irq output, and connect it to the microblaze_0′s interrupt input pin.
- Pick the RS232_Uart_1 and make a new connection for the interrupt line. Connect that signal to the interrupt controller.
- Add an AXI Timer/Counter, and accept defaults. Make a new connection for the interrupt, and connect it to the interrupt controller.
- Connect the interrupts of the Ethernet lite, SPI Flash, IIC SFP, IIC EEPROM, IIC_DVI, and SysACE cores to the interrupt controller as well.
Then generate bitstream, export to SDK, and run the SDK, adopting this hardware platform. The goal of this is to generate a .mss file, which will be needed later. For this to happen, make a new C project (“Hello World” will do just fine) and compile it.
There is no need to “update the bitstream” like with standalone applications: The Linux kernel can take care of itself, without having its entry address hardwired in the FPGA’s block RAM. We’ll use the system.bit, and not the download.bit (even though the latter works too).
Creating a Device Tree file
The purpose of this stage is to generate a .dts file, which is the format expected by the kernel build environment. It informs the kernel about the structure of the processor and its peripherals. The device tree structure is discusses further here.
If you chose to download and use my processor with no changes whatsoever, you can also get my DTS file. Just copy it to arch/microblaze/boot/dts/ in the to-be compiled kernel source tree.
To make your own .dts file, first create a special directory, and make it the working directory of your shell.
The device tree file is generated automatically with the libgen utility with the help of a Tcl script. As of ISE 13.2, this script needs to be loaded separately with git:
bash> git clone git://git.xilinx.com/device-tree.git
This generates a device-tree directory. Another web page explains how to make SDK recognize the script, but I prefer command line for things like this. Another post of mine explains the device tree further.
Copy the system.xml file from the directory to which you exported to SDK (in the “hw” subdirectory), into the current one. Then copy system.mss from the project’s BSP directory. It will have a name like hello_world_bsp_0.
Edit the copy you made of system.mss, so that the BEGIN OS to END part reads
BEGIN OS PARAMETER OS_NAME = device-tree PARAMETER OS_VER = 0.00.x PARAMETER PROC_INSTANCE = microblaze_0 END
and not “standalone” for OS.
And then run libgen as follows (make sure it’s in the PATH. The easiest way is to launch a “Xilinx shell” from the EDK’s project menu):
libgen -hw system.xml -lp device-tree -pe microblaze_0 -log libgen.log system.mss
Which generates a xilinx.dts in microblaze_0/libsrc/device-tree_v0_00_x. Copy this file to arch/microblaze/boot/dts/ in the to-be compiled kernel source tree. If you can’t find the file there, and libgen didn’t complain about some error, you may have forgotten to edit system.mss as mentioned just above.
Now let’s go on to compiling the kernel, in part II.