STM32F1(STM32F103RCT6) Stm32CubeIDE fatfs sdio sdcard always returns FR_DISK_ERR
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.
- STM32CubeIDE - Version: 1.6.1
- STM32CubeMX - Version: 6.1.2
- See Attachment
Am i forgetting about something?
Please let me know the answer of this question.
