drivers: hwinfo: Implement hwinfo_get_device_id for ESP32-C3

ESP32-C3 uses different fuse addresses for storing the MAC addr,
but the the format is the same.

Signed-off-by: Michal Moskal <michal@moskal.me>
This commit is contained in:
Michal Moskal 2022-11-29 18:06:01 -06:00 committed by Carles Cufí
parent f8f3629efd
commit d46b9bd124
2 changed files with 6 additions and 1 deletions

View file

@ -118,7 +118,7 @@ config HWINFO_SAM0
config HWINFO_ESP32 config HWINFO_ESP32
bool "ESP32 device ID" bool "ESP32 device ID"
default y default y
depends on SOC_ESP32 depends on SOC_ESP32 || SOC_ESP32C3
help help
Enable ESP32 hwinfo driver. Enable ESP32 hwinfo driver.

View file

@ -12,8 +12,13 @@
ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length) ssize_t z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
{ {
#ifdef CONFIG_SOC_ESP32C3
uint32_t rdata1 = sys_read32(EFUSE_RD_MAC_SPI_SYS_0_REG);
uint32_t rdata2 = sys_read32(EFUSE_RD_MAC_SPI_SYS_1_REG);
#else
uint32_t rdata1 = sys_read32(EFUSE_BLK0_RDATA1_REG); uint32_t rdata1 = sys_read32(EFUSE_BLK0_RDATA1_REG);
uint32_t rdata2 = sys_read32(EFUSE_BLK0_RDATA2_REG); uint32_t rdata2 = sys_read32(EFUSE_BLK0_RDATA2_REG);
#endif
uint8_t id[6]; uint8_t id[6];
/* The first word provides the lower 32 bits of the MAC /* The first word provides the lower 32 bits of the MAC