Load spi flash with raw data at an offset


Chris_C

Recommended Posts

Suppose I want my design to "load" data from the flash chip into sdram, at the moment I'd need a separate design to load data over serial (slow and painful even at 115200) save it temporarily in sdram and then write it into the flash

If instead I could use the loader app with an offset I could upload the data to say +1mb in the flash at full USB speed

AFAICT there is no parameter to specify where the data should start

I suppose I could take my bit file pad it out at the end with zeros and add the data on the end but then thats going to make a very large file to upload...

Link to comment
Share on other sites

Suppose I want my design to "load" data from the flash chip into sdram, at the moment I'd need a separate design to load data over serial (slow and painful even at 115200) save it temporarily in sdram and then write it into the flash

If instead I could use the loader app with an offset I could upload the data to say +1mb in the flash at full USB speed

AFAICT there is no parameter to specify where the data should start

I suppose I could take my bit file pad it out at the end with zeros and add the data on the end but then thats going to make a very large file to upload...

 

The loader app does not have an offset parameter but it would be simple to add.  However, be aware that the loader app need to erase before it writes and on some flash chips (like the SST found on Papilio One) it erases the whole chip before the write since that's faster than doing a partial erase, which is probably not what you want if you just want to add some code at an offset. On Papilio Pro it only erases the area that will be programmed.

 

I'm not sure this will help you but let me explain how I solved basically the same problem that you have in two different cases.  This actually applies to Pipistrello but nothing prevents you from doing the same for Papilio Pro.

 

Case 1 (Linux bootloader for Pipistrello)

The Microblaze Linux hardware platform was created in ISE.  The processor can execute from either a 32 KB area in BRAM or from SDRAM.  I then wrote an ELF bootloader that looks at a specific location in the flash chip (at address 0x180000 which is a little bit beyond the end of the bit file) and if it finds a valid ELF header there it will load it based on the information in the header (hopefully to SDRAM) and then jump to the program entry address.  The bootloader is compiled and linked so that it sits in BRAM.  The bootloader code was then added to the bit file using data2mem and this new bitfile is now the base bit file that can basically run any program from SDRAM by adding the ELF version of the program to the flash chip at address 0x180000.  To get the Linux kernel and file system added to the flash I used Mike's bitmerge program to merge the base bitfile (with the the ELF loader pre-installed) and the Linux ELF file produced when the Linux kernel was compiled.  BTW, the ELF file is quite big since it also contains the initial file system (about 5 MB) so the resulting bit file is now about 6.8 MB.  The loader app was then used to write the whole thing to flash.

This is how it looks when it boots up: http://www.saanlima.com/videos/linux_on_pipistrello.swf.html

Files can be found here (including the source for the ELF bootloader): http://www.saanlima.com/download/pipistrello-v2.0/Pipistrello_LX45_axi_Linux.zip

 

Case 2: (Arduino on Pipistrello)

The flow is very similar to Case 1 (i.e. the Microblaze hardware platform was built in ISE, the same ELF bootloader was added to the bit file etc.).  The main difference is that for the Linux case the writing to flash only happens once when the system is created but for the Arduino case the writing to flash happens every time the Arduino program is compiled and run, so it would be nice to just write the Arduino code to flash (at 0x180000) and not the whole merged bit file.  To solve this I added an option -n in the loader app that will allow you to skip writing up to a specific address. (in this case 0x180000).  In the Arduino GUI board option you can select either to write both the bit file and the program (needed the first time in order to get the correct bit file in the flash) or to skip the bit file part and only write the program.  

Zip file with modified loader app (called fpgaprog, with source and windows executable):http://www.saanlima.com/download/pipistrello-v2.0/fpgaprog_win.zip

Picture of the Arduino GUI where the board selection can be done:http://www.saanlima.com/download/pipistrello-v2.0/arduino.png

 

This was my way of solving this problem, there are probably lots of other ways to get the job done.

 

Magnus

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.