Forum Discussion

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

Web Server example

Hi,

With reference to the web server example available in Altera Wiki http://www.alterawiki.com/wiki/web_server_with_ajax_progress_bar, I tested the example project and it works fine ( it was tested on FPGA Cyclone III with flash memory on the development kit.

I want to run the web server project on a kit that does not have flash memory, instead I used epcs controller to upload the ro_zipfs.zip file (of course I modified the base address of epcs controller accordingly) ......what I got on the web browser is: Can't open the 404 File Not Found error page. Have you programmed the filing system into flash?

Is it possible to use epcs controller instead of flash memory,if yes, why am I receiving the above error message?

Thanks

17 Replies

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

    Good job Drinkyfish,

    I am trying to test it on my setup, but it seems that altera_ro_zipfs.c file is different from what I have. can you attach the complete file, so I can check the differences.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi abubaha,

    I have manged to get this working (or at least on my setup) What you'll need to do is change 3 sections within the altera_ro_zipfs.c file.

     
    static alt_u32 read_word(alt_u8* current_ptr)
    { 
    if (ALTERA_RO_ZIPFS_BASE == EPCS_FLASH_CONTROLLER_BASE)
    {
     alt_u32 RetValue;
     alt_u32 Offset = (current_ptr - ALTERA_RO_ZIPFS_BASE);
     alt_flash_dev *dev = alt_flash_open_dev("/dev/epcs_flash_controller\0");
     //Do EPCS Flash Read
     alt_epcs_flash_read(dev, Offset, (void*)&RetValue, 4);
     alt_flash_close_dev(dev);
     
     return RetValue;
    }
    else
    {
     As before
    }
    

    Same as above for the read_half_word (only replace the 4 with 2 for length)

     
    int alt_ro_zipfs_read(alt_fd* fd, char* ptr, int len)
    {
      ...
    if (ALTERA_RO_ZIPFS_BASE == EPCS_FLASH_CONTROLLER_BASE)
    {
      alt_u32 RetValue;
      alt_u32 Offset = (current - ALTERA_RO_ZIPFS_BASE);
      alt_flash_dev *fdev = alt_flash_open_dev("/dev/epcs_flash_controller\0");
      //Do EPCS Flash Read
      alt_epcs_flash_read(fdev, Offset, (void*)current, amount_to_copy);
      alt_flash_close_dev(fdev);
     
    }
      memcpy(ptr, current, amount_to_copy);
    

    The code isnt very pretty at the minute as it should use the# defines from system.h etc. As far as i can make out the EPCS is not a memory mapped peripheral and as such you have to do the reading. I would really like to know if there is a better way to do this. It appears that normally it just dereferences the pointer to get the data. Perhaps one of the Gurus could better explain. (I'd really like to know if this is just a hack or legit!!!)

    Either way the answer is yes you can and the above works for me....

    Cheers

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

    Hi abubaha,

    I know the reason for the 2Kb size, this is because the EPCS controller component only exposes some registers and is not the actual peripheral itself. I have tried to convert the flash file using the bin2flash command and setting the offset, this has worked and i can then use a modified setup with SrecParsing based on the altera design in the Alternative boot loading example (An458). This writes the file to the correct location in EPCS. But still no go on loading the files. I'll look into the Source files for the ro-zipfs must be something in there...

    I'll let you know if i find anything.

    Cheers

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

    Hi Drinkyfish,

    Unfortunately I did not reach to a solution for this problem yet!

    Regarding setting the offset, it is one of the modification that you have to made, however it is not the only one, there should be some modification in the C code that is responsible of "reading" and "writing" to the ecps (this part I did not work on it yet)

    Regarding the 2kb size, I also face this issue, however it does not make a sense! because the smallest epcs is 2MB.....but I do not know why it show 2kb

    In order to find the base address and offset for the epcs, do the following:

    1- From the flash programmer --> select New--> select the sopcinfo file

    2- Under epcs_controller tab --> add the zip file --> after that you can see the base address and offset. (see picture 01 in the attachment)

    3- Now right clich on the component folder --> Nios II --> BSP Editor --> select "Software Packages" tab

    4- Fill here the base address and offset accordingly (pic 02 attached)

    Good luck in your work and update me with any news!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi abubaha,

    Did you get any further with this, i have also attempted to put the zip file in epcs as i was hoping to remove the flash from our board. I encountered a number of problems. One of which is being unable to easily locate (Offset within EPCS) the zip file in the EPCS using the flash programmer as the epcs controller is only 2kb in size i cannot add an offset.

    I tried to modify the Address and then use the srec parsing to add this to the correct offset. I can send the file but still no dice on accessing the file.

    Any ideas or anyone else who knows what to do this would be great.

    Cheers

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

    Thanks for your hint.

    I looked for something related to the flash memory in the c code, however I could not find any thing!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I don't know the exact location but as far as i remember you have to modify the source-code to match the epcs controller instead of the flash.