Skip to content
/ ot-nxp Public
forked from openthread/ot-nxp

Commit

Permalink
Integrate RT1060/K32W0 update until tag v1.0_branch_upstream_15_12_2022
Browse files Browse the repository at this point in the history
  • Loading branch information
Micr_SW Connectivity_01 committed Dec 15, 2022
1 parent 3e9b92b commit c9d3eee
Show file tree
Hide file tree
Showing 36 changed files with 889 additions and 543 deletions.
17 changes: 6 additions & 11 deletions cmake/platform/jn5189.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,10 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

set(COMMON_C_FLAGS
-mcpu=cortex-m4
-mfloat-abi=soft
-mthumb
)
set(PLATFORM_C_FLAGS "-mcpu=cortex-m4 -mfloat-abi=soft -mthumb")
set(PLATFORM_LINKER_FLAGS "${PLATFORM_C_FLAGS}")

add_compile_options(
${COMMON_C_FLAGS}
)
add_link_options(
${COMMON_C_FLAGS}
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_C_FLAGS}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${PLATFORM_C_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKER_FLAGS} ")
17 changes: 6 additions & 11 deletions cmake/platform/k32w061.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,10 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

set(COMMON_C_FLAGS
-mcpu=cortex-m4
-mfloat-abi=soft
-mthumb
)
set(PLATFORM_C_FLAGS "-mcpu=cortex-m4 -mfloat-abi=soft -mthumb")
set(PLATFORM_LINKER_FLAGS "${PLATFORM_C_FLAGS}")

add_compile_options(
${COMMON_C_FLAGS}
)
add_link_options(
${COMMON_C_FLAGS}
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_C_FLAGS}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${PLATFORM_C_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKER_FLAGS} ")
42 changes: 7 additions & 35 deletions cmake/platform/rt1060.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,11 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

set(COMMON_C_FLAGS
-mcpu=cortex-m7
-mfloat-abi=hard
-mthumb
-mfpu=fpv5-d16
-fno-common
-ffreestanding
-fno-builtin
-mapcs
)
set(C_FLAGS
${COMMON_C_FLAGS}
)
set(CXX_FLAGS
${COMMON_C_FLAGS}
-MMD
-MP
)
set(ASM_FLAGS
${COMMON_C_FLAGS}
)
add_compile_options(
"$<$<COMPILE_LANGUAGE:C>:${C_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CXX>:${CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:ASM>:${ASM_FLAGS}>"
)
set(PLATFORM_C_FLAGS "-mcpu=cortex-m7 -mfloat-abi=hard -mthumb -mfpu=fpv5-d16 -fno-common -ffreestanding -fno-builtin -mapcs")
set(PLATFORM_CXX_FLAGS "${PLATFORM_C_FLAGS} -MMD -MP")
set(PLATFORM_LINKER_FLAGS "${PLATFORM_C_FLAGS} -u qspiflash_config -u image_vector_table -u boot_data -u dcd_data -Wl,--sort-section=alignment -Wl,--cref")

add_link_options(
${COMMON_C_FLAGS}
"SHELL:-u qspiflash_config"
"SHELL:-u image_vector_table"
"SHELL:-u boot_data"
"SHELL:-u dcd_data"
-Wl,--sort-section=alignment
-Wl,--cref
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CXX_FLAGS}")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${PLATFORM_C_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKER_FLAGS} ")
26 changes: 13 additions & 13 deletions cmake/toolchain/arm-none-eabi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,21 @@ set(CMAKE_ASM_FLAGS_INIT "${COMMON_C_FLAGS} -x assembler-with-cpp")
set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs -Xlinker --gc-sections")

# Optimize for debug operation
set(CMAKE_C_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_ASM_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_DEBUG "-g -O0" CACHE STRING "C compiler flags for Debug build type")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0" CACHE STRING "C++ compiler flags for Debug build type")
set(CMAKE_ASM_FLAGS_DEBUG "-g -O0" CACHE STRING "ASM compiler flags for Debug build type")

# Balanced optimization between size and speed
set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_ASM_FLAGS_RELEASE "")
# Optimization for speed
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "C compiler flags for Release build type")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "C++ compiler flags for Release build type")
set(CMAKE_ASM_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "ASM compiler flags for Release build type")

# Optimization for size
set(CMAKE_C_FLAGS_MINSIZEREL "-Os")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
set(CMAKE_ASM_FLAGS_MINSIZEREL "")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING "C compiler flags for MinSizeRel build type")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING "C++ compiler flags for MinSizeRel build type")
set(CMAKE_ASM_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING "ASM compiler flags for MinSizeRel build type")

# Balanced optimization with debug infos
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2")
set(CMAKE_ASM_FLAGS_RELWITHDEBINFO "-g")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG" CACHE STRING "C compiler flags for RelWithDebInfo build type")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG" CACHE STRING "C++ compiler flags for RelWithDebInfo build type")
set(CMAKE_ASM_FLAGS_RELWITHDEBINFO "-g -O2 -DNDEBUG" CACHE STRING "ASM compiler flags for RelWithDebInfo build type")
8 changes: 4 additions & 4 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ function(export_target_to_bin target)
# message(STATUS "Target ${target} will be exported to raw binary format")
set(target_bin_filename ${target}.bin)
add_custom_command(
OUTPUT ${target_bin_filename}
OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_bin_filename}
COMMAND ${CMAKE_OBJCOPY} ARGS -v -O binary ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target}${CMAKE_EXECUTABLE_SUFFIX_C} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_bin_filename}
DEPENDS ${target}
)
add_custom_target(export_${target}_to_bin ALL
DEPENDS ${target_bin_filename}
DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_bin_filename}
)
endif()
endfunction()
Expand All @@ -62,12 +62,12 @@ function(export_target_to_srec target)
# message(STATUS "Target ${target} will be exported to srec format")
set(target_srec_filename ${target}.srec)
add_custom_command(
OUTPUT ${target_srec_filename}
OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_srec_filename}
COMMAND ${CMAKE_OBJCOPY} ARGS -v -O srec ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target}${CMAKE_EXECUTABLE_SUFFIX_C} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_srec_filename}
DEPENDS ${target}
)
add_custom_target(export_${target}_to_srec ALL
DEPENDS ${target_srec_filename}
DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_srec_filename}
)
endif()
endfunction()
Expand Down
5 changes: 4 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
# POSSIBILITY OF SUCH DAMAGE.
#

add_subdirectory(cli)
if (OT_APP_CLI_FREERTOS)
add_subdirectory(cli)
endif()

add_subdirectory(hybrid)
29 changes: 26 additions & 3 deletions examples/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,29 @@
# POSSIBILITY OF SUCH DAMAGE.
#

if (OT_APP_CLI_FREERTOS)
add_subdirectory(rtos)
endif ()
add_executable(ot-cli-${OT_NXP_PLATFORM}
main.c
app_ot_freertos.c
app_freertos_hooks.c
${PROJECT_SOURCE_DIR}/openthread/examples/apps/cli/cli_uart.cpp
)

target_include_directories(ot-cli-${OT_NXP_PLATFORM} PRIVATE
..
${PROJECT_SOURCE_DIR}/openthread/examples/platforms
)

target_link_libraries(ot-cli-${OT_NXP_PLATFORM} PRIVATE
openthread-cli-ftd
openthread-ftd
${OT_PLATFORM_LIB}
${NXP_DRIVER_LIB}
ot-config
-Wl,--start-group ${OT_PLATFORM_LIB} -Wl,--end-group
)

if(NXP_BOARD_LIB)
target_link_libraries(ot-cli-${OT_NXP_PLATFORM} PRIVATE
${NXP_BOARD_LIB}
)
endif()
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, The OpenThread Authors.
* Copyright (c) 2022, NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand All @@ -26,12 +26,38 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "common/logging.hpp"
/**
* @file
* This file implements FreeRTOS hooks that can be enabled through FreeRTOSConfig.h
*
* This file is just for example, but not for production.
*
*/

/* -------------------------------------------------------------------------- */
/* Includes */
/* -------------------------------------------------------------------------- */

#include "FreeRTOS.h"
#include "assert.h"
#include "ot_platform_common.h"
#include "task.h"

/* -------------------------------------------------------------------------- */
/* Public functions */
/* -------------------------------------------------------------------------- */

void vApplicationIdleHook(void)
{
otSysRunIdleTask();
}

void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
{
assert(0);
}

uint16_t hci_transport_enqueue(uint8_t *packet, uint16_t packet_len, uint16_t *enqueued_len)
void vApplicationMallocFailedHook(void)
{
otLogDebgPlat("Frame dropped %d", packet_len);
/* Empty hci transport wrapper */
*enqueued_len = packet_len;
return 0;
assert(0);
}
1 change: 1 addition & 0 deletions examples/cli/app_ot.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, The OpenThread Authors.
* Copyright (c) 2022, NXP.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, The OpenThread Authors.
* Copyright (c) 2022, NXP.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -63,7 +64,6 @@ static TaskHandle_t sMainTask = NULL;

extern void otAppCliInit(otInstance *aInstance);
extern void otSysRunIdleTask(void);
extern void BOARD_InitHardware(void);

static void appOtInit()
{
Expand Down Expand Up @@ -116,8 +116,6 @@ static void mainloop(void *aContext)

void appOtStart(int argc, char *argv[])
{
/* Init board hardware */
BOARD_InitHardware();
xTaskCreate(mainloop, "ot", OT_MAIN_TASK_SIZE, NULL, OT_MAIN_TASK_PRIORITY, &sMainTask);
vTaskStartScheduler();
}
Expand All @@ -136,27 +134,6 @@ void otSysEventSignalPending(void)
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}

#if (defined(configUSE_IDLE_HOOK) && (configUSE_IDLE_HOOK > 0))
void vApplicationIdleHook(void)
{
otSysRunIdleTask();
}
#endif

#if (defined(configCHECK_FOR_STACK_OVERFLOW) && (configCHECK_FOR_STACK_OVERFLOW > 0))
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
{
assert(0);
}
#endif

#if (defined(configUSE_MALLOC_FAILED_HOOK) && (configUSE_MALLOC_FAILED_HOOK > 0))
void vApplicationMallocFailedHook(void)
{
assert(0);
}
#endif

#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
void *otPlatCAlloc(size_t aNum, size_t aSize)
{
Expand Down
18 changes: 18 additions & 0 deletions examples/cli/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, The OpenThread Authors.
* Copyright (c) 2022, NXP.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -34,10 +35,27 @@
*
*/

/* -------------------------------------------------------------------------- */
/* Includes */
/* -------------------------------------------------------------------------- */

#include "app_ot.h"

/* -------------------------------------------------------------------------- */
/* Public prototypes */
/* -------------------------------------------------------------------------- */

extern void BOARD_InitHardware(void);

/* -------------------------------------------------------------------------- */
/* Public functions */
/* -------------------------------------------------------------------------- */

int main(int argc, char *argv[])
{
/* Init board hardware */
BOARD_InitHardware();

appOtStart(argc, argv);
return 0;
}
2 changes: 1 addition & 1 deletion openthread
Submodule openthread updated 557 files
6 changes: 6 additions & 0 deletions src/common/ot_platform_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ otError otPlatRadioSendSetPropVendorUint8Cmd(uint32_t aKey, uint8_t value);
*/
void otPlatUartSetInstance(uint8_t newInstance);

/**
* This function is called from idle hook, likely for system idle operation such as flash operations
*
*/
void otSysRunIdleTask(void);

#ifdef __cplusplus
} // end of extern "C"
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/common/ram_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ typedef enum
{
RS_ERROR_NONE,
RS_ERROR_NOT_FOUND,
RS_ERROR_NO_BUFS
RS_ERROR_NO_BUFS,
RS_ERROR_PDM_ENC
} rsError;

/* Header for a RAM buffer descriptor.
Expand Down
7 changes: 6 additions & 1 deletion src/common/spinel/radio.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*
* Copyright (c) 2021, The OpenThread Authors.
* Copyright (c) 2022, NXP.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -41,7 +43,10 @@
#if defined(OT_PLAT_SPINEL_OVER_SPI)
#include "spi_interface.hpp"
static ot::Spinel::RadioSpinel<ot::NXP::SpiInterface, otInstance> sRadioSpinel;
#elif defined(OT_PLAT_SPINEL_HCI_OVER_UART)
#elif defined(OT_PLAT_SPINEL_OVER_HDLC)
#include "spinel_hdlc.hpp"
static ot::Spinel::RadioSpinel<ot::NXP::HdlcInterface, otInstance> sRadioSpinel;
#elif defined(OT_PLAT_SPINEL_HCI_OVER_HDLC)
#include "spinel_hci_hdlc.hpp"
static ot::Spinel::RadioSpinel<ot::NXP::HdlcSpinelHciInterface, otInstance> sRadioSpinel;
#endif
Expand Down
Loading

0 comments on commit c9d3eee

Please sign in to comment.