Page 1 of 1

Does ESP32 have code to read-out manufacturer of Flash?

Posted: Fri Jul 09, 2021 10:36 am
by ullixesp
I am having trouble with reading flash memory, which seems to be rather specific to a certain Flash manufacturer viewtopic.php?f=19&t=21733

I know to readout flash manufacturer with esptool.py:

Code: Select all

esptool.py flash_id
The result is e.g.:

Code: Select all

Manufacturer: 20
Device: 4016
Detected flash size: 4MB
Are there functions in ESP code - preferably accessible in the Arduino-Framwork - which return the same info? My search came up empty.

Re: Does ESP32 have code to read-out manufacturer of Flash?

Posted: Fri Jul 09, 2021 1:49 pm
by lbernstone

Code: Select all

  #include <esp_flash.h>
  uint32_t chipid;
  esp_flash_read_id(NULL, &chipid);
  Serial.printf("chipid: %6x", chipid);

Re: Does ESP32 have code to read-out manufacturer of Flash?

Posted: Fri Jul 09, 2021 5:06 pm
by ullixesp
Thanks, but looking into both the PlatformIO and Arduino folders, the code fails here:

- include fails because the file `esp_flash.h` doesn't exist,
- searching over all files for function `esp_flash_read_id()` comes back empty

What to do?

Re: Does ESP32 have code to read-out manufacturer of Flash?

Posted: Sat Jul 10, 2021 12:38 am
by lbernstone

Code: Select all

  #include <rom/spi_flash.h>
  Serial.begin(115200);
  uint32_t chipid = g_rom_flashchip.device_id;
  Serial.printf("chipid: %6x\n", chipid);

Re: Does ESP32 have code to read-out manufacturer of Flash?

Posted: Sat Jul 10, 2021 7:39 am
by ullixesp
Yes, this does work. Many thanks!