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

ullixesp
Posts: 83
Joined: Wed Oct 16, 2019 9:34 am
Location: Germany

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

Postby ullixesp » Fri Jul 09, 2021 10:36 am

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.

lbernstone
Posts: 827
Joined: Mon Jul 22, 2019 3:20 pm

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

Postby lbernstone » Fri Jul 09, 2021 1:49 pm

Code: Select all

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

ullixesp
Posts: 83
Joined: Wed Oct 16, 2019 9:34 am
Location: Germany

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

Postby ullixesp » Fri Jul 09, 2021 5:06 pm

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?

lbernstone
Posts: 827
Joined: Mon Jul 22, 2019 3:20 pm

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

Postby lbernstone » Sat Jul 10, 2021 12:38 am

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);

ullixesp
Posts: 83
Joined: Wed Oct 16, 2019 9:34 am
Location: Germany

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

Postby ullixesp » Sat Jul 10, 2021 7:39 am

Yes, this does work. Many thanks!

Who is online

Users browsing this forum: Baidu [Spider] and 74 guests