cancel
Showing results for 
Search instead for 
Did you mean: 

FATFS and STM32CubeIDE

I generate the code for FATFS. But functions in user_diskio.c not populated.

for example

DRESULT USER_write (
	BYTE pdrv,          /* Physical drive nmuber to identify the drive */
	const BYTE *buff,   /* Data to be written */
	DWORD sector,       /* Sector address in LBA */
	UINT count          /* Number of sectors to write */
)
{
  /* USER CODE BEGIN WRITE */
  /* USER CODE HERE */
    return RES_OK;
  /* USER CODE END WRITE */
}

What should I set to populate these functions?

8 REPLIES 8
KnarfB
Principal III

You are supposed to implement the backend yourself.

For a SD specific backend, there is sample code here: https://github.com/STMicroelectronics/STM32CubeF0/tree/master/Drivers/BSP/Adafruit_Shield

And the original FATFS authors docs: http://elm-chan.org/fsw/ff/00index_e.html

I see. Thank you. To implement myself - it's better be in IAR with simple and clear code.

Well. You sure have a specific backend for your design. FATFS is "just" a translation from file ops to block level IO. What is your target hardware?

It's B-L475E-IOT01A with STM32L475vc inside.

If you wanna use QSPI check here https://github.com/STMicroelectronics/STM32CubeL4/tree/master/Drivers/BSP/B-L475E-IOT01

SD card is nearby (Adafruit Shield)

You still have to write some glue code.

That's the problem, why I drifted to STM32CubeIDE. No BSP driver for regular SPI. :))

search the forum for stm32_spi_flash_fatfs ?

Thank you.