Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12606 Discussions

Altera zip read-only filesystem

Altera_Forum
Honored Contributor II
1,787 Views

Hello, 

I am trying to use the Altera zip read-only fileysystem on an altera development kit. I can run the app okay when in debug mode but after flash programmed into the flash, the system does not boot up. I found out that in the examples, it was writing the zip file to the flash at offset address 0x0, the beginning of the flash i guess. So then I moved this address quite a bit further away and it started to work but now I've overwritten the "safe factory" image.  

So is there a simple method that i can run to figure out where I should put my zip read only files so that it will not interface with my app? This offset changes if my app grows, but I can live with it as long as I know where i need to place it. I just want to place a couple of read-only files in my app and be able to access it from my app. 

 

thanx, 

-Quan
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
445 Views

Basically you need to ensure that the zip file offset is past the end of your code.  

 

The only way to do this is to look at the ext_flash.flash file, which is your code.  

 

This file is in S-Record format if you decode the last line and the second line and calculate the difference that should tell you how much of your flash contains the code.
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

thank you rugbybloke for the response. 

I will give that a try.  

 

-Quan
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

One 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.
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

scs, 

 

Yes what you suggest will get a .zip file into the code. However it will not be available for use by the Altera Read Only Zip Filing System which is what the original question was about!!
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

rugbybloke- your method worked. The app ran with no problem after moving the flash file slightly after the end of the application. Now I don't overrun into the factory safe image.  

 

scs- I have tried that with another project, but for this particular one I needed a simple read only filesystem that might contain several files and so it was easier to use the altera file sys for now. 

 

thanx again for all your suggestions. 

-Quan 

 

ps. now if I can only get this dma to behave like it did in the nios 3.01 days then i would really be in a happy mood...
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

Hi Quan, 

 

I have tested the zip-filesystem project and have some question to ask you. 

 

1. The offset of zip file writing to the flash is described in \debug\____.sh file. It overwrite the zip-filesystem app address, if app is downloaded to the flash. Yes? 

2. I can change the the "location" of bin2flash in the \debug\_____.sh file to avoid the overwritting. Yes? 

Or in the Nios II SDK Shell to generate by inputing command. 

3. rugbybloke said, to decode the last line and the second line of ext_flash.flash file to calculate the app size in flash. But I do not know how to do that. Can tell me? 

 

Thank you.
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

Liangyi, 

 

You're "barking up the wrong tree".  

 

1. The zip file system will only over-write the application if the offset you chose for the zip file system overlaps the application. 

2. You should not change the zip file location in a .sh file, this will not change the# defines which are used for the code. You should change the location of the file system by right clicking on your application project, then selecting System Library properties. The select Software Components and the read only zip filing system, in here you can set the offset.
0 Kudos
Altera_Forum
Honored Contributor II
445 Views

Rugbybloke, 

 

I do as you said, it works fine. 

But I have question to ask you. 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

This file is in S-Record format if you decode the last line and the second line and calculate the difference that should tell you how much of your flash contains the code.[/b] 

--- Quote End ---  

 

I do now how to calculate, can you describe in detailed? 

 

Is The .sh file generated automatically?  

My Flash is 4MB, just from 0x0--0x3FFFFF. But in .sh file,  

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

$SOPC_KIT_NIOS2/bin/elf2flash --flash=U20 --base=0x00000000 --end=0x200000[/b] 

--- Quote End ---  

 

It is only 2MB, I do not know how it come. Can you explain? 

 

Thank you.
0 Kudos
Reply