12-11-2009 04:23 AM
I am planning an application where I will store my main program in a spi flash. A bootloader that will copy data from flash to DDR will be placed in bram an integrated in the bit file.
Q1: Do I use the elf format for the main program stored in flash?
Q2: If I use elf fromat. Do I just start executing from the address where I placed the elf file, or do I need to handle to elf header some how?
using edk 11.3, V5 ppc 440
12-11-2009 07:47 AM
Your codeimage must ultimately be converted into an actual bit-perfect absolute memory image. ELF is not a binary image in this sense, and neither is srec. So to answer your question, you first need to understand your tool chain. The last tool on your tool chain is the one that actually writes to the flash: what format toes that tool accept? If you intend to use Impact directly, then it is the last tool in the chain to touch the data before it is written into the flash. Impact wants to use the mcs format as its input, so you need to convert from ELF to MCS somehow. If you are using some other flash writer system, you need to create an input file for that system in a format that it wil accept.
In my case, I append the RAM image to the FPGA image and then have Impact write the entire image to the platform flash. The FPGA gets loaded from the platform flash and then the BRAM-resident bootloader reads the image from the platform flash into the RAM.
To get this to work, I first use binutils to convert from elf to srec. I then use srec_cat to append the srec file t the mcs bitfile, and I then use Impact to write the file.
To be absolutely pedantic about this, the very last software that touches this image before it is placed in RAM, is your bootloader. Therefore, the bit image in the Flash must be in whatever form you bootloader wants to see. in the above description, I make the assumption that you intend for the bootloader to be as simple as possible, so you want it to do a direct copy with no data transformation.
12-11-2009 02:54 PM
Thanks for your reply.
This solution is a work-a-round of a problem with a XL flash that I can not acccess with the emc.
I will connect the spi flash to general i/o, so I think that impact will not be able to handle the flash writing (please correct me if I am wrong). My plan was to let XMD put the elf file to ddr and then write a simple program for the copy to spi flash.Now when you know a little more about my applicatio, which format do you recommend? Can XMD put any file into a memory space?
Once the file is copied from ddr to spi flash, I hope it will be easy to let a boot program copy it from spi flash to ddr and then start to execute it.
Any comments and hints will be appreciated.
12-11-2009 03:23 PM
I'm sorry, but I am not familiar with XMD. Therefore, I would use the "objcopy" command from the binutils tool suite to create a raw absolute binary file. On a Linux system, issue the command
to see how this works.
Copy this raw binary file to the SPI flash using whatever method works for you (probably a simple bit-banging program that is sort of like your bootloader running in the opposite direction.)
If you need to do any tricks first, then use objcopy to convert from elf to srec, then use srec_cat (from the srecord tool suite) to play the games, and finally use srect_cat again to create the raw binary.
You clearly already have a way to convey the ELF file to the target, so I must assume you can convey the raw binary in a similar fashion.
But perhaps some XMD expert will come along and answer your original question...