forked from espressif/esp-idf
mac_addr(C6 and H2): Fix byte order of MAC_EXT and change format of IEEE802154 MAC
The changes only related to C6 and H2 chips where CONFIG_SOC_IEEE802154_SUPPORTED=y. For this case these APIs return 8 bytes esp_efuse_mac_get_default() -> 8 bytes esp_efuse_mac_get_custom() -> 8 bytes esp_read_mac(..., ESP_MAC_IEEE802154) -> 8 bytes The rest cases len is 6 bytes
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#include <assert.h>
|
||||
#include "esp_efuse_table.h"
|
||||
|
||||
// md5_digest_table 7bd417676a69ed11f4908b6146efeaeb
|
||||
// md5_digest_table fd5a35cea89bfad954e834bc92bed385
|
||||
// This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
|
||||
// If you want to change some fields, you need to change esp_efuse_table.csv file
|
||||
// then run `efuse_common_table` or `efuse_custom_table` command it will generate this file.
|
||||
@@ -549,7 +549,8 @@ static const esp_efuse_desc_t MAC[] = {
|
||||
};
|
||||
|
||||
static const esp_efuse_desc_t MAC_EXT[] = {
|
||||
{EFUSE_BLK1, 48, 16}, // [] Stores the extended bits of MAC address,
|
||||
{EFUSE_BLK1, 56, 8}, // [] Stores the extended bits of MAC address,
|
||||
{EFUSE_BLK1, 48, 8}, // [] Stores the extended bits of MAC address,
|
||||
};
|
||||
|
||||
static const esp_efuse_desc_t WAFER_VERSION_MINOR[] = {
|
||||
@@ -1363,6 +1364,7 @@ const esp_efuse_desc_t* ESP_EFUSE_MAC[] = {
|
||||
|
||||
const esp_efuse_desc_t* ESP_EFUSE_MAC_EXT[] = {
|
||||
&MAC_EXT[0], // [] Stores the extended bits of MAC address
|
||||
&MAC_EXT[1], // [] Stores the extended bits of MAC address
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@@ -148,7 +148,8 @@ MAC, EFUSE_BLK1, 40, 8, [MAC_FACT
|
||||
, EFUSE_BLK1, 16, 8, [MAC_FACTORY] MAC address
|
||||
, EFUSE_BLK1, 8, 8, [MAC_FACTORY] MAC address
|
||||
, EFUSE_BLK1, 0, 8, [MAC_FACTORY] MAC address
|
||||
MAC_EXT, EFUSE_BLK1, 48, 16, [] Stores the extended bits of MAC address
|
||||
MAC_EXT, EFUSE_BLK1, 56, 8, [] Stores the extended bits of MAC address
|
||||
, EFUSE_BLK1, 48, 8, [] Stores the extended bits of MAC address
|
||||
WAFER_VERSION_MINOR, EFUSE_BLK1, 114, 4, []
|
||||
WAFER_VERSION_MAJOR, EFUSE_BLK1, 118, 2, []
|
||||
PKG_VERSION, EFUSE_BLK1, 120, 3, [] Package version
|
||||
|
Can't render this file because it contains an unexpected character in line 8 and column 53.
|
@@ -10,7 +10,7 @@ extern "C" {
|
||||
|
||||
#include "esp_efuse.h"
|
||||
|
||||
// md5_digest_table 7bd417676a69ed11f4908b6146efeaeb
|
||||
// md5_digest_table fd5a35cea89bfad954e834bc92bed385
|
||||
// This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
|
||||
// If you want to change some fields, you need to change esp_efuse_table.csv file
|
||||
// then run `efuse_common_table` or `efuse_custom_table` command it will generate this file.
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#include <assert.h>
|
||||
#include "esp_efuse_table.h"
|
||||
|
||||
// md5_digest_table 35c27f867ff30c0bcddad78a296ab037
|
||||
// md5_digest_table 6b9b5b452050328626d767c44e489b8d
|
||||
// This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
|
||||
// If you want to change some fields, you need to change esp_efuse_table.csv file
|
||||
// then run `efuse_common_table` or `efuse_custom_table` command it will generate this file.
|
||||
@@ -493,7 +493,8 @@ static const esp_efuse_desc_t MAC[] = {
|
||||
};
|
||||
|
||||
static const esp_efuse_desc_t MAC_EXT[] = {
|
||||
{EFUSE_BLK1, 48, 16}, // [] Stores the extended bits of MAC address,
|
||||
{EFUSE_BLK1, 56, 8}, // [] Stores the extended bits of MAC address,
|
||||
{EFUSE_BLK1, 48, 8}, // [] Stores the extended bits of MAC address,
|
||||
};
|
||||
|
||||
static const esp_efuse_desc_t RXIQ_VERSION[] = {
|
||||
@@ -1189,6 +1190,7 @@ const esp_efuse_desc_t* ESP_EFUSE_MAC[] = {
|
||||
|
||||
const esp_efuse_desc_t* ESP_EFUSE_MAC_EXT[] = {
|
||||
&MAC_EXT[0], // [] Stores the extended bits of MAC address
|
||||
&MAC_EXT[1], // [] Stores the extended bits of MAC address
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@@ -134,7 +134,8 @@ MAC, EFUSE_BLK1, 40, 8, [MAC_FACT
|
||||
, EFUSE_BLK1, 16, 8, [MAC_FACTORY] MAC address
|
||||
, EFUSE_BLK1, 8, 8, [MAC_FACTORY] MAC address
|
||||
, EFUSE_BLK1, 0, 8, [MAC_FACTORY] MAC address
|
||||
MAC_EXT, EFUSE_BLK1, 48, 16, [] Stores the extended bits of MAC address
|
||||
MAC_EXT, EFUSE_BLK1, 56, 8, [] Stores the extended bits of MAC address
|
||||
, EFUSE_BLK1, 48, 8, [] Stores the extended bits of MAC address
|
||||
RXIQ_VERSION, EFUSE_BLK1, 64, 3, [] RF Calibration data. RXIQ version
|
||||
RXIQ_0, EFUSE_BLK1, 67, 7, [] RF Calibration data. RXIQ data 0
|
||||
RXIQ_1, EFUSE_BLK1, 74, 7, [] RF Calibration data. RXIQ data 1
|
||||
|
Can't render this file because it contains an unexpected character in line 8 and column 53.
|
@@ -10,7 +10,7 @@ extern "C" {
|
||||
|
||||
#include "esp_efuse.h"
|
||||
|
||||
// md5_digest_table 35c27f867ff30c0bcddad78a296ab037
|
||||
// md5_digest_table 6b9b5b452050328626d767c44e489b8d
|
||||
// This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
|
||||
// If you want to change some fields, you need to change esp_efuse_table.csv file
|
||||
// then run `efuse_common_table` or `efuse_custom_table` command it will generate this file.
|
||||
|
@@ -19,14 +19,15 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ESP_MAC_WIFI_STA,
|
||||
ESP_MAC_WIFI_SOFTAP,
|
||||
ESP_MAC_BT,
|
||||
ESP_MAC_ETH,
|
||||
ESP_MAC_IEEE802154,
|
||||
ESP_MAC_BASE,
|
||||
ESP_MAC_EFUSE_FACTORY,
|
||||
ESP_MAC_EFUSE_CUSTOM,
|
||||
ESP_MAC_WIFI_STA, /**< MAC for WiFi Station (6 bytes) */
|
||||
ESP_MAC_WIFI_SOFTAP, /**< MAC for WiFi Soft-AP (6 bytes) */
|
||||
ESP_MAC_BT, /**< MAC for Bluetooth (6 bytes) */
|
||||
ESP_MAC_ETH, /**< MAC for Ethernet (6 bytes) */
|
||||
ESP_MAC_IEEE802154, /**< if CONFIG_SOC_IEEE802154_SUPPORTED=y, MAC for IEEE802154 (8 bytes) */
|
||||
ESP_MAC_BASE, /**< Base MAC for that used for other MAC types (6 bytes) */
|
||||
ESP_MAC_EFUSE_FACTORY, /**< MAC_FACTORY eFuse which was burned by Espressif in production (6 bytes) */
|
||||
ESP_MAC_EFUSE_CUSTOM, /**< MAC_CUSTOM eFuse which was can be burned by customer (6 bytes) */
|
||||
ESP_MAC_EFUSE_EXT, /**< if CONFIG_SOC_IEEE802154_SUPPORTED=y, MAC_EXT eFuse which is used as an extender for IEEE802154 MAC (2 bytes) */
|
||||
} esp_mac_type_t;
|
||||
|
||||
/** @cond */
|
||||
@@ -62,9 +63,8 @@ typedef enum {
|
||||
* @note If not using a valid OUI, set the "locally administered" bit
|
||||
* (bit value 0x02 in the first byte) to avoid collisions.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes/8 bytes.
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
* length: 6 bytes for MAC-48
|
||||
* 8 bytes for EUI-64(used for IEEE 802.15.4)
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_ARG If mac is NULL or is not a unicast MAC
|
||||
@@ -76,9 +76,8 @@ esp_err_t esp_base_mac_addr_set(const uint8_t *mac);
|
||||
*
|
||||
* @note If no custom Base MAC has been set, this returns the pre-programmed Espressif base MAC address.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes/8 bytes.
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
* length: 6 bytes for MAC-48
|
||||
* 8 bytes for EUI-64(used for IEEE 802.15.4)
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_ARG mac is NULL
|
||||
@@ -100,7 +99,7 @@ esp_err_t esp_base_mac_addr_get(uint8_t *mac);
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes/8 bytes.
|
||||
* length: 6 bytes for MAC-48
|
||||
* 8 bytes for EUI-64(used for IEEE 802.15.4)
|
||||
* 8 bytes for EUI-64(used for IEEE 802.15.4, if CONFIG_SOC_IEEE802154_SUPPORTED=y)
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_ARG mac is NULL
|
||||
@@ -115,7 +114,7 @@ esp_err_t esp_efuse_mac_get_custom(uint8_t *mac);
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes/8 bytes.
|
||||
* length: 6 bytes for MAC-48
|
||||
* 8 bytes for EUI-64(used for IEEE 802.15.4)
|
||||
* 8 bytes for EUI-64(used for IEEE 802.15.4, if CONFIG_SOC_IEEE802154_SUPPORTED=y)
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_ARG mac is NULL
|
||||
@@ -133,7 +132,7 @@ esp_err_t esp_efuse_mac_get_default(uint8_t *mac);
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes/8 bytes.
|
||||
* length: 6 bytes for MAC-48
|
||||
* 8 bytes for EUI-64(used for IEEE 802.15.4)
|
||||
* 8 bytes for EUI-64(used for IEEE 802.15.4, if CONFIG_SOC_IEEE802154_SUPPORTED=y)
|
||||
* @param type Type of MAC address to return
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
@@ -151,9 +150,8 @@ esp_err_t esp_read_mac(uint8_t *mac, esp_mac_type_t type);
|
||||
* address, then the first octet is XORed with 0x4 in order to create a different
|
||||
* locally administered MAC address.
|
||||
*
|
||||
* @param local_mac base MAC address, length: 6 bytes/8 bytes.
|
||||
* @param local_mac base MAC address, length: 6 bytes.
|
||||
* length: 6 bytes for MAC-48
|
||||
* 8 bytes for EUI-64(used for IEEE 802.15.4)
|
||||
* @param universal_mac Source universal MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
@@ -166,7 +164,7 @@ esp_err_t esp_derive_local_mac(uint8_t *local_mac, const uint8_t *universal_mac)
|
||||
*
|
||||
* @param mac MAC address, length: 6 bytes/8 bytes.
|
||||
* length: 6 bytes for MAC-48
|
||||
* 8 bytes for EUI-64(used for ESP_MAC_IEEE802154 type)
|
||||
* 8 bytes for EUI-64(used for ESP_MAC_IEEE802154 type, if CONFIG_SOC_IEEE802154_SUPPORTED=y)
|
||||
* @param type Type of MAC address
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
@@ -176,9 +174,11 @@ esp_err_t esp_iface_mac_addr_set(const uint8_t *mac, esp_mac_type_t type);
|
||||
/**
|
||||
* @brief Return the size of the MAC type in bytes.
|
||||
*
|
||||
* If CONFIG_IEEE802154_ENABLED is set then for these types:
|
||||
* ESP_MAC_IEEE802154, ESP_MAC_BASE, ESP_MAC_EFUSE_FACTORY and ESP_MAC_EFUSE_CUSTOM the MAC size is 8 bytes.
|
||||
* If CONFIG_IEEE802154_ENABLED is not set then for all types it returns 6 bytes.
|
||||
* If CONFIG_SOC_IEEE802154_SUPPORTED is set then for these types:
|
||||
* - ESP_MAC_IEEE802154 is 8 bytes.
|
||||
* - ESP_MAC_BASE, ESP_MAC_EFUSE_FACTORY and ESP_MAC_EFUSE_CUSTOM the MAC size is 6 bytes.
|
||||
* - ESP_MAC_EFUSE_EXT is 2 bytes.
|
||||
* If CONFIG_SOC_IEEE802154_SUPPORTED is not set then for all types it returns 6 bytes.
|
||||
*
|
||||
* @param type Type of MAC address
|
||||
*
|
||||
|
@@ -18,7 +18,7 @@
|
||||
#define MAC_ADDR_UNIVERSE_BT_OFFSET 1
|
||||
#endif
|
||||
|
||||
#if CONFIG_IEEE802154_ENABLED
|
||||
#if CONFIG_SOC_IEEE802154_SUPPORTED
|
||||
#define ESP_MAC_ADDRESS_LEN 8
|
||||
#else
|
||||
#define ESP_MAC_ADDRESS_LEN 6
|
||||
@@ -39,29 +39,35 @@ typedef struct {
|
||||
} mac_t;
|
||||
|
||||
static mac_t s_mac_table[] = {
|
||||
#ifdef CONFIG_ESP_WIFI_ENABLED
|
||||
{ESP_MAC_WIFI_STA, STATE_INIT, 6, {0}},
|
||||
{ESP_MAC_WIFI_SOFTAP, STATE_INIT, 6, {0}},
|
||||
#if CONFIG_SOC_WIFI_SUPPORTED
|
||||
{ESP_MAC_WIFI_STA, STATE_INIT, 6, {0}},
|
||||
{ESP_MAC_WIFI_SOFTAP, STATE_INIT, 6, {0}},
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_MAC_ADDR_UNIVERSE_BT
|
||||
{ESP_MAC_BT, STATE_INIT, 6, {0}},
|
||||
{ESP_MAC_BT, STATE_INIT, 6, {0}},
|
||||
#endif
|
||||
|
||||
{ESP_MAC_ETH, STATE_INIT, 6, {0}},
|
||||
{ESP_MAC_ETH, STATE_INIT, 6, {0}},
|
||||
|
||||
#ifdef CONFIG_ESP_MAC_ADDR_UNIVERSE_IEEE802154
|
||||
{ESP_MAC_IEEE802154, STATE_INIT, 8, {0}},
|
||||
#ifdef CONFIG_SOC_IEEE802154_SUPPORTED
|
||||
{ESP_MAC_IEEE802154, STATE_INIT, ESP_MAC_ADDRESS_LEN, {0}},
|
||||
{ESP_MAC_EFUSE_EXT, STATE_INIT, 2, {0}},
|
||||
#endif
|
||||
|
||||
{ESP_MAC_BASE, STATE_INIT, ESP_MAC_ADDRESS_LEN, {0}},
|
||||
{ESP_MAC_EFUSE_FACTORY, STATE_INIT, ESP_MAC_ADDRESS_LEN, {0}},
|
||||
{ESP_MAC_EFUSE_CUSTOM, STATE_INIT, ESP_MAC_ADDRESS_LEN, {0}},
|
||||
{ESP_MAC_BASE, STATE_INIT, 6, {0}},
|
||||
{ESP_MAC_EFUSE_FACTORY, STATE_INIT, 6, {0}},
|
||||
{ESP_MAC_EFUSE_CUSTOM, STATE_INIT, 6, {0}},
|
||||
};
|
||||
|
||||
#define ITEMS_IN_MAC_TABLE (sizeof(s_mac_table) / sizeof(mac_t))
|
||||
|
||||
static esp_err_t generate_mac(uint8_t *mac, uint8_t *base_mac_addr, esp_mac_type_t type);
|
||||
static esp_err_t get_efuse_mac_get_default(uint8_t *mac);
|
||||
static esp_err_t get_efuse_mac_custom(uint8_t *mac);
|
||||
#if CONFIG_SOC_IEEE802154_SUPPORTED
|
||||
static esp_err_t get_efuse_mac_ext(uint8_t *mac);
|
||||
#endif
|
||||
|
||||
static int get_idx(esp_mac_type_t type)
|
||||
{
|
||||
@@ -70,7 +76,7 @@ static int get_idx(esp_mac_type_t type)
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
ESP_LOGE(TAG, "mac type is incorrect (not found)");
|
||||
ESP_LOGE(TAG, "%d mac type is incorrect (not found)", type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -81,13 +87,18 @@ static esp_err_t get_mac_addr_from_mac_table(uint8_t *mac, int idx, bool silent)
|
||||
}
|
||||
if (!(s_mac_table[idx].state & STATE_SET)) {
|
||||
esp_mac_type_t type = s_mac_table[idx].type;
|
||||
if (type == ESP_MAC_BASE || type == ESP_MAC_EFUSE_FACTORY || type == ESP_MAC_EFUSE_CUSTOM) {
|
||||
if (ESP_MAC_BASE <= type && type <= ESP_MAC_EFUSE_EXT) {
|
||||
esp_err_t err = ESP_OK;
|
||||
if (type == ESP_MAC_BASE || type == ESP_MAC_EFUSE_FACTORY) {
|
||||
err = esp_efuse_mac_get_default(s_mac_table[idx].mac);
|
||||
err = get_efuse_mac_get_default(s_mac_table[idx].mac);
|
||||
} else if (type == ESP_MAC_EFUSE_CUSTOM) {
|
||||
err = esp_efuse_mac_get_custom(s_mac_table[idx].mac);
|
||||
err = get_efuse_mac_custom(s_mac_table[idx].mac);
|
||||
}
|
||||
#if CONFIG_SOC_IEEE802154_SUPPORTED
|
||||
else if (type == ESP_MAC_EFUSE_EXT) {
|
||||
err = get_efuse_mac_ext(s_mac_table[idx].mac);
|
||||
}
|
||||
#endif
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
@@ -151,7 +162,45 @@ esp_err_t esp_base_mac_addr_get(uint8_t *mac)
|
||||
return esp_read_mac(mac, ESP_MAC_BASE);
|
||||
}
|
||||
|
||||
#if CONFIG_SOC_IEEE802154_SUPPORTED
|
||||
static esp_err_t get_efuse_mac_ext(uint8_t *mac)
|
||||
{
|
||||
// ff:fe
|
||||
esp_err_t err = esp_efuse_read_field_blob(ESP_EFUSE_MAC_EXT, mac, 16);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Reading MAC_EXT failed, error=%d", err);
|
||||
return err;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t insert_mac_ext_into_mac(uint8_t *mac)
|
||||
{
|
||||
uint8_t mac_tmp[3];
|
||||
memcpy(mac_tmp, &mac[3], 3);
|
||||
esp_err_t err = get_efuse_mac_ext(&mac[3]);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
memcpy(&mac[5], mac_tmp, 3);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
esp_err_t esp_efuse_mac_get_custom(uint8_t *mac)
|
||||
{
|
||||
esp_err_t err = get_efuse_mac_custom(mac);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
#if CONFIG_SOC_IEEE802154_SUPPORTED
|
||||
return insert_mac_ext_into_mac(mac);
|
||||
#else
|
||||
return ESP_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
static esp_err_t get_efuse_mac_custom(uint8_t *mac)
|
||||
{
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
size_t size_bits = esp_efuse_get_field_size(ESP_EFUSE_USER_DATA_MAC_CUSTOM);
|
||||
@@ -165,14 +214,6 @@ esp_err_t esp_efuse_mac_get_custom(uint8_t *mac)
|
||||
ESP_LOGE(TAG, "eFuse MAC_CUSTOM is empty");
|
||||
return ESP_ERR_INVALID_MAC;
|
||||
}
|
||||
#if (ESP_MAC_ADDRESS_LEN == 8)
|
||||
err = esp_efuse_read_field_blob(ESP_EFUSE_MAC_EXT, &mac[6], ESP_MAC_ADDRESS_LEN * 8 - size_bits);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Reading MAC_EXT failed, error=%d", err);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
return ESP_OK;
|
||||
#else
|
||||
uint8_t version;
|
||||
esp_efuse_read_field_blob(ESP_EFUSE_MAC_CUSTOM_VER, &version, 8);
|
||||
@@ -199,11 +240,24 @@ esp_err_t esp_efuse_mac_get_custom(uint8_t *mac)
|
||||
return ESP_ERR_INVALID_CRC;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_mac_get_default(uint8_t *mac)
|
||||
{
|
||||
esp_err_t err = get_efuse_mac_get_default(mac);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
#if CONFIG_SOC_IEEE802154_SUPPORTED
|
||||
return insert_mac_ext_into_mac(mac);
|
||||
#else
|
||||
return ESP_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_mac_get_default(uint8_t *mac)
|
||||
static esp_err_t get_efuse_mac_get_default(uint8_t *mac)
|
||||
{
|
||||
size_t size_bits = esp_efuse_get_field_size(ESP_EFUSE_MAC_FACTORY);
|
||||
assert((size_bits % 8) == 0);
|
||||
@@ -211,13 +265,6 @@ esp_err_t esp_efuse_mac_get_default(uint8_t *mac)
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
#if (ESP_MAC_ADDRESS_LEN == 8)
|
||||
err = esp_efuse_read_field_blob(ESP_EFUSE_MAC_EXT, &mac[6], ESP_MAC_ADDRESS_LEN * 8 - size_bits);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Reading MAC_EXT failed, error=%d", err);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
// Only ESP32 has MAC CRC in efuse
|
||||
uint8_t efuse_crc;
|
||||
@@ -349,9 +396,15 @@ static esp_err_t generate_mac(uint8_t *mac, uint8_t *base_mac_addr, esp_mac_type
|
||||
esp_derive_local_mac(mac, base_mac_addr);
|
||||
#endif // CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH
|
||||
break;
|
||||
#if CONFIG_IEEE802154_ENABLED
|
||||
#if CONFIG_SOC_IEEE802154_SUPPORTED
|
||||
case ESP_MAC_IEEE802154:
|
||||
memcpy(mac, base_mac_addr, 8);
|
||||
// 60:55:f9
|
||||
memcpy(mac, base_mac_addr, 3);
|
||||
// 60:55:f9 + ff:fe
|
||||
esp_read_mac(&mac[3], ESP_MAC_EFUSE_EXT);
|
||||
// 60:55:f9:ff:fe + f7:2c:a2
|
||||
memcpy(&mac[5], &base_mac_addr[3], 3);
|
||||
// 60:55:f9:ff:fe:f7:2c:a2
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@@ -6,12 +6,6 @@ examples/system/app_trace_basic:
|
||||
temporary: true
|
||||
reason: target esp32c6, esp32h2 is not supported yet
|
||||
|
||||
examples/system/base_mac_address:
|
||||
disable_test:
|
||||
- if: IDF_TARGET in ["esp32h2"]
|
||||
temporary: true
|
||||
reason: cannot pass, IDF-6809
|
||||
|
||||
examples/system/console/advanced:
|
||||
disable_test:
|
||||
- if: IDF_TARGET not in ["esp32", "esp32c3"]
|
||||
|
@@ -119,4 +119,14 @@ void app_main(void)
|
||||
ESP_LOGI("New Ethernet MAC", "0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x",
|
||||
derived_mac_addr[0], derived_mac_addr[1], derived_mac_addr[2],
|
||||
derived_mac_addr[3], derived_mac_addr[4], derived_mac_addr[5]);
|
||||
|
||||
#if CONFIG_SOC_IEEE802154_SUPPORTED
|
||||
uint8_t mac_ext[2] = {0};
|
||||
ESP_ERROR_CHECK(esp_read_mac(mac_ext, ESP_MAC_EFUSE_EXT));
|
||||
ESP_LOGI("MAC_EXT", "0x%x, 0x%x", mac_ext[0], mac_ext[1]);
|
||||
uint8_t eui64[8] = {0};
|
||||
ESP_ERROR_CHECK(esp_read_mac(eui64, ESP_MAC_IEEE802154));
|
||||
ESP_LOGI("IEEE802154", "0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x",
|
||||
eui64[0], eui64[1], eui64[2], eui64[3], eui64[4], eui64[5], eui64[6], eui64[7]);
|
||||
#endif
|
||||
}
|
||||
|
@@ -6,11 +6,12 @@ from pytest_embedded import Dut
|
||||
|
||||
|
||||
@pytest.mark.supported_targets
|
||||
@pytest.mark.temp_skip_ci(targets=['esp32h2'], reason='cannot pass') # IDF-6809
|
||||
@pytest.mark.generic
|
||||
def test_base_mac_address(dut: Dut) -> None:
|
||||
def get_hex_r(num_bytes: int) -> str:
|
||||
return r', '.join((r'0x([0-9a-f]{1,2})',) * num_bytes)
|
||||
hex_r = get_hex_r(6)
|
||||
dut.expect_exact('BASE_MAC: Base MAC Address read from EFUSE BLK0')
|
||||
hex_r = r', '.join((r'0x([0-9a-f]{1,2})',) * 6)
|
||||
mac_m = dut.expect(r'BASE_MAC: Using "' + hex_r + r'" as base MAC address', timeout=5).groups()
|
||||
|
||||
def get_expected_mac_string(increment: int, target: str) -> str:
|
||||
@@ -40,8 +41,18 @@ def test_base_mac_address(dut: Dut) -> None:
|
||||
dut.expect_exact('WIFI_STA MAC: ' + get_expected_mac_string(0, dut.target), timeout=2)
|
||||
dut.expect_exact('SoftAP MAC: ' + get_expected_mac_string(1, dut.target))
|
||||
|
||||
if dut.target != 'esp32s2':
|
||||
if dut.target != 'esp32s2' and dut.target != 'esp32h2':
|
||||
if sdkconfig.get('ESP_MAC_ADDR_UNIVERSE_BT'):
|
||||
dut.expect_exact('BT MAC: ' + get_expected_mac_string(2, dut.target))
|
||||
dut.expect_exact('Ethernet MAC: ' + get_expected_mac_string(3, dut.target))
|
||||
dut.expect_exact('New Ethernet MAC: ' + get_expected_mac_string(6, dut.target))
|
||||
elif dut.target == 'esp32h2':
|
||||
dut.expect_exact('BT MAC: ' + get_expected_mac_string(0, dut.target))
|
||||
dut.expect_exact('New Ethernet MAC: ' + get_expected_mac_string(6, dut.target))
|
||||
|
||||
if sdkconfig.get('SOC_IEEE802154_SUPPORTED'):
|
||||
mac_ext_m = dut.expect(r'MAC_EXT: ' + get_hex_r(2), timeout=5).groups()
|
||||
mac_ext = ['0x{}'.format(m.decode('utf8')) for m in mac_ext_m]
|
||||
mac = ['0x{}'.format(m.decode('utf8')) for m in mac_m]
|
||||
expected_eui64 = f'{mac[0]}, {mac[1]}, {mac[2]}, {mac_ext[0]}, {mac_ext[1]}, {mac[3]}, {mac[4]}, {mac[5]}'
|
||||
dut.expect_exact(r'IEEE802154: ' + expected_eui64, timeout=5)
|
||||
|
Reference in New Issue
Block a user