drivers: hwinfo: Add support for ESP32
ESP32 can sport up to 4 network interfaces: two 802.11 (station and ap), ethernet, and bluetooth. All of them derive from the same RDATA register in efuse block 0. However, in most cases, the last (sixth) octet will change like so: - 802.11 station: mac[5] += 0 - 802.11 ap: mac[5] += 1 - bluetooth: mac[5] += 2 - ethernet: mac[5] += 3 Read "Number of universally admnistered MAC address" section in esp-idf documentation[1] for more information. [1] https://docs.espressif.com/projects/esp-idf/en/latest/ Signed-off-by: Leandro Pereira <leandro@hardinfo.org>
This commit is contained in:
parent
e85b9315c2
commit
05351dbf9d
3 changed files with 34 additions and 0 deletions
|
@ -6,6 +6,7 @@ zephyr_sources_ifdef(CONFIG_HWINFO hwinfo_weak_impl.c)
|
||||||
zephyr_sources_ifdef(CONFIG_HWINFO_STM32 hwinfo_stm32.c)
|
zephyr_sources_ifdef(CONFIG_HWINFO_STM32 hwinfo_stm32.c)
|
||||||
zephyr_sources_ifdef(CONFIG_HWINFO_NRF hwinfo_nrf.c)
|
zephyr_sources_ifdef(CONFIG_HWINFO_NRF hwinfo_nrf.c)
|
||||||
zephyr_sources_ifdef(CONFIG_HWINFO_MCUX_SIM hwinfo_mcux_sim.c)
|
zephyr_sources_ifdef(CONFIG_HWINFO_MCUX_SIM hwinfo_mcux_sim.c)
|
||||||
|
zephyr_sources_ifdef(CONFIG_HWINFO_ESP32 hwinfo_esp32.c)
|
||||||
zephyr_sources_ifdef(CONFIG_HWINFO_IMXRT hwinfo_imxrt.c)
|
zephyr_sources_ifdef(CONFIG_HWINFO_IMXRT hwinfo_imxrt.c)
|
||||||
zephyr_sources_ifdef(CONFIG_HWINFO_SAM hwinfo_sam.c)
|
zephyr_sources_ifdef(CONFIG_HWINFO_SAM hwinfo_sam.c)
|
||||||
zephyr_sources_ifdef(CONFIG_HWINFO_SAM0 hwinfo_sam0.c)
|
zephyr_sources_ifdef(CONFIG_HWINFO_SAM0 hwinfo_sam0.c)
|
||||||
|
|
|
@ -62,4 +62,11 @@ config HWINFO_SAM0
|
||||||
help
|
help
|
||||||
Enable Atmel SAM0 hwinfo driver.
|
Enable Atmel SAM0 hwinfo driver.
|
||||||
|
|
||||||
|
config HWINFO_ESP32
|
||||||
|
bool "ESP32 device ID"
|
||||||
|
default y
|
||||||
|
depends on SOC_ESP32
|
||||||
|
help
|
||||||
|
Enable ESP32 hwinfo driver.
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
26
drivers/hwinfo/hwinfo_esp32.c
Normal file
26
drivers/hwinfo/hwinfo_esp32.c
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Leandro A. F. Pereira
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <soc/efuse_reg.h>
|
||||||
|
|
||||||
|
#include <hwinfo.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
ssize_t _impl_hwinfo_get_device_id(u8_t *buffer, size_t length)
|
||||||
|
{
|
||||||
|
uint32_t fuse_rdata[] = {
|
||||||
|
sys_read32(EFUSE_BLK0_RDATA1_REG),
|
||||||
|
sys_read32(EFUSE_BLK0_RDATA2_REG),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (length > sizeof(fuse_rdata)) {
|
||||||
|
length = sizeof(fuse_rdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(buffer, fuse_rdata, length);
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue