2012-02-08 04:06 PM
Hi Chaps,
Going slowly mad trying to get Chan Fat working with the sdio libs on a stm32f4.I'm using the most recent (1.0.0) library for the F4, and the low level access demo within that library builds and (at least appears to ) work OK. I've spent many, many hours attempting to patch in 0.9 version of fatfs from chan (thks chan, you're a hero) - but I can't get it to work.If possible, I'd really really appreciate a demo project/source (or direction to - though I've scoured the web and can't find anything that works!)I'll post separately about the current problems I'm having with the my current build, but a working example would sort it.Many thanks,nat. #hse-sdio-stm32 #stm32-fat-chanfat-fatfs-sdio #sdcard-stm32f4-sdio-fatfs #sdcard-stm32f4-sdio-fatfs2012-11-01 10:27 PM
Thanks alot for guiding me :)
2012-11-05 11:39 PM
Hi all,
You may find on the following link a full implementation of FatFS on STM32F2xx and STM32F4xx devices. link:2012-11-06 05:13 AM
You may find on the following link a full implementation of FatFS on STM32F2xx and STM32F4xx devices. link: STM32F2 and STM32F4 demonstration builder platform
As discussed on other threads, the examples target STM32x0G-EVAL, and have issues with larger SDHC cards due to the use of 32-bit byte addressing rather than block addressing. The versions I've ported to the STM32F4-Discovery address this and the lack of LCD panels. However, as a general rule I'd recommend people try the original ST code, on the ST EVAL boards, and become comfortable with a known working platform. This will help identify issues with hardware vs software. It is critical that a socket is wired correctly, with pull-up resistors, as it is with the EVAL boards. Review the schematic, understand the circuit.2012-11-07 12:15 AM
@AMSN
Please paste the complete link2012-11-07 04:27 AM
Please paste the complete link
Per the link provided, Design Resources tab, bottom of the page Demonstration Builderhttp://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/FIRMWARE/stm32f2-f4_demobuild.zip
2012-11-08 08:49 AM
clive1,
Thank you this has been a most helpful thread. I wonder if you could advise me where my issues are. When trying to write a file, I am getting the error FR_INT_ERR returned. I have stepped through the code and found the fail. I have a 2GB SD card formatted with Fat32 and one file in the root directory. In the ''remove_chain'' function on the line: if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ res = FR_INT_ERR; clst = 4294967295 fs->n_fatent = 481794 so it fails and sets the res = FR_INT_ERR; When trying to read a file I get a FR_NO_FILE When I step through the code it leads me to ''SD_ReadMultiBlocks'' function, inside diskio.c, which I copied directly from the web site. The function call to SD_ReadMultiBlocks returns SD_OK, but when SD_WaitReadOperation function it hangs. Killing the debug session and restarting, not single stepping, the f_open function returns FR_NO_FILE. I'm using IAR EWARM 6.40.2.3992 with an STM3240G-EVAL board. Any Suggestions? Thank you.2012-11-08 09:39 AM
Hard to say, I made a number of changes to the SDIO code to address some basic flaws I found in it. You could download my Keil build and look at the files with a diff/merge tool like WinMerge or Araxis Merge. This would be illustrative of what I did.
In terms of the routines hanging, I would check that the IRQ routines are set up and working properly. Non SDHC cards (ie sub 4GB) need to have the block size sent to them for the reads to work properly. My routines in diskio.c address potential DMA alignment issues, and also use fixed versions of the multi sector read/write routines. I don't have an STM3240G-EVAL board, or IAR to work with, but have successfully used SDIO/FATFS on other F2 and F4 platforms, and cards up to 32GB.2013-03-27 04:43 AM
Hi clive1, I have tested your STM32f4_discovery_sdio_sd library, with FatFs on my STM3240G-EVAL following your keil project (I use Atollic), all is working correctly, but performane are very poor (370KB/s)
The test is made by the following code:
fresult = f_mount(0, &fat );
fresult = f_open( &file,
''0:test.dat''
, FA_CREATE_ALWAYS | FA_WRITE );
while
(*** < 5);
GPIO_WriteBit(GPIOG, GPIO_Pin_8, Bit_SET);
while
(*** < 6)
{
fresult = f_write( &file, b,
sizeof
(b), &n);
}
GPIO_WriteBit(GPIOG, GPIO_Pin_8, Bit_RESET);
fresult = f_close(&file);
*** is incremented by 1 every 1 second TIM2 interrupt.
b is a 512 byte array
When I take off my MicroSD 4G Class 10 the file is about 370 / 380 KB).
Any idea about to increase the performance drastically ?
Best regards
Gian
2013-03-27 05:28 AM
When I take off my MicroSD 4G Class 10 the file is about 370 / 380 KB). Any idea about to increase the performance drastically ?
Implement caching and lazy writes? Long aligned runs? Cluster writes? I've seen 460 KBps writes across USB, the local speed is much higher writing directly to the card, FatFs is not designed for higher performance but rather small foot print.2013-03-27 07:33 AM
Generic 2GB Class 4(?) at the SD interface on a 120 MHz F2 design
51200 Bytes, 1189115 Cycles 5.166868 MBps Read 51200 Bytes, 2585850 Cycles 2.376008 MBps Write