Skip to content

Commit c1c8c99

Browse files
committed
Merge pull request #266 from ficeto/esp8266
fix buffer and block size
2 parents 7073d71 + 8000f27 commit c1c8c99

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

cores/esp8266/Esp.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ uint32_t EspClass::getFlashChipId(void)
158158
return spi_flash_get_id();
159159
}
160160

161+
uint32_t EspClass::getFlashChipRealSize(void)
162+
{
163+
return (1 << ((spi_flash_get_id() >> 16) & 0xFF));
164+
}
165+
161166
uint32_t EspClass::getFlashChipSize(void)
162167
{
163168
uint32_t data;
@@ -175,6 +180,12 @@ uint32_t EspClass::getFlashChipSize(void)
175180
return (2_MB);
176181
case 0x4: // 32 MBit (4MB)
177182
return (4_MB);
183+
case 0x5: // 64 MBit (8MB)
184+
return (8_MB);
185+
case 0x6: // 128 MBit (16MB)
186+
return (16_MB);
187+
case 0x7: // 256 MBit (32MB)
188+
return (32_MB);
178189
default: // fail?
179190
return 0;
180191
}

cores/esp8266/Esp.h

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class EspClass {
9090
uint8_t getCpuFreqMHz(void);
9191

9292
uint32_t getFlashChipId(void);
93+
//gets the actual chip size based on the flash id
94+
uint32_t getFlashChipRealSize(void);
95+
//gets the size of the flash as set by the compiler
9396
uint32_t getFlashChipSize(void);
9497
uint32_t getFlashChipSpeed(void);
9598
FlashMode_t getFlashChipMode(void);

cores/esp8266/FileSystem.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "spiffs/spiffs_esp8266.h"
2424

2525
#define LOGICAL_PAGE_SIZE 256
26-
#define LOGICAL_BLOCK_SIZE 512
26+
#define LOGICAL_BLOCK_SIZE (INTERNAL_FLASH_SECTOR_SIZE * 1)
2727

2828

2929
// These addresses are defined in the linker script.
@@ -64,7 +64,7 @@ int FSClass::_mountInternal(){
6464

6565
SPIFFS_API_DBG_V("FSClass::_mountInternal: start:%x, size:%d Kb\n", cfg.phys_addr, cfg.phys_size / 1024);
6666

67-
_work.reset(new uint8_t[LOGICAL_BLOCK_SIZE]);
67+
_work.reset(new uint8_t[2*LOGICAL_PAGE_SIZE]);
6868
_fdsSize = 32 * _maxOpenFiles;
6969
_fds.reset(new uint8_t[_fdsSize]);
7070
_cacheSize = (32 + LOGICAL_PAGE_SIZE) * _maxOpenFiles;

0 commit comments

Comments
 (0)