22
22
#include " Arduino.h"
23
23
#include " spiffs/spiffs_esp8266.h"
24
24
25
- #define LOGICAL_PAGE_SIZE 256
26
- #define LOGICAL_BLOCK_SIZE (INTERNAL_FLASH_SECTOR_SIZE * 1 )
27
-
28
-
29
- // These addresses are defined in the linker script.
25
+ // These addresses and sizes are defined in the linker script.
30
26
// For each flash memory size there is a linker script variant
31
27
// which sets spiffs location and size.
32
28
extern " C" uint32_t _SPIFFS_start;
33
29
extern " C" uint32_t _SPIFFS_end;
30
+ extern " C" uint32_t _SPIFFS_page;
31
+ extern " C" uint32_t _SPIFFS_block;
34
32
35
33
static s32_t api_spiffs_read (u32_t addr, u32_t size, u8_t *dst);
36
34
static s32_t api_spiffs_write (u32_t addr, u32_t size, u8_t *src);
@@ -51,23 +49,25 @@ int FSClass::_mountInternal(){
51
49
SPIFFS_API_DBG_E (" Can't start file system, wrong address\r\n " );
52
50
return SPIFFS_ERR_NOT_CONFIGURED;
53
51
}
52
+ if (_SPIFFS_page == 0 ) _SPIFFS_page = 256 ;
53
+ if (_SPIFFS_block == 0 ) _SPIFFS_block = 4096 ;
54
54
55
55
spiffs_config cfg = {0 };
56
56
cfg.phys_addr = _beginAddress;
57
57
cfg.phys_size = _endAddress - _beginAddress;
58
58
cfg.phys_erase_block = INTERNAL_FLASH_SECTOR_SIZE;
59
- cfg.log_block_size = LOGICAL_BLOCK_SIZE ;
60
- cfg.log_page_size = LOGICAL_PAGE_SIZE ;
59
+ cfg.log_block_size = _SPIFFS_block ;
60
+ cfg.log_page_size = _SPIFFS_page ;
61
61
cfg.hal_read_f = api_spiffs_read;
62
62
cfg.hal_write_f = api_spiffs_write;
63
63
cfg.hal_erase_f = api_spiffs_erase;
64
64
65
65
SPIFFS_API_DBG_V (" FSClass::_mountInternal: start:%x, size:%d Kb\n " , cfg.phys_addr , cfg.phys_size / 1024 );
66
66
67
- _work.reset (new uint8_t [2 *LOGICAL_PAGE_SIZE ]);
67
+ _work.reset (new uint8_t [2 *_SPIFFS_page ]);
68
68
_fdsSize = 32 * _maxOpenFiles;
69
69
_fds.reset (new uint8_t [_fdsSize]);
70
- _cacheSize = (32 + LOGICAL_PAGE_SIZE ) * _maxOpenFiles;
70
+ _cacheSize = (32 + _SPIFFS_page ) * _maxOpenFiles;
71
71
_cache.reset (new uint8_t [_cacheSize]);
72
72
73
73
s32_t res = SPIFFS_mount (&_fs,
0 commit comments