cancel
Showing results for 
Search instead for 
Did you mean: 

FatFS problem with SDIO on stm32f103vet6

angeletti
Associate II
Posted on December 18, 2014 at 16:23

Hi guys, I'm trying to use an SD card with the aforementioned chip on the Primer2. I started from a working project but when ported to my application, it simply doesn't work. Anyone can help?

In detail, I've ported the interface's code from the STM3210E-EVAL and just adapted some functions to work with FatFS.

http://www55.zippyshare.com/v/83185557/file.html

#stm3210e-eval #stm32f103 #sdio
8 REPLIES 8
Posted on December 18, 2014 at 17:26

Probably want to enable the NVIC before generating interrupts. Watch for the 32-bit overflow on cards >2GB

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
angeletti
Associate II
Posted on December 18, 2014 at 17:40

Currently I'm using a 2GB sdcard formatted as FAT32 with 512bytes blocks. I've just added the NVIC configuration for both SDIO and DMA, still not working.

case

MMC :
SD_Init();
SD_GetCardInfo(&SDCardInfo2);
SD_SelectDeselect((uint32_t) (SDCardInfo2.RCA << 16));
SD_EnableWideBusOperation(SDIO_BusWide_4b);
//SD_SetDeviceMode(SD_DMA_MODE);
NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = SD_SDIO_DMA_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_Init(&NVIC_InitStructure);
return

0;

There is the

http://www.stm32circle.com/projects/download.php?id=226&file=Chan-s-FatFS-Menu-Matthias-framework-wo-CilrcleOS-1.0.zip

http://www.stm32circle.com/projects/project.php?id=226

from which I started. Any suggestion will be highly appreciated
Posted on December 18, 2014 at 18:11

I don't have a Primer 2

Ok, but why do you initialize the interrupts last, wouldn't you want that working first?

I have an STM3210E-EVAL, perhaps you can enumerate the differences between the boards, so I can gauge how complicated a port it would be.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on December 18, 2014 at 18:15

So what debugging have you actually done? ''Not working'' is a bit nebulous. Does it call the initializations code, have you break pointed it? Do you have any of the non-MMC nodes working, or is that just junk left over? Do any of the SD commands work, what kinds of errors and status issues do you observe?

Suggest you get the SD abstraction working outside of FatFs functionality, prove the Read/Write functionality gets the sectors you expect.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
angeletti
Associate II
Posted on December 18, 2014 at 18:42

There aren't a lot of differences between the boards (speaking of SD connection and clock), just the Primer2 hasn't an SD_DETECT line, so I've disabled it in the code (SD_Detect() returns always SD_PRESENT). Right now I've no debugger with me (I'm programming through an stm32vl-discovery integrated SWD), so I've just checked simple operations, for example f_mount seems to work but I can't be 100% sure. Now I'm trying to check if the SD driver is working, excluding the FatFS module. Do you a simple working code for the EVAL board? Maybe I can restart from here.

Posted on December 18, 2014 at 19:02

STM3210E-EVAL_FW_V2.1.0\Utilities\STM32_EVAL\STM3210E_EVAL\stm3210e_eval_sdio_sd.c

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
angeletti
Associate II
Posted on December 18, 2014 at 20:12

The drivers seems to behave strangely with the function:

static
SD_Error CmdError(
void
)

inside fatfs_sdio_sd.c. Seems at the point that calls:

FlagStatus SDIO_GetFlagStatus(uint32_t SDIO_FLAG)

within stm32f10x_sdio.c. The code is pretty identical to the one from stm3210e-eval-demo V2.1.0, still no success. However the only example that works 100% comes from a Ride7 project and uses a syntax not welcome from Keil. Still tryin' to figure it out, butwithout debugger seems hard
angeletti
Associate II
Posted on December 19, 2014 at 00:55

I've solved the main problem recreating the entire project from the previously linked example, and now the project includes the latest fatfs version. Now I'm facing another problem: ''ff.h'' defines really useful functions like f_puts, f_printf but i can't use them. uVision successfully compiles every file, and the main has the ''#include ''ff.h'', the path to /fatfs/src is also present for the compiler. I have this linker error:

.\obj\project.axf: Error: L6218E: Undefined symbol f_printf (referred from main.o).

However if anyone interested there is the current working

http://http://www41.zippyshare.com/v/53359693/file.html