Skip to content

Commit

Permalink
ports/esp32: Add basic espressif IDF v5.3 compatibility.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Leech <[email protected]>
  • Loading branch information
pi-anl committed Aug 27, 2024
1 parent a8d1c25 commit a20171b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
8 changes: 4 additions & 4 deletions extmod/nimble/modbluetooth_nimble.c
Original file line number Diff line number Diff line change
Expand Up @@ -1911,13 +1911,13 @@ static int ble_secret_store_read(int obj_type, const union ble_store_key *key, u
// <type=peer,addr,*> (single)
// Find the entry for this specific peer.
assert(key->sec.idx == 0);
assert(!key->sec.ediv_rand_present);
// assert(!key->sec.ediv_rand_present);
key_data = (const uint8_t *)&key->sec.peer_addr;
key_data_len = sizeof(ble_addr_t);
} else {
// <type=peer,*> (with index)
// Iterate all known peers.
assert(!key->sec.ediv_rand_present);
// assert(!key->sec.ediv_rand_present);
key_data = NULL;
key_data_len = 0;
}
Expand All @@ -1928,7 +1928,7 @@ static int ble_secret_store_read(int obj_type, const union ble_store_key *key, u
// Find our secret for this remote device, matching this ediv/rand key.
assert(ble_addr_cmp(&key->sec.peer_addr, BLE_ADDR_ANY)); // Must have address.
assert(key->sec.idx == 0);
assert(key->sec.ediv_rand_present);
// assert(key->sec.ediv_rand_present);
key_data = (const uint8_t *)&key->sec.peer_addr;
key_data_len = sizeof(ble_addr_t);
break;
Expand Down Expand Up @@ -1977,7 +1977,7 @@ static int ble_secret_store_write(int obj_type, const union ble_store_value *val
ble_store_key_from_value_sec(&key_sec, value_sec);

assert(ble_addr_cmp(&key_sec.peer_addr, BLE_ADDR_ANY)); // Must have address.
assert(key_sec.ediv_rand_present);
// assert(key_sec.ediv_rand_present);

if (!mp_bluetooth_gap_on_set_secret(obj_type, (const uint8_t *)&key_sec.peer_addr, sizeof(ble_addr_t), (const uint8_t *)value_sec, sizeof(struct ble_store_value_sec))) {
DEBUG_printf("Failed to write key: type=%d\n", obj_type);
Expand Down
3 changes: 3 additions & 0 deletions ports/esp32/modnetwork_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
{ MP_ROM_QSTR(MP_QSTR_AUTH_WPA3_EXT_PSK), MP_ROM_INT(WIFI_AUTH_WPA3_EXT_PSK) },
{ MP_ROM_QSTR(MP_QSTR_AUTH_WPA3_EXT_PSK_MIXED_MODE), MP_ROM_INT(WIFI_AUTH_WPA3_EXT_PSK_MIXED_MODE) },
#endif
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
{ MP_ROM_QSTR(MP_QSTR_AUTH_DPP), MP_ROM_INT(WIFI_AUTH_DPP) },
#endif
{ MP_ROM_QSTR(MP_QSTR_AUTH_MAX), MP_ROM_INT(WIFI_AUTH_MAX) },
#endif

Expand Down
4 changes: 3 additions & 1 deletion ports/esp32/network_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ static mp_obj_t esp_phy_mode(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_network_phy_mode_obj, 0, 1, esp_phy_mode);

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
_Static_assert(WIFI_AUTH_MAX == 14, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types_generic.h");
#elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
_Static_assert(WIFI_AUTH_MAX == 13, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
#elif ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 5) && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 1, 0) || ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 2)
_Static_assert(WIFI_AUTH_MAX == 11, "Synchronize WIFI_AUTH_XXX constants with the ESP-IDF. Look at esp-idf/components/esp_wifi/include/esp_wifi_types.h");
Expand Down
11 changes: 10 additions & 1 deletion ports/esp32/network_wlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,16 @@ static const mp_rom_map_elem_t wlan_if_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_SEC_WPA2_WPA3), MP_ROM_INT(WIFI_AUTH_WPA2_WPA3_PSK) },
{ MP_ROM_QSTR(MP_QSTR_SEC_WAPI), MP_ROM_INT(WIFI_AUTH_WAPI_PSK) },
{ MP_ROM_QSTR(MP_QSTR_SEC_OWE), MP_ROM_INT(WIFI_AUTH_OWE) },

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 5) && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 1, 0) || ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 2)
{ MP_ROM_QSTR(MP_QSTR_SEC_WPA3_ENT_192), MP_ROM_INT(WIFI_AUTH_WPA3_ENT_192) },
#endif
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
{ MP_ROM_QSTR(MP_QSTR_SEC_WPA3_EXT_PSK), MP_ROM_INT(WIFI_AUTH_WPA3_EXT_PSK) },
{ MP_ROM_QSTR(MP_QSTR_SEC_WPA3_EXT_PSK_MIXED_MODE), MP_ROM_INT(WIFI_AUTH_WPA3_EXT_PSK_MIXED_MODE) },
#endif
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
{ MP_ROM_QSTR(MP_QSTR_SEC_DPP), MP_ROM_INT(WIFI_AUTH_DPP) },
#endif
{ MP_ROM_QSTR(MP_QSTR_PM_NONE), MP_ROM_INT(WIFI_PS_NONE) },
{ MP_ROM_QSTR(MP_QSTR_PM_PERFORMANCE), MP_ROM_INT(WIFI_PS_MIN_MODEM) },
{ MP_ROM_QSTR(MP_QSTR_PM_POWERSAVE), MP_ROM_INT(WIFI_PS_MAX_MODEM) },
Expand Down
4 changes: 4 additions & 0 deletions ports/esp32/usb_serial_jtag.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ void usb_serial_jtag_poll_rx(void) {
}
}

#ifndef USB_SERIAL_JTAG_PACKET_SZ_BYTES
#define USB_SERIAL_JTAG_PACKET_SZ_BYTES USB_SERIAL_JTAG_RDWR_BYTE_S
#endif

void usb_serial_jtag_tx_strn(const char *str, size_t len) {
while (len) {
size_t l = len;
Expand Down

0 comments on commit a20171b

Please sign in to comment.