Merge branch 'backport/fix_br_issues_of_cert' into 'release/v5.1'

OpenThread: fix issues found in certification(backport v5.1)

See merge request espressif/esp-idf!24079
This commit is contained in:
Shu Chen 2023-07-14 15:01:07 +08:00
commit 1296991b2f
13 changed files with 76 additions and 42 deletions

View File

@ -73,6 +73,7 @@ if(CONFIG_OPENTHREAD_ENABLED)
"openthread/src/core/api/message_api.cpp" "openthread/src/core/api/message_api.cpp"
"openthread/src/core/api/nat64_api.cpp" "openthread/src/core/api/nat64_api.cpp"
"openthread/src/core/api/netdata_api.cpp" "openthread/src/core/api/netdata_api.cpp"
"openthread/src/core/api/netdiag_api.cpp"
"openthread/src/core/api/random_crypto_api.cpp" "openthread/src/core/api/random_crypto_api.cpp"
"openthread/src/core/api/tcp_api.cpp" "openthread/src/core/api/tcp_api.cpp"
"openthread/src/core/api/udp_api.cpp" "openthread/src/core/api/udp_api.cpp"
@ -106,6 +107,7 @@ if(CONFIG_OPENTHREAD_ENABLED)
"openthread/src/core/thread/network_data_leader_ftd.cpp" "openthread/src/core/thread/network_data_leader_ftd.cpp"
"openthread/src/core/thread/network_data_types.cpp" "openthread/src/core/thread/network_data_types.cpp"
"openthread/src/core/thread/network_data_service.cpp" "openthread/src/core/thread/network_data_service.cpp"
"openthread/src/core/thread/network_diagnostic.cpp"
"openthread/src/core/thread/panid_query_server.cpp" "openthread/src/core/thread/panid_query_server.cpp"
"openthread/src/core/thread/thread_netif.cpp" "openthread/src/core/thread/thread_netif.cpp"
"openthread/src/core/thread/tmf.cpp" "openthread/src/core/thread/tmf.cpp"

View File

@ -255,4 +255,11 @@ menu "OpenThread"
default n default n
help help
Select this option to set rx on when sleep in CSL feature, only for debug Select this option to set rx on when sleep in CSL feature, only for debug
config OPENTHREAD_DUA_ENABLE
bool "Enable Domain Unicast Address feature"
depends on OPENTHREAD_ENABLED
default n
help
Only used for Thread1.2 certification
endmenu endmenu

@ -1 +1 @@
Subproject commit 36cb2202e10b5ba7484654962ca9e3ceb51f6d51 Subproject commit 785e946222f6c6ab453d7d47c15c551d4a181f79

@ -1 +1 @@
Subproject commit 091f68ed706ce7a4831802408cdd0b0b4f309e3b Subproject commit 5beae143700db54c6e9bd4b15a568abe2f305723

View File

@ -85,7 +85,7 @@ public:
* @param[in] mainloop The mainloop context * @param[in] mainloop The mainloop context
* *
*/ */
void Process(const esp_openthread_mainloop_context_t &mainloop); void Process(const void *mainloop);
/** /**
* This methods updates the mainloop context. * This methods updates the mainloop context.
@ -93,7 +93,7 @@ public:
* @param[inout] mainloop The mainloop context. * @param[inout] mainloop The mainloop context.
* *
*/ */
void Update(esp_openthread_mainloop_context_t &mainloop); void Update(void *mainloop);
/** /**
* This methods registers the callback for RCP failure. * This methods registers the callback for RCP failure.
@ -114,7 +114,7 @@ public:
* This method is called when RCP failure detected and resets internal states of the interface. * This method is called when RCP failure detected and resets internal states of the interface.
* *
*/ */
void OnRcpReset(void); otError HardwareReset(void);
private: private:
static constexpr uint8_t kSPIFrameHeaderSize = 5; static constexpr uint8_t kSPIFrameHeaderSize = 5;

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -11,6 +11,7 @@
#include "esp_openthread_types.h" #include "esp_openthread_types.h"
#include "hal/uart_types.h" #include "hal/uart_types.h"
#include "lib/spinel/spinel_interface.hpp" #include "lib/spinel/spinel_interface.hpp"
#include "lib/hdlc/hdlc.hpp"
#include "openthread/error.h" #include "openthread/error.h"
namespace esp { namespace esp {
@ -90,7 +91,7 @@ public:
* @param[in] mainloop The mainloop context * @param[in] mainloop The mainloop context
* *
*/ */
void Process(const esp_openthread_mainloop_context_t &mainloop); void Process(const void *mainloop);
/** /**
* This methods updates the mainloop context. * This methods updates the mainloop context.
@ -98,7 +99,7 @@ public:
* @param[inout] mainloop The mainloop context. * @param[inout] mainloop The mainloop context.
* *
*/ */
void Update(esp_openthread_mainloop_context_t &mainloop); void Update(void *mainloop);
/** /**
* This methods registers the callback for RCP failure. * This methods registers the callback for RCP failure.
@ -108,8 +109,17 @@ public:
*/ */
void RegisterRcpFailureHandler(esp_openthread_rcp_failure_handler handler) { mRcpFailureHandler = handler; } void RegisterRcpFailureHandler(esp_openthread_rcp_failure_handler handler) { mRcpFailureHandler = handler; }
void OnRcpReset(void); /**
* This method is called when RCP failure detected and resets internal states of the interface.
*
*/
otError HardwareReset(void);
/**
* This method is called when RCP is reset to recreate the connection with it.
* Intentionally empty.
*
*/
otError ResetConnection(void) { return OT_ERROR_NONE; } otError ResetConnection(void) { return OT_ERROR_NONE; }
private: private:

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -371,6 +371,7 @@
*/ */
#define OPENTHREAD_CONFIG_PING_SENDER_ENABLE 1 #define OPENTHREAD_CONFIG_PING_SENDER_ENABLE 1
#if CONFIG_OPENTHREAD_DUA_ENABLE
/** /**
* @def OPENTHREAD_CONFIG_DUA_ENABLE * @def OPENTHREAD_CONFIG_DUA_ENABLE
* *
@ -378,8 +379,9 @@
* *
*/ */
#ifndef OPENTHREAD_CONFIG_DUA_ENABLE #ifndef OPENTHREAD_CONFIG_DUA_ENABLE
#define OPENTHREAD_CONFIG_DUA_ENABLE 0 #define OPENTHREAD_CONFIG_DUA_ENABLE 1
#endif #endif
#endif //CONFIG_OPENTHREAD_DUA_ENABLE
/** /**
* @def OPENTHREAD_CONFIG_MLR_ENABLE * @def OPENTHREAD_CONFIG_MLR_ENABLE
@ -495,4 +497,14 @@
#endif #endif
#endif //CONFIG_OPENTHREAD_LINK_METRICS #endif //CONFIG_OPENTHREAD_LINK_METRICS
/**
* @def OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT
*
* Define as 1 to enable support for locally initializing an Active Operational Dataset.
*
*/
#ifndef OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT
#define OPENTHREAD_CONFIG_OPERATIONAL_DATASET_AUTO_INIT 1
#endif
#define OPENTHREAD_FTD 1 #define OPENTHREAD_FTD 1

View File

@ -207,6 +207,7 @@
#define OPENTHREAD_RADIO 1 #define OPENTHREAD_RADIO 1
#if CONFIG_OPENTHREAD_LINK_METRICS
/** /**
* @def OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE * @def OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
* *
@ -216,3 +217,4 @@
#ifndef OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE #ifndef OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1 #define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1
#endif #endif
#endif //CONFIG_OPENTHREAD_LINK_METRICS

View File

@ -25,10 +25,10 @@ using ot::Spinel::RadioSpinel;
#if CONFIG_OPENTHREAD_RADIO_SPINEL_UART #if CONFIG_OPENTHREAD_RADIO_SPINEL_UART
using esp::openthread::UartSpinelInterface; using esp::openthread::UartSpinelInterface;
static RadioSpinel<UartSpinelInterface, esp_openthread_mainloop_context_t> s_radio; static RadioSpinel<UartSpinelInterface> s_radio;
#else // CONFIG_OPENTHREAD_RADIO_SPINEL_SPI #else // CONFIG_OPENTHREAD_RADIO_SPINEL_SPI
using esp::openthread::SpiSpinelInterface; using esp::openthread::SpiSpinelInterface;
static RadioSpinel<SpiSpinelInterface, esp_openthread_mainloop_context_t> s_radio; static RadioSpinel<SpiSpinelInterface> s_radio;
#endif // CONFIG_OPENTHREAD_RADIO_SPINEL_UART #endif // CONFIG_OPENTHREAD_RADIO_SPINEL_UART
static const char *radiospinel_workflow = "radio_spinel"; static const char *radiospinel_workflow = "radio_spinel";
@ -42,7 +42,7 @@ esp_err_t esp_openthread_radio_init(const esp_openthread_platform_config_t *conf
ESP_RETURN_ON_ERROR(s_radio.GetSpinelInterface().Init(config->radio_config.radio_spi_config), OT_PLAT_LOG_TAG, ESP_RETURN_ON_ERROR(s_radio.GetSpinelInterface().Init(config->radio_config.radio_spi_config), OT_PLAT_LOG_TAG,
"Spinel interface init failed"); "Spinel interface init failed");
#endif // CONFIG_OPENTHREAD_RADIO_SPINEL_UART #endif // CONFIG_OPENTHREAD_RADIO_SPINEL_UART
s_radio.Init(/*reset_radio=*/true, /*restore_dataset_from_ncp=*/false, /*skip_rcp_compatibility_check=*/false); s_radio.Init(/*reset_radio=*/true, /*skip_rcp_compatibility_check=*/false);
return esp_openthread_platform_workflow_register(&esp_openthread_radio_update, &esp_openthread_radio_process, return esp_openthread_platform_workflow_register(&esp_openthread_radio_update, &esp_openthread_radio_process,
radiospinel_workflow); radiospinel_workflow);
} }
@ -65,14 +65,14 @@ void esp_openthread_radio_deinit(void)
esp_err_t esp_openthread_radio_process(otInstance *instance, const esp_openthread_mainloop_context_t *mainloop) esp_err_t esp_openthread_radio_process(otInstance *instance, const esp_openthread_mainloop_context_t *mainloop)
{ {
s_radio.Process(*mainloop); s_radio.Process((void *)mainloop);
return ESP_OK; return ESP_OK;
} }
void esp_openthread_radio_update(esp_openthread_mainloop_context_t *mainloop) void esp_openthread_radio_update(esp_openthread_mainloop_context_t *mainloop)
{ {
s_radio.GetSpinelInterface().Update(*mainloop); s_radio.GetSpinelInterface().Update((void *)mainloop);
} }
void otPlatRadioGetIeeeEui64(otInstance *instance, uint8_t *ieee_eui64) void otPlatRadioGetIeeeEui64(otInstance *instance, uint8_t *ieee_eui64)

View File

@ -305,6 +305,9 @@ otError otPlatUdpConnect(otUdpSocket *udp_socket)
}; };
task.addr = map_openthread_addr_to_lwip_addr(&udp_socket->mPeerName.mAddress); task.addr = map_openthread_addr_to_lwip_addr(&udp_socket->mPeerName.mAddress);
if (ip_addr_isany_val(task.addr) && task.port == 0) {
return OT_ERROR_NONE;
}
tcpip_callback(udp_connect_task, &task); tcpip_callback(udp_connect_task, &task);
wait_for_task_notification(); wait_for_task_notification();

View File

@ -19,7 +19,7 @@
#include "hal/gpio_types.h" #include "hal/gpio_types.h"
#include "ncp/ncp_spi.hpp" #include "ncp/ncp_spi.hpp"
using ot::Ncp::SpiFrame; using ot::Spinel::SpiFrame;
using ot::Spinel::SpinelInterface; using ot::Spinel::SpinelInterface;
namespace esp { namespace esp {
@ -180,26 +180,26 @@ void SpiSpinelInterface::GpioIntrHandler(void *arg)
write(instance->m_event_fd, &event, sizeof(event)); write(instance->m_event_fd, &event, sizeof(event));
} }
void SpiSpinelInterface::Update(esp_openthread_mainloop_context_t &mainloop) void SpiSpinelInterface::Update(void *mainloop)
{ {
if (m_pending_data_len > 0) { if (m_pending_data_len > 0) {
mainloop.timeout.tv_sec = 0; ((esp_openthread_mainloop_context_t *)mainloop)->timeout.tv_sec = 0;
mainloop.timeout.tv_usec = 0; ((esp_openthread_mainloop_context_t *)mainloop)->timeout.tv_usec = 0;
} }
FD_SET(m_event_fd, &mainloop.read_fds); FD_SET(m_event_fd, &((esp_openthread_mainloop_context_t *)mainloop)->read_fds);
FD_SET(m_event_fd, &mainloop.error_fds); FD_SET(m_event_fd, &((esp_openthread_mainloop_context_t *)mainloop)->error_fds);
if (m_event_fd > mainloop.max_fd) { if (m_event_fd > ((esp_openthread_mainloop_context_t *)mainloop)->max_fd) {
mainloop.max_fd = m_event_fd; ((esp_openthread_mainloop_context_t *)mainloop)->max_fd = m_event_fd;
} }
} }
void SpiSpinelInterface::Process(const esp_openthread_mainloop_context_t &mainloop) void SpiSpinelInterface::Process(const void *mainloop)
{ {
if (FD_ISSET(m_event_fd, &mainloop.error_fds)) { if (FD_ISSET(m_event_fd, &((esp_openthread_mainloop_context_t *)mainloop)->error_fds)) {
ESP_LOGE(OT_PLAT_LOG_TAG, "SPI INTR GPIO error event"); ESP_LOGE(OT_PLAT_LOG_TAG, "SPI INTR GPIO error event");
return; return;
} }
if (FD_ISSET(m_event_fd, &mainloop.read_fds)) { if (FD_ISSET(m_event_fd, &((esp_openthread_mainloop_context_t *)mainloop)->read_fds)) {
uint64_t event; uint64_t event;
read(m_event_fd, &event, sizeof(event)); read(m_event_fd, &event, sizeof(event));
m_pending_data_len = SpinelInterface::kMaxFrameSize; m_pending_data_len = SpinelInterface::kMaxFrameSize;
@ -240,13 +240,14 @@ otError SpiSpinelInterface::WaitForFrame(uint64_t timeout_us)
return OT_ERROR_NONE; return OT_ERROR_NONE;
} }
void SpiSpinelInterface::OnRcpReset(void) otError SpiSpinelInterface::HardwareReset(void)
{ {
if (mRcpFailureHandler) { if (mRcpFailureHandler) {
mRcpFailureHandler(); mRcpFailureHandler();
ConductSPITransaction(true, 0, 0); // clear ConductSPITransaction(true, 0, 0); // clear
} }
return OT_ERROR_NONE;
}
} // namespace openthread } // namespace openthread
} // namespace esp } // namespace esp
}

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -69,7 +69,7 @@ esp_err_t UartSpinelInterface::Deinit(void)
otError UartSpinelInterface::SendFrame(const uint8_t *frame, uint16_t length) otError UartSpinelInterface::SendFrame(const uint8_t *frame, uint16_t length)
{ {
otError error = OT_ERROR_NONE; otError error = OT_ERROR_NONE;
ot::Hdlc::FrameBuffer<kMaxFrameSize> encoder_buffer; ot::Spinel::FrameBuffer<kMaxFrameSize> encoder_buffer;
ot::Hdlc::Encoder hdlc_encoder(encoder_buffer); ot::Hdlc::Encoder hdlc_encoder(encoder_buffer);
SuccessOrExit(error = hdlc_encoder.BeginFrame()); SuccessOrExit(error = hdlc_encoder.BeginFrame());
@ -88,21 +88,21 @@ exit:
return error; return error;
} }
void UartSpinelInterface::Process(const esp_openthread_mainloop_context_t &mainloop) void UartSpinelInterface::Process(const void *mainloop)
{ {
if (FD_ISSET(m_uart_fd, &mainloop.read_fds)) { if (FD_ISSET(m_uart_fd, &((esp_openthread_mainloop_context_t *)mainloop)->read_fds)) {
ESP_LOGD(OT_PLAT_LOG_TAG, "radio uart read event"); ESP_LOGD(OT_PLAT_LOG_TAG, "radio uart read event");
TryReadAndDecode(); TryReadAndDecode();
} }
} }
void UartSpinelInterface::Update(esp_openthread_mainloop_context_t &mainloop) void UartSpinelInterface::Update(void *mainloop)
{ {
// Register only READ events for radio UART and always wait // Register only READ events for radio UART and always wait
// for a radio WRITE to complete. // for a radio WRITE to complete.
FD_SET(m_uart_fd, &mainloop.read_fds); FD_SET(m_uart_fd, &((esp_openthread_mainloop_context_t *)mainloop)->read_fds);
if (m_uart_fd > mainloop.max_fd) { if (m_uart_fd > ((esp_openthread_mainloop_context_t *)mainloop)->max_fd) {
mainloop.max_fd = m_uart_fd; ((esp_openthread_mainloop_context_t *)mainloop)->max_fd = m_uart_fd;
} }
} }
@ -285,12 +285,13 @@ esp_err_t UartSpinelInterface::TryRecoverUart(void)
return ESP_OK; return ESP_OK;
} }
void UartSpinelInterface::OnRcpReset(void) otError UartSpinelInterface::HardwareReset(void)
{ {
if (mRcpFailureHandler) { if (mRcpFailureHandler) {
mRcpFailureHandler(); mRcpFailureHandler();
TryRecoverUart(); TryRecoverUart();
} }
return OT_ERROR_NONE;
} }
} // namespace openthread } // namespace openthread

View File

@ -363,10 +363,6 @@ def test_service_discovery_of_WiFi_device(Init_interface:bool, Init_avahi:bool,
ocf.execute_command(cli, command) ocf.execute_command(cli, command)
cli.expect('Done', timeout=5) cli.expect('Done', timeout=5)
ocf.wait(cli, 1) ocf.wait(cli, 1)
command = 'dns resolve FA000123.default.service.arpa.'
ocf.clean_buffer(cli)
ocf.execute_command(cli, command)
cli.expect('Error', timeout=15)
domain_name = ocf.get_domain() domain_name = ocf.get_domain()
print('domain name is: ', domain_name) print('domain name is: ', domain_name)
command = 'dns resolve ' + domain_name + '.default.service.arpa.' command = 'dns resolve ' + domain_name + '.default.service.arpa.'