Skip to content

Commit

Permalink
Merge branch 'feat/support_vendor_hook_for_rcp_spi' into 'master'
Browse files Browse the repository at this point in the history
feat(openthread): support vendor hook for rcp spi

Closes IDFGH-13771

See merge request espressif/esp-idf!33773
  • Loading branch information
zwx1995esp committed Sep 30, 2024
2 parents 76b3cf5 + 1c75f46 commit b835986
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 44 deletions.
7 changes: 7 additions & 0 deletions components/openthread/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ if(CONFIG_OPENTHREAD_ENABLED)
if(CONFIG_OPENTHREAD_NCP_VENDOR_HOOK)
list(APPEND src_dirs
"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()

if(NOT CONFIG_OPENTHREAD_DNS64_CLIENT)
Expand Down
5 changes: 1 addition & 4 deletions components/openthread/src/ncp/esp_openthread_ncp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "sdkconfig.h"
#include "esp_ieee802154.h"
#include "esp_openthread_ncp.h"
#include "ncp_base.hpp"

#if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK

#if CONFIG_OPENTHREAD_RCP_UART
#include "utils/uart.h"
#endif
Expand Down Expand Up @@ -107,5 +106,3 @@ otError NcpBase::VendorSetPropertyHandler(spinel_prop_key_t aPropKey)

} // namespace Ncp
} // namespace ot

#endif // #if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK
6 changes: 1 addition & 5 deletions components/openthread/src/ncp/esp_openthread_ncp_hdlc.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "common/new.hpp"
#include "ncp_hdlc.hpp"

#if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK

namespace ot {
namespace Ncp {

Expand All @@ -29,5 +27,3 @@ extern "C" void otNcpHdlcInit(otInstance *aInstance, otNcpHdlcSendCallback aSend

} // namespace Ncp
} // namespace ot

#endif // #if OPENTHREAD_ENABLE_NCP_VENDOR_HOOK
29 changes: 29 additions & 0 deletions components/openthread/src/ncp/esp_openthread_ncp_spi.cpp
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions examples/openthread/.build-test-rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ examples/openthread/ot_rcp:
enable:
- if: SOC_IEEE802154_SUPPORTED == 1
disable_test:
- if: IDF_TARGET not in ["esp32c6"]
reason: only test on esp32c6
- if: IDF_TARGET not in ["esp32h2", "esp32c6"]
reason: only test on esp32h2 and esp32c6
<<: *openthread_dependencies

examples/openthread/ot_sleepy_device/deep_sleep:
Expand Down
1 change: 1 addition & 0 deletions examples/openthread/ot_br/sdkconfig.ci.br_spi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_OPENTHREAD_RADIO_SPINEL_SPI=y
Empty file.
2 changes: 0 additions & 2 deletions examples/openthread/ot_cli/sdkconfig.ci.cli_c6

This file was deleted.

2 changes: 0 additions & 2 deletions examples/openthread/ot_cli/sdkconfig.ci.cli_h2

This file was deleted.

2 changes: 0 additions & 2 deletions examples/openthread/ot_cli/sdkconfig.ci.disable_cli
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
CONFIG_IDF_TARGET="esp32h2"
CONFIG_IDF_TARGET_ESP32H2=y
CONFIG_OPENTHREAD_CLI=n
CONFIG_OPENTHREAD_CLI_ESP_EXTENSION=n
1 change: 1 addition & 0 deletions examples/openthread/ot_rcp/sdkconfig.ci.rcp_spi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_OPENTHREAD_RCP_SPI=y
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
CONFIG_IDF_TARGET="esp32c6"
CONFIG_IDF_TARGET_ESP32C6=y
CONFIG_OPENTHREAD_NETWORK_CHANNEL=12
CONFIG_OPENTHREAD_NETWORK_MASTERKEY="aabbccddeeff00112233445566778899"
CONFIG_ESP_SLEEP_DEBUG=y
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
CONFIG_IDF_TARGET="esp32c6"

#
# Sleep Config
#
Expand Down

This file was deleted.

35 changes: 20 additions & 15 deletions examples/openthread/pytest_otbr.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,16 @@ def fixture_Init_interface() -> bool:
@pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize(
'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_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
'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,
)
Expand Down Expand Up @@ -161,7 +166,7 @@ def formBasicWiFiThreadNetwork(br:IdfDut, cli:IdfDut) -> None:
@pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize(
'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_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
Expand Down Expand Up @@ -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.parametrize(
'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_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
Expand Down Expand Up @@ -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.parametrize(
'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_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
Expand Down Expand Up @@ -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.parametrize(
'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_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
Expand Down Expand Up @@ -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.parametrize(
'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_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
Expand Down Expand Up @@ -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.parametrize(
'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_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
Expand Down Expand Up @@ -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.parametrize(
'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_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
Expand Down Expand Up @@ -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.parametrize(
'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_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
Expand Down Expand Up @@ -575,11 +580,11 @@ def test_TCP_NAT64(Init_interface:bool, dut: Tuple[IdfDut, IdfDut, IdfDut]) -> N
@pytest.mark.openthread_sleep
@pytest.mark.parametrize(
'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_sleepy_device/light_sleep")}',
'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_sleepy_device/light_sleep")}',
'esp32c6|esp32h2'),
Expand Down Expand Up @@ -627,7 +632,7 @@ def test_ot_sleepy_device(dut: Tuple[IdfDut, IdfDut]) -> None:
@pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize(
'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_br")}',
'esp32c6|esp32s3'),
Expand Down Expand Up @@ -666,7 +671,7 @@ def test_basic_startup(dut: Tuple[IdfDut, IdfDut]) -> None:
@pytest.mark.flaky(reruns=1, reruns_delay=1)
@pytest.mark.parametrize(
'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_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
Expand Down Expand Up @@ -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.parametrize(
'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_br")}',
'esp32c6|esp32s3'),
Expand Down Expand Up @@ -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.parametrize(
'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_cli")}'
f'|{os.path.join(os.path.dirname(__file__), "ot_br")}',
Expand Down

0 comments on commit b835986

Please sign in to comment.