Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

EPCS: Free memory?

Hi all!

I have a cyclone2 board including EPCS device.

On the cyclone2 i have got a nios2 running.

The configuration for the cyclone2 and the software for the nios2 come from the EPCS device.

The nios2 can access the EPCS device via a EPCS serial flash controller (added with SOPC builder to nios2).

Now the question:

How do i find out if (and where) there is any free memory in the EPCS device where i can write to?

I would like to store some additional data in the EPCS device but I do not want to kill my FPGA configuration by accident.

Any ideas?

Regards

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    From the fpga configuration file (.sof) and the Nios firmware file (.elf) you know exactly the epcs space required. The remaining (if any) is free for general purpose use.

    Some important points to remind:

    - epcs must be erased in blocks (64k if I remember correctly). So your data and firmware must be stored in a separate blocks.

    - at the end of used epcs space allow some headroom for future upgrades

    - similarly, you must account for extra space if your design provides remote update
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    From the fpga configuration file (.sof) and the Nios firmware file (.elf) you know exactly the epcs space required.

    --- Quote End ---

    While this is mostly true, when using the default bootloader it's not exactly the case. While the software data is stored right after the FPGA configuration bitstream in the EPCS/serial flash device, it is in "boot record" format, not raw binary format.

    The tools will generate the "flash/SRecord" data for you using sof2flash, bin2flash, and elf2flash. You can see the size that these SRecords take on flash/epcs by running
    nios2-elf-size <your_elf_flash_filename>.flash

    Once you have this information, you should be able to determine where best to place your additional data.

    Regards,

    slacker
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You are right Slacker. I assumed Fred already knows how to retrieve the information from elf file.

    For your convenience, this is what I use.

     sof2flash --epcs --input=fpga_project.sof --output=fpga_hardware.flash
     elf2flash  --epcs --after=project_hw.flash --input=nios_project.elf --output=nios_firmware.flash
    

    The above commands generate the files I use for epcs programming. Since the .flash files are in ASCII format, I usually open the nios_firmware.flash with a text editor, go to the end of file where I can easily read the highest epcs address used.