Intel® FPGA University Program
University Program Material, Education Boards, and Laboratory Exercises
1156 Discussions

altera_sd_up_card_avalon_interface, I'm having troubles with the size of the file.

Honored Contributor II

I'm using the UP SD card IP, almost everything is fine, I've saved succesfully a text file on the SD card, my problem starts when the file size is higher than the cluster size(32kb). then the PC doesn't recognize the file, an error notification is shown.  



I wanna know:  

does the IP supports higher files? 

Should I do assign a new cluster by myself or the core does it by itself?(how I'm assuming.)  

Has someone test it with larger files? (I repeat, when the file is smaller then the cluster size, everything works fine) 



here is code, It's just a test, sorry for my mess: 



int main(void){ 

alt_up_sd_card_dev *device_reference = NULL; 

int connected = 0; 

short int handler; 

short int handler2; 

short int att; 

char data = 0x00; 

long int loop; 


printf("Insert the SD Card \n"); 


device_reference = alt_up_sd_card_open_dev(ALTERA_UP_SD_CARD_AVALON_INTERFACE_0_NAME); 

if (device_reference != NULL) { 


if((connected ==0) && (alt_up_sd_card_is_Present())){ 

printf("SD Card Connected. \n"); 


printf("FAT16 file system detected!!! \n"); 


/* Start to create a file */ 


handler = alt_up_sd_card_fopen ("file.txt", true); 

printf("%x \n", handler); 

for(loop = 0; loop < 10000; loop++){ 


alt_up_sd_card_write(handler, 0x33); 

alt_up_sd_card_write(handler, 0x20);/*0x20 = space , 0x0D = enter*/ 


att = alt_up_sd_card_get_attributes(handler); 

printf ("get_attrubutes return: %d\n", att); 





handler2 = alt_up_sd_card_fopen ("/sistema/file2.txt", true); 

printf("%x \n", handler2); 

for(loop = 0; loop < 20000; loop++){ 


alt_up_sd_card_write(handler2, 0x33); 

alt_up_sd_card_write(handler2, 0x20);/*0x20 = space , 0x0D = enter*/ 


att = alt_up_sd_card_get_attributes(handler2); 

printf ("get_attrubutes return: %d\n", att); 



/* End */ 


} else{ 

printf("Unknown file system. \n"); 

connected = 1; 


} else if ((connected == 1) && (alt_up_sd_card_is_Present() == false)){ 

printf("SD disconected. \n"); 

connected = 0; 

return 0; 




It opens two text files, an 20kb and an 40kb files, one of them works(the smaller), I can view it in a text editor for instance, the another, doesn´t work at all. 



thank you for your time, and if my english isn't good: I'm sorry! correct me In a kind way, I'll apreciate it ;)
0 Kudos
0 Replies