Forum Discussion
Altera_Forum
Honored Contributor
21 years agoOne approach, that works quite well if the zip file data doesn't depend on the code itself, is to add it to your program as a data array.
On the pro side, the linker looks after allocating space for the data, telling your program where it is and including it in the image to be loaded into flash. On the con side, your flash image is bigger since you are always loading the code and data file together (even if only one of them changed). To do this, add a C file (say "zip_data.c") with a single data array:char zip_data = {# include "zip_data_contents.h"
}; Now, write a simple script or executable (perl, awk, C, ...) that runs on the host machine (the one where you develop code) that reads a file and outputs the bytes in the format required for a C array initializer list: 0x01, 0x02, 0x03, 0x04 ... In your make file, add a rule to use your script to produce "zip_data_contents.h" from your zip file, and make sure the makefile has the information that "zip_data.c" depends on "zip_data_contents.h". Now, whenever the zip file contents change, your make file will automatically recompile zip_data.c and build an object module containing the zip file contents in a form acceptable to the linker.