Skip to content

Commit 7e9d42d

Browse files
PA4WDMartijn Scheepers
and
Martijn Scheepers
authored
ESP.getChipModel() and ESP.getChipCores() (espressif#3847)
* ESP.getChipModel() returns model of the chip * ESP.getChipCores() returns the core count. * Example gives chip model, revision and core count. * Read efuse for chipmodel Co-authored-by: Martijn Scheepers <ms@SDNengineering.nl>
1 parent e34e0b4 commit 7e9d42d

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

Diff for: cores/esp32/Esp.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,33 @@ uint8_t EspClass::getChipRevision(void)
218218
return chip_info.revision;
219219
}
220220

221+
const char * EspClass::getChipModel(void)
222+
{
223+
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
224+
uint32_t pkg_ver = chip_ver & 0x7;
225+
switch (pkg_ver) {
226+
case EFUSE_RD_CHIP_VER_PKG_ESP32D0WDQ6 :
227+
return "ESP32-D0WDQ6";
228+
case EFUSE_RD_CHIP_VER_PKG_ESP32D0WDQ5 :
229+
return "ESP32-D0WDQ5";
230+
case EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 :
231+
return "ESP32-D2WDQ5";
232+
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 :
233+
return "ESP32-PICO-D2";
234+
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4 :
235+
return "ESP32-PICO-D4";
236+
default:
237+
return "Unknown";
238+
}
239+
}
240+
241+
uint8_t EspClass::getChipCores(void)
242+
{
243+
esp_chip_info_t chip_info;
244+
esp_chip_info(&chip_info);
245+
return chip_info.cores;
246+
}
247+
221248
const char * EspClass::getSdkVersion(void)
222249
{
223250
return esp_get_idf_version();

Diff for: cores/esp32/Esp.h

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class EspClass
7575
uint32_t getMaxAllocPsram();
7676

7777
uint8_t getChipRevision();
78+
const char * getChipModel();
79+
uint8_t getChipCores();
7880
uint32_t getCpuFreqMHz(){ return getCpuFrequencyMhz(); }
7981
inline uint32_t getCycleCount() __attribute__((always_inline));
8082
const char * getSdkVersion();

Diff for: libraries/ESP32/examples/ChipID/GetChipID/GetChipID.ino

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ void loop() {
99
Serial.printf("ESP32 Chip ID = %04X",(uint16_t)(chipid>>32));//print High 2 bytes
1010
Serial.printf("%08X\n",(uint32_t)chipid);//print Low 4bytes.
1111

12+
Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());
13+
Serial.printf("This chip has %d cores\n", ESP.getChipCores());
14+
1215
delay(3000);
1316

1417
}

0 commit comments

Comments
 (0)