diff --git a/components/efuse/esp32c6/esp_efuse_table.c b/components/efuse/esp32c6/esp_efuse_table.c index 8f4ef4601e3..a1dcabf9d74 100644 --- a/components/efuse/esp32c6/esp_efuse_table.c +++ b/components/efuse/esp32c6/esp_efuse_table.c @@ -9,7 +9,7 @@ #include #include "esp_efuse_table.h" -// md5_digest_table ab312e31f6976fdf923a9809093323fd +// md5_digest_table 344c54cf227f74643e4d13dce1b1d30f // 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. @@ -481,7 +481,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[] = { @@ -1142,6 +1143,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 }; diff --git a/components/efuse/esp32c6/esp_efuse_table.csv b/components/efuse/esp32c6/esp_efuse_table.csv index d49e5f85ee1..78304fe59d9 100644 --- a/components/efuse/esp32c6/esp_efuse_table.csv +++ b/components/efuse/esp32c6/esp_efuse_table.csv @@ -131,7 +131,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 diff --git a/components/efuse/esp32c6/include/esp_efuse_table.h b/components/efuse/esp32c6/include/esp_efuse_table.h index 4d81d00566a..b9837019281 100644 --- a/components/efuse/esp32c6/include/esp_efuse_table.h +++ b/components/efuse/esp32c6/include/esp_efuse_table.h @@ -10,7 +10,7 @@ extern "C" { #include "esp_efuse.h" -// md5_digest_table ab312e31f6976fdf923a9809093323fd +// md5_digest_table 344c54cf227f74643e4d13dce1b1d30f // 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. diff --git a/components/efuse/esp32h2/esp_efuse_table.c b/components/efuse/esp32h2/esp_efuse_table.c index c7b08d8019e..5a89b0fa7a5 100644 --- a/components/efuse/esp32h2/esp_efuse_table.c +++ b/components/efuse/esp32h2/esp_efuse_table.c @@ -9,7 +9,7 @@ #include #include "esp_efuse_table.h" -// md5_digest_table 910e196e9c9c5c052f1c57710fe3977c +// md5_digest_table 47596a1f76a01780351e34b4785323dd // 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. @@ -481,7 +481,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[] = { @@ -1150,6 +1151,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 }; diff --git a/components/efuse/esp32h2/esp_efuse_table.csv b/components/efuse/esp32h2/esp_efuse_table.csv index bcb5fc7db02..0cf4ca0966a 100644 --- a/components/efuse/esp32h2/esp_efuse_table.csv +++ b/components/efuse/esp32h2/esp_efuse_table.csv @@ -131,7 +131,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, 3, [] WAFER_VERSION_MAJOR, EFUSE_BLK1, 117, 2, [] DISABLE_WAFER_VERSION_MAJOR, EFUSE_BLK1, 119, 1, [] Disables check of wafer version major diff --git a/components/efuse/esp32h2/include/esp_efuse_table.h b/components/efuse/esp32h2/include/esp_efuse_table.h index dfabab30e94..feab76c1319 100644 --- a/components/efuse/esp32h2/include/esp_efuse_table.h +++ b/components/efuse/esp32h2/include/esp_efuse_table.h @@ -10,7 +10,7 @@ extern "C" { #include "esp_efuse.h" -// md5_digest_table 910e196e9c9c5c052f1c57710fe3977c +// md5_digest_table 47596a1f76a01780351e34b4785323dd // 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. diff --git a/components/esp_hw_support/include/esp_mac.h b/components/esp_hw_support/include/esp_mac.h index 7b1bf37c832..8ead3a393f3 100644 --- a/components/esp_hw_support/include/esp_mac.h +++ b/components/esp_hw_support/include/esp_mac.h @@ -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 * diff --git a/components/esp_hw_support/mac_addr.c b/components/esp_hw_support/mac_addr.c index 4525c7af234..c917b57c109 100644 --- a/components/esp_hw_support/mac_addr.c +++ b/components/esp_hw_support/mac_addr.c @@ -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,25 +240,31 @@ esp_err_t esp_efuse_mac_get_custom(uint8_t *mac) return ESP_ERR_INVALID_CRC; #endif } - return ESP_OK; #endif + return ESP_OK; } esp_err_t esp_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); - esp_err_t err = esp_efuse_read_field_blob(ESP_EFUSE_MAC_FACTORY, mac, size_bits); + esp_err_t err = get_efuse_mac_get_default(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 CONFIG_SOC_IEEE802154_SUPPORTED + return insert_mac_ext_into_mac(mac); +#else + return ESP_OK; +#endif +} + +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); + esp_err_t err = esp_efuse_read_field_blob(ESP_EFUSE_MAC_FACTORY, mac, 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: diff --git a/examples/system/.build-test-rules.yml b/examples/system/.build-test-rules.yml index 31792a27c8b..2a8c2fb9704 100644 --- a/examples/system/.build-test-rules.yml +++ b/examples/system/.build-test-rules.yml @@ -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: - if: IDF_TARGET in ["esp32c2", "esp32c6", "esp32h2"] diff --git a/examples/system/base_mac_address/main/base_mac_address_example_main.c b/examples/system/base_mac_address/main/base_mac_address_example_main.c index 874f001eb24..763ed39bb92 100644 --- a/examples/system/base_mac_address/main/base_mac_address_example_main.c +++ b/examples/system/base_mac_address/main/base_mac_address_example_main.c @@ -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 } diff --git a/examples/system/base_mac_address/pytest_base_mac_address.py b/examples/system/base_mac_address/pytest_base_mac_address.py index de6373b0667..8fa8b7f5434 100644 --- a/examples/system/base_mac_address/pytest_base_mac_address.py +++ b/examples/system/base_mac_address/pytest_base_mac_address.py @@ -6,11 +6,12 @@ @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 get_expected_mac_string(increment: int, target: str) -> str: 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)