- Om oss
- Plattformar och lösningar
- Utvecklingsverktyg och arbetsmetodik
Booting PetaLinux from SPI flash
2012-05-31Publicerad av Sven-Åke Andersson
Petalinux is using a 2-stage booting process. The first stage boot, FS-Boot, is running from the Spartan-6 FPGA's BRAM once powered on. It's responsibility is to load the main system bootloader, U-Boot, from the flash to the larger external DDR memory, and run U-Boot from the external memory. U-boot will then load the Linux image and start the Linux boot.
Booting from SPI flash run sequence
Here are all the operations that will take place when we boot PetaLinux from the SPI flash.
- Power-up the board or press the PROG FPGA push button on the board, to start the boot-up.
- The Spartan-6 FPGA will automatically transfer the configuration image from the SPI flash to the FPGA configuration memory together with the first stage bootloader that will copied to the MicroBlaze local memory (BRAM). The FPGA is now configured and fully operating.
- The first stage bootloader will start to execute and copy the u-boot loader from the SPI flash to the system memory (LPDDR).
- The u-boot loader will execute and bring in the PetaLinux image to the system memory.
- The system will boot up.
Copying the u-boot loader to SPI flash
We have already copied the FPGA configuration image and the first stage bootloader to SPI flash. Now we only have to figure out how to move the U-boot loader and the PetaLinux image to SPI flash. For the first step we will involve the Xilinx Microprocessor Debugger (XMD).
Xilinx Microprocessor Debugger
The Xilinx Microprocessor Debugger (XMD) is a tool that facilitates debugging programs and verifying systems using the PowerPC (405 or 440) processor or the MicroBlaze processor. We can use it to debug programs on MicroBlaze or PowerPC 405 processors running on a hardware board, cycle-accurate Instruction Set Simulator (ISS). XMD provides a Tool Command Language (Tcl) interface. This interface can be used for command line control and debugging of the target as well as for running complex verification test scripts to test a complete system. Today we will use it to download the u-boot.elf program to the MicroBlaze system memory (LPDDR).
Power-up the board
Power-up the board and make sure the First-stage bootloader is running.
Downloading the u-boot elf file
To download the u-boot.elf file we will create a small xmd init file (xmd.ini) that will automatically run when we start xmd. It looks like this:
Start xmd and load U-boot.
The U-boot starts and the following text is displayed on the console. We stop the auto-boot by hitting any key on the keyboard.
Fixing a problem
I didn't notice at first but the when the first stage bootloader starts it displays the message: Flash is not configured. There is a problem in our SPI flash interface. After a few days of debugging I found out that the QUAD_SPI_FLASH interface is not supported in FS-BOOT and U-BOOT. We have to replace the QUAD SPI flash interface with the standard axi_spi_flash module.
Answer from PetaLogix
OK, that makes sense. In our next release we support the Xilinx QSPI controller, although only in single-SPI mode.
Changing SPI flash interface
We will delete the QUAD_SPI interface and add the standard AXI SPI interface block.
Here is the setup after adding AXI SPI interface (axi_spi_flash).
Connect SPISEL to vcc.
Connect the interrrupt signal from axi_spi_flash.
Edit the ucf file and remove the QUAD SPI pins and add the axi_spi0 pins.
Exit Xilinx Platform Studio and edit the system.mhs file and change all S_AXI_ACLK declarations from 50MHz to 100MHz.
Start XPS and load the project. Click Export SDK. We have a new design that hopefully will support SPI flash booting. We will go through the complete software design flow once more to generate a new Linux image.
First stage bootloader
This time the FS-Boot starts up displaying the message: No existing image in FLASH.
Moving U-boot to SPI flash
We will load U-boot using the method decribed earlier in this document. When we have U-boot running we can use the command: run update_uboot to copy the U-boot image from the SDRAM to the SPI flash. Don't forget to set the environment variable: serverip to point to our host computer.
The next time we power up our board or press the PROG button the U-boot will come up.
Moving the Linux image to SPI flash
We can use the command: run update_kernel to move the Linux image to SPI flash.
By pressing the PROG button it should be possible to boot Linux from the SPI flash. But something is wrong here. The INIT LED stays on and the DONE LED stays off and Linux is not booting. What is wrong. I have no idea.
Reporting a problem
To report a problem we run the following command: petalinux-send-configs > configs.out and send the result to PetaLogix. We can also execute this command at the U-boot prompt to provide more information about the setup.