Forum Discussion
URGENT: Flash memory
Hello. I am doing a project regarding DMA. However I need to use flash memory on the DE2 Board. I have done the instantiation for the flash but I cannot use because it always return zero for the function alt_flash_open_dev().
Spec: Altera DE2 Board with 1Mb flash memory. Can I ask if it is possible to have someone to provide me a sample simple C-programming code on how to use flash? Like from beginning such as from library part till the end. Just a simple one will do. Because I tried so many but cant get it to work. I left lots of threads regarding this but none is helping. My code just to test alt_flash_open_dev() --- Quote Start --- # 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; 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; } --- Quote End --- Thanks!13 Replies
- Altera_Forum
Honored Contributor
Sorry, typo error, is 4MB.
- Altera_Forum
Honored Contributor
Sir,
Thanks for the reply. I have worked with all different timings, even though same result. My doubt about 22-bit is, it can assign only 4MB data using 8-bit data. How you are able to configure 8MB with 22-bit address? Another doubt is their any fixed Base Address for CFI Flash? Srinivas M - Altera_Forum
Honored Contributor
i think 20-bit should be fine because different size. Try change the setup time and hold time to 40ns each.
- Altera_Forum
Honored Contributor
Sir,
Thanks for the reply. My settings are also same like you. Even though it is not working. I am using Custom Board with 1MB Flash attached. My setting in SOPC: Address Width: 20-bit Data Width: 8-bit Timing: Setup: 45 Wait: 160 Hold: 45 Unit: ns Already added in Avalon MM Tristate Bridge. For 1MB i am using 20-bit and you are using 22-bit for 8MB. Is their any mistake here? Srinivas M - Altera_Forum
Honored Contributor
I am using Altera DE2 Board with 4MB Flash attached.
My setting in SOPC: Address Width: 22-bit Data Width: 8-bit Timing: Setup: 40 Wait: 160 Hold: 40 Unit: ns Remember to add in Avalon MM Tristate Bridge. For the top level entity: Open the .vhdl or .v file generated by the SOPC, find for your system, see the code generated and set according to it. - Altera_Forum
Honored Contributor
--- Quote Start --- My problem is regarding the setting in the SOPC and the top level entity file in Quartus II. I am not sure in your case, you can use 1MB instead of 4MB in that way. You need to make sure you are using the right controller. what board are you using? --- Quote End --- Sir, Thanks for the reply. It is an custom board. Can you clearly tell me the setting in SOPC and Top level entity in Quartus. Interfacing's are correct and tested by taking address, data and control lines as io lines instead of CFI Flash. Thanks in advance, Srinivas M - Altera_Forum
Honored Contributor
My problem is regarding the setting in the SOPC and the top level entity file in Quartus II. I am not sure in your case, you can use 1MB instead of 4MB in that way. You need to make sure you are using the right controller. what board are you using?
- Altera_Forum
Honored Contributor
Sir,
I am also trying in the same way. But, flash open is always returning zero. I have interfaced S29GL032 (Actually 4MB but using only 1MB by connecting MSB address lines on board to ground) to EP3C25E with 50MHz external crystal (No PLL). Please help regarding this problem. Thanks in advance. Thanks and Regards, Srinivas M - Altera_Forum
Honored Contributor
--- Quote Start --- Thanks, I can successfully use the flash now. The problem is not from coding or setting but the board itself. --- Quote End --- Sir, I am also trying in the same way. But, flash open is always returning zero. I have interfaced S29GL032 (Actually 4MB but using only 1MB by connecting MSB address lines on board to ground) to EP3C25E with 50MHz external crystal (No PLL). Please help regarding this problem. Thanks in advance. Thanks and Regards, Srinivas M - Altera_Forum
Honored Contributor
Thanks, I can successfully use the flash now. The problem is not from coding or setting but the board itself.