Skip to content

Commit 81d038f

Browse files
ficetoficeto
ficeto
authored and
ficeto
committed
add method to get the actual size of the flash
1 parent 469427c commit 81d038f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

hardware/esp8266com/esp8266/cores/esp8266/Esp.cpp

+5
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;

hardware/esp8266com/esp8266/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);

0 commit comments

Comments
 (0)