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:
Damien George 2017-01-29 15:26:24 +11:00
parent 95635ade8b
commit 0bd61d23b9
8 changed files with 2 additions and 80 deletions

View File

@ -64,7 +64,6 @@
#define MICROPY_QSTR_BYTES_IN_HASH (1) #define MICROPY_QSTR_BYTES_IN_HASH (1)
// fatfs configuration used in ffconf.h // fatfs configuration used in ffconf.h
#define MICROPY_FATFS_OO (1)
#define MICROPY_FATFS_ENABLE_LFN (2) #define MICROPY_FATFS_ENABLE_LFN (2)
#define MICROPY_FATFS_MAX_LFN (MICROPY_ALLOC_PATH_MAX) #define MICROPY_FATFS_MAX_LFN (MICROPY_ALLOC_PATH_MAX)
#define MICROPY_FATFS_LFN_CODE_PAGE (437) // 1=SFN/ANSI 437=LFN/U.S.(OEM) #define MICROPY_FATFS_LFN_CODE_PAGE (437) // 1=SFN/ANSI 437=LFN/U.S.(OEM)

View File

@ -95,7 +95,6 @@
#define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool #define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool
#define MICROPY_VFS (1) #define MICROPY_VFS (1)
#define MICROPY_FATFS_OO (1)
#define MICROPY_FATFS_ENABLE_LFN (1) #define MICROPY_FATFS_ENABLE_LFN (1)
#define MICROPY_FATFS_RPATH (2) #define MICROPY_FATFS_RPATH (2)
#define MICROPY_FATFS_MAX_SS (4096) #define MICROPY_FATFS_MAX_SS (4096)

View File

@ -32,10 +32,6 @@
#error "with MICROPY_VFS_FAT enabled, must also enable MICROPY_VFS" #error "with MICROPY_VFS_FAT enabled, must also enable MICROPY_VFS"
#endif #endif
#if !MICROPY_FATFS_OO
#error "with MICROPY_VFS_FAT enabled, must also enable MICROPY_FATFS_OO"
#endif
#include <string.h> #include <string.h>
#include "py/nlr.h" #include "py/nlr.h"
#include "py/runtime.h" #include "py/runtime.h"

View File

@ -36,13 +36,8 @@
#include "py/mphal.h" #include "py/mphal.h"
#include "py/runtime.h" #include "py/runtime.h"
#if MICROPY_FATFS_OO
#include "lib/oofatfs/ff.h" #include "lib/oofatfs/ff.h"
#include "lib/oofatfs/diskio.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" #include "extmod/fsusermount.h"
#if _MAX_SS == _MIN_SS #if _MAX_SS == _MIN_SS
@ -51,29 +46,16 @@
#define SECSIZE(fs) ((fs)->ssize) #define SECSIZE(fs) ((fs)->ssize)
#endif #endif
#if MICROPY_FATFS_OO
typedef void *bdev_t; typedef void *bdev_t;
STATIC fs_user_mount_t *disk_get_device(void *bdev) { STATIC fs_user_mount_t *disk_get_device(void *bdev) {
return (fs_user_mount_t*)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 */ /* Initialize a Drive */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
#if MICROPY_FATFS_OO
STATIC STATIC
#endif
DSTATUS disk_initialize ( DSTATUS disk_initialize (
bdev_t pdrv /* Physical drive nmuber (0..) */ bdev_t pdrv /* Physical drive nmuber (0..) */
) )
@ -105,9 +87,7 @@ DSTATUS disk_initialize (
/* Get Disk Status */ /* Get Disk Status */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
#if MICROPY_FATFS_OO
STATIC STATIC
#endif
DSTATUS disk_status ( DSTATUS disk_status (
bdev_t pdrv /* Physical drive nmuber (0..) */ bdev_t pdrv /* Physical drive nmuber (0..) */
) )
@ -159,7 +139,6 @@ DRESULT disk_read (
/* Write Sector(s) */ /* Write Sector(s) */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
#if MICROPY_FATFS_OO || _USE_WRITE
DRESULT disk_write ( DRESULT disk_write (
bdev_t pdrv, /* Physical drive nmuber (0..) */ bdev_t pdrv, /* Physical drive nmuber (0..) */
const BYTE *buff, /* Data to be written */ const BYTE *buff, /* Data to be written */
@ -191,14 +170,12 @@ DRESULT disk_write (
return RES_OK; return RES_OK;
} }
#endif
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Miscellaneous Functions */ /* Miscellaneous Functions */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
#if MICROPY_FATFS_OO || _USE_IOCTL
DRESULT disk_ioctl ( DRESULT disk_ioctl (
bdev_t pdrv, /* Physical drive nmuber (0..) */ bdev_t pdrv, /* Physical drive nmuber (0..) */
BYTE cmd, /* Control code */ BYTE cmd, /* Control code */
@ -237,7 +214,7 @@ DRESULT disk_ioctl (
} else { } else {
*((WORD*)buff) = mp_obj_get_int(ret); *((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 // need to store ssize because we use it in disk_read/disk_write
vfs->fatfs.ssize = *((WORD*)buff); vfs->fatfs.ssize = *((WORD*)buff);
#endif #endif
@ -248,7 +225,6 @@ DRESULT disk_ioctl (
*((DWORD*)buff) = 1; // erase block size in units of sector size *((DWORD*)buff) = 1; // erase block size in units of sector size
return RES_OK; return RES_OK;
#if MICROPY_FATFS_OO
case IOCTL_INIT: case IOCTL_INIT:
*((DSTATUS*)buff) = disk_initialize(pdrv); *((DSTATUS*)buff) = disk_initialize(pdrv);
return RES_OK; return RES_OK;
@ -256,7 +232,6 @@ DRESULT disk_ioctl (
case IOCTL_STATUS: case IOCTL_STATUS:
*((DSTATUS*)buff) = disk_status(pdrv); *((DSTATUS*)buff) = disk_status(pdrv);
return RES_OK; return RES_OK;
#endif
default: default:
return RES_PARERR; return RES_PARERR;
@ -278,7 +253,7 @@ DRESULT disk_ioctl (
case GET_SECTOR_SIZE: case GET_SECTOR_SIZE:
*((WORD*)buff) = 512; // old protocol had fixed 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 // need to store ssize because we use it in disk_read/disk_write
vfs->fatfs.ssize = 512; vfs->fatfs.ssize = 512;
#endif #endif
@ -288,7 +263,6 @@ DRESULT disk_ioctl (
*((DWORD*)buff) = 1; // erase block size in units of sector size *((DWORD*)buff) = 1; // erase block size in units of sector size
return RES_OK; return RES_OK;
#if MICROPY_FATFS_OO
case IOCTL_INIT: case IOCTL_INIT:
*((DSTATUS*)buff) = disk_initialize(pdrv); *((DSTATUS*)buff) = disk_initialize(pdrv);
return RES_OK; return RES_OK;
@ -296,13 +270,11 @@ DRESULT disk_ioctl (
case IOCTL_STATUS: case IOCTL_STATUS:
*((DSTATUS*)buff) = disk_status(pdrv); *((DSTATUS*)buff) = disk_status(pdrv);
return RES_OK; return RES_OK;
#endif
default: default:
return RES_PARERR; return RES_PARERR;
} }
} }
} }
#endif
#endif // MICROPY_VFS #endif // MICROPY_VFS

View File

@ -34,11 +34,7 @@
#include "py/runtime.h" #include "py/runtime.h"
#include "py/stream.h" #include "py/stream.h"
#include "py/mperrno.h" #include "py/mperrno.h"
#if MICROPY_FATFS_OO
#include "lib/oofatfs/ff.h" #include "lib/oofatfs/ff.h"
#else
#include "lib/fatfs/ff.h"
#endif
#include "extmod/fsusermount.h" #include "extmod/fsusermount.h"
#include "extmod/vfs_fat.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) { STATIC mp_obj_t file_obj_close(mp_obj_t self_in) {
pyb_file_obj_t *self = MP_OBJ_TO_PTR(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 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) { if (self->fp.obj.fs != NULL) {
#else
if (self->fp.fs != NULL) {
#endif
FRESULT res = f_close(&self->fp); FRESULT res = f_close(&self->fp);
if (res != FR_OK) { if (res != FR_OK) {
mp_raise_OSError(fresult_to_errno_table[res]); 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; o->base.type = type;
const char *fname = mp_obj_str_get_str(args[0].u_obj); const char *fname = mp_obj_str_get_str(args[0].u_obj);
#if MICROPY_FATFS_OO
assert(vfs != NULL); assert(vfs != NULL);
FRESULT res = f_open(&vfs->fatfs, &o->fp, fname, mode); 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) { if (res != FR_OK) {
m_del_obj(pyb_file_obj_t, o); m_del_obj(pyb_file_obj_t, o);
mp_raise_OSError(fresult_to_errno_table[res]); mp_raise_OSError(fresult_to_errno_table[res]);

View File

@ -30,19 +30,11 @@
#include <string.h> #include <string.h>
#include "py/nlr.h" #include "py/nlr.h"
#include "py/runtime.h" #include "py/runtime.h"
#if MICROPY_FATFS_OO
#include "lib/oofatfs/ff.h" #include "lib/oofatfs/ff.h"
#else
#include "lib/fatfs/ff.h"
#endif
#include "extmod/vfs_fat.h" #include "extmod/vfs_fat.h"
#include "extmod/fsusermount.h" #include "extmod/fsusermount.h"
#include "py/lexer.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() // TODO: actually, the core function should be ilistdir()
mp_obj_t fat_vfs_listdir(const char *path, bool is_str_type) { 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; FRESULT res;
FILINFO fno; FILINFO fno;
FF_DIR dir; 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); res = f_opendir(&vfs->fatfs, &dir, path);
#else
res = f_opendir(&dir, path); /* Open the directory */
#endif
if (res != FR_OK) { if (res != FR_OK) {
mp_raise_OSError(fresult_to_errno_table[res]); 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] == 0) continue; /* Ignore . entry */
if (fno.fname[0] == '.' && fno.fname[1] == '.' && fno.fname[2] == 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; char *fn = fno.fname;
#endif
/* /*
if (fno.fattrib & AM_DIR) { 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) { mp_import_stat_t fat_vfs_import_stat(fs_user_mount_t *vfs, const char *path) {
FILINFO fno; FILINFO fno;
#if !MICROPY_FATFS_OO && _USE_LFN
fno.lfname = NULL;
fno.lfsize = 0;
#endif
#if MICROPY_FATFS_OO
assert(vfs != NULL); assert(vfs != NULL);
FRESULT res = f_stat(&vfs->fatfs, path, &fno); FRESULT res = f_stat(&vfs->fatfs, path, &fno);
#else
(void)vfs;
FRESULT res = f_stat(path, &fno);
#endif
if (res == FR_OK) { if (res == FR_OK) {
if ((fno.fattrib & AM_DIR) != 0) { if ((fno.fattrib & AM_DIR) != 0) {
return MP_IMPORT_STAT_DIR; return MP_IMPORT_STAT_DIR;

View File

@ -135,7 +135,6 @@
#endif #endif
// fatfs configuration used in ffconf.h // fatfs configuration used in ffconf.h
#define MICROPY_FATFS_OO (1)
#define MICROPY_FATFS_ENABLE_LFN (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_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
#define MICROPY_FATFS_USE_LABEL (1) #define MICROPY_FATFS_USE_LABEL (1)

View File

@ -131,7 +131,6 @@
#define MICROPY_MACHINE_MEM_GET_READ_ADDR mod_machine_mem_get_addr #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_MACHINE_MEM_GET_WRITE_ADDR mod_machine_mem_get_addr
#define MICROPY_FATFS_OO (1)
#define MICROPY_FATFS_ENABLE_LFN (1) #define MICROPY_FATFS_ENABLE_LFN (1)
#define MICROPY_FATFS_RPATH (2) #define MICROPY_FATFS_RPATH (2)
#define MICROPY_FATFS_MAX_SS (4096) #define MICROPY_FATFS_MAX_SS (4096)