This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SD Card over SPI, FSMediaError on Mount

Hello folks, my first time posting on this forum so apologies if I am missing any information in this post.

I am using a STM32F746NHGx with MDK-Pro. The hardware I am working with has an 8GB SD card connected over SPI that I'm told has "never worked". I was hoping to change that but I'm unsuccessful so far.

I have found and fixed few configuration issues that may be contributing to the problem, and I've gone through the demo FileSystemComponent application, but I still get an FsMediaError when I call the fmount or fformat operations. The finit operation returns fsOK.

Here is my configuration for FS_Config_MC_0.h

Fullscreen
1
2
3
4
5
6
7
8
9
#define MC0_ENABLE 1
#define MC0_MCI_DRIVER 0
#define MC0_SPI_DRIVER 2
#define MC0_SPI 1
#define MC0_CACHE_SIZE 4
#define MC0_CACHE_RELOC 0
#define MC0_CACHE_ADDR 0x7FD00000
#define MC0_NAME_CACHE_SIZE 0
#define MC0_FAT_JOURNAL 0
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And what I believe are the relevant portions of RTE_Device.h (I've verified the pins match on the PCB with the correct SD card components)

Fullscreen
1
2
3
4
5
6
7
8
9
#define RTE_SPI2 1
#define RTE_SPI2_MISO_PORT_ID 3
#define RTE_SPI2_MOSI_PORT_ID 4
#define RTE_SPI2_SCL_PORT_ID 3
#define RTE_SPI2_NSS_PORT_ID 4
#define RTE_SPI2_RX_DMA 0
#define RTE_SPI2_TX_DMA 0
#define RTE_SDMMC1 0
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Finally, the other possibly relevant setting I have found is in FS_Config.c

Fullscreen
1
#define FS_INITIAL_CDRIVE 2
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

My main.c (abbreviated below) is pretty simple:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define SD_FILESYS_DRIVE "M0"
int main(void)
{
MPU_Config();
CPU_CACHE_Enable();
osKernelInitialize();
errorMutexId = osMutexCreate(osMutex(errorMutex));
HAL_Init();
BSP_ClocksInit();
PeriphClock_Config();
digIOInit();
Init_Power_Reset();
MX_RTC_Init();
BSP_SDRAM_Init();
init_I2C();
framInit();
initNORFilesystem();
initSDFilesystem();
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

All I'm hoping for is a suggestion of a configuration option I may have overlooked or some suggestions for next steps in debugging this issue. Other possibly relevant notes:

1. I'm using SPI1 successfully for other operations.

2. I can read and write successfully to the NOR flash.

3. There are no other components on the SPI bus.

4. I've tried formatting the filesystem as fat32 using a PC and then just calling fmount, but no luck.

Any advice would be greatly appreciated!

0