Skip to content

Commit 3230545

Browse files
committed
feat(mbedtls): upgrade to mbedtls v3.3.0
* upgrade to mbedtls v3.3.0 * minor fixes to all platforms * some cmake refactoring
1 parent 5007a09 commit 3230545

25 files changed

+348
-1702
lines changed

CMakeLists.txt

+29-6
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,23 @@ set(QORVO_PLATFORM_VALUES
3434
"qpg6105"
3535
"qpg7015m"
3636
)
37+
set(QORVO_MBEDTLS_USED
38+
"qpg6105"
39+
)
40+
3741
set_property(CACHE QORVO_PLATFORM PROPERTY STRINGS ${QORVO_PLATFORM_VALUES})
3842
if(NOT QORVO_PLATFORM IN_LIST QORVO_PLATFORM_VALUES)
3943
message(FATAL_ERROR "Please select a supported platform: ${QORVO_PLATFORM_VALUES}")
4044
endif()
4145

42-
set(OT_PLATFORM_LIB_FTD "openthread-${QORVO_PLATFORM}-ftd")
43-
set(OT_PLATFORM_LIB_MTD "openthread-${QORVO_PLATFORM}-mtd")
44-
set(OT_PLATFORM_LIB_RCP "openthread-${QORVO_PLATFORM}-ftd")
45-
set(OT_PLATFORM_LIB "openthread-${QORVO_PLATFORM}-ftd")
46-
46+
if (QORVO_PLATFORM IN_LIST QORVO_MBEDTLS_USED)
47+
set(OT_BUILTIN_MBEDTLS_MANAGEMENT OFF CACHE BOOL "disable builtin mbedtls management" FORCE)
48+
set(OT_EXTERNAL_MBEDTLS "qorvo-mbedtls" CACHE STRING "use qorvo mbedtls" FORCE)
49+
set(OT_MBEDTLS ${OT_EXTERNAL_MBEDTLS})
50+
set(QORVO_MBEDTLS 1)
51+
else()
52+
set(QORVO_MBEDTLS 0)
53+
endif()
4754

4855
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
4956
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
@@ -53,15 +60,31 @@ if (DEFINED ENV{QORVO_OT_SDK})
5360
SET(SDK_DIR "$ENV{QORVO_OT_SDK}")
5461
else()
5562
SET(SDK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/Qorvo/repo")
63+
if(NOT EXISTS ${SDK_DIR}/${QORVO_PLATFORM})
64+
message(FATAL_ERROR "Please select a correct SDK directory: ${SDK_DIR}/${QORVO_PLATFORM} does not exist")
65+
endif()
5666
endif()
5767

68+
set(PLATFORM_TARGET_FTD "openthread-${QORVO_PLATFORM}-ftd")
69+
set(PLATFORM_DRIVER_FTD "${QORVO_PLATFORM}-driver-ftd")
70+
set(OT_PLATFORM_LIB_FTD "${PLATFORM_TARGET_FTD}")
71+
72+
set(PLATFORM_TARGET_MTD "openthread-${QORVO_PLATFORM}-mtd")
73+
set(PLATFORM_DRIVER_MTD "${QORVO_PLATFORM}-driver-mtd")
74+
set(OT_PLATFORM_LIB_MTD "${PLATFORM_TARGET_MTD}")
75+
76+
set(PLATFORM_TARGET_RCP "openthread-${QORVO_PLATFORM}-ftd")
77+
set(PLATFORM_DRIVER_RCP "${QORVO_PLATFORM}-driver-ftd")
78+
set(OT_PLATFORM_LIB_RCP "${PLATFORM_TARGET_RCP}")
79+
5880
include("${PROJECT_SOURCE_DIR}/etc/options.cmake")
5981

6082
set(OPENTHREAD_DIR ${PROJECT_SOURCE_DIR}/openthread)
6183
add_subdirectory(${OPENTHREAD_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
6284

6385
target_compile_definitions(ot-config INTERFACE
64-
OPENTHREAD_PLATFORM_CORE_CONFIG_FILE="openthread-core-${QORVO_PLATFORM}-config.h"
86+
OPENTHREAD_CONFIG_FILE="openthread-core-${QORVO_PLATFORM}-config.h"
87+
OPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-${QORVO_PLATFORM}-config.h"
6588
OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE="openthread-core-${QORVO_PLATFORM}-config-check.h"
6689
)
6790

etc/options.cmake

+6
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ endif()
3434

3535
# Uart transport option
3636
option(OT_QORVO_SOCKET "enable socket interface for uart transport on RPi based platforms" OFF)
37+
38+
# Number of supported children
39+
option(OT_QORVO_SUPPORTED_CHILDREN "The amount of children supported on the platform" OFF)
40+
if (OT_QORVO_SUPPORTED_CHILDREN)
41+
add_definitions(-DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=${OT_QORVO_SUPPORTED_CHILDREN})
42+
endif()

script/build

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ main()
9797

9898
case "${platform}" in
9999
qpg6105)
100-
find "${builddir}/bin" -type f -executable -not -name '*.*' -not -name "${platform}-*" \
100+
find "${builddir}/bin" -type f -executable -not -name '*.*' -not -name "${platform}-*" -not -name "*-test-*" \
101101
-execdir sh -c 'x="$1"; arm-none-eabi-objcopy -O ihex "$1" "$2-$(basename ${x}).hex"' _ {} "${platform}" \;
102102
;;
103103
esac
104-
find "${builddir}/bin" -type f -executable -not -name '*.*' -not -name "${platform}-*" \
104+
find "${builddir}/bin" -type f -executable -not -name '*.*' -not -name "${platform}-*" -not -name "*-test-*" \
105105
-execdir sh -c 'x="$1"; mv "$x" "$2-$(basename ${x}).elf"' _ {} "${platform}" \;
106106
}
107107

src/gp712/CMakeLists.txt

+17-27
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ list(APPEND OT_PLATFORM_DEFINES
3232
)
3333

3434
target_compile_definitions(ot-config INTERFACE
35-
"MBEDTLS_USER_CONFIG_FILE=\"gp712-mbedtls-config.h\""
35+
"MBEDTLS_USER_CONFIG_FILE=\"${QORVO_PLATFORM}-mbedtls-config.h\""
3636
)
3737

3838
list(APPEND OT_PUBLIC_INCLUDES
@@ -43,14 +43,6 @@ set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
4343

4444
set(OT_PUBLIC_INCLUDES ${OT_PUBLIC_INCLUDES} PARENT_SCOPE)
4545

46-
if(OT_CFLAGS MATCHES "-pedantic-errors")
47-
string(REPLACE "-pedantic-errors" "" OT_CFLAGS "${OT_CFLAGS}")
48-
endif()
49-
50-
if(OT_CFLAGS MATCHES "-Wno-c\\+\\+14-compat")
51-
string(REPLACE "-Wno-c++14-compat" "" OT_CFLAGS "${OT_CFLAGS}")
52-
endif()
53-
5446
set(PLATFORM_SOURCES
5547
alarm.c
5648
diag.c
@@ -72,22 +64,21 @@ else()
7264
)
7365
endif()
7466

75-
add_library(openthread-gp712-ftd
67+
add_library(${PLATFORM_TARGET_FTD}
7668
STATIC
7769
${PLATFORM_SOURCES}
7870
)
7971

80-
set_target_properties(
81-
openthread-gp712-ftd
72+
set_target_properties(${PLATFORM_TARGET_FTD}
8273
PROPERTIES
8374
C_STANDARD 99
84-
CXX_STANDARD 11
75+
CXX_STANDARD 14
8576
)
8677

87-
target_link_libraries(openthread-gp712-ftd
78+
target_link_libraries(${PLATFORM_TARGET_FTD}
8879
PRIVATE
8980
-Wl,--start-group
90-
gp712-driver-ftd
81+
${PLATFORM_DRIVER_FTD}
9182
${OT_MBEDTLS}
9283
ot-config
9384
-Wl,--end-group
@@ -98,38 +89,37 @@ target_link_libraries(openthread-gp712-ftd
9889
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
9990
)
10091

101-
target_compile_definitions(openthread-gp712-ftd
92+
target_compile_definitions(${PLATFORM_TARGET_FTD}
10293
PUBLIC
10394
${OT_PLATFORM_DEFINES}
10495
)
10596

106-
target_compile_options(openthread-gp712-ftd
97+
target_compile_options(${PLATFORM_TARGET_FTD}
10798
PRIVATE
10899
${OT_CFLAGS}
109100
)
110101

111-
target_include_directories(openthread-gp712-ftd
102+
target_include_directories(${PLATFORM_TARGET_FTD}
112103
PRIVATE
113104
${OT_PUBLIC_INCLUDES}
114105
${OPENTHREAD_DIR}/examples/platforms
115106
)
116107

117-
add_library(openthread-gp712-mtd
108+
add_library(${PLATFORM_TARGET_MTD}
118109
STATIC
119110
${PLATFORM_SOURCES}
120111
)
121112

122-
set_target_properties(
123-
openthread-gp712-mtd
113+
set_target_properties(${PLATFORM_TARGET_MTD}
124114
PROPERTIES
125115
C_STANDARD 99
126-
CXX_STANDARD 11
116+
CXX_STANDARD 14
127117
)
128118

129-
target_link_libraries(openthread-gp712-mtd
119+
target_link_libraries(${PLATFORM_TARGET_MTD}
130120
PRIVATE
131121
-Wl,--start-group
132-
gp712-driver-mtd
122+
${PLATFORM_DRIVER_MTD}
133123
${OT_MBEDTLS}
134124
ot-config
135125
-Wl,--end-group
@@ -140,17 +130,17 @@ target_link_libraries(openthread-gp712-mtd
140130
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
141131
)
142132

143-
target_compile_definitions(openthread-gp712-mtd
133+
target_compile_definitions(${PLATFORM_TARGET_MTD}
144134
PUBLIC
145135
${OT_PLATFORM_DEFINES}
146136
)
147137

148-
target_compile_options(openthread-gp712-mtd
138+
target_compile_options(${PLATFORM_TARGET_MTD}
149139
PRIVATE
150140
${OT_CFLAGS}
151141
)
152142

153-
target_include_directories(openthread-gp712-mtd
143+
target_include_directories(${PLATFORM_TARGET_MTD}
154144
PRIVATE
155145
${OT_PUBLIC_INCLUDES}
156146
${OPENTHREAD_DIR}/examples/platforms

src/gp712/openthread-core-gp712-config.h

-10
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,4 @@
116116
#define OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE (2048 * sizeof(void *))
117117
#endif
118118

119-
/**
120-
* @def OPENTHREAD_CONFIG_TLS_ENABLE
121-
*
122-
* Define as 1 to enable support for TLS over TCP.
123-
*
124-
*/
125-
#ifndef OPENTHREAD_CONFIG_TLS_ENABLE
126-
#define OPENTHREAD_CONFIG_TLS_ENABLE 0
127-
#endif
128-
129119
#endif // OPENTHREAD_CORE_GP712_CONFIG_H_

src/gp712/radio.c

+19-14
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,24 @@
3636

3737
#include <openthread/platform/diag.h>
3838
#include <openthread/platform/radio.h>
39+
#include <openthread/platform/time.h>
3940

4041
#include "utils/code_utils.h"
4142

4243
#include "radio_qorvo.h"
4344

44-
#define QPG_RECEIVE_SENSITIVITY -100 // dBm
45-
46-
#define IEEE802154_MIN_LENGTH 5
47-
#define IEEE802154_MAX_LENGTH 127
48-
#define IEEE802154_ACK_LENGTH 5
49-
#define IEEE802154_FRAME_TYPE_MASK 0x7
50-
#define IEEE802154_FRAME_TYPE_ACK 0x2
51-
#define IEEE802154_FRAME_PENDING 1 << 4
52-
#define IEEE802154_ACK_REQUEST 1 << 5
53-
#define IEEE802154_DSN_OFFSET 2
45+
enum
46+
{
47+
QPG_RECEIVE_SENSITIVITY = -100, // [dBm]
48+
};
5449

55-
#define QORVO_RSSI_OFFSET 73
56-
#define QORVO_CRC_BIT_MASK 0x80
57-
#define QORVO_LQI_BIT_MASK 0x7f
50+
enum
51+
{
52+
IEEE802154_ACK_LENGTH = 5,
53+
IEEE802154_FRAME_TYPE_ACK = 0x2,
54+
IEEE802154_FRAME_PENDING = 1 << 4,
55+
IEEE802154_DSN_OFFSET = 2,
56+
};
5857

5958
extern otRadioFrame sTransmitFrame;
6059

@@ -225,6 +224,12 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
225224
qorvoRadioSetPromiscuous(aEnable);
226225
}
227226

227+
uint64_t otPlatTimeGet(void)
228+
{
229+
// required for RCP/spinel
230+
return qorvoRadioGetNow();
231+
}
232+
228233
uint32_t otPlatRadioGetBusSpeed(otInstance *aInstance)
229234
{
230235
OT_UNUSED_VARIABLE(aInstance);
@@ -360,7 +365,7 @@ void cbQorvoRadioTransmitDone(otRadioFrame *aFrame, bool aFramePending, otError
360365
ackFrame.mPsdu[1] = 0;
361366
ackFrame.mPsdu[2] = aFrame->mPsdu[IEEE802154_DSN_OFFSET];
362367

363-
otPlatRadioTxDone(pQorvoInstance, aFrame, &ackFrame, aError);
368+
otPlatRadioTxDone(pQorvoInstance, aFrame, (aError == OT_ERROR_NONE) ? &ackFrame : NULL, aError);
364369
}
365370

366371
int8_t otPlatRadioGetRssi(otInstance *aInstance)

src/gp712/uart-posix.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static void cbKeyPressed(uint8_t Param)
7979
{
8080
OT_UNUSED_VARIABLE(Param);
8181

82-
qorvoAlarmScheduleEventArg(0, platformDummy, (void *)&s_in_fd);
82+
qorvoAlarmMilliStart(0, platformDummy, (void *)&s_in_fd);
8383
}
8484

8585
void platformUartRestore(void)
@@ -216,7 +216,7 @@ otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
216216
s_write_buffer = aBuf;
217217
s_write_length = aBufLength;
218218

219-
qorvoAlarmScheduleEventArg(0, platformDummy, (void *)&s_in_fd);
219+
qorvoAlarmMilliStart(0, platformDummy, (void *)&s_in_fd);
220220

221221
exit:
222222
return error;

0 commit comments

Comments
 (0)