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:
KonstantinKondrashov
2023-05-30 22:31:22 +08:00
parent 5cd6189677
commit f7dfd1f48e
11 changed files with 145 additions and 71 deletions
@@ -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)