Skip to main content
Senior
November 9, 2023
Question

Can not execute f_open

  • November 9, 2023
  • 1 reply
  • 937 views

I have connected microsd by SDIo to STM4Disc1 board. I am using SD 4 bit. 

 I see on STM forums there is a bug and needs to set 1bit in MX_SDIO_SD_Init

so I changed to   hsd.Init.BusWide = SDIO_BUS_WIDE_1B and reduce SDIO CLK by 192 factor.

I am able to execute FATFS_LinkDriver, f_mount  & f_mks function runs successfully  but f_open  function always fails... 

I tried to create new file using f_open function.

f_open(&MyFile, "TESTING.TXT", FA_CREATE_ALWAYS | FA_WRITE )

 I also tried to open already exiting file  but it also fails.

f_open(&MyFile, "test123.txt", FA_READ)

On seeing FRSEULT  , I see FR_NOFILESYSTEM

 

This topic has been closed for replies.

1 reply

Semer CHERNI
ST Employee
November 10, 2023

Hello @Nico3 

First let me thank you for posting.

In fact this is a known issue which is tracked internally.
Waiting for a permanent solution I advise you to go ahead and configure the bus width in CubeMX to1bits.
Then in the generated code for the MX_SDIO_SD_Init function add the following code in the user code section 2:

if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)
 {
 Error_Handler();
 }

BR,

Semer. 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Nico3Author
Senior
November 10, 2023

bus is set to 1 bit. but on executing below function, it goes to error handler

if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)
 {
 Error_Handler();
 }

 

Nico3Author
Senior
November 13, 2023

I think there is bug in lower level bugs.. DMA  looks mandatory.  I enable it with SDIO IRQ, I can run now with no issues.