Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Reading EPCS Flash

Honored Contributor II

Dear all, 


We have planned to use the free space in our EPCS64 configuration IC to store user data. So we have selected the last block in our EPCS memory for the same.  


We have used the following method to read the data, 


p_epcs_fd = alt_flash_open_dev("/dev/epcs_flash_controller_0"); 

if (p_epcs_fd) { 

alt_epcs_flash_get_info(p_epcs_fd, &p_epcs_reg_info, &num_epcs_regs); 

epcsAddr = (p_epcs_reg_info->number_of_blocks 

- BOARD_DATA_BLOCK_FROM_END) * p_epcs_reg_info->block_size; 

alt_read_flash(p_epcs_fd, epcsaddr, &var, sizeof(var)); 





but we have a doubt regarding "datatype" of epcsaddr passed in alt_read_flash() method. according to the method, it needs to be an integer but for a epcs64 device the address of last block is "0x7f0000" (8323072 dec) which is beyond the scope of integer variable. kindly let know how the method operates.
0 Kudos
3 Replies
Honored Contributor II

What do you mean by "beyond the scope"? The integer type is 32 bits wide, and big enough to store the value 0x7F0000.

Honored Contributor II

Dear DAIXIWEN... thanks for the reply, i was assuming that signed int is -32767 to + 32768 and unsigned is 0 to 65535, which are 16 bit wide. Is it different for Embedded C ?

Honored Contributor II

Almost nothing 'mainstream' has used 16 bit 'int' for best part of 20 years [1]. 

There are some 16bit cpu in embedded systems, but the niosII is a 32bit cpu - so has a 32bit 'int'. 


[1] excluding microsoft windows which kept 16bit int for a long time even when support for 286 (and earlier) processors had been dropped.