Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor III
1,260 Views

Web server using EPCS controller

With reference to the web server example available in Altera Wiki http://www.alterawiki.com/wiki/web_s...x_progress_bar (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). 

 

Now I am working on running this example on a board that does not has a flash memory, so I will be using EPCS serial flash controller. 

 

Thanks to DrinkFish (http://www.alteraforum.com/forum/showthread.php?t=30925&highlight=web+server+using+epcs+controller) he provide a modified file of altera_ro_zipfs.c that can read from the EPCS controller. 

 

Result: I think I moved one step forward, I can see something displayed on the web browser (picture attached), but it seems that there is corruption in the received data (in the reading process) 

 

The size of ro_zipfs.zip is 242 KB, it is too small, so I can not say the file size is larger than EPCS available memory space (I am working on EPCS64 == 64Mbits = 8 Mb). 

 

I also attached a copy of the modified altera_ro_zipfs.c file 

 

Can somebody explain to me why the received data on the web browser is corrupted?:confused:
0 Kudos
5 Replies
Highlighted
Valued Contributor III
9 Views

What have you done to validate that your epcs_controller is functional? Booting from it will give you a reasonable degree of certainty, but I'd advocate running code from the memory test example on it as well. 

 

Start there to rule out any strangeness with the interface itself, then move onto _very_ simple "Hello, World" HTML content...find out where things start breaking and you'll have a good chance at getting things to work. 

 

Cheers! 

 

- slacker
0 Kudos
Highlighted
Valued Contributor III
9 Views

One of the problems with the EPCS driver in a multitasking environment is that it isn't thread safe. The EPCS needs a series of instructions and will return a series of bytes for each request, and the transaction mustn't be interrupted by another one. If you have two threads that try to access the EPCS at the same time, both will get garbage data as a result. You should check if by any chance you could have another task that could try to access the EPCS or the file system just when you are answering to a http request (or have several parallel tasks that handle http requests, but it doesn't seem to be the case in this code). If yes then you need either to allow only one task to access the EPCS, or add a synchronization system in the driver (mutexes) to prevent this from happening. 

The CFI flash doesn't have this problem because it answers immediately to a read or write request, those operations are atomic by design.
0 Kudos
Highlighted
Valued Contributor III
9 Views

Hi abubaha,I had similar corruption as you....I believe I know what the problem is..will post back when I've checked the solution  

 

 

(http://www.alteraforum.com/forum/member.php?u=49382)
0 Kudos
Highlighted
Valued Contributor III
9 Views

update....i wish i could read, i see that you have an update issue...i may be looking at that in the future, if i detect any problems i'll post back...i need do some download tests before.... 

 

the following is for displaying web pages.....i guessed you solved that? 

 

update again.....i just downloaded you code.... it needs correcting as below....if this solves your problems let us know 

 

 

There is a bug in the modified code....  

 

In the function "int alt_ro_zipfs_read(alt_fd* fd, char* ptr, int len)" 

 

The following section of modified code needs to be changed  

 

from................ 

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); } else { } memcpy(ptr, current, amount_to_copy); return amount_to_copy; to.................... 

if (ALTERA_RO_ZIPFS_BASE == EPCS_FLASH_CONTROLLER_BASE) /* i.e. if serial flash */ { /* serial flash */ alt_u32 Offset = (current - ALTERA_RO_ZIPFS_BASE); alt_flash_dev *fdev = alt_flash_open_dev("/dev/epcs_flash_controller\0"); // TODO should check for open and read errors // Do EPCS Flash Read alt_epcs_flash_read(fdev, Offset, (char*)ptr , amount_to_copy); alt_flash_close_dev(fdev); } else /* memory mapped i.e. parallel flash */ { memcpy(ptr, current, amount_to_copy); } return amount_to_copy; Attached is the original altera file and a modified version of DrinkFish file 

(i made some other very minor changes ) 

 

Update... If you have the BEMicro SDK I have created some instructions to make the webserver run on this kit  

http://www.alteraforum.com/forum/sho...158#post133158 (http://www.alteraforum.com/forum/showthread.php?p=133158#post133158)
0 Kudos
Highlighted
Valued Contributor III
9 Views

Hi Rick101, 

 

Thanks for your corrections. 

 

Yes, it seems your corrections did the job, I can now read from EPCS without any problem. 

 

Good job!
0 Kudos