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

User avatar
By draco
#14825
Code: Select all// we need to include these to be able to use the spi_flash_get_id() function
extern "C" {
#include "c_types.h"
#include "ets_sys.h"
#include "os_type.h"
#include "osapi.h"
#include "spi_flash.h"
}

size_t fs_size() { // returns the flash chip's size, in BYTES
  uint32_t id = spi_flash_get_id(); 
  uint8_t mfgr_id = id & 0xff;
  uint8_t type_id = (id >> 8) & 0xff; // not relevant for size calculation
  uint8_t size_id = (id >> 16) & 0xff; // lucky for us, WinBond ID's their chips as a form that lets us calculate the size
  if(mfgr_id != 0xEF) // 0xEF is WinBond; that's all we care about (for now)
    return 0;
  return 1 << size_id;
}


On my ESP-12, this returns 4194304 bytes, which is 4 megabytes.
User avatar
By dkdileep
#21852 EspressIf flash download tool v1.2 shows the installed flash size. I guess it uses the same logic as yours. Connect the board to USB, set to flash mode and the program detects the chip, flash size and clock speed.
User avatar
By jjorsett
#29815 In a NodeMCU unit, if you have a terminal session running you can manually get the flash size with the following:

> majorVer, minorVer, devVer, chipid, flashid, flashsize, flashmode, flashspeed = node.info();
> print(flashsize)
4096 -- This is what my Adafruit Huzzah running NodeMCU 0.9.5 returned
User avatar
By kolban
#31787 Using esptool to read the flash_id information, I find that my NodeMCU dev kit returns:

Manufacturer: e0
Device: 4016

I am not sure how to interpret this. I am thinking that based on the manufacturer, the device code can then be looked up ... but where would one find a list of codes for decoding purposes?