diff --git a/README b/README index fb7a746..fff2d06 100644 --- a/README +++ b/README @@ -25,11 +25,13 @@ Spiffs is designed with following characteristics in mind: ** Features What spiffs does: - - Spiffs presents a posix-like api: open, close, read, write, seek, stat, etc + - Posix-like api: open, close, read, write, seek, stat, etc + - It can be run on any NOR flash, not only SPI flash - theoretically also on + embedded flash of an microprocessor - Multiple spiffs configurations can be run on same target - and even on same SPI flash device - - It implements static wear leveling - - It has built in file system consistency checks + - Implements static wear leveling + - Built in file system consistency checks What spiffs does not: - Presently, spiffs does not support directories. It produces a flat @@ -38,7 +40,7 @@ What spiffs does not: - It is not a realtime stack. One write operation might take much longer than another. - Poor scalability. Spiffs is intended for small memory devices - the normal - sizes for SPI flashes. + sizes for SPI flashes. Going beyond ~128MB is probably a bad idea. - Presently, it does not detect or handle bad blocks. For integration, see the docs/INTEGRATION file. diff --git a/docs/INTEGRATION b/docs/INTEGRATION index b3c60aa..a188a2e 100644 --- a/docs/INTEGRATION +++ b/docs/INTEGRATION @@ -119,8 +119,9 @@ you point out these files in your make script for compilation. Also copy the spiffs_config.h over from the default/ folder. -Build fails, nagging about inclusions and u32_t and whatnot. Open the -spiffs_config.h and delete the bad inclusions. Also, add following typedefs: +Try buliding. This fails, nagging about inclusions and u32_t and whatnot. Open +the spiffs_config.h and delete the bad inclusions. Also, add following +typedefs: typedef signed int s32_t; typedef unsigned int u32_t; @@ -129,7 +130,7 @@ spiffs_config.h and delete the bad inclusions. Also, add following typedefs: typedef signed char s8_t; typedef unsigned char u8_t; -Now it should builds. Over to the mounting business. Assume you already +Now it should build. Over to the mounting business. Assume you already implemented the read, write and erase functions to your SPI flash: void my_spi_read(int addr, int size, char *buf) @@ -156,9 +157,9 @@ Now, write the my_spiffs_mount function: spiffs_config cfg; cfg.phys_size = 2*1024*1024; // use all spi flash cfg.phys_addr = 0; // start spiffs at start of spi flash - cfg.phys_erase_block = 65536; // well, this is what the datasheet says - cfg.log_block_size = 65536; // seems sensible - cfg.log_block_size = LOG_PAGE_SIZE; // seems sensible + cfg.phys_erase_block = 65536; // according to datasheet + cfg.log_block_size = 65536; // let us not complicate things + cfg.log_block_size = LOG_PAGE_SIZE; // as we said cfg.hal_read_f = my_spi_read; cfg.hal_write_f = my_spi_write; diff --git a/src/default/spiffs_config.h b/src/default/spiffs_config.h index 44a2ea6..93e2ed4 100644 --- a/src/default/spiffs_config.h +++ b/src/default/spiffs_config.h @@ -10,7 +10,7 @@ // following includes are for the linux test build of spiffs // this may/should/must be removed/altered/replaced in your target -#include "stypes.h" +#include "params_test.h" #include #include #include diff --git a/src/test/main.c b/src/test/main.c index d4ff4e5..05feae4 100644 --- a/src/test/main.c +++ b/src/test/main.c @@ -1,31 +1,6 @@ -/* - ============================================================================ - Name : spiffs_test_.c - Author : - Version : - Copyright : Your copyright notice - Description : Hello World in C, Ansi-style - ============================================================================ - */ - -#include -#include -#include - -#include "stypes.h" -#include "spiffs.h" -#include "spiffs_nucleus.h" - #include "testrunner.h" -#include -#include -#include -#include -#include - int main(void) { run_tests(); - return EXIT_SUCCESS; + return 1; } - diff --git a/src/test/stypes.h b/src/test/params_test.h similarity index 68% rename from src/test/stypes.h rename to src/test/params_test.h index f3656d8..5a9ac36 100644 --- a/src/test/stypes.h +++ b/src/test/params_test.h @@ -1,14 +1,17 @@ /* - * stypes.h + * params_test.h * * Created on: May 26, 2013 * Author: petera */ -#ifndef STYPES_H_ -#define STYPES_H_ +#ifndef PARAMS_TEST_H_ +#define PARAMS_TEST_H_ -#define print(...) printf(__VA_ARGS__) +#define FLASH_SIZE 2*1024*1024 +#define SECTOR_SIZE 65536 +#define LOG_BLOCK 65536 +#define LOG_PAGE 256 #define ASSERT(c, m) real_assert((c),(m), __FILE__, __LINE__); @@ -25,4 +28,4 @@ typedef signed char s8_t; typedef unsigned char u8_t; -#endif /* STYPES_H_ */ +#endif /* PARAMS_TEST_H_ */ diff --git a/src/test/test_spiffs.c b/src/test/test_spiffs.c index e159230..cbfac27 100644 --- a/src/test/test_spiffs.c +++ b/src/test/test_spiffs.c @@ -10,7 +10,7 @@ #include #include -#include "stypes.h" +#include "params_test.h" #include "spiffs.h" #include "spiffs_nucleus.h" @@ -24,14 +24,7 @@ #include #include - - -#define SECTOR_SIZE 65536 //(0x10000) -#define PAGE_SIZE 256 //256 -#define LOG_BLOCK 1*65536 -#define LOG_PAGE 1*PAGE_SIZE - -static unsigned char area[2*1024*1024]; +static unsigned char area[FLASH_SIZE]; static int erases[sizeof(area)/SECTOR_SIZE]; static char _path[256]; @@ -39,7 +32,7 @@ static char _path[256]; spiffs __fs; static u8_t _work[LOG_PAGE*2]; static u8_t _fds[256+256/2]; -static u8_t _cache[LOG_PAGE*5]; +static u8_t _cache[(LOG_PAGE+32)*4]; static int check_valid_flash = 1; @@ -75,10 +68,10 @@ static s32_t _write(u32_t addr, u32_t size, u8_t *src) { int i; //printf("wr %08x %i\n", addr, size); for (i = 0; i < size; i++) { - if (((addr + i) & (PAGE_SIZE-1)) != offsetof(spiffs_page_header, flags)) { + if (((addr + i) & (LOG_PAGE-1)) != offsetof(spiffs_page_header, flags)) { if (check_valid_flash && ((area[addr + i] ^ src[i]) & src[i])) { printf("trying to write %02x to %02x at addr %08x\n", src[i], area[addr + i], addr+i); - spiffs_page_ix pix = (addr + i) / PAGE_SIZE; + spiffs_page_ix pix = (addr + i) / LOG_PAGE; dump_page(&__fs, pix); return -1; }