Running Linux on Microblaze Processor Part 1
This article is just a bunch of notes for myself. I found a lot of articles on the internet but at times they were confusing. I got the job done using the resources from the internet and Xilinx website, thanks to those fellows. In the meantime, I jotted down the steps that worked for me. At the end of this article I have given the references to the articles from where I have prepared this article, I’d advise you to go through those articles too.
This article enumerates the steps necessary to port a minimal Linux kernel on microblaze soft core processor. I have used Virtex-6 ML605 FPGA Board and Xilinx design suite 13.3. There are various approaches for booting Linux from microblaze, but I did it without using any bootloader. The Bitstream and Linux kernel image is loaded from SystemACE to FPGA.
You should have access to a machine running Linux since compiling the kernel will require this. Xilinx tools can be run on any platform. In addition, you should be able to read and write files to compact flash. You can get a simple adapter to a PC computer from any camera or computer shop.
Outline of the steps
The main steps are:
- Setup up a Microblaze Processor in EDK and generate the bitstream
- Export the generated processor to Xilinx SDK, and generate the meta-data by creating a dummy application
- Generate a device tree file (.dts) and copy it in Linux kernel sources
- Configure the kernel and compile it
- Create a .ace file from the bitstream and the compiled kernel image
- Setup the Compact Flash card
Throughout the article I will be using the following directory hierarchy. The top project directory is $TOP_DIR. It contains two sub-directories, “hw” for creating the EDK project and “sw” for the SDK workspace.
Setting up the Processor
Open XPS and create a new platform based upon the wizard defaults. Save the project file in “hw” directory. The Microblaze on Linux guide mentions the minimal hardware requirements. Make sure you have the MMU in virtual mode and two memory protection zones, a timer which has both timers in it (C_ONE_TIMER_ONLY = 0), a UART for the console (either UARTLite or UART 16550) and an Interrupt controller with the timer and UART connected. Follow the steps given below to generate a hardware platform which satisfies the minimal requirements:
- Make a system with default XPS components (I have created an AXI based system).
- Go to the ports tab and double click microblaze_0. Configuration Wizard will open. Select “Linux with MMU” configuration and then click the “OK” button.
- 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.
- Add an AXI Timer/Counter (under “DMA and Timer” in the “IP Catalog”) by accepting defaults. Make sure “Only One Timer is present” check-box is unchecked.
- Now we need to connect the interrupts of Ethernet_Lite, SPI Flash, IIC SFP, IICE EEPROM, IIC_DVI, RS232_Uart_1, and SysACE cores to the interrupt controller. To do so, expand axi_intc_0 in the “Ports” tab and click on the “Connected Port” column in front of “Intr” row. An Interrupt Connection Dialog box will appear, add the ports of above mentioned components from the Unconnected Interrupt(s) column to Connected Interrupt(s) column.
Setting a Device Tree file
What is a Device Tree ?
The Linux kernel needs to know certain information about the peripherals like what peripherals are present and where they can be found. In the PC Systems, the BIOS detects the peripherals, allocates their addresses and interrupts and tells the operating system what it has and where it can be found. In the embedded systems this information was hardcoded into pieces of the kernel sources, which were written specifically for every board. With many boards out there, the kernel source grew way too fast. This far-from-optimal solution is not feasible with a soft core processor, whose peripherals are configured per case.
The elegant solution for this is the Flattened Device Tree. The device tree file (.dts) has the information for the hardware design in the EDK project. The idea is to create some binary data structure, which is either linked into the kernel image or given to it during boot. This binary file contains information about the processor itself and its peripherals, including the addresses, interrupts and several application-specific parameters.
The device tree file (.dts) is generated by the device tree generator.
Creating a Device Tree
The aim is to generate a .dts file which is the format expected by the kernel build environment. Go to the base directory of your project and download the device tree generator by typing the following command from terminal:
$ cd $TOP_DIR $ git clone git://git.xilinx.com/device-tree.git
After getting the device tree generator, you will need to copy the “bsp” directory to the top of your project directory.
$ mkdir $TOP_DIR/bsptop $ cp -r device-tree/bsp hw/bsptop
If the project is currently open in XPS then close it and again open it for the change to take place.
Setting up EDK and SDK
The device tree can only be generated from SDK. Therefore, Export the project and Launch SDK. Select $TOP_DIR/sw as the workspace.
Follow the steps below to build the device tree board support package:
- In the SDK menu, Go to “Windows” → ”Preferences”.
- Navigate to “Xilinx SDK” → “Repositories”.
- Click “New” button beside “Local Repositories”.
- Select bsptop in “$TOP_DIR/hw” and click “OK”.
- Click “Rescan Repositories” and then click “OK”.
- Right-click in the “Project Explorer” pane on the left and select menu item “New → Project…”.
- Select “Xilinx Board Support Package” and click “Next”.
- Select board support package “device-tree”.
- Click “Finish”.
- In the “Board Support Package Settings” dialog that appears, set “console device” to RS232_Uart_1.
- Click “OK”.
- Select menu item “Project” → “Build All”.
- Close the SDK.
In part 2 of this article we will see how to compile the kernel and get the microblaze processor up and running.
The link to part 2 is Running Linux on Microblaze processor : Part 2.
|Print article||This entry was posted by Gaurav Tewari on December 2, 2011 at 9:26 am, and is filed under Embedded Computing, FPGA, Linux. Follow any responses to this post through RSS 2.0. You can skip to the end and leave a response. Pinging is currently not allowed.|
No comments yet.
about 1 year ago - 1 comment
Second part of instructions on porting Linux to a Xilinx Microblaze processor on Virtex ML605 evaluation Board.
about 1 year ago - No comments
While I was trying to migrate my FPGA development environment from Windows to Linux I had a hard time trying to find how to get Xilinx JTAG drivers for Linux. After reading many tutorials and trying out many approaches for installing the USB drivers, I came across one article which enumerates the step wise procedure