Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mbedtls] add support for mbedtls 3.3.0 #672

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,23 @@ set(QORVO_PLATFORM_VALUES
"qpg6105"
"qpg7015m"
)
set(QORVO_MBEDTLS_USED
"qpg6105"
)

set_property(CACHE QORVO_PLATFORM PROPERTY STRINGS ${QORVO_PLATFORM_VALUES})
if(NOT QORVO_PLATFORM IN_LIST QORVO_PLATFORM_VALUES)
message(FATAL_ERROR "Please select a supported platform: ${QORVO_PLATFORM_VALUES}")
endif()

set(OT_PLATFORM_LIB_FTD "openthread-${QORVO_PLATFORM}-ftd")
set(OT_PLATFORM_LIB_MTD "openthread-${QORVO_PLATFORM}-mtd")
set(OT_PLATFORM_LIB_RCP "openthread-${QORVO_PLATFORM}-ftd")
set(OT_PLATFORM_LIB "openthread-${QORVO_PLATFORM}-ftd")

if (QORVO_PLATFORM IN_LIST QORVO_MBEDTLS_USED)
set(OT_BUILTIN_MBEDTLS_MANAGEMENT OFF CACHE BOOL "disable builtin mbedtls management" FORCE)
set(OT_EXTERNAL_MBEDTLS "qorvo-mbedtls" CACHE STRING "use qorvo mbedtls" FORCE)
set(OT_MBEDTLS ${OT_EXTERNAL_MBEDTLS})
set(QORVO_MBEDTLS 1)
else()
set(QORVO_MBEDTLS 0)
endif()

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
Expand All @@ -53,15 +60,31 @@ if (DEFINED ENV{QORVO_OT_SDK})
SET(SDK_DIR "$ENV{QORVO_OT_SDK}")
else()
SET(SDK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/Qorvo/repo")
if(NOT EXISTS ${SDK_DIR}/${QORVO_PLATFORM})
message(FATAL_ERROR "Please select a correct SDK directory: ${SDK_DIR}/${QORVO_PLATFORM} does not exist")
endif()
endif()

set(PLATFORM_TARGET_FTD "openthread-${QORVO_PLATFORM}-ftd")
set(PLATFORM_DRIVER_FTD "${QORVO_PLATFORM}-driver-ftd")
set(OT_PLATFORM_LIB_FTD "${PLATFORM_TARGET_FTD}")

set(PLATFORM_TARGET_MTD "openthread-${QORVO_PLATFORM}-mtd")
set(PLATFORM_DRIVER_MTD "${QORVO_PLATFORM}-driver-mtd")
set(OT_PLATFORM_LIB_MTD "${PLATFORM_TARGET_MTD}")

set(PLATFORM_TARGET_RCP "openthread-${QORVO_PLATFORM}-ftd")
set(PLATFORM_DRIVER_RCP "${QORVO_PLATFORM}-driver-ftd")
set(OT_PLATFORM_LIB_RCP "${PLATFORM_TARGET_RCP}")

include("${PROJECT_SOURCE_DIR}/etc/options.cmake")

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

target_compile_definitions(ot-config INTERFACE
OPENTHREAD_PLATFORM_CORE_CONFIG_FILE="openthread-core-${QORVO_PLATFORM}-config.h"
OPENTHREAD_CONFIG_FILE="openthread-core-${QORVO_PLATFORM}-config.h"
OPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-${QORVO_PLATFORM}-config.h"
OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE="openthread-core-${QORVO_PLATFORM}-config-check.h"
)

Expand Down
6 changes: 6 additions & 0 deletions etc/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ endif()

# Uart transport option
option(OT_QORVO_SOCKET "enable socket interface for uart transport on RPi based platforms" OFF)

# Number of supported children
option(OT_QORVO_SUPPORTED_CHILDREN "The amount of children supported on the platform" OFF)
if (OT_QORVO_SUPPORTED_CHILDREN)
add_definitions(-DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=${OT_QORVO_SUPPORTED_CHILDREN})
endif()
4 changes: 2 additions & 2 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ main()

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

Expand Down
44 changes: 17 additions & 27 deletions src/gp712/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ list(APPEND OT_PLATFORM_DEFINES
)

target_compile_definitions(ot-config INTERFACE
"MBEDTLS_USER_CONFIG_FILE=\"gp712-mbedtls-config.h\""
"MBEDTLS_USER_CONFIG_FILE=\"${QORVO_PLATFORM}-mbedtls-config.h\""
)

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

set(OT_PUBLIC_INCLUDES ${OT_PUBLIC_INCLUDES} PARENT_SCOPE)

if(OT_CFLAGS MATCHES "-pedantic-errors")
string(REPLACE "-pedantic-errors" "" OT_CFLAGS "${OT_CFLAGS}")
endif()

if(OT_CFLAGS MATCHES "-Wno-c\\+\\+14-compat")
string(REPLACE "-Wno-c++14-compat" "" OT_CFLAGS "${OT_CFLAGS}")
endif()

set(PLATFORM_SOURCES
alarm.c
diag.c
Expand All @@ -72,22 +64,21 @@ else()
)
endif()

add_library(openthread-gp712-ftd
add_library(${PLATFORM_TARGET_FTD}
STATIC
${PLATFORM_SOURCES}
)

set_target_properties(
openthread-gp712-ftd
set_target_properties(${PLATFORM_TARGET_FTD}
PROPERTIES
C_STANDARD 99
CXX_STANDARD 11
CXX_STANDARD 14
)

target_link_libraries(openthread-gp712-ftd
target_link_libraries(${PLATFORM_TARGET_FTD}
PRIVATE
-Wl,--start-group
gp712-driver-ftd
${PLATFORM_DRIVER_FTD}
${OT_MBEDTLS}
ot-config
-Wl,--end-group
Expand All @@ -98,38 +89,37 @@ target_link_libraries(openthread-gp712-ftd
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
)

target_compile_definitions(openthread-gp712-ftd
target_compile_definitions(${PLATFORM_TARGET_FTD}
PUBLIC
${OT_PLATFORM_DEFINES}
)

target_compile_options(openthread-gp712-ftd
target_compile_options(${PLATFORM_TARGET_FTD}
PRIVATE
${OT_CFLAGS}
)

target_include_directories(openthread-gp712-ftd
target_include_directories(${PLATFORM_TARGET_FTD}
PRIVATE
${OT_PUBLIC_INCLUDES}
${OPENTHREAD_DIR}/examples/platforms
)

add_library(openthread-gp712-mtd
add_library(${PLATFORM_TARGET_MTD}
STATIC
${PLATFORM_SOURCES}
)

set_target_properties(
openthread-gp712-mtd
set_target_properties(${PLATFORM_TARGET_MTD}
PROPERTIES
C_STANDARD 99
CXX_STANDARD 11
CXX_STANDARD 14
)

target_link_libraries(openthread-gp712-mtd
target_link_libraries(${PLATFORM_TARGET_MTD}
PRIVATE
-Wl,--start-group
gp712-driver-mtd
${PLATFORM_DRIVER_MTD}
${OT_MBEDTLS}
ot-config
-Wl,--end-group
Expand All @@ -140,17 +130,17 @@ target_link_libraries(openthread-gp712-mtd
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
)

target_compile_definitions(openthread-gp712-mtd
target_compile_definitions(${PLATFORM_TARGET_MTD}
PUBLIC
${OT_PLATFORM_DEFINES}
)

target_compile_options(openthread-gp712-mtd
target_compile_options(${PLATFORM_TARGET_MTD}
PRIVATE
${OT_CFLAGS}
)

target_include_directories(openthread-gp712-mtd
target_include_directories(${PLATFORM_TARGET_MTD}
PRIVATE
${OT_PUBLIC_INCLUDES}
${OPENTHREAD_DIR}/examples/platforms
Expand Down
10 changes: 0 additions & 10 deletions src/gp712/openthread-core-gp712-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,4 @@
#define OPENTHREAD_CONFIG_HEAP_INTERNAL_SIZE (2048 * sizeof(void *))
#endif

/**
* @def OPENTHREAD_CONFIG_TLS_ENABLE
*
* Define as 1 to enable support for TLS over TCP.
*
*/
#ifndef OPENTHREAD_CONFIG_TLS_ENABLE
#define OPENTHREAD_CONFIG_TLS_ENABLE 0
#endif

#endif // OPENTHREAD_CORE_GP712_CONFIG_H_
33 changes: 19 additions & 14 deletions src/gp712/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,24 @@

#include <openthread/platform/diag.h>
#include <openthread/platform/radio.h>
#include <openthread/platform/time.h>

#include "utils/code_utils.h"

#include "radio_qorvo.h"

#define QPG_RECEIVE_SENSITIVITY -100 // dBm

#define IEEE802154_MIN_LENGTH 5
#define IEEE802154_MAX_LENGTH 127
#define IEEE802154_ACK_LENGTH 5
#define IEEE802154_FRAME_TYPE_MASK 0x7
#define IEEE802154_FRAME_TYPE_ACK 0x2
#define IEEE802154_FRAME_PENDING 1 << 4
#define IEEE802154_ACK_REQUEST 1 << 5
#define IEEE802154_DSN_OFFSET 2
enum
{
QPG_RECEIVE_SENSITIVITY = -100, // [dBm]
};

#define QORVO_RSSI_OFFSET 73
#define QORVO_CRC_BIT_MASK 0x80
#define QORVO_LQI_BIT_MASK 0x7f
enum
{
IEEE802154_ACK_LENGTH = 5,
IEEE802154_FRAME_TYPE_ACK = 0x2,
IEEE802154_FRAME_PENDING = 1 << 4,
IEEE802154_DSN_OFFSET = 2,
};

extern otRadioFrame sTransmitFrame;

Expand Down Expand Up @@ -225,6 +224,12 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
qorvoRadioSetPromiscuous(aEnable);
}

uint64_t otPlatTimeGet(void)
{
// required for RCP/spinel
return qorvoRadioGetNow();
}

uint32_t otPlatRadioGetBusSpeed(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
Expand Down Expand Up @@ -360,7 +365,7 @@ void cbQorvoRadioTransmitDone(otRadioFrame *aFrame, bool aFramePending, otError
ackFrame.mPsdu[1] = 0;
ackFrame.mPsdu[2] = aFrame->mPsdu[IEEE802154_DSN_OFFSET];

otPlatRadioTxDone(pQorvoInstance, aFrame, &ackFrame, aError);
otPlatRadioTxDone(pQorvoInstance, aFrame, (aError == OT_ERROR_NONE) ? &ackFrame : NULL, aError);
}

int8_t otPlatRadioGetRssi(otInstance *aInstance)
Expand Down
4 changes: 2 additions & 2 deletions src/gp712/uart-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void cbKeyPressed(uint8_t Param)
{
OT_UNUSED_VARIABLE(Param);

qorvoAlarmScheduleEventArg(0, platformDummy, (void *)&s_in_fd);
qorvoAlarmMilliStart(0, platformDummy, (void *)&s_in_fd);
}

void platformUartRestore(void)
Expand Down Expand Up @@ -216,7 +216,7 @@ otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
s_write_buffer = aBuf;
s_write_length = aBufLength;

qorvoAlarmScheduleEventArg(0, platformDummy, (void *)&s_in_fd);
qorvoAlarmMilliStart(0, platformDummy, (void *)&s_in_fd);

exit:
return error;
Expand Down
Loading