- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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; }Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You cannot use onchip_mem directly. Please read to a buffer, (dump/check it) then copy the content to the onchip_mem.
You should check return of every file functions, such as open/seek/read/close etc. - Hippo- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks.
I want to use DMA to encrypt file between two onchip mems, and it will save some time if I can read data to onchip mem directly. Is there any other method can do that? Any of your help will be appreciated!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You cannot handle interrupt in user space. So you might have to do it in kernel space, like using a driver or syscall.
Beside, you should add return value check in your program and test it again before doing anything else. - Hippo- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- You cannot use onchip_mem directly. --- Quote End --- This _should_ be possible in a Kernel driver ?!?!?!? -Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But I can use fwrite() to move data from on-chip mem to a file directly.
Why fread() can't copy a file to on-chip mem? I tried kernel function like read(), failed too.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I wonder if the fread did work eventually to write to on chip memory? if so, what was the solution? thanks
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page