feat(openthread): support vendor hook for rcp spi

This commit is contained in:
Xu Si Yu
2024-09-24 10:35:54 +08:00
committed by zwx
parent 0e883d99ff
commit 38f024681c
17 changed files with 62 additions and 45 deletions

View File

@ -154,6 +154,13 @@ if(CONFIG_OPENTHREAD_ENABLED)
if(CONFIG_OPENTHREAD_NCP_VENDOR_HOOK) if(CONFIG_OPENTHREAD_NCP_VENDOR_HOOK)
list(APPEND src_dirs list(APPEND src_dirs
"src/ncp") "src/ncp")
if(CONFIG_OPENTHREAD_RCP_UART)
list(APPEND exclude_srcs
"src/ncp/esp_openthread_ncp_spi.cpp")
elseif(CONFIG_OPENTHREAD_RCP_SPI)
list(APPEND exclude_srcs
"src/ncp/esp_openthread_ncp_hdlc.cpp")
endif()
endif() endif()
if(NOT CONFIG_OPENTHREAD_DNS64_CLIENT) if(NOT CONFIG_OPENTHREAD_DNS64_CLIENT)

View File

@ -4,12 +4,11 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
#include "sdkconfig.h"
#include "esp_ieee802154.h" #include "esp_ieee802154.h"
#include "esp_openthread_ncp.h" #include "esp_openthread_ncp.h"
#include "ncp_base.hpp" #include "ncp_base.hpp"
#if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK
#if CONFIG_OPENTHREAD_RCP_UART #if CONFIG_OPENTHREAD_RCP_UART
#include "utils/uart.h" #include "utils/uart.h"
#endif #endif
@ -107,5 +106,3 @@ otError NcpBase::VendorSetPropertyHandler(spinel_prop_key_t aPropKey)
} // namespace Ncp } // namespace Ncp
} // namespace ot } // namespace ot
#endif // #if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@ -7,8 +7,6 @@
#include "common/new.hpp" #include "common/new.hpp"
#include "ncp_hdlc.hpp" #include "ncp_hdlc.hpp"
#if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK
namespace ot { namespace ot {
namespace Ncp { namespace Ncp {
@ -29,5 +27,3 @@ extern "C" void otNcpHdlcInit(otInstance *aInstance, otNcpHdlcSendCallback aSend
} // namespace Ncp } // namespace Ncp
} // namespace ot } // namespace ot
#endif // #if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK

View File

@ -0,0 +1,29 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "common/new.hpp"
#include "ncp_spi.hpp"
namespace ot {
namespace Ncp {
static OT_DEFINE_ALIGNED_VAR(sNcpRaw, sizeof(NcpSpi), uint64_t);
extern "C" void otNcpSpiInit(otInstance *aInstance)
{
NcpSpi *ncpSpi = nullptr;
Instance *instance = static_cast<Instance *>(aInstance);
ncpSpi = new (&sNcpRaw) NcpSpi(instance);
if (ncpSpi == nullptr || ncpSpi != NcpBase::GetNcpInstance())
{
OT_ASSERT(false);
}
}
} // namespace Ncp
} // namespace ot

View File

@ -36,9 +36,8 @@ examples/openthread/ot_rcp:
enable: enable:
- if: SOC_IEEE802154_SUPPORTED == 1 - if: SOC_IEEE802154_SUPPORTED == 1
disable_test: disable_test:
- if: IDF_TARGET == "esp32h2" - if: IDF_TARGET not in ["esp32h2", "esp32c6"]
temporary: true reason: only test on esp32h2 and esp32c6
reason: only test on esp32c6
<<: *openthread_dependencies <<: *openthread_dependencies
examples/openthread/ot_sleepy_device/deep_sleep: examples/openthread/ot_sleepy_device/deep_sleep:

View File

@ -0,0 +1 @@
CONFIG_OPENTHREAD_RADIO_SPINEL_SPI=y

View File

@ -1,2 +0,0 @@
CONFIG_IDF_TARGET="esp32c6"
CONFIG_IDF_TARGET_ESP32C6=y

View File

@ -1,2 +0,0 @@
CONFIG_IDF_TARGET="esp32h2"
CONFIG_IDF_TARGET_ESP32H2=y

View File

@ -1,4 +1,2 @@
CONFIG_IDF_TARGET="esp32h2"
CONFIG_IDF_TARGET_ESP32H2=y
CONFIG_OPENTHREAD_CLI=n CONFIG_OPENTHREAD_CLI=n
CONFIG_OPENTHREAD_CLI_ESP_EXTENSION=n CONFIG_OPENTHREAD_CLI_ESP_EXTENSION=n

View File

@ -0,0 +1 @@
CONFIG_OPENTHREAD_RCP_SPI=y

View File

@ -1,5 +1,3 @@
CONFIG_IDF_TARGET="esp32c6"
CONFIG_IDF_TARGET_ESP32C6=y
CONFIG_OPENTHREAD_NETWORK_CHANNEL=12 CONFIG_OPENTHREAD_NETWORK_CHANNEL=12
CONFIG_OPENTHREAD_NETWORK_MASTERKEY="aabbccddeeff00112233445566778899" CONFIG_OPENTHREAD_NETWORK_MASTERKEY="aabbccddeeff00112233445566778899"
CONFIG_ESP_SLEEP_DEBUG=y CONFIG_ESP_SLEEP_DEBUG=y

View File

@ -1,7 +0,0 @@
CONFIG_IDF_TARGET="esp32h2"
CONFIG_IDF_TARGET_ESP32H2=y
CONFIG_OPENTHREAD_NETWORK_CHANNEL=12
CONFIG_OPENTHREAD_NETWORK_MASTERKEY="aabbccddeeff00112233445566778899"
CONFIG_ESP_SLEEP_DEBUG=y
CONFIG_LOG_MAXIMUM_LEVEL_DEBUG=y
CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y

View File

@ -1,5 +1,3 @@
CONFIG_IDF_TARGET="esp32c6"
# #
# Sleep Config # Sleep Config
# #

View File

@ -1 +0,0 @@
CONFIG_IDF_TARGET="esp32h2"

View File

@ -91,11 +91,16 @@ default_cli_ot_para = ocf.thread_parameter('router', '', '', '', False)
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|cli_h2|br', 3, ('rcp_uart|cli|br', 3,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
'esp32c6|esp32h2|esp32s3'), 'esp32c6|esp32h2|esp32s3'),
('rcp_spi|cli|br_spi', 3,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
'esp32h2|esp32c6|esp32s3'),
], ],
indirect=True, indirect=True,
) )
@ -161,7 +166,7 @@ def formBasicWiFiThreadNetwork(br:IdfDut, cli:IdfDut) -> None:
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|cli_h2|br', 3, ('rcp_uart|cli|br', 3,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
@ -210,7 +215,7 @@ def test_Bidirectional_IPv6_connectivity(Init_interface:bool, dut: Tuple[IdfDut,
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|cli_h2|br', 3, ('rcp_uart|cli|br', 3,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
@ -260,7 +265,7 @@ def test_multicast_forwarding_A(Init_interface:bool, dut: Tuple[IdfDut, IdfDut,
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|cli_h2|br', 3, ('rcp_uart|cli|br', 3,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
@ -311,7 +316,7 @@ def test_multicast_forwarding_B(Init_interface:bool, dut: Tuple[IdfDut, IdfDut,
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|cli_h2|br', 3, ('rcp_uart|cli|br', 3,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
@ -367,7 +372,7 @@ def test_service_discovery_of_Thread_device(Init_interface:bool, Init_avahi:bool
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|cli_h2|br', 3, ('rcp_uart|cli|br', 3,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
@ -430,7 +435,7 @@ def test_service_discovery_of_WiFi_device(Init_interface:bool, Init_avahi:bool,
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|cli_h2|br', 3, ('rcp_uart|cli|br', 3,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
@ -465,7 +470,7 @@ def test_ICMP_NAT64(Init_interface:bool, dut: Tuple[IdfDut, IdfDut, IdfDut]) ->
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|cli_h2|br', 3, ('rcp_uart|cli|br', 3,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
@ -518,7 +523,7 @@ def test_UDP_NAT64(Init_interface:bool, dut: Tuple[IdfDut, IdfDut, IdfDut]) -> N
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|cli_h2|br', 3, ('rcp_uart|cli|br', 3,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
@ -575,11 +580,11 @@ def test_TCP_NAT64(Init_interface:bool, dut: Tuple[IdfDut, IdfDut, IdfDut]) -> N
@pytest.mark.openthread_sleep @pytest.mark.openthread_sleep
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('cli_h2|sleepy_c6', 2, ('cli|sleepy', 2,
f'{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_sleepy_device/light_sleep")}', f'|{os.path.join(os.path.dirname(__file__), "ot_sleepy_device/light_sleep")}',
'esp32h2|esp32c6'), 'esp32h2|esp32c6'),
('cli_c6|sleepy_h2', 2, ('cli|sleepy', 2,
f'{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_sleepy_device/light_sleep")}', f'|{os.path.join(os.path.dirname(__file__), "ot_sleepy_device/light_sleep")}',
'esp32c6|esp32h2'), 'esp32c6|esp32h2'),
@ -627,7 +632,7 @@ def test_ot_sleepy_device(dut: Tuple[IdfDut, IdfDut]) -> None:
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|br', 2, ('rcp_uart|br', 2,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
'esp32c6|esp32s3'), 'esp32c6|esp32s3'),
@ -666,7 +671,7 @@ def test_basic_startup(dut: Tuple[IdfDut, IdfDut]) -> None:
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|cli_h2|br', 3, ('rcp_uart|cli|br', 3,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
@ -703,7 +708,7 @@ def test_NAT64_DNS(Init_interface:bool, dut: Tuple[IdfDut, IdfDut, IdfDut]) -> N
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|br', 2, ('rcp_uart|br', 2,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
'esp32c6|esp32s3'), 'esp32c6|esp32s3'),
@ -761,7 +766,7 @@ def test_br_meshcop(Init_interface:bool, Init_avahi:bool, dut: Tuple[IdfDut, Idf
@pytest.mark.flaky(reruns=1, reruns_delay=1) @pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config, count, app_path, target', [ 'config, count, app_path, target', [
('rcp|cli_h2|br', 3, ('rcp_uart|cli|br', 3,
f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}' f'{os.path.join(os.path.dirname(__file__), "ot_rcp")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}' f'|{os.path.join(os.path.dirname(__file__), "ot_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}', f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',