Forum Discussion

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

alt_flash_open_dev

following is my code:

# include <stdio.h> # include <stdlib.h># include <string.h># include "system.h" # include "altera_avalon_pio_regs.h" # include "alt_types.h" # include "altera_avalon_performance_counter.h"# include "sys/alt_flash.h" # include "sys/alt_flash_dev.h"

int main(void)

{

alt_flash_fd* fd;

//int number_of_regions;

//int block;

//flash_region* regions;

//int ret_code = 0x0;

alt_u8 flashname[30];

strcpy(flashname, "/dev/ext_flash");;

fd = alt_flash_open_dev("/dev/ext_flash");

if (fd)

{

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

}

else{

printf("The end\n");}

return 0;

}

why the return of alt_flash_open_dev is always error where The end is printed? i am using altera de2 board. 1mb flash, reset vector is set to sdram as well as exception vector.

6 Replies

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

    Provided "/dev/ext_flash" is correctly the name of the sopc device as reported in system.h file (I think you have already checked it...), maybe the problem is that your flash device is not included in the driver CFI table.

    What's your flash device part number?

    Read the de2 board documentation and look if there's a driver patch for the flash.

    I had to do the same with another eval board.

    You can also try run in debug mode and step into alt_flash_open_dev in order to find out where the problem exactly is.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    what is driver CFI table? the flash part number is 29LV800TE-90PFTN 0441 F84. where to find the de2 board documentation? how to do the step in debug mode? sorry, i am new in this. thanks!

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

    Compile all in debug mode.

    Place a breakpoint on alt_flash_open_dev function.

    Launch the program with "Debug as..." instead of "Run as...

    Wait until the breakpoint hits. Then step into the function and find the point where the driver generates the error.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You must step the driver code until you find a function returning a zero or negative value, while it is intended to return a positive one.

    Probably this is one of the functions in altera_avalon_cfi_flash_table.c, or in any other altera_avalon_cfi_flash*.c.