2021-10-14 04:23 AM
Hello.
I've tried to test sdcard with fatfs on STM32F103RCT6.
I don't have a compleat 100% sure hardware or software, so I'm struggling to debug if its a software or hardware issue.
I've read trough some topics hear, one with issue with https://community.st.com/s/question/0D50X00009XkWceSAF/stm32f411re-stm32cube-fatfs-sdio-sdcard-always-returns-frdiskerr
I tried to set DMA along the link, but SDIO_RX and SDIO_TX were not found.
Also, I couldn't find the 'Use dma template' item in FATFS settings.
I've generated the code from Stm32CubeIDE, and added a custom code:
int main(void)
{
/* USER CODE BEGIN 1 */
FRESULT res; /* FatFs function common result code */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_SDIO_SD_Init();
MX_USART1_UART_Init();
MX_FATFS_Init();
MX_ADC1_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
RetargetInit(&huart1);
printf("start test...\n");
res = f_mount(&SDFatFS , &SDPath[0], 1);
// if(res == FR_OK)
// while(1);
if(res == FR_OK)
printf("mount ok! SDPath:%s\n", SDPath);
else
printf("mount fail:%d\n", res);
res = f_mkdir("0:/abc");
// if((res != FR_OK) && (res != FR_EXIST))
// while(1);
if(res != FR_OK)
{
printf("mkdir dir fail:%d\n", res);
}
else
{
printf("mkdir dir ok!\n");
}
res = f_mkdir("abc");
if(res != FR_OK)
{
printf("mkdir dir fail:%d\n", res);
}
else
{
printf("mkdir dir ok!\n");
}
res = f_open(&SDFile, "LOG.TXT", FA_CREATE_ALWAYS | FA_WRITE);
if(res != FR_OK)
{
printf("LOG.TXT open fail:%d\n", res);
}
else
{
printf("LOG.TXT open ok!\n");
}
res = f_open(&SDFile, "0:/LOG.TXT", FA_CREATE_ALWAYS | FA_WRITE);
if(res != FR_OK)
{
printf("LOG.TXT open fail:%d\n", res);
}
else
{
printf("LOG.TXT open ok!\n");
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
FR_DISK_ERR starts from the f_mount function.
The program environment is as follows.
Am i forgetting about something?
Please let me know the answer of this question.
Solved! Go to Solution.
2021-10-28 01:00 AM
Hello @RKim.1
In our F1 Firmware package, we provide examples without ioc files.
Otherwise, take a look at this training that Starts project from STM32CubeMX. This should help you.
BeST Regards,
Walid
2021-10-22 04:08 AM
Hello @RKim.1 ,
Can you try to port the following example provided under our F1 Firmware Package to your board :
Please let me know if this example works for you. otherwise, it could be a hardware problem.
BeST regards,
Walid
2021-10-27 08:22 AM
Hello @RKim.1
Did you try what I suggested?
Please click on Select as Best if my post fully answered your question. This will help other customers with the same issue to find the solution faster!
BeST Regards,
Walid
2021-10-27 09:41 PM
I've reviewed your answer.
I reviewed the Firmware\Projects\STM3210C_EVAL\Applications\FatFs\FatFs_uSD file,
but I don't know how to apply it in STM32CubeIDE or STM32CubeMX.
Is there any way to apply it from STM32CubeIDE's .ioc or STM32CubeMX?
2021-10-28 01:00 AM
Hello @RKim.1
In our F1 Firmware package, we provide examples without ioc files.
Otherwise, take a look at this training that Starts project from STM32CubeMX. This should help you.
BeST Regards,
Walid
2021-10-28 03:08 AM
Thanks @Walid ZRELLI for the reply.
The STM32F7 series in the video you linked can set both RX and TX DMA settings,
But the STM32F1 series cannot settings.
Is it impossible to set DMA RX, TX in the .ioc file for STM32F1 series?
Is there no other way?
I would very much appreciate it if you confirm this question.
Best regards,
Robert
2021-10-28 03:51 AM
Hello @RKim.1
This is normal because as mentioned in the reference manual SDIO DMA settings can only be configured on DMA2 Channel4 with peripheral to memory direction.
You can refer to the Reference manual.
BeST Regards,
Walid
2021-10-28 04:14 AM
Hello. @Walid ZRELLI
BeST Regards,
Robert