Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12409 Discussions

SDCard only saves 3 kB of information

Honored Contributor II

I am using the SDCard port on teh altera DE2 board, and the SDCARD University IP Core and added it to my SOPC. In Nios I am using HAL driver used for the University core. 


I want to write around 2 MB worth of information on the SDCARD, but a small fraction of that is actually written. I formatted my 2 GB SDCARD in windows to FAT, with 32 kB allocated per cluster.  


As a small test I run a for loop to write into my text file 20000 lines, and a check to make sure each write was successful. 


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

success = alt_up_sd_card_write(handler, 0x61); //prints the letter 'a' 




success = alt_up_sd_card_write(handler, 0x0D); //writesnew line 





printf("Total Failures: %d\n", error); 


THere are never any failures, but only 16640 lines are written into. The rest of the values are null (in notepad++). If try to fill in all the values that I want, the text file becomes blank in notepad++, and as junk in regular notepad. The problem is not the line number, but when the text file reaches around 36-40 kB. 


I spent my whole day today writing code to send the right data to teh SD Card, I would hate for it to be a waste of time. Is there something that I am missing, or new way of trying to figure it out? The value I want gets saved to the card, it's just not all of it is being saved. My only other option right now would be to print the data and copy and paste to a text file, but I would be printing around 100k lines, I tried before and it takes almost a half hour to finish. 


Edit: Post title should read 39 kB not 3 kB
0 Kudos
1 Reply
Honored Contributor II

Hello, I'm working with this IP right now, sadly, I got the same results, I've been working in that for 2 weeks, and I think that the .h file just doesn't work, it failes when you try to store files bigger than the cluster size. and the OS doesn't recognize them anymore.  

Besides, I don't like the fat16 format, it's too old fashioned.  

I posted something similar here in altera forum, but nobody has responsed, please, if you find any solution make me know, I'll do the same. thank you!