cancel
Showing results for 
Search instead for 
Did you mean: 

ST32f4discovery+sdcard+fatfs problem

arnold
Associate II
Posted on June 30, 2012 at 23:43

Hello, 

i have a small problem i think.

With the help of this forum and google i created a project with CoIDE.

What it should do is reading the directory of an SDCARD.

The SDCARD part is working. but the fatfs is not working and i don't know what i'm doing wrong. 

I believe everything is oke. 

so i hope someone could help me. 

I attached the whole project. 

#sdcard-stm32f4-sdio-fatfs
48 REPLIES 48
arnold
Associate II
Posted on July 05, 2012 at 19:12

it was a connection error in the addapter, i replaced it and the sd card is working again. 

even when switching to 4b data mode 

[code]Status = SD_EnableWideBusOperation(SDIO_BusWide_4b);[/code]

this goes also well, it returns no error 

[code]res = f_mount(0, &fs);[/code]

but when running this code i get a fr_no_filesystem

[code]

      DIR dirs;

      char path[50]={''''};

      

       res=f_opendir(&dirs, path);

[/code]

the code above i found on the internet. 

you use printf, but i don't have a serial connection to my discovery board.

could  someone help me more, i think SD card with resistors is working. since it could switch to 4b mode.

arnold
Associate II
Posted on July 05, 2012 at 19:38

i did some debuging. 

and find out that 

fmt = check_fs(fs, bsect = 0); gives 2

not a boot record, but how can i put a bootrecord on a sdcard. 

it is formated as fat, it's a 2Gb card.

what could i do next to solve this problem.

Posted on July 06, 2012 at 18:54

If the media is readable on a PC, it should be readable here. For this type of media a MBR (Master Boot Record) is optional, and the FAT file system could exist with, or without, a partition table.

The way to effectively test this stuff is to connect the SDCard to the USB via the Mass Storage Controller. That should work, and if it doesn't it's a pretty sure indicator that something else is wrong.

Running CHKDSK on the media is also good at verifying integrity.

Formatting, either via the Media Properties, or Disk Manager.

Dumping out the content of the first sector should be instructive as to whether things are reading properly.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arnold
Associate II
Posted on July 06, 2012 at 19:25

How can i read sector 0 ?

if i use SDBlockread and use adres 0 is this sector 0. 

I searched google, but could not find any help on this problem.

Posted on July 06, 2012 at 20:17

Please refer to the disk_read() code I've posted earlier, and the USB MSC package.

Sector 0 is at offset 0

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arnold
Associate II
Posted on July 06, 2012 at 21:17

i altered it in diskio.c

i think BLOCKSIZE should be 512.

but now it keeps waiting on 

       Status = SD_WaitReadOperation(); // Check if the Transfer is finished

so it looks like it could not complete the readoperation. 

how can i check that. 

and what should i expect after doing this

 Status=disk_read(0,buffer2,0,1);

what should be in buffer2 ?

Posted on July 07, 2012 at 01:20

BLOCKSIZE is 512 and was defined in your original code.

Sounds awfully like you're not handling the interrupts for the SDIO library properly.

/**
* @brief This function handles SDIO global interrupt request.
* @param None
* @retval None
*/
void SDIO_IRQHandler(void)
{
/* Process All SDIO Interrupt Sources */
SD_ProcessIRQSrc();
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arnold
Associate II
Posted on July 07, 2012 at 19:05

Clive,

I'm still stuck at the above line.

i think i turned on Interupt, but i don't now if i did it right.

Could you look in to the attached code ?

is stm32xxx_it by default loaded or do i load it manualy ?

this because of the interupt handler.

________________

Attachments :

LCD_SD.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtU9&d=%2Fa%2F0X0000000aQg%2FKF1_t1i2dJ8scXb69hsvwAgtQePc6kUFqdTLSVMvAeI&asPdf=false
Posted on July 08, 2012 at 01:39

CooCox is not my IDE, but try to see if this builds.

________________

Attachments :

LCD_SD_Rev2.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtWX&d=%2Fa%2F0X0000000aRF%2F.B2UetsQznJJ3_lT.zycwQsnpE8bQt1v7GatmAP91js&asPdf=false
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arnold
Associate II
Posted on July 08, 2012 at 13:14

I just flashed the board with your example project

stm32f4_discovery_msc_sdhc_release_1

there was a bin file inside. 

With this example running, i can read the sd card with my computer. 

So everything is connected well.

Your rev2 code at the end of this post isn't working, the program is hanging at the same point again. 

So i have to figure out where it goes wrong.

With what kind of compiler do you work ?