2012-09-12 11:37 PM
Hello,
I've a problem with sdhc used with sdio in stm32f4-discovery platform. I've tried 2 versions of fat file system and sd driver, but I am not able to run sdhc properly. The things I tried; 1) Nemui's sdio implementation with chan's fat version 0.09a. 2) stm324xg-eval implementation with also chan's fat 0.09.(which is used from stm32-demonstration builder) Both codes are working perfectly with standard sdsc card (which are below 2gb) but when I insert a FAT32 formated sdhc card, the following occur. 1) SD_init() returns OK 2) f_mount() returns OK 3) f_open with create new file option returns OK 4) f_write returns OK with byteswritten value returned as expected. 5) f_sync returns OK but when I connect the sdhc card to pc there seems nothings has been written. Also there exists only one file in sdhc named as ''audio.wav'', f_open to this file returns FR_NO_FILE the standard sdsc versions are working perfectly, the init sequence seems to support sdhc but there must be something I forget. Can you please help me ? Regards, Yigit #stm32-sdio-sdhc #sdio-sdhc-stm32 #stm32-sdio-sdhc #stm32-sdio-wide-mode-sdhc2013-12-18 07:53 AM
Ok, thanks for the help! If I wanted to enable long file names, is it as simple as defining _USE_LFN or is there some more code I need to add/modify?
2013-12-18 08:46 AM
I just found this in the ffconf.h file:
#define _USE_LFN 0 /* 0 to 3 */
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
/* The _USE_LFN option switches the LFN support.
/
/ 0: Disable LFN feature. _MAX_LFN and _LFN_UNICODE have no effect.
/ 1: Enable LFN with static working buffer on the BSS. Always NOT reentrant.
/ 2: Enable LFN with dynamic working buffer on the STACK.
/ 3: Enable LFN with dynamic working buffer on the HEAP.
/
/ The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes. To enable LFN,
/ Unicode handling functions ff_convert() and ff_wtoupper() must be added
/ to the project. When enable to use heap, memory control functions
/ ff_memalloc() and ff_memfree() must be added to the project. */
Anyone know where the files it mentions might be? I can't find them. Otherwise I'm guessing all I need to do is change the 0 to a 1,2 or 3 to enable LFN...
2013-12-18 09:11 AM
STM32F2-F4_Demonstration_Builder_V1.3.0\Utilities\Third_Party\fat_fs\src\option\ccsbcs.c
STM32F2-F4_Demonstration_Builder_V1.3.0\Utilities\Third_Party\fat_fs\src\option\syscall.c Or other fw library \Utilities\Third_Party\fat_fs\src\option directories?2013-12-19 01:10 AM
Thanks, found them! I'm now getting an error in your main.c file on this bit of code:
#if _USE_LFN
static char lfn[_MAX_LFN + 1];
fno.lfname = lfn;
fno.lfsize = sizeof lfn;
#endif
It's complaining abouterror: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token. It gives me this error for the fno.lfname = lfn and the next line.
I can't find where or why the error might be coming from. Any ideas?
2013-12-19 08:22 AM
Any ideas?
I haven't played with it in a very long while, I think the code fragment in question needs to be inside one of the loops processing the directory listing. It may well just be parked somewhere arbitrarily.2013-12-20 12:49 AM
Looks like you were right about it being parked arbitrarily. I moved it inside the main function and it all worked.
2014-02-27 11:12 PM
I had a same problem, and after a few days I solved it. I think, it'll help you too. The reason was in GPIO initialization. In Clive's example maximum GPIO speed is 25 MHz, but it's not enaught for many SDHC cards. In my project i set GPIO speed to 100MHz and now all works fine.
2015-02-01 11:35 AM
Hey Clive
I was running the old code and hit the 4GB limit and then found your code. It seems to work great so far but do you know what the size limit is? I tried a 16GB and 32GB so far but don't have anything bigger on hand.2015-02-01 01:09 PM
I've tinkered with 64GB and 128GB cards, although they tend to be XFAT when used in a Windows PC. The math for the current driver is going to go pear shaped at 2TB, based on 4 billion 512-byte sectors...
2015-02-08 02:26 PM