Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
794 Views

Reading EPCS

Hello, I am trying to read data in EPCS by the following: 

== 

char buf[65535]; 

alt_flash_fd* epcs = alt_flash_open_dev(EPCS_FLASH_NAME); 

alt_epcs_flash_read(epcs, offset, buf, length); 

== 

I have tried various offsets & lengths, 

but buf is always filled with 0x14141414... 

I am booting my board from EPCS without any problem, 

so I am sure this is not the right answer. 

Am I missing something? 

Thanks in advance.
0 Kudos
6 Replies
Altera_Forum
Honored Contributor I
51 Views

This threat discussion below seems is demotrating the usage of the read and write EPCS as well. 

 

http://www.alteraforum.com/forum/showthread.php?t=18461
Altera_Forum
Honored Contributor I
51 Views

Thanks, tony_stark. 

I did read the post, but still not working. I tried below: 

== 

static flash_region *p_epcs_reg_info; 

static int num_epcs_regs; 

alt_u8 buf[16]; 

alt_u8 buf2[16] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F}; 

alt_flash_fd* epcs = alt_flash_open_dev(EPCS_FLASH_NAME); 

int error = alt_epcs_flash_get_info(epcs, &p_epcs_reg_info, &num_epcs_regs); 

alt_epcs_flash_erase_block(epcs,0); 

alt_epcs_flash_write_block(epcs, 0, 0, (void*)buf2, 16); 

alt_epcs_flash_read(epcs, 0, (void*)buf, 16); 

== 

As for p_epcs_reg_info & num_epcs_regs, I get below which seems OK: 

offset=0, region_size=2097152, number_of_blocks=32, block_size=65536, num_epcs_regs=1 

I get error = 0, epcs is not NULL, so there seems to be no error. 

But I still get 0x14 for buf[0] to buf[15].. 

Is there anything else I should look for? 

Thanks in advance.
Altera_Forum
Honored Contributor I
51 Views

Did you check whether alt_flash_open_dev() returns a valid handle and if alt_epcs_flash_get_info() returns no error? 

Your posted code misses these points
Altera_Forum
Honored Contributor I
51 Views

Thanks Cris72, 

Yes, I did. As I wrote above,  

== 

alt_flash_fd* epcs = alt_flash_open_dev(EPCS_FLASH_NAME); 

int error = alt_epcs_flash_get_info(epcs, &p_epcs_reg_info, &num_epcs_regs); 

== 

epcs was not NULL & error = 0
Altera_Forum
Honored Contributor I
51 Views

Hello, I found out my problem. 

I was not connecting nCS of EPCS properly. 

Assigned it to "nCSO" in my top module, but passing "n_CSO" to the lower module. 

I wonder why Quartus did not raise an error because "n_CSO" exists nowhere in my code... 

It was bit tricky to find out, because configuration works totally fine.  

I was not aware that the problem could be on my FPGA side. 

Thanks,
Altera_Forum
Honored Contributor I
51 Views

 

--- Quote Start ---  

Hello, I found out my problem. 

I was not connecting nCS of EPCS properly. 

Assigned it to "nCSO" in my top module, but passing "n_CSO" to the lower module. 

I wonder why Quartus did not raise an error because "n_CSO" exists nowhere in my code... 

It was bit tricky to find out, because configuration works totally fine.  

I was not aware that the problem could be on my FPGA side. 

Thanks, 

--- Quote End ---  

 

 

good one! we all also never aware something not right with the FPGa and we focus on the software only :D
Reply