diff --git a/src/00history.txt b/src/00history.txt index cb8753b..7a153a2 100644 --- a/src/00history.txt +++ b/src/00history.txt @@ -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 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. + diff --git a/src/00readme.txt b/src/00readme.txt index 234c675..3de3aea 100644 --- a/src/00readme.txt +++ b/src/00readme.txt @@ -1,4 +1,4 @@ -FatFs Module Source Files R0.14 +FatFs Module Source Files R0.15 FILES diff --git a/src/drivers/sd_diskio.c b/src/drivers/sd_diskio.c index d041c63..2c9eee7 100644 --- a/src/drivers/sd_diskio.c +++ b/src/drivers/sd_diskio.c @@ -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*/ @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -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****/ - diff --git a/src/drivers/sd_diskio.h b/src/drivers/sd_diskio.h index 2be3c38..2300574 100644 --- a/src/drivers/sd_diskio.h +++ b/src/drivers/sd_diskio.h @@ -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 */ diff --git a/src/ff_gen_drv.h b/src/ff_gen_drv.h index 89d115c..5d2695f 100644 --- a/src/ff_gen_drv.h +++ b/src/ff_gen_drv.h @@ -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; diff --git a/src/integer.h b/src/integer.h deleted file mode 100644 index 9ce7865..0000000 --- a/src/integer.h +++ /dev/null @@ -1,38 +0,0 @@ -/*-------------------------------------------*/ -/* Integer type definitions for FatFs module */ -/*-------------------------------------------*/ - -#ifndef _FF_INTEGER -#define _FF_INTEGER - -#ifdef _WIN32 /* FatFs development platform */ - -#include -#include -typedef unsigned __int64 QWORD; - - -#else /* Embedded platform */ - -/* These types MUST be 16-bit or 32-bit */ -typedef int INT; -typedef unsigned int UINT; - -/* This type MUST be 8-bit */ -typedef unsigned char BYTE; - -/* These types MUST be 16-bit */ -typedef short SHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types MUST be 32-bit */ -typedef long LONG; -typedef unsigned long DWORD; - -/* This type MUST be 64-bit (Remove this for ANSI C (C89) compatibility) */ -typedef unsigned long long QWORD; - -#endif - -#endif diff --git a/src/st_readme.txt b/src/st_readme.txt index 0355017..173feed 100644 --- a/src/st_readme.txt +++ b/src/st_readme.txt @@ -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.