extmod/vfs_fat: Remove MICROPY_FATFS_OO config option.
Everyone should now be using the new ooFatFs library. The old one is no longer supported and will be removed.
This commit is contained in:
parent
95635ade8b
commit
0bd61d23b9
@ -64,7 +64,6 @@
|
||||
#define MICROPY_QSTR_BYTES_IN_HASH (1)
|
||||
|
||||
// fatfs configuration used in ffconf.h
|
||||
#define MICROPY_FATFS_OO (1)
|
||||
#define MICROPY_FATFS_ENABLE_LFN (2)
|
||||
#define MICROPY_FATFS_MAX_LFN (MICROPY_ALLOC_PATH_MAX)
|
||||
#define MICROPY_FATFS_LFN_CODE_PAGE (437) // 1=SFN/ANSI 437=LFN/U.S.(OEM)
|
||||
|
@ -95,7 +95,6 @@
|
||||
#define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool
|
||||
|
||||
#define MICROPY_VFS (1)
|
||||
#define MICROPY_FATFS_OO (1)
|
||||
#define MICROPY_FATFS_ENABLE_LFN (1)
|
||||
#define MICROPY_FATFS_RPATH (2)
|
||||
#define MICROPY_FATFS_MAX_SS (4096)
|
||||
|
@ -32,10 +32,6 @@
|
||||
#error "with MICROPY_VFS_FAT enabled, must also enable MICROPY_VFS"
|
||||
#endif
|
||||
|
||||
#if !MICROPY_FATFS_OO
|
||||
#error "with MICROPY_VFS_FAT enabled, must also enable MICROPY_FATFS_OO"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "py/nlr.h"
|
||||
#include "py/runtime.h"
|
||||
|
@ -36,13 +36,8 @@
|
||||
#include "py/mphal.h"
|
||||
|
||||
#include "py/runtime.h"
|
||||
#if MICROPY_FATFS_OO
|
||||
#include "lib/oofatfs/ff.h"
|
||||
#include "lib/oofatfs/diskio.h"
|
||||
#else
|
||||
#include "lib/fatfs/ff.h" /* FatFs lower layer API */
|
||||
#include "lib/fatfs/diskio.h" /* FatFs lower layer API */
|
||||
#endif
|
||||
#include "extmod/fsusermount.h"
|
||||
|
||||
#if _MAX_SS == _MIN_SS
|
||||
@ -51,29 +46,16 @@
|
||||
#define SECSIZE(fs) ((fs)->ssize)
|
||||
#endif
|
||||
|
||||
#if MICROPY_FATFS_OO
|
||||
typedef void *bdev_t;
|
||||
STATIC fs_user_mount_t *disk_get_device(void *bdev) {
|
||||
return (fs_user_mount_t*)bdev;
|
||||
}
|
||||
#else
|
||||
typedef BYTE bdev_t;
|
||||
STATIC fs_user_mount_t *disk_get_device(uint id) {
|
||||
if (id < MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount))) {
|
||||
return MP_STATE_PORT(fs_user_mount)[id];
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Initialize a Drive */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if MICROPY_FATFS_OO
|
||||
STATIC
|
||||
#endif
|
||||
DSTATUS disk_initialize (
|
||||
bdev_t pdrv /* Physical drive nmuber (0..) */
|
||||
)
|
||||
@ -105,9 +87,7 @@ DSTATUS disk_initialize (
|
||||
/* Get Disk Status */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if MICROPY_FATFS_OO
|
||||
STATIC
|
||||
#endif
|
||||
DSTATUS disk_status (
|
||||
bdev_t pdrv /* Physical drive nmuber (0..) */
|
||||
)
|
||||
@ -159,7 +139,6 @@ DRESULT disk_read (
|
||||
/* Write Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if MICROPY_FATFS_OO || _USE_WRITE
|
||||
DRESULT disk_write (
|
||||
bdev_t pdrv, /* Physical drive nmuber (0..) */
|
||||
const BYTE *buff, /* Data to be written */
|
||||
@ -191,14 +170,12 @@ DRESULT disk_write (
|
||||
|
||||
return RES_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Miscellaneous Functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if MICROPY_FATFS_OO || _USE_IOCTL
|
||||
DRESULT disk_ioctl (
|
||||
bdev_t pdrv, /* Physical drive nmuber (0..) */
|
||||
BYTE cmd, /* Control code */
|
||||
@ -237,7 +214,7 @@ DRESULT disk_ioctl (
|
||||
} else {
|
||||
*((WORD*)buff) = mp_obj_get_int(ret);
|
||||
}
|
||||
#if MICROPY_FATFS_OO && _MAX_SS != _MIN_SS
|
||||
#if _MAX_SS != _MIN_SS
|
||||
// need to store ssize because we use it in disk_read/disk_write
|
||||
vfs->fatfs.ssize = *((WORD*)buff);
|
||||
#endif
|
||||
@ -248,7 +225,6 @@ DRESULT disk_ioctl (
|
||||
*((DWORD*)buff) = 1; // erase block size in units of sector size
|
||||
return RES_OK;
|
||||
|
||||
#if MICROPY_FATFS_OO
|
||||
case IOCTL_INIT:
|
||||
*((DSTATUS*)buff) = disk_initialize(pdrv);
|
||||
return RES_OK;
|
||||
@ -256,7 +232,6 @@ DRESULT disk_ioctl (
|
||||
case IOCTL_STATUS:
|
||||
*((DSTATUS*)buff) = disk_status(pdrv);
|
||||
return RES_OK;
|
||||
#endif
|
||||
|
||||
default:
|
||||
return RES_PARERR;
|
||||
@ -278,7 +253,7 @@ DRESULT disk_ioctl (
|
||||
|
||||
case GET_SECTOR_SIZE:
|
||||
*((WORD*)buff) = 512; // old protocol had fixed sector size
|
||||
#if MICROPY_FATFS_OO && _MAX_SS != _MIN_SS
|
||||
#if _MAX_SS != _MIN_SS
|
||||
// need to store ssize because we use it in disk_read/disk_write
|
||||
vfs->fatfs.ssize = 512;
|
||||
#endif
|
||||
@ -288,7 +263,6 @@ DRESULT disk_ioctl (
|
||||
*((DWORD*)buff) = 1; // erase block size in units of sector size
|
||||
return RES_OK;
|
||||
|
||||
#if MICROPY_FATFS_OO
|
||||
case IOCTL_INIT:
|
||||
*((DSTATUS*)buff) = disk_initialize(pdrv);
|
||||
return RES_OK;
|
||||
@ -296,13 +270,11 @@ DRESULT disk_ioctl (
|
||||
case IOCTL_STATUS:
|
||||
*((DSTATUS*)buff) = disk_status(pdrv);
|
||||
return RES_OK;
|
||||
#endif
|
||||
|
||||
default:
|
||||
return RES_PARERR;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // MICROPY_VFS
|
||||
|
@ -34,11 +34,7 @@
|
||||
#include "py/runtime.h"
|
||||
#include "py/stream.h"
|
||||
#include "py/mperrno.h"
|
||||
#if MICROPY_FATFS_OO
|
||||
#include "lib/oofatfs/ff.h"
|
||||
#else
|
||||
#include "lib/fatfs/ff.h"
|
||||
#endif
|
||||
#include "extmod/fsusermount.h"
|
||||
#include "extmod/vfs_fat.h"
|
||||
|
||||
@ -115,11 +111,7 @@ STATIC mp_uint_t file_obj_write(mp_obj_t self_in, const void *buf, mp_uint_t siz
|
||||
STATIC mp_obj_t file_obj_close(mp_obj_t self_in) {
|
||||
pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
// if fs==NULL then the file is closed and in that case this method is a no-op
|
||||
#if MICROPY_FATFS_OO
|
||||
if (self->fp.obj.fs != NULL) {
|
||||
#else
|
||||
if (self->fp.fs != NULL) {
|
||||
#endif
|
||||
FRESULT res = f_close(&self->fp);
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
@ -221,13 +213,8 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar
|
||||
o->base.type = type;
|
||||
|
||||
const char *fname = mp_obj_str_get_str(args[0].u_obj);
|
||||
#if MICROPY_FATFS_OO
|
||||
assert(vfs != NULL);
|
||||
FRESULT res = f_open(&vfs->fatfs, &o->fp, fname, mode);
|
||||
#else
|
||||
(void)vfs;
|
||||
FRESULT res = f_open(&o->fp, fname, mode);
|
||||
#endif
|
||||
if (res != FR_OK) {
|
||||
m_del_obj(pyb_file_obj_t, o);
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
|
@ -30,19 +30,11 @@
|
||||
#include <string.h>
|
||||
#include "py/nlr.h"
|
||||
#include "py/runtime.h"
|
||||
#if MICROPY_FATFS_OO
|
||||
#include "lib/oofatfs/ff.h"
|
||||
#else
|
||||
#include "lib/fatfs/ff.h"
|
||||
#endif
|
||||
#include "extmod/vfs_fat.h"
|
||||
#include "extmod/fsusermount.h"
|
||||
#include "py/lexer.h"
|
||||
|
||||
#if !MICROPY_FATFS_OO && _USE_LFN
|
||||
STATIC char lfn[_MAX_LFN + 1]; /* Buffer to store the LFN */
|
||||
#endif
|
||||
|
||||
// TODO: actually, the core function should be ilistdir()
|
||||
|
||||
mp_obj_t fat_vfs_listdir(const char *path, bool is_str_type) {
|
||||
@ -53,16 +45,8 @@ mp_obj_t fat_vfs_listdir2(fs_user_mount_t *vfs, const char *path, bool is_str_ty
|
||||
FRESULT res;
|
||||
FILINFO fno;
|
||||
FF_DIR dir;
|
||||
#if !MICROPY_FATFS_OO && _USE_LFN
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = sizeof lfn;
|
||||
#endif
|
||||
|
||||
#if MICROPY_FATFS_OO
|
||||
res = f_opendir(&vfs->fatfs, &dir, path);
|
||||
#else
|
||||
res = f_opendir(&dir, path); /* Open the directory */
|
||||
#endif
|
||||
if (res != FR_OK) {
|
||||
mp_raise_OSError(fresult_to_errno_table[res]);
|
||||
}
|
||||
@ -75,11 +59,7 @@ mp_obj_t fat_vfs_listdir2(fs_user_mount_t *vfs, const char *path, bool is_str_ty
|
||||
if (fno.fname[0] == '.' && fno.fname[1] == 0) continue; /* Ignore . entry */
|
||||
if (fno.fname[0] == '.' && fno.fname[1] == '.' && fno.fname[2] == 0) continue; /* Ignore .. entry */
|
||||
|
||||
#if !MICROPY_FATFS_OO && _USE_LFN
|
||||
char *fn = *fno.lfname ? fno.lfname : fno.fname;
|
||||
#else
|
||||
char *fn = fno.fname;
|
||||
#endif
|
||||
|
||||
/*
|
||||
if (fno.fattrib & AM_DIR) {
|
||||
@ -108,17 +88,8 @@ mp_obj_t fat_vfs_listdir2(fs_user_mount_t *vfs, const char *path, bool is_str_ty
|
||||
|
||||
mp_import_stat_t fat_vfs_import_stat(fs_user_mount_t *vfs, const char *path) {
|
||||
FILINFO fno;
|
||||
#if !MICROPY_FATFS_OO && _USE_LFN
|
||||
fno.lfname = NULL;
|
||||
fno.lfsize = 0;
|
||||
#endif
|
||||
#if MICROPY_FATFS_OO
|
||||
assert(vfs != NULL);
|
||||
FRESULT res = f_stat(&vfs->fatfs, path, &fno);
|
||||
#else
|
||||
(void)vfs;
|
||||
FRESULT res = f_stat(path, &fno);
|
||||
#endif
|
||||
if (res == FR_OK) {
|
||||
if ((fno.fattrib & AM_DIR) != 0) {
|
||||
return MP_IMPORT_STAT_DIR;
|
||||
|
@ -135,7 +135,6 @@
|
||||
#endif
|
||||
|
||||
// fatfs configuration used in ffconf.h
|
||||
#define MICROPY_FATFS_OO (1)
|
||||
#define MICROPY_FATFS_ENABLE_LFN (1)
|
||||
#define MICROPY_FATFS_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
|
||||
#define MICROPY_FATFS_USE_LABEL (1)
|
||||
|
@ -131,7 +131,6 @@
|
||||
#define MICROPY_MACHINE_MEM_GET_READ_ADDR mod_machine_mem_get_addr
|
||||
#define MICROPY_MACHINE_MEM_GET_WRITE_ADDR mod_machine_mem_get_addr
|
||||
|
||||
#define MICROPY_FATFS_OO (1)
|
||||
#define MICROPY_FATFS_ENABLE_LFN (1)
|
||||
#define MICROPY_FATFS_RPATH (2)
|
||||
#define MICROPY_FATFS_MAX_SS (4096)
|
||||
|
Loading…
x
Reference in New Issue
Block a user