From fb3d6549b82358e688ee869a9673aa7a021ebee2 Mon Sep 17 00:00:00 2001 From: LorenzoRai Date: Wed, 14 Jun 2023 15:43:03 +0200 Subject: [PATCH 1/5] Add support for RTT UART --- script/build | 14 +++++++++++++- script/test | 9 +++++++++ src/CMakeLists.txt | 16 ++++++++++------ src/src/system.c | 5 +++++ 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/script/build b/script/build index c6ce6e0a..d4d4e1f2 100755 --- a/script/build +++ b/script/build @@ -34,7 +34,7 @@ OT_CMAKE_NINJA_TARGET=${OT_CMAKE_NINJA_TARGET:-} NRF_PLATFORMS=(nrf52811 nrf52833 nrf52840) readonly NRF_PLATFORMS -NRF_BUILD_TYPES=(UART_trans USB_trans SPI_trans_NCP soft_crypto soft_crypto_threading) +NRF_BUILD_TYPES=(UART_trans USB_trans SPI_trans_NCP RTT_trans soft_crypto soft_crypto_threading) readonly NRF_BUILD_TYPES OT_SRCDIR="$(pwd)" @@ -107,6 +107,10 @@ main() OT_CMAKE_NINJA_TARGET=("ot-ncp-mtd" "ot-rcp") options+=("${local_options[@]}" "-DOT_NCP_SPI=ON") ;; + RTT_trans) + OT_CMAKE_NINJA_TARGET=("ot-cli-mtd" "ot-rcp") + options+=("${local_options[@]}" "-DOT_RTT_UART=ON") + ;; esac ;; nrf52833) @@ -122,6 +126,10 @@ main() OT_CMAKE_NINJA_TARGET=("ot-ncp-ftd" "ot-ncp-mtd" "ot-rcp") options+=("${local_options[@]}" "-DOT_NCP_SPI=ON") ;; + RTT_trans) + OT_CMAKE_NINJA_TARGET=("ot-cli-ftd" "ot-cli-mtd" "ot-rcp") + options+=("${local_options[@]}" "-DOT_RTT_UART=ON") + ;; esac ;; nrf52840) @@ -137,6 +145,10 @@ main() OT_CMAKE_NINJA_TARGET=("ot-ncp-ftd" "ot-ncp-mtd" "ot-rcp") options+=("${local_options[@]}" "-DOT_NCP_SPI=ON" "-DOT_EXTERNAL_MBEDTLS=nordicsemi-mbedtls") ;; + RTT_trans) + OT_CMAKE_NINJA_TARGET=("ot-cli-ftd" "ot-cli-mtd" "ot-rcp") + options+=("${local_options[@]}" "-DOT_RTT_UART=ON" "-DOT_EXTERNAL_MBEDTLS=nordicsemi-mbedtls") + ;; soft_crypto) options+=("${local_options[@]}") ;; diff --git a/script/test b/script/test index 935d0c06..aebe9d4a 100755 --- a/script/test +++ b/script/test @@ -68,6 +68,15 @@ main() rm -rf "$OT_BUILDDIR" "$(dirname "$0")"/build nrf52840 SPI_trans_NCP "${OT_OPTIONS[@]}" + rm -rf "$OT_BUILDDIR" + "$(dirname "$0")"/build nrf52811 RTT_trans "${OT_OPTIONS[@]}" + + rm -rf "$OT_BUILDDIR" + "$(dirname "$0")"/build nrf52833 RTT_trans "${OT_OPTIONS[@]}" + + rm -rf "$OT_BUILDDIR" + "$(dirname "$0")"/build nrf52840 RTT_trans "${OT_OPTIONS[@]}" + rm -rf "$OT_BUILDDIR" "$(dirname "$0")"/build nrf52840 soft_crypto "${OT_OPTIONS[@]}" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f3857a0a..c726380a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,14 +26,18 @@ # POSSIBILITY OF SUCH DAMAGE. # -if(OT_NCP_SPI) - list(APPEND OT_PLATFORM_DEFINES "SPIS_AS_SERIAL_TRANSPORT=1") +if(OT_RTT_UART) + list(APPEND OT_PLATFORM_DEFINES "OPENTHREAD_UART_RTT_ENABLE=1") else() - option(OT_USB "enable nrf USB as serial transport support") - if(OT_USB) - list(APPEND OT_PLATFORM_DEFINES "USB_CDC_AS_SERIAL_TRANSPORT=1") + if(OT_NCP_SPI) + list(APPEND OT_PLATFORM_DEFINES "SPIS_AS_SERIAL_TRANSPORT=1") else() - list(APPEND OT_PLATFORM_DEFINES "UART_AS_SERIAL_TRANSPORT=1") + option(OT_USB "enable nrf USB as serial transport support") + if(OT_USB) + list(APPEND OT_PLATFORM_DEFINES "USB_CDC_AS_SERIAL_TRANSPORT=1") + else() + list(APPEND OT_PLATFORM_DEFINES "UART_AS_SERIAL_TRANSPORT=1") + endif() endif() endif() diff --git a/src/src/system.c b/src/src/system.c index 0e49c447..c8cc957f 100644 --- a/src/src/system.c +++ b/src/src/system.c @@ -46,6 +46,8 @@ #include +#include + #if !OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT && PLATFORM_OPENTHREAD_VANILLA #include @@ -139,6 +141,9 @@ bool otSysPseudoResetWasRequested(void) void otSysProcessDrivers(otInstance *aInstance) { +#if OPENTHREAD_UART_RTT_ENABLE + utilsUartRttUpdate(); +#endif nrf5RadioProcess(aInstance); nrf5TransportProcess(); nrf5TempProcess(); From 1cefa38497e9b1750c8af56007da3d8e070c9f9f Mon Sep 17 00:00:00 2001 From: Lorenzo Rai Date: Wed, 16 Aug 2023 09:43:00 +0200 Subject: [PATCH 2/5] Update function name --- src/src/system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/src/system.c b/src/src/system.c index c8cc957f..17576b28 100644 --- a/src/src/system.c +++ b/src/src/system.c @@ -142,7 +142,7 @@ bool otSysPseudoResetWasRequested(void) void otSysProcessDrivers(otInstance *aInstance) { #if OPENTHREAD_UART_RTT_ENABLE - utilsUartRttUpdate(); + utilsUartRttProcess(); #endif nrf5RadioProcess(aInstance); nrf5TransportProcess(); From 14e3a334dadde0ec983354677bbb544c2aa1d382 Mon Sep 17 00:00:00 2001 From: Lorenzo Rai Date: Wed, 16 Aug 2023 11:01:38 +0200 Subject: [PATCH 3/5] Cleanup cmake file --- src/CMakeLists.txt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c726380a..fffb99b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,16 +28,14 @@ if(OT_RTT_UART) list(APPEND OT_PLATFORM_DEFINES "OPENTHREAD_UART_RTT_ENABLE=1") +elseif(OT_NCP_SPI) + list(APPEND OT_PLATFORM_DEFINES "SPIS_AS_SERIAL_TRANSPORT=1") else() - if(OT_NCP_SPI) - list(APPEND OT_PLATFORM_DEFINES "SPIS_AS_SERIAL_TRANSPORT=1") + option(OT_USB "enable nrf USB as serial transport support") + if(OT_USB) + list(APPEND OT_PLATFORM_DEFINES "USB_CDC_AS_SERIAL_TRANSPORT=1") else() - option(OT_USB "enable nrf USB as serial transport support") - if(OT_USB) - list(APPEND OT_PLATFORM_DEFINES "USB_CDC_AS_SERIAL_TRANSPORT=1") - else() - list(APPEND OT_PLATFORM_DEFINES "UART_AS_SERIAL_TRANSPORT=1") - endif() + list(APPEND OT_PLATFORM_DEFINES "UART_AS_SERIAL_TRANSPORT=1") endif() endif() From afaf3936cc9f97b3d3a44f78be492cbba3932fae Mon Sep 17 00:00:00 2001 From: Lorenzo Rai Date: Mon, 9 Oct 2023 06:29:39 +0200 Subject: [PATCH 4/5] Moved uartRTTProcess call --- src/src/system.c | 3 --- src/src/transport/transport.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/src/system.c b/src/src/system.c index 17576b28..597e9d6a 100644 --- a/src/src/system.c +++ b/src/src/system.c @@ -141,9 +141,6 @@ bool otSysPseudoResetWasRequested(void) void otSysProcessDrivers(otInstance *aInstance) { -#if OPENTHREAD_UART_RTT_ENABLE - utilsUartRttProcess(); -#endif nrf5RadioProcess(aInstance); nrf5TransportProcess(); nrf5TempProcess(); diff --git a/src/src/transport/transport.c b/src/src/transport/transport.c index 074be886..8949a760 100644 --- a/src/src/transport/transport.c +++ b/src/src/transport/transport.c @@ -82,6 +82,9 @@ void nrf5TransportProcess(void) #if (SPIS_AS_SERIAL_TRANSPORT == 1) nrf5SpiSlaveProcess(); #endif +#if (OPENTHREAD_UART_RTT_ENABLE == 1) + utilsUartRttProcess(); +#endif } bool nrf5TransportPseudoResetRequired(void) From 99443a0d68d7042c664de02516733ac9fe34eceb Mon Sep 17 00:00:00 2001 From: Lorenzo Rai Date: Mon, 9 Oct 2023 10:28:24 +0200 Subject: [PATCH 5/5] Fixed missing include and cleanup --- src/src/system.c | 2 -- src/src/transport/transport.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/src/system.c b/src/src/system.c index 597e9d6a..0e49c447 100644 --- a/src/src/system.c +++ b/src/src/system.c @@ -46,8 +46,6 @@ #include -#include - #if !OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT && PLATFORM_OPENTHREAD_VANILLA #include diff --git a/src/src/transport/transport.c b/src/src/transport/transport.c index 8949a760..c79df4d1 100644 --- a/src/src/transport/transport.c +++ b/src/src/transport/transport.c @@ -38,6 +38,8 @@ #include "transport-drivers.h" +#include "utils/uart_rtt.h" + void nrf5TransportInit(bool aPseudoReset) { OT_UNUSED_VARIABLE(aPseudoReset);