AR# 46503


13.4 EDK - How to Execute Code Directly from Flash


This article describes an updated flow to execute code directly out of flash memory.


  1. Create your hardware specification in XPS; be sure to include the EMC if using parallel flashes, and the (q)spi controller if using serial flashes.
  2. If you want to debug from flash:
    1. Right-click on the MicroBlaze in the System Assembly Viewer -> Configure IP.
    2. Click the Advanced button.
    3. Click the Debug tab, and enable at least one hardware breakpoint.
    4. Click OK.
  3. Export your design to SDK with the bitstream.
  4. In SDK, create your software application.
  5. Right-click on your software application, and Generate Linker Script.
  6. Move the following sections (under the Advanced tab) to the Flash:
    • .text
    • .rodata
    • .sdata2
    • .sbss2
  7. All other sections should be linked to block RAM.
  8. Click Generate.
  9. Click on Xilinx Tools -> Launch Shell.
  10. Navigate to your application's Debug folder within the workspace.
  11. Run the following commands:
    • $ mb-objcopy \ --set-section-flags .text=alloc,readonly,code \
      --set-section-flags .init=alloc,readonly,code \
      --set-section-flags .fini=alloc,readonly,code \
      --set-section-flags .rodata=alloc \
      --set-section-flags .sdata2=contents \
      --set-section-flags .sbss2=contents \ myApp.elf volatile.elf
    • $ mb-objcopy -O binary \
      -j .text \
      -j .init \
      -j .fini \
      -j .rodata \
      -j .sdata2 \
      -j .sbss2 \
    • Close the shell.
    • Click Xilinx Tools -> Program FPGA.
    • Download the bootloop.
    • Click Xilinx Tools -> Program Flash.
    • Program your flash.bin to an offset of 0x0, with working memory as block RAM.
    • Click Xilinx Tools ->Program FPGA.
    • Select your volatile.elf.
    • Your application should be running out of flash, with small exceptions for the mandatory non-volatile parts.

    • You can also connect via XMD ("connect mb mdm" and "dow volatile.elf") to debug out of flash. Some extra steps required are:

      1. Open Debug Configurations (Run -> Debug configurations).
      2. Under the Main tab, ensure the "C/C++ application" is your "volatile.elf".
      3. Under the Device Initialization tab, "Do not download program to memory" needs to be selected (download via XMD).
      4. Under the Remote Debug tab, you need to connect to "localhost" at whatever port you see in XMD when you "connect mb mdm". The default is 1234.
      5. You can now debug, setting as many breakpoints as you configured in XPS.

      If you want to bootload this application:

      1. You will need to use the "." (location counter) operand for linker-scripts to offset the address where you programyour "flash.bin", as described above. This is beyond the scope of this answer record. For more information, see: Red Hat GNU Linker help.
      2. You will then program the flash.bin to a different location, and use your download.bit (containing your volatile.elf) as mentioned in (Xilinx Answer 46518).
    AR# 46503
    日期 02/05/2013
    状态 Active
    Type 综合文章
    People Also Viewed