We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
#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
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)
#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
Finally, the other possibly relevant setting I have found is in FS_Config.c
#define FS_INITIAL_CDRIVE 2
My main.c (abbreviated below) is pretty simple:
#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(); } int initSDFilesystem(void) fsStatus SDStatus; SDStatus=finit(SD_FILESYS_DRIVE); if (SDStatus != fsOK) { printf("SD init Failed\n"); return SD_INIT_FAILED; } SDStatus=fformat(SD_FILESYS_DRIVE, NULL); if (SDStatus != fsOK) { printf("SD init Failed\n"); return SD_INIT_FAILED; } }
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!
Hi,
if everything is correct in firmware, it could still be a problem in the HW:
-check PullUp at DO line, SD-Card output is initially open-drain and requires the external pullUp until output is configured for push-pull.
-Not required but recommended: Connect a PullUp to unused data lines of SD-Card ...
Regards, Gunnar