Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By ToSa
#14553 Is there an easy way to determine the size of the flash chip used on a module via software? It appears that ESP-12 modules are shipped with different flash sizes. Is there a way to get the size of the flash chip installed via software (without opening the metal housing to read the chip model)?
As far as I can tell the SDK functions just provide back what's stored initially which is essentially defined in the makefile - hence if I define 512kB (4Mbit) in the makefile everything works fine no matter if the actual chip is way bigger but probably the SDK calls to determine flash size will return 512kB no matter what the real size is.
One option (last resort) could be to write a program that just tries write to the flash and then reads from the same address... (starting with 128M and then going down).
User avatar
By draco
#14598 I wrote a simple Arduino function to determine what size flash is onboard. I don't have the code on this computer, unfortunately, but I will try to post it tomorrow.

Essentially, I am using the flash chip's ID to tell how big it is. The flash ID is a 24 bit number, with the final 8 bits correlating to the manufacturer... Which should be WinBond. The next 8 bits correlate to the size of the module.
User avatar
By ToSa
#14601 Thanks!

As I didn't want tot flash nodemcu just to determine the flash size I ended up looking at their code and realized it's all available in spi_flash.h in the SDK (not the size directly but the manufacturer/device ID):

uint32 spi_flash_get_id(void);

The first ESP-12 I checked actually has a Winbond W25Q32BV - not 512kB but 4MB :)