Skip to content

Commit 267c595

Browse files
committed
FATFS: FATFileSystem.cpp migration, according to FatFs version upgrade from R0.13a to R0.14b
1 parent 9e5f21b commit 267c595

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

storage/filesystem/fat/source/FATFileSystem.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
#include "fat/ChaN/diskio.h"
1817
#include "fat/ChaN/ffconf.h"
1918
#include "fat/ChaN/ff.h"
19+
#include "fat/ChaN/diskio.h"
2020
#include "platform/mbed_debug.h"
2121
#include "platform/mbed_critical.h"
2222
#include "filesystem/mbed_filesystem.h"
@@ -199,7 +199,7 @@ extern "C" DSTATUS disk_initialize(BYTE pdrv)
199199
return (DSTATUS)_ffs[pdrv]->init();
200200
}
201201

202-
extern "C" DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
202+
extern "C" DRESULT disk_read(BYTE pdrv, BYTE *buff, LBA_t sector, UINT count)
203203
{
204204
debug_if(FFS_DBG, "disk_read(sector %lu, count %u) on pdrv [%d]\n", sector, count, pdrv);
205205
DWORD ssize = disk_get_sector_size(pdrv);
@@ -209,7 +209,7 @@ extern "C" DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
209209
return err ? RES_PARERR : RES_OK;
210210
}
211211

212-
extern "C" DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
212+
extern "C" DRESULT disk_write(BYTE pdrv, const BYTE *buff, LBA_t sector, UINT count)
213213
{
214214
debug_if(FFS_DBG, "disk_write(sector %lu, count %u) on pdrv [%d]\n", sector, count, pdrv);
215215
DWORD ssize = disk_get_sector_size(pdrv);
@@ -409,7 +409,15 @@ int FATFileSystem::format(BlockDevice *bd, bd_size_t cluster_size)
409409
}
410410

411411
// Logical drive number, Partitioning rule, Allocation unit size (bytes per cluster)
412-
FRESULT res = f_mkfs(fs._fsid, FM_ANY | FM_SFD, cluster_size, NULL, 0);
412+
MKFS_PARM opt;
413+
FRESULT res;
414+
opt.fmt = (FM_ANY | FM_SFD);
415+
opt.n_fat = 0U;
416+
opt.align = 0U;
417+
opt.n_root = 0U;
418+
opt.au_size = (DWORD)cluster_size;
419+
420+
res = f_mkfs((const TCHAR*)fs._fsid, &opt, NULL, FF_MAX_SS);
413421
if (res != FR_OK) {
414422
fs.unmount();
415423
fs.unlock();

0 commit comments

Comments
 (0)