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

Urgent: sdram to flash

Altera_Forum
Honored Contributor II
893 Views

How to write 1Mb of data, let's say all '0' from sdram to flash? I know how to transfer like 100 digits but I am stuck when I tried to transfer 1Mb of data. When I try to transfer 1Mb of data, it seems like stuck during writing into flash. I am using de2 board with 8mb sdram and 4mb flash. 

 

 

--- Quote Start ---  

# include <stdio.h># include <stdlib.h># include "system.h"# include "alt_types.h"# include "sys/alt_dma.h"# include "sys/alt_flash.h" # include "sys/alt_flash_dev.h" 

# define size 1048576 

 

 

int main () 

int rc; 

 

 

alt_flash_fd* fd; 

int ret_code, i; 

int source; 

int dest; 

 

 

//printf("Source\tDest:\n"); 

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

source = i; 

dest = 0; 

 

printf("%d\t%d\n", source, dest);  

printf("Final\n\n"); 

fd = alt_flash_open_dev(EXT_FLASH_NAME); 

if (fd!=NULL) 

if((ret_code = alt_write_flash(fd, 0, source, 1048576)) == 0) 

 

if((ret_code = alt_read_flash(fd, 0, dest, 1048576)) == 0) 

 

printf("%d\t%d\n", source, dest);  

 

}else 

printf("Error in reading from flash\n"); 

}  

}else 

printf("Error in writing to flash\n"); 

}  

}else 

printf("Error in opening flash\n"); 

exit(1); 

return 0; 

 

--- Quote End ---  

 

 

It stucks here: 

 

 

--- Quote Start ---  

 

nios2-terminal: connected to hardware target using JTAG UART on cable 

nios2-terminal: "USB-Blaster [USB-0]", device 1, instance 0 

nios2-terminal: (Use the IDE stop button or Ctrl-C to terminate) 

 

--- Quote End ---  

0 Kudos
0 Replies
Reply