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

SD Card read fails on NIOS2 DE2 Board

Altera_Forum
Honored Contributor II
2,147 Views

Hi guys, 

 

I am a university student trying to get the demonstration project working. The project that I am trying to get it to work is, DE2_SD_Card_Audio. I am able to synthesize and transfer the SOF file to the FPGA. However, when I run the NIOS 2 project on the FPGA, I get the following error,  

 

[AUDIO] set audio reg[15] = 0000h 

[AUDIO] set audio reg[09] = 0000h 

[AUDIO] set audio reg[00] = 0017h 

[AUDIO] set audio reg[01] = 0017h 

[AUDIO] set audio reg[02] = 005Bh 

[AUDIO] set audio reg[03] = 005Bh 

[AUDIO] set audio reg[04] = 003Dh 

[AUDIO] set audio reg[05] = 0000h 

[AUDIO] set audio reg[06] = 0000h 

[AUDIO] set audio reg[07] = 0042h 

[AUDIO] set audio reg[08] = 0002h 

[AUDIO] set audio reg[09] = 0001h 

[AUDIO] AUDIO_Init success 

[AUDIO] set audio reg[02] = 0078h 

[AUDIO] set audio reg[03] = 0078h 

[AUDIO] set Line-Out vol(120,120) success 

Please insert SD card. 

find sd card 

[fat]read section 0 error. 

[fat]fat_mount fail 

sd card mount fail. 

 

How do I fix this ?
0 Kudos
16 Replies
Altera_Forum
Honored Contributor II
618 Views

What is 

 

1. Size of SD card 

2. Speed / class of SD card 

3. Format of the SD card 

 

???
0 Kudos
Altera_Forum
Honored Contributor II
618 Views

SD Card size - 4Gb 

Class - Class 4 

Formatted with Fat 16, Fat 32 , both failed.
0 Kudos
Altera_Forum
Honored Contributor II
618 Views

Try a SD Card 2 GB (maximum) formatted into FAT16 system

0 Kudos
Altera_Forum
Honored Contributor II
618 Views

Thanks for the quick response . I will tty that. In many places on the internet I read that 4 GB is max for fat16Also can I use a 4 GB SD card format it to 2 GB partition and try .

0 Kudos
Altera_Forum
Honored Contributor II
618 Views

No I think you really need a 2Gb SD card. SD cards with capacities higher than 2Gb use the SDHC standard instead of the "regular" SD and may not be compatible with the FPGA project.

0 Kudos
Altera_Forum
Honored Contributor II
618 Views

You must use a 2 GB SD card. 2 GB maximum. I have been through this already. The 4 GB card formatted into FAT16 does not work.

0 Kudos
Altera_Forum
Honored Contributor II
618 Views

Thanks guys! I will try it out.

0 Kudos
Altera_Forum
Honored Contributor II
618 Views

Hi, 

I am having a similar problem when trying the example software provided in the University program PDF i.e. 

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

 

device_reference = alt_up_sd_card_open_dev(SDCARD_INTERFACE_NAME); 

if (device_reference != NULL) 

while(1) 

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

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

if(alt_up_sd_card_is_FAT16()) 

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

 

.... 

Each time I debug the program, the function alt_up_sd_card_is_Present() always return 0. In Altera_UP_SD_Card_Avalon_Interface.c the pointer *aux_status_register value is 0x01 which leads to 0 in the operation *aux_status_register & 0x02. 

What I don't understand is why this pointer has that particular value? 

I know the SD Card is well formatted because I can run the DE1_SD_Card_Audio example.
0 Kudos
Altera_Forum
Honored Contributor II
618 Views

There could be a speed problem. I had two SD cards, one is rated class 4, the other one is unrated. The unrated one could not work. They both are FAT16. I have tested both of them on DE2 + DE2-70 platforms. Some problem.

0 Kudos
Altera_Forum
Honored Contributor II
618 Views

I have a SanDisk Ultra 2GB but as I said it works with the Audio project. Is there a way to flash a LED on the DE1 board when the SD is detected?

0 Kudos
Altera_Forum
Honored Contributor II
618 Views

Guys, I tried it with a brand new 2GB SD Card, Formatted as FAT16 system, unfortunately I still get the same error, 

 

Find SD card 

[FAT]Read section 0 error. 

[FAT]Fat_Mount fail 

SD card mount fail.
0 Kudos
Altera_Forum
Honored Contributor II
618 Views

I have a similar problem as wangrin. My board is also DE2 and SD card is 1GB which is formatted to FAT 16. Has anyone already solved this? Thanks in advance.

0 Kudos
Altera_Forum
Honored Contributor II
618 Views

Same problem with 1G sd card no matter in FAT16 or FAT32, anyone could help??or where can i found reference about this problem?

0 Kudos
Altera_Forum
Honored Contributor II
618 Views

I have same problem. I am unable to read the SDHC micro-SD card which has been formatted to create a 512MB FAT16 partition.  

I get the SD card mount fail error like a slap on my face. 

All these reference designs I have tried on this FPGA DE2-115 board have issues with them.
0 Kudos
iplayball27
Beginner
618 Views

I also had this problem and I was able to get it fixed by using the SD Card Association's formatting tool. For some reason, the windows formatting DOES NOT WORK. Just put your SD card into your computer, open the program, and it will format it as a FAT16 that the DE2-115 board can recognize. Don't know why the windows formatting tool doesn't work, but it doesn't. As others have mentioned, make sure you're using a plain SD card (not SDHC or SDXC), 2GB maximum.

 

Link to the tool (Windows): https://www.sdcard.org/downloads/formatter/eula_windows/index.html

iplayball27
Beginner
618 Views

ALSO: to anyone reading this, I got this to work using a 2GB SDSC Class 4 card. The Class 4 became super important after we tried using a class 2 card and got constant read failures because of the slower read speeds.

Reply