- Om oss
- Plattformar och lösningar
- Utvecklingsverktyg och arbetsmetodik
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.
We have to setup the PetaLinux environment before we start SDK.
--> cd /opt/home/svan/PetaLinux/petalinux-v2.1-final-full
--> source settings.sh
--> xsdk &
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
- Click Xilinx Tools menu and select Repositories.
- Click the New button in the upper left corner.
- 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.
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
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:
- Right click on the fs-boot_0 project in the Project Explorer
- Select C/C++ Build settings
- Select the Tool Settings tab
- Set configuration profile at the top of the page to [All configurations]
- Click Symbols under MicroBlaze gcc compiler
- In the Defined symbols box click the Add button (with the plus sign)
- 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:
- Click Miscellaneous under MicroBlaze gcc linker
- Enter <-Zxl-mode-novectors> in the Linker field.
- Click Apply
Set fs-boot to Release profile
- Right click on the <fs-boot_0> project in the Project Explorer
- Select Build Configurations
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.
- Right click on the fs-boot_0 project in the Project Explorer
- Select Build project
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.
- Start XPS if not already running.
- In the Project tab of the project information area, expand the <Elf Files> option.
- Double click on the microblaze_0 item.
- A Select Elf file window will pop up and allows us to select which Elf file to be used to initialize the BRAM.
- Find the fs-boot executable created by SDK.
- Click OK to close the Elf file window.
- 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.