Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21600 Discussions

alt_flash_open_dev

Altera_Forum
Honored Contributor II
2,524 Views

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.
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
1,559 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
1,559 Views

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!

0 Kudos
Altera_Forum
Honored Contributor II
1,559 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
1,559 Views

i tried but i didnt see any error msg. where to see the error msg?

0 Kudos
Altera_Forum
Honored Contributor II
1,559 Views

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.
0 Kudos
Altera_Forum
Honored Contributor II
1,559 Views

i can use the flash if i am using de2 control panel. why?

0 Kudos
Reply