Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Reading EPCS Flash

Altera_Forum
Honored Contributor II
2,715 Views

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)); 

 

 

alt_flash_close_dev(p_epcs_fd); 

 

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
Altera_Forum
Honored Contributor II
282 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
282 Views

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 ?

0 Kudos
Altera_Forum
Honored Contributor II
282 Views

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.
0 Kudos
Reply