^

AR# 23748 13.1 EDK - How can I execute MicroBlaze code directly from flash?


How can I execute MicroBlaze code directly from flash rather than copying it to RAM with a bootloader?

My software application has loose speed requirements, so the extra latency of flash access is not a problem.


First, consider the following points related to this issue:
  • The code should be located in flash. However, this cannot be set in the linker script. Instead, you must use the FlashWriter program.
  • The processor must locate the code in the flash, so you should set up the linker script as needed.
  • All of the sections that are put into flash should be read-only, or you must write extra code to handle the write operations to flash.

The flow is as follows:
  1. Using "Generate Linker Script," assign read-only sections of the software project to the flash memory and all other sections to block RAM.
  2. Build the project and create the "executable.elf" file.
  3. Run "Update Bitstream" to add the block RAM initialization data from the ".elf" file to the FPGA configuration file creating the "download.bit" file.
  4. Run the EDK shell (cygwin) and change to the directory containing the "executable.elf" file.
  5. Run the GNU utility "mb-objcopy" to extract the read-only sections of code into a binary file as follows:

    $ mb-objcopy -O binary -j .text -j .init -j .fini -j .rodata -j .sbss2 executable.elf flash.bin

    This command creates the "flash.bin" file containing exactly the bytes to be written to the flash. The code sections must be contiguous and start at the beginning of the flash memory's address space; this is normally the case. You can make sure that the code is contiguous using the "mb-objdump" utility.
  6. Run the "Program Flash Memory" script under Device Configuration in XPS, and specify the "flash.bin" file as the source.
  7. Download the "download.bit" file to the FPGA using iMPACT. The application runs.

    NOTE: The following step is optional:
  8. Convert the "download.bit" file to MCS format using iMPACT, and write it to the serial flash configuration memory. Then, if the configuration mode is set to master serial, the FPGA configuration and the application will load and run automatically on power-up or after selecting the restart button.

NOTE: Refer also to (Xilinx XAPP482): "MicroBlaze Platform Flash/PROM Boot Loader and User Data Storage."



EDK 9.1i and Newer

During Base System Builder (BSB), EDK 9.1i added the option to select the kind of boot memory you will use. After selecting the flash memory as your boot device, you need to add the following to "mb-objcopy" in step 5:

-j .vectors.reset -j .vectors.sw_exception -j .vectors.interrupt -j .vectors.hw_exception



All of the previously detailed steps remain the same.
AR# 23748
Date Created 09/04/2007
Last Updated 03/16/2011
Status Active
Type
Tools
  • EDK - 10.1 sp2
  • EDK - 10.1
  • EDK - 10.1 sp1
  • More
  • EDK - 10.1 sp3
  • EDK - 11.1
  • EDK - 11.2
  • EDK - 11.3
  • EDK - 11.4
  • EDK - 11.5
  • EDK - 12.1
  • EDK - 12.2
  • EDK - 12.3
  • EDK - 12.4
  • EDK - 13.0
  • EDK - 13.1
  • EDK - 8.1i
  • EDK - 8.1i sp1
  • EDK - 8.1i sp2
  • EDK - 8.1i sp3
  • EDK - 8.2i
  • EDK - 8.2i sp1
  • EDK - 8.2i sp2
  • EDK - 8.2i sp3
  • EDK - 9.1i
  • EDK - 9.1i sp1
  • EDK - 9.1i sp2
  • EDK - 9.1i sp3
  • EDK - 9.2i
  • EDK - 9.2i sp1
  • EDK - 9.2i sp2
  • EDK - 9.2i sp3
  • EDK - 9.2i sp4
  • Less
Feed Back