Skip to main content
Erenburg.Evgeny
Associate III
August 13, 2020
Question

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?

This topic has been closed for replies.

8 replies

KnarfB
Super User
August 13, 2020

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

Erenburg.Evgeny
Associate III
August 13, 2020

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

KnarfB
Super User
August 13, 2020

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?