From 49baa7eae405451954cbdf1222425757409f0588 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 12 Oct 2018 18:21:36 +0700 Subject: [PATCH] porting mynewt-nffs --- libraries/FileSystem/src/FileIO.h | 3 --- libraries/FileSystem/src/InternalFS.cpp | 13 +++++++++++++ .../src/mynewt-nffs/include/nffs/config.h | 8 +++++--- .../FileSystem/src/mynewt-nffs/include/nffs/nffs.h | 4 ++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/libraries/FileSystem/src/FileIO.h b/libraries/FileSystem/src/FileIO.h index f78a336a..7d123c5c 100644 --- a/libraries/FileSystem/src/FileIO.h +++ b/libraries/FileSystem/src/FileIO.h @@ -75,9 +75,6 @@ class File: public Stream class FileSystemClass { public: - FileSystemClass (); - virtual ~FileSystemClass (); - virtual bool begin () = 0; // Open the specified file/directory with the supplied mode (e.g. read or diff --git a/libraries/FileSystem/src/InternalFS.cpp b/libraries/FileSystem/src/InternalFS.cpp index d8c2c9b4..4ac4488d 100644 --- a/libraries/FileSystem/src/InternalFS.cpp +++ b/libraries/FileSystem/src/InternalFS.cpp @@ -39,6 +39,19 @@ MynewtNFFS InternalFS; +//--------------------------------------------------------------------+ +// Mynewt NFFS port +//--------------------------------------------------------------------+ +extern "C" +{ +nffs_os_mempool_t nffs_file_pool; +nffs_os_mempool_t nffs_dir_pool; +nffs_os_mempool_t nffs_inode_entry_pool; +nffs_os_mempool_t nffs_block_entry_pool; +nffs_os_mempool_t nffs_cache_inode_pool; +nffs_os_mempool_t nffs_cache_block_pool; +} + MynewtNFFS::MynewtNFFS (void) { diff --git a/libraries/FileSystem/src/mynewt-nffs/include/nffs/config.h b/libraries/FileSystem/src/mynewt-nffs/include/nffs/config.h index f2e1eb82..0623daf5 100644 --- a/libraries/FileSystem/src/mynewt-nffs/include/nffs/config.h +++ b/libraries/FileSystem/src/mynewt-nffs/include/nffs/config.h @@ -20,11 +20,13 @@ #ifndef H_CONFIG_ #define H_CONFIG_ -#if 1 // Adafruit Bluefruit +#ifdef ARDUINO_NRF52_ADAFRUIT + +typedef void* nffs_os_mempool_t; #define NFFS_CONFIG_USE_HEAP 0 -#define CONFIG_NFFS_FILESYSTEM_MAX_AREAS 7 - +#define NFFS_CONFIG_MAX_AREAS 7 +#define NFFS_CONFIG_MAX_BLOCK_SIZE 2048 #elif __ZEPHYR__ diff --git a/libraries/FileSystem/src/mynewt-nffs/include/nffs/nffs.h b/libraries/FileSystem/src/mynewt-nffs/include/nffs/nffs.h index 56c99306..07ffe94c 100644 --- a/libraries/FileSystem/src/mynewt-nffs/include/nffs/nffs.h +++ b/libraries/FileSystem/src/mynewt-nffs/include/nffs/nffs.h @@ -328,7 +328,7 @@ extern void *nffs_dir_mem; extern uint32_t nffs_hash_next_file_id; extern uint32_t nffs_hash_next_dir_id; extern uint32_t nffs_hash_next_block_id; -extern struct nffs_area nffs_areas[CONFIG_NFFS_FILESYSTEM_MAX_AREAS]; +extern struct nffs_area nffs_areas[NFFS_CONFIG_MAX_AREAS]; extern uint8_t nffs_num_areas; extern uint8_t nffs_scratch_area_idx; extern uint16_t nffs_block_max_data_sz; @@ -557,7 +557,7 @@ int nffs_write_to_file(struct nffs_file *file, const void *data, int len); #define NFFS_FLASH_LOC_NONE nffs_flash_loc(NFFS_AREA_ID_NONE, 0) -#if __ZEPHYR__ +#if __ZEPHYR__ || defined(ARDUINO_NRF52_ADAFRUIT) #define NFFS_LOG(lvl, ...) #define MYNEWT_VAL(val) 0