Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/00history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,32 @@ R0.14 (October 14, 2019)
Fixed f_readdir() function returns file names with wrong case conversion. (appeared at R0.12)
Fixed f_mkfs() function can fail to create exFAT volume in the second partition. (appeared at R0.12)


R0.14a (December 5, 2020)
Limited number of recursive calls in f_findnext().
Fixed old floppy disks formatted with MS-DOS 2.x and 3.x cannot be mounted.
Fixed some compiler warnings.



R0.14b (April 17, 2021)
Made FatFs uses standard library <string.h> for copy, compare and search instead of built-in string functions.
Added support for long long integer and floating point to f_printf(). (FF_STRF_LLI and FF_STRF_FP)
Made path name parser ignore the terminating separator to allow "dir/".
Improved the compatibility in Unix style path name feature.
Fixed the file gets dead-locked when f_open() failed with some conditions. (appeared at R0.12a)
Fixed f_mkfs() can create wrong exFAT volume due to a timing dependent error. (appeared at R0.12)
Fixed code page 855 cannot be set by f_setcp().
Fixed some compiler warnings.



R0.15 (November 6, 2022)
Changed user provided synchronization functions in order to completely eliminate the platform dependency from FatFs code.
FF_SYNC_t is removed from the configuration options.
Fixed a potential error in f_mount when FF_FS_REENTRANT.
Fixed file lock control FF_FS_LOCK is not mutal excluded when FF_FS_REENTRANT && FF_VOLUMES > 1 is true.
Fixed f_mkfs() creates broken exFAT volume when the size of volume is >= 2^32 sectors.
Fixed string functions cannot write the unicode characters not in BMP when FF_LFN_UNICODE == 2 (UTF-8).
Fixed a compatibility issue in identification of GPT header.

2 changes: 1 addition & 1 deletion src/00readme.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FatFs Module Source Files R0.14
FatFs Module Source Files R0.15


FILES
Expand Down
131 changes: 57 additions & 74 deletions src/drivers/sd_diskio.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@
******************************************************************************
* @attention
*
* Copyright (c) 2017-2019 STMicroelectronics. All rights reserved.
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
* This software is licensed under terms that can be found in the st_license.txt
* file in the root directory of this software component.
* If no st_license.txt file comes with this software, it is provided AS-IS.
*
******************************************************************************
**/
*/
/* Includes ------------------------------------------------------------------*/
#include "ff_gen_drv.h"
#include "sd_diskio.h"


/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* use the default SD timout as defined in the platform BSP driver*/
Expand All @@ -46,33 +44,29 @@
static volatile DSTATUS Stat = STA_NOINIT;

/* Private function prototypes -----------------------------------------------*/
static DSTATUS SD_CheckStatus(BYTE lun);
DSTATUS SD_initialize (BYTE);
DSTATUS SD_status (BYTE);
DRESULT SD_read (BYTE, BYTE*, DWORD, UINT);
#if _USE_WRITE == 1
DRESULT SD_write (BYTE, const BYTE*, DWORD, UINT);
#endif /* _USE_WRITE == 1 */
#if _USE_IOCTL == 1
DRESULT SD_ioctl (BYTE, BYTE, void*);
#endif /* _USE_IOCTL == 1 */
static DSTATUS SD_check_status (BYTE);
static DSTATUS SD_initialize (BYTE);
static DSTATUS SD_status (BYTE);
static DRESULT SD_read (BYTE, BYTE*, LBA_t, UINT);
static DRESULT SD_write (BYTE, const BYTE*, LBA_t, UINT);
static DRESULT SD_ioctl (BYTE, BYTE, void*);

const Diskio_drvTypeDef SD_Driver =
{
SD_initialize,
SD_status,
SD_read,
#if _USE_WRITE == 1
SD_write,
#endif /* _USE_WRITE == 1 */

#if _USE_IOCTL == 1
SD_ioctl,
#endif /* _USE_IOCTL == 1 */
};

/* Private functions ---------------------------------------------------------*/
static DSTATUS SD_CheckStatus(BYTE lun)
/**
* @brief Check the status of the sd card
* @param lun : not used
* @retval DSTATUS: return 0 if the sd card is ready and 1 otherwise
*/
static DSTATUS SD_check_status(BYTE lun)
{
(void)lun;
Stat = STA_NOINIT;
Expand All @@ -86,45 +80,43 @@ static DSTATUS SD_CheckStatus(BYTE lun)
}

/**
* @brief Initializes a Drive
* @param lun : not used
* @retval DSTATUS: Operation status
*/
DSTATUS SD_initialize(BYTE lun)
* @brief Initialize the SD Diskio lowlevel driver
* @param lun : not used
* @retval DSTATUS: return 0 on Success STA_NOINIT otherwise
*/
static DSTATUS SD_initialize(BYTE lun)
{
Stat = STA_NOINIT;
#if !defined(DISABLE_SD_INIT)

if(BSP_SD_Init() == MSD_OK)
{
Stat = SD_CheckStatus(lun);
Stat = SD_check_status(lun);
}

#else
Stat = SD_CheckStatus(lun);
Stat = SD_check_status(lun);
#endif
return Stat;
}

/**
* @brief Gets Disk Status
* @param lun : not used
* @retval DSTATUS: Operation status
*/
DSTATUS SD_status(BYTE lun)
* @brief Get the Disk Status
* @param lun : not used
* @retval DSTATUS: Operation status
*/
static DSTATUS SD_status(BYTE lun)
{
return SD_CheckStatus(lun);
return SD_check_status(lun);
}

/**
* @brief Reads Sector(s)
* @param lun : not used
* @param *buff: Data buffer to store read data
* @param sector: Sector address (LBA)
* @param count: Number of sectors to read (1..128)
* @retval DRESULT: Operation result
*/
DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
* @brief Reads Sector(s)
* @param lun : not used
* @param *buff: Data buffer to store read data
* @param sector: Sector address (LBA)
* @param count: Number of sectors to read (1..128)
* @retval DRESULT: return RES_OK otherwise
*/
static DRESULT SD_read(BYTE lun, BYTE *buff, LBA_t sector, UINT count)
{
(void)lun;
DRESULT res = RES_ERROR;
Expand All @@ -133,26 +125,24 @@ DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
(uint32_t) (sector),
count, SD_TIMEOUT) == MSD_OK)
{
/* wait until the read operation is finished */
/* Wait until the card state is ready */
while(BSP_SD_GetCardState()!= MSD_OK)
{
}
res = RES_OK;
}

return res;
}

/**
* @brief Writes Sector(s)
* @param lun : not used
* @param *buff: Data to be written
* @param sector: Sector address (LBA)
* @param count: Number of sectors to write (1..128)
* @retval DRESULT: Operation result
*/
#if _USE_WRITE == 1
DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
* @brief Write data from sd card into a buffer
* @param lun : not used
* @param *buff: Data to be written
* @param sector: Sector address (LBA)
* @param count: Number of sectors to write (1..128)
* @retval DRESULT: return RES_OK otherwise
*/
static DRESULT SD_write(BYTE lun, const BYTE *buff, LBA_t sector, UINT count)
{
(void)lun;
DRESULT res = RES_ERROR;
Expand All @@ -161,26 +151,23 @@ DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
(uint32_t)(sector),
count, SD_TIMEOUT) == MSD_OK)
{
/* wait until the Write operation is finished */
/* Wait until the card state is ready */
while(BSP_SD_GetCardState() != MSD_OK)
{
}
res = RES_OK;
}

return res;
}
#endif /* _USE_WRITE == 1 */

/**
* @brief I/O control operation
* @param lun : not used
* @param cmd: Control code
* @param *buff: Buffer to send/receive control data
* @retval DRESULT: Operation result
*/
#if _USE_IOCTL == 1
DRESULT SD_ioctl(BYTE lun, BYTE cmd, void *buff)
* @brief I/O control operation
* @param lun : not used
* @param cmd: Control code
* @param *buff: Buffer to send/receive control data
* @retval DRESULT: return RES_OK otherwise
*/
static DRESULT SD_ioctl(BYTE lun, BYTE cmd, void *buff)
{
(void)lun;
DRESULT res = RES_ERROR;
Expand All @@ -191,7 +178,7 @@ DRESULT SD_ioctl(BYTE lun, BYTE cmd, void *buff)
switch (cmd)
{
/* Make sure that no pending write process */
case CTRL_SYNC :
case CTRL_SYNC:
res = RES_OK;
break;

Expand Down Expand Up @@ -222,7 +209,3 @@ DRESULT SD_ioctl(BYTE lun, BYTE cmd, void *buff)

return res;
}
#endif /* _USE_IOCTL == 1 */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

29 changes: 18 additions & 11 deletions src/drivers/sd_diskio.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,37 @@
******************************************************************************
* @file sd_diskio.h
* @author MCD Application Team
* @brief Header for sd_diskio.c module.
* @brief Header for sd_diskio.c module
******************************************************************************
* @attention
*
* Copyright (c) 2017 STMicroelectronics. All rights reserved.
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
* This software is licensed under terms that can be found in the st_license.txt
* file in the root directory of this software component.
* If no st_license.txt file comes with this software, it is provided AS-IS.
*
******************************************************************************
**/
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __SD_DISKIO_H
#define __SD_DISKIO_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "ff_gen_drv.h"

/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
extern const Diskio_drvTypeDef SD_Driver;
extern const Diskio_drvTypeDef SD_Driver;

#endif /* __SD_DISKIO_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#ifdef __cplusplus
}
#endif

#endif /* __SD_DISKIO_H */
4 changes: 2 additions & 2 deletions src/ff_gen_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ typedef struct
{
DSTATUS (*disk_initialize) (BYTE); /*!< Initialize Disk Drive*/
DSTATUS (*disk_status) (BYTE); /*!< Get Disk Status*/
DRESULT (*disk_read) (BYTE, BYTE*, DWORD, UINT); /*!< Read Sector(s)*/
DRESULT (*disk_write) (BYTE, const BYTE*, DWORD, UINT); /*!< Write Sector(s)*/
DRESULT (*disk_read) (BYTE, BYTE*, LBA_t, UINT); /*!< Read Sector(s)*/
DRESULT (*disk_write) (BYTE, const BYTE*, LBA_t, UINT); /*!< Write Sector(s)*/
DRESULT (*disk_ioctl) (BYTE, BYTE, void*); /*!< I/O control operation*/
}Diskio_drvTypeDef;

Expand Down
38 changes: 0 additions & 38 deletions src/integer.h

This file was deleted.

18 changes: 18 additions & 0 deletions src/st_readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@
******************************************************************************
@endverbatim

### V4.0.4/20-02-2026 ###
============================
+ Update the "sector address" parameter type from "DWORD" to "LBA_t" in the disk_read() and disk_write() function prototypes
- ff_gen_drv.h

### V4.0.3/14-03-2025 ###
============================
+ Protect the SCB_CleanDCache_by_Addr calls in SD_DMA_Write() by a check on ENABLE_SD_DMA_CACHE_MAINTENANCE config flag.
- drivers/sd/sd_diskio_dma_rtos.c

### V4.0.2/20-12-2024 ###
============================
+ Remove wrong casting of "buff" in the USBH_read(), USBH_write() and USBH_ioctl() functions
- drivers/usb_host/usbh_diskio.c

+ Fix wrong cache management in the SD_DMA_write() function
- drivers/sd/sd_diskio_dma_rtos.c

### V4.0.1/18-08-2023 ###
============================
+ Add LICENSE.md file at the root directory.
Expand Down