Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
709 Views

SDCard only saves 3 kB of information

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' 

if(!success) 

error++; 

 

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

if(!success) 

error++; 

 

 

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
Altera_Forum
Honored Contributor I
32 Views

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!
Reply