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:
- Using "Generate Linker Script," assign read-only sections of the software project to the flash memory and all other sections to block RAM.
- Build the project and create the "executable.elf" file.
- Run "Update Bitstream" to add the block RAM initialization data from the ".elf" file to the FPGA configuration file creating the "download.bit" file.
- Run the EDK shell (cygwin) and change to the directory containing the "executable.elf" file.
- 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. - Run the "Program Flash Memory" script under Device Configuration in XPS, and specify the "flash.bin" file as the source.
- Download the "download.bit" file to the FPGA using iMPACT. The application runs.
NOTE: The following step is optional: - 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.