mirror of
https://github.com/pellepl/spiffs.git
synced 2025-05-17 15:26:18 +08:00
renaming, minor changes
This commit is contained in:
10
README
10
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.
|
||||
|
@ -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;
|
||||
|
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -1,31 +1,6 @@
|
||||
/*
|
||||
============================================================================
|
||||
Name : spiffs_test_.c
|
||||
Author :
|
||||
Version :
|
||||
Copyright : Your copyright notice
|
||||
Description : Hello World in C, Ansi-style
|
||||
============================================================================
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "stypes.h"
|
||||
#include "spiffs.h"
|
||||
#include "spiffs_nucleus.h"
|
||||
|
||||
#include "testrunner.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void) {
|
||||
run_tests();
|
||||
return EXIT_SUCCESS;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -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_ */
|
@ -10,7 +10,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "stypes.h"
|
||||
#include "params_test.h"
|
||||
#include "spiffs.h"
|
||||
#include "spiffs_nucleus.h"
|
||||
|
||||
@ -24,14 +24,7 @@
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user