Skip to content

esp8266: Making esp.flash_id() more useful #1336

@owens-bill

Description

@owens-bill

The esp8266 port exposes the SDK function that reads out the ID of the SPI flash module; it produces a result like this:

>>> esp.flash_id()
1261768

Unfortunately, that's not terribly helpful because it isn't the representation of the ID that people actually use. To get that we can use esptool:

./esptool.py -p /dev/tty.usbserial flash_id
Connecting...
Manufacturer: c8
Device: 4013

Or the code for the flash_id method could be enhanced to do some simple parsing and spit out the same thing. The question I have is whether this is useful. The different ESP8266 modules do have different sized flash, and it might be handy to know how big they are, but this result doesn't directly tell you that; instead, you have to search for the result, or know that you can go grab a big file of flash IDs (http://code.coreboot.org/svn/flashrom/trunk/flashchips.h) and grep through it, and then look up the manufacturer's datasheet. We could work around that by building in a table of the most-commonly-used SPI flash modules, but I could see that getting out of hand pretty quickly!

It would be nicer to have an SDK function that simply told you how big the flash is. There is a new SDK function in 1.1.0 called system_get_flash_size_map but it seems to report what was configured when the software was linked, not what is actually on the board. I added a simple wrapper for it and tested on modules with 512 KB, 2 MB and 4 MB, and it always reported map 0, which is 512 KB. Assuming I wrote the wrapper correctly, that is not helpful ;)

So the questions are these, IMO:

  • Is it useful to be able to retrieve the flash ROM size from within MicroPython, or will people just look up the spec sheet or use esptool?
  • Is the current flash_id method sufficient?
  • If not, should it parse the answer to display the manufacturer and device codes?
  • Or should it have a lookup table of known flash chips, so it can also report the size?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions