There doesn't seem to be a single way of figuring out flash size of an ESP8266 module. Aside from the filesystem related, programmatic way of figuring out how much memory is currently free, it would be useful to have the means of getting the total size before the firmware is even flashed, or perhaps as a part of modesp as well, but I don't see the need for it. For example to avoid warning users about 1MB minimum flash size and let makefile/esptool.py handle this before attempting to flash the build that would cause problems.
I wanted to take a chance and sum up how to determine your flash size manually. With your ESP in bootloader mode, use the esptool.py that comes with the
pfalcon/esp-open-sdk (change the port accordingly):
Code: Select all
esptool.py --port /dev/ttyUSB0 flash_id
Connecting...
this will give the manufacturer and device IDs:
The same manufacturer/device ID combo can be obtained by running:
Code: Select all
import esp
hex(esp.flash_id())
'0x1640c8' # note that it's backwards
What I found so far, is a header file with flash chip manufacturers and devices they produced mapped to part numbers,
can be pulled from here. Searching through this I see lines:
Code: Select all
#define GIGADEVICE_ID 0xC8 /* GigaDevice */
#define GIGADEVICE_GD25Q32 0x4016 /* Same as GD25Q32B */
Googling the part number takes me to
a page that describes the naming convention of this device, which indicates that the last two digits decode to device density: 32 = 32Mbit = 4MB of flash. This is incredibly convoluted and I hope there will be a way of doing this without depending on 2 external sources. But in the meantime I wanted to share my findings with others and perhaps hear suggestions on how can this be tackled.