mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
commit
be74265c82
@ -23,9 +23,12 @@
|
||||
*/
|
||||
|
||||
#include "FS.h"
|
||||
#undef max
|
||||
#undef min
|
||||
#include "FSImpl.h"
|
||||
#include "spiffs/spiffs.h"
|
||||
#include "debug.h"
|
||||
#include <limits>
|
||||
|
||||
extern "C" {
|
||||
#include "c_types.h"
|
||||
@ -119,6 +122,27 @@ protected:
|
||||
config.log_block_size = _blockSize;
|
||||
config.log_page_size = _pageSize;
|
||||
|
||||
|
||||
if (((uint32_t) std::numeric_limits<spiffs_block_ix>::max()) < (_size / _blockSize)) {
|
||||
DEBUGV("spiffs_block_ix type too small");
|
||||
abort();
|
||||
}
|
||||
|
||||
if (((uint32_t) std::numeric_limits<spiffs_page_ix>::max()) < (_size / _pageSize)) {
|
||||
DEBUGV("spiffs_page_ix type too small");
|
||||
abort();
|
||||
}
|
||||
|
||||
if (((uint32_t) std::numeric_limits<spiffs_obj_id>::max()) < (2 + (_size / (2*_pageSize))*2)) {
|
||||
DEBUGV("spiffs_obj_id type too small");
|
||||
abort();
|
||||
}
|
||||
|
||||
if (((uint32_t) std::numeric_limits<spiffs_span_ix>::max()) < (_size / _pageSize - 1)) {
|
||||
DEBUGV("spiffs_span_ix type too small");
|
||||
abort();
|
||||
}
|
||||
|
||||
// hack: even though fs is not initialized at this point,
|
||||
// SPIFFS_buffer_bytes_for_cache uses only fs->config.log_page_size
|
||||
// suggestion: change SPIFFS_buffer_bytes_for_cache to take
|
||||
@ -381,8 +405,8 @@ extern "C" uint32_t _SPIFFS_page;
|
||||
extern "C" uint32_t _SPIFFS_block;
|
||||
|
||||
static SPIFFSImpl s_defaultFs(
|
||||
(uint32_t) &_SPIFFS_start - 0x40200000,
|
||||
(uint32_t) (&_SPIFFS_end - &_SPIFFS_start),
|
||||
(uint32_t) (&_SPIFFS_start) - 0x40200000,
|
||||
(uint32_t) (&_SPIFFS_end) - (uint32_t) (&_SPIFFS_start),
|
||||
(uint32_t) &_SPIFFS_page,
|
||||
(uint32_t) &_SPIFFS_block,
|
||||
5);
|
||||
|
@ -31,18 +31,20 @@ extern "C" {
|
||||
}
|
||||
|
||||
static int spi_flash_read_locked(uint32_t addr, uint32_t* dst, uint32_t size) {
|
||||
InterruptLock lock;
|
||||
optimistic_yield(10000);
|
||||
AutoInterruptLock(5);
|
||||
return spi_flash_read(addr, dst, size);
|
||||
}
|
||||
|
||||
static int spi_flash_write_locked(uint32_t addr, const uint32_t* src, uint32_t size) {
|
||||
InterruptLock lock;
|
||||
optimistic_yield(10000);
|
||||
AutoInterruptLock(5);
|
||||
return spi_flash_write(addr, (uint32_t*) src, size);
|
||||
}
|
||||
|
||||
static int spi_flash_erase_sector_locked(uint32_t sector) {
|
||||
optimistic_yield(10000);
|
||||
InterruptLock lock;
|
||||
AutoInterruptLock(5);
|
||||
return spi_flash_erase_sector(sector);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user