Forum Discussion

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

Help:Cann't read or write EPCS in Nios II,why?

my system includes Flash,EPCS,etc,and has a EPCS controller.i want to read and write the EPCS in the nios.i tried to open the device using "alt_flash_open_dev()",but it's alway wrong--"can not open the device".so i used IORD()/IOWR(),and found Flash could be read/writen correctly,but EPCS couldn't be read/writen.Why?is anybody help me?

12 Replies

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

    mike21, i have set the nios boot from flash, in sopc builder, i set the reset address to flash. in nios ii ide setting, i also set the .text and .rodata flash to flash.

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

    hi everybody,

    iam using a nios II system generated from sopc builder.my system contains

    a CFI FLASH and SDRAM.Iam trying to simulate THE MEMTESTC.C exemple from the IDE.the sdram test is allright but the flash test is not.

    I have an error in Modelsim "

    -ERROR: Could not open flash

    i think that the problem is in the function

    alt_flash_open_dev witch don't recognize the flash

    i changed the code a little bit to be a ble to simulate

    static void TestFlash(int mode, int flash_type)

    {

    alt_flash_fd* fd;

    int number_of_regions;

    int block;

    int y=0;

    flash_region* regions;

    int ret_code = 0x0;

    // alt_u8 entry[4];

    alt_u8 flashname[30];i replace this variable by CFI_FLASH_NAME

    printf("\n get flash name\n");

    ret_code = GetFlashName(CFI_FLASH_NAME,CFI);

    printf("\n openning the falsh\n");

    fd = alt_flash_open_dev(CFI_FLASH_NAME);

    if (fd)

    {

    printf(" -Successfully opened %s\n", CFI_FLASH_NAME);

    /* Get some useful info about the flash */

    ret_code = alt_get_flash_info(fd, &regions, &number_of_regions);

    if (!ret_code)

    {

    printf(" -Region 0 contains %d blocks.\n", regions->number_of_blocks);

    block = FlashFindErasedBlocks(fd, regions, number_of_regions, mode);

    /* If we're in TEST mode, ask if this block is okay to test. */

    if(( mode == TEST ) && ( block != QUIT_WITHOUT_TESTING ))

    {

    printf(" -Block %d, at address 0x%X identified.\n", block, (regions->offset + (block * regions->block_size)));

    printf(" -Would you like to test this block? (y/n)");

    //GetInputString(entry, sizeof(entry), stdin);

    y=1;

    // if ( entry[0] == 'y' && entry[1] == '\n' )

    if(y==1)

    {

    /* Test that Flash! */

    FlashRunTests(fd, block, regions);

    printf(" -Closing flash device \"%s\".\n",CFI_FLASH_NAME);

    alt_flash_close_dev(fd);

    }

    }

    }

    }

    else

    {

    printf(" -ERROR: Could not open %s\n", CFI_FLASH_NAME);

    }

    }

    i tried a lot of things and i get the same result

    if somebody have an idea about how to solve this problem please HELP ME