Altera_Forum
Honored Contributor
16 years agoCannot write on-chip memory with fread.
I use DE2-70 to develop my project. My uClinux is running in SDRAM, and I want to copy a file to on-chip memory, but there is only 0 in on-chip memory, the fread() function didn't work.
can anyone help me in removing this error, Thanks a lot ! Code: int main() { FILE *fp1; unsigned int *mem_source = (unsigned int *)(na_onchip_mem_source|0x80000000); fp1 = open_file("P.dat",READ); long length; fseek(fp1, 0L, SEEK_END); length = ftell(fp1); int counter = 0; fseek(fp1,0L,SEEK_SET); fread(mem_source,length,1,fp1); int i; for(i=0;i<(length+3)/4;i++) printf("mem_source %d = %x\n",i,mem_source[i]); return 0; }