ESP8266: Flash chip information functions

The objective of this post is to explain how to get some information about the flash chip of an ESP8266 board, using the Arduino IDE libraries functions.


Introduction

The objective of this post is to explain how to get some information about the flash chip of an ESP8266 board, using the Arduino IDE libraries functions. To do so, we will use the methods available here, which are exposed in a class called EspClass.

As we can see in the header file for the class, these are ESP8266 specific APIs, which expose some core functionality. Also, we can see in the same file that an extern variable called ESP, of class EspClass, is declared, so we can access it in our code.


The code

We are going to do all the coding in our setup function, since we just want to print some information about the Flash chip.

As usual, we start by opening a serial connection, in order to print the output of the methods we are going to call.

First, we will get the flash chip ID. To do so, we call the getFlashChipId method on the ESP object. This will return the chip ID as a uint32_t, which we then can convert to hexadecimal. After the conversion, you can confirm here if yours is in the list defined in the libraries code.

ESP.getFlashChipId();

Next,we will get the flash chip size. To do so, we have two methods available: the getFlashChipRealSize and the getFlashChipSize. The difference is that the first gets the chip size based on its ID, and the second gets the size of the flash based on what the compiler set.

ESP.getFlashChipRealSize();
ESP.getFlashChipSize();

Next, we will get the flash chip speed. To do so, we just need to call the getFlashChipSpeed method.

ESP.getFlashChipSpeed();

Finally, we will call the getFlashChipMode method, to get the mode of the chip. Nevertheless, it’s not clear how to decode this chip mode to understand the meaning.

ESP.getFlashChipMode();

The full source code can be seen bellow

void setup() {

  Serial.begin(115200);
  Serial.println();

  Serial.print("Chip ID: ");
  Serial.println(ESP.getFlashChipId());

  Serial.print("Chip Real Size: ");
  Serial.println(ESP.getFlashChipRealSize());

  Serial.print("Chip Size: ");
  Serial.println(ESP.getFlashChipSize());

  Serial.print("Chip Speed: ");
  Serial.println(ESP.getFlashChipSpeed());

  Serial.print("Chip Mode: ");
  Serial.println(ESP.getFlashChipMode());
}

void loop() {
}


Testing the code

For the tests I’m using a NodeMCU board. After uploading the code and open the serial console, I get the output shown in figure 1. Yours will depend on the board used.

ESP8266 Flash chip information

Figure 1 – Output of the program with information from the flash chip.

If we convert the chip ID to hexadecimal, we will get 1640E0, which would correspond to the BergMicro manufacturer and to the BG25Q32 chip, which has 4 MB [2]. Also, the speed of the device is 40 MHz,


References

[1] https://github.com/esp8266/Arduino/blob/master/cores/esp8266/Esp.h#L117

[2] https://github.com/esp8266/Arduino/blob/master/cores/esp8266/Esp.cpp#L331


Technical details

  • ESP8266 libraries: v2.3.0

1 thought on “ESP8266: Flash chip information functions”

  1. Pingback: ESP8266: MicroPython support | techtutorialsx

  2. Pingback: ESP8266: MicroPython support | techtutorialsx

Leave a Reply