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

SD Card Fat16 not recognized - up sdcard interface

Hi, 

 

when I try to start the university test program in Eclipse, it says that the sdcard is inserted but the File System is unkown. I tried with different sdcards but the problem remains. I tried to debugging and I found where the problem is. Please check the code for the red line. This is the part where the program returns result = false, and I get the message "Unknown File System". I don't really know what I should try now. Any help is appreciated. Thank you in advance. Please aks me if you need further information. 

 

Information SD-Card: 

 

sdcard 256 mb - FAT16 format - tried with 4kb, 8kb, 16kb cluster size 

 

Information about the SoPC: 

Avalon_UP_SD_Card_Interface_0 component is connected to: 

avalon_slave_0 to cpu.data_master 

clock_sink to pll.c0 (pll.co = 50 MHz) 

clock_sink_reset to pll.requestreset 

conduit_end is wired to nothing 

 

 

 

bool Check_for_Master_Boot_Record(void) // This function reads the first 512 bytes on the SD Card. This data should // contain the Master Boot Record. If it does, then print // relevant information and return true. Otherwise, return false. { bool result = false; int index; int end, offset, partition_size; /* Load the first 512 bytes of data from SD card. */ if (Read_Sector_Data(0, 0)) { end = (*((volatile short int *)SD_CARD_BUFFER(device_pointer->base, 0x1fe))); // Check if the end of the sector contains an end string 0xaa55. if ((end & 0x0000ffff) == 0x0000aa55) { // Check four partition entries and see if any are valid for (index = 0; index < 4; index++) { int partition_data_offset = (index * 16) + 0x01be; char type; // Read Partition type type = (*((volatile unsigned char *)SD_CARD_BUFFER(device_pointer->base, partition_data_offset + 0x04))); // Check if this is an FAT parition // This is where the program can't find any type of those below if ((type == 1) || (type == 4) || (type == 6) || (type == 14)) { // Get partition offset and size. offset = ((*((unsigned short int *)SD_CARD_BUFFER(device_pointer->base, partition_data_offset + 0x0A))) << 16) | (*((unsigned short int *)SD_CARD_BUFFER(device_pointer->base, partition_data_offset + 0x08))); partition_size = ((*((unsigned short int *)SD_CARD_BUFFER(device_pointer->base, partition_data_offset + 0x0E))) << 16) | (*((unsigned short int *)SD_CARD_BUFFER(device_pointer->base, partition_data_offset + 0x0C))); // Check if the partition is valid if (partition_size > 0) { result = true; fat_partition_size_in_512_byte_sectors = partition_size; fat_partition_offset_in_512_byte_sectors = offset; break; } } } } } return result; }
0 Kudos
0 Replies
Reply