Forum Discussion

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

Store the data on the EPCS4!!

Hello ,I want to keep the data to the EPCS4,following is the process:# include <stdio.h># include <unistd.h># include "system.h"# include "alt_types.h"# include "sys/alt_flash.h" # include "sys/alt_flash_dev.h"# include "altera_avalon_epcs_flash_controller.h"

alt_u8 epcsbuf[32]="123456789";

int ret_code,i;

int number_of_regions;

alt_flash_fd* my_epcs;

flash_region* regions;

int main (void) __attribute__ ((weak, alias ("alt_main")));

int alt_main(void)

{

my_epcs = alt_flash_open_dev("/dev/epcs_flash_controller");

ret_code = alt_epcs_flash_get_info (my_epcs, &regions, &number_of_regions);

if(my_epcs)

{

ret_code = alt_epcs_flash_erase_block(my_epcs, 0x70000);

ret_code = alt_epcs_flash_write(my_epcs, 0x70000, epcsbuf, 10);

for(i=0;i<10;i++)

epcsbuf[i]=0;

ret_code = alt_epcs_flash_read(my_epcs, 0x70000, epcsbuf, 10);

}

while(1)

{

}

return 0;

}

Why is red part of the function return value is 0?And the address of the EPCS4 is absolutely correct.

2 Replies

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

    What about the name? Are you sure that the controller name is /dev/epcs_flash_controller ? You can look for it in your system.h

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

    you can pick up the macro EPCS_NAME (something like that) from your system.h