Determine flash size on your module

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Determine flash size on your module

Post by platforma » Thu Apr 14, 2016 11:25 am

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:

Code: Select all

Manufacturer: c8
Device: 4016
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.

User avatar
deshipu
Posts: 1348
Joined: Thu May 28, 2015 5:54 pm

Re: Determine flash size on your module

Post by deshipu » Thu Apr 14, 2016 1:12 pm

Personally, I always just used the Arduino IDE and flashed this example on the board:
https://github.com/esp8266/Arduino/tree ... lashConfig

Then it will print all the relevant information on the serial.

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: Determine flash size on your module

Post by platforma » Thu Apr 14, 2016 2:25 pm

That is of course absolutely fine as well! But I don't have Arduino IDE installed, and setting that up/flashing just to see the flash size seems like a lot of unnecessary work. So having our own way of dealing with this would have been great :)

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Determine flash size on your module

Post by pfalcon » Thu Apr 14, 2016 4:03 pm

MicroPython ESP8266 port (in git master) now includes "port_diag" module to query various diagnostic information about port/board for own review or submitting with bug reports. Use it as:

Code: Select all

import port_diag
It will be extended over time.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

gojimmypi
Posts: 36
Joined: Wed Mar 02, 2016 8:01 pm
Contact:

Re: Determine flash size on your module

Post by gojimmypi » Thu Apr 14, 2016 9:13 pm

platforma wrote:... 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...
interesting. fwiw, my Manufacturer ID (0xe0) was not on that page:

Code: Select all

mylogin@mymachine:~$ ~/workspace/esptool/esptool.py --port /dev/ttyUSB0 flash_id
Connecting...
Manufacturer: e0
Device: 4016
I'm a usingGeekcreit™ Doit NodeMcu Lua ESP8266 ESP-12E WIFI Development Board:
http://www.banggood.com/Geekcreit-Doit- ... 85891.html

Let me know if this is helpful - I have several other types of boards that I could check if you are interested.

User avatar
beic
Posts: 1
Joined: Wed Sep 07, 2016 7:55 pm

Re: Determine flash size on your module

Post by beic » Wed Sep 07, 2016 7:59 pm

Hi there,

Ok, but how can I determine flash size on Windows platform?!

Thank you! ;)

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: Determine flash size on your module

Post by platforma » Fri Sep 09, 2016 1:46 pm

beic wrote:Hi there,

Ok, but how can I determine flash size on Windows platform?!

Thank you! ;)
Same thing, as pfalcon said, import port_diag when connected to your python prompt.

jms
Posts: 108
Joined: Thu May 05, 2016 8:29 pm
Contact:

Re: Determine flash size on your module

Post by jms » Mon Sep 12, 2016 9:00 am

Or use the NodeMCU flashing tool which just works and knows what you have.

User avatar
c.man
Posts: 21
Joined: Thu Jul 06, 2017 9:12 pm

Re: Determine flash size on your module

Post by c.man » Tue Jul 25, 2017 6:57 pm

I bought a "WeMos D1 USB NodeMcu Lua V3 CH340G".
I confirm that this has 4 MB (=32 Mbit) flash size memory.
Is there a NodeMCU with 16 MB flash size memory ?
Did you buy someone?

User avatar
deshipu
Posts: 1348
Joined: Thu May 28, 2015 5:54 pm

Re: Determine flash size on your module

Post by deshipu » Tue Jul 25, 2017 10:55 pm

There is WeMos D1 Mini Pro, which has a 16MB flash chip on it. However, MicroPython still doesn't support that size, and will not make use of all the space.

Post Reply