cancel
Showing results for 
Search instead for 
Did you mean: 

I am trying to use fatfs with STM32L496g. Whenever i call f_mount, i am getting res = 1, (A hard error occurred in the low level disk I/O driver). I am using a discovery board for now. The sample project that comes along with it, is working fine.

Ashei.8
Associate II

I have tried debugging, and the error comes whenever

f_mkfs -> find_volume-> checkfs -> move_window -> disk_write is called.

looking at it, i see the implementation in diskio.c

DRESULT disk_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 */
)
{
  DRESULT res;
 
  res = disk.drv[pdrv]->disk_write(disk.lun[pdrv], buff, sector, count);
  return res;

i think its a function pointer, during debugging i cant step into it, and see its implementation in both projects.

can anyone please help me?

i have attached both projects,

however, the project FatFs_uSD_Standalone ( demo project) might not build correctly; there might be some files missing. i am not sure about how the include structure works on this project.

3 REPLIES 3

ST's model requires additional DISKIO drivers, which you select/enable with FATFS_LinkDriver()

There is typically a sd_diskio.c file with the real routines in it.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

there is a file called sd_diskio.c.

and i am linking drivers, by calling FATFS_LinkDriver(), however, im not sure if im doing it correctly.

the project file that you have uploaded at

https://drive.google.com/open?id=0B7OY5pub_GfINVZnNXFvTGxaWmM

i couldn't find where the drivers are linked.

Ashei.8
Associate II

I changed the optimization settings to reflect the optimization settings of the demo project, and now f_mkfs returns the error

(3) The physical drive cannot work