Skip to content

Commit f92c1b2

Browse files
committed
network_common.cpp: add efuse reading for hwversion and serial number
1 parent ab1e6f2 commit f92c1b2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

SmartEVSE-3/src/network_common.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <ESPmDNS.h>
1111
#include <Update.h>
1212
#include <Preferences.h>
13+
#include "esp_efuse.h"
1314

1415
#include "esp32.h"
1516
#if SMARTEVSE_VERSION >=30
@@ -1483,6 +1484,18 @@ void WiFiSetup(void) {
14831484

14841485
_LOG_A("hwversion %04x serialnr:%u \n",hwversion, serialnr);
14851486
//_LOG_A(ec_public);
1487+
1488+
// SmartEVSE v3.1 has this also stored in efuses
1489+
uint8_t efuse_block1[32];
1490+
uint8_t efuse_hwversion[2];
1491+
uint8_t efuse_serialnr[3];
1492+
esp_efuse_read_block(EFUSE_BLK1, efuse_block1, 0, 32*8);
1493+
esp_efuse_read_block(EFUSE_BLK3, efuse_hwversion, 56, 16);
1494+
esp_efuse_read_block(EFUSE_BLK3, efuse_serialnr, 72, 24);
1495+
1496+
//_LOG_A("Private key: ");
1497+
//for (uint8_t x=0; x<32; x++) _LOG_A_NO_FUNC("%02x",efuse_block1[x]);
1498+
//_LOG_A_NO_FUNC(" hwver: %02x%02x serialnr: %u\n", efuse_hwversion[1], efuse_hwversion[0], efuse_serialnr[0]+(efuse_serialnr[1]<<8));
14861499
} else {
14871500
_LOG_A("No KeyStorage found in nvs!\n");
14881501
if (!serialnr) serialnr = MacId() & 0xffff; // when serialnr is not programmed (anymore), we use the Mac address

0 commit comments

Comments
 (0)