Skip to content

Commit

Permalink
update freertos build to pass certification
Browse files Browse the repository at this point in the history
  • Loading branch information
srickardti committed Apr 18, 2023
1 parent b1b0de4 commit 1fbe76c
Show file tree
Hide file tree
Showing 15 changed files with 555 additions and 142 deletions.
12 changes: 6 additions & 6 deletions script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@

set -euxo pipefail

SYSCONFIG_USER=~/ti/sysconfig_1.14.0/
SYSCONFIG_SYSTEM=/opt/ti/sysconfig_1.14.0/
SYSCONFIG_DL=https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-nsUM6f7Vvb/1.14.0.2667/sysconfig-1.14.0_2667-setup.run
SYSCONFIG_USER=~/ti/sysconfig_1.15.0/
SYSCONFIG_SYSTEM=/opt/ti/sysconfig_1.15.0/
SYSCONFIG_DL=https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-nsUM6f7Vvb/1.15.0.2826/sysconfig-1.15.0_2826-setup.run

if [ ! -d "$SYSCONFIG_USER" ] && [ ! -d "$SYSCONFIG_SYSTEM"]; then
wget "$SYSCONFIG_DL" -O /tmp/sysconfig-1.14.0_2667-setup.run
chmod +x /tmp/sysconfig-1.14.0_2667-setup.run
/tmp/sysconfig-1.14.0_2667-setup.run --mode unattended
wget "$SYSCONFIG_DL" -O /tmp/sysconfig-1.15.0_2826-setup.run
chmod +x /tmp/sysconfig-1.15.0_2826-setup.run
/tmp/sysconfig-1.15.0_2826-setup.run --mode unattended
fi

"$(dirname "$0")"/../openthread/script/bootstrap
39 changes: 37 additions & 2 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ readonly TI_LAUNCHPAD=(

readonly OT_SRCDIR="$(pwd)"
readonly OT_OPTIONS=(
"-DCMAKE_BUILD_TYPE=MinSizeRel"
"-DOT_PLATFORM=external"
"-DOT_SLAAC=ON"
)

build()
Expand All @@ -79,11 +77,48 @@ build()
ninja
fi

if [[ ${ot_reference_release} == true ]]; then
cd bin
for exe in *.out; do
cp -- "${exe}" "${exe%.out}"
done
fi

cd "${OT_SRCDIR}"
}

main()
{
local usage="usage: $0 [-h] [--skip-silabs-apps] <TI LaunchPad> [-D<OT_XXXX=ON> -D<OT_YYYY=OFF>]"

local ot_reference_release=false
# Parse flags
optspec=":h-:"
while getopts "$optspec" optchar; do
case "${optchar}" in
-)
case "${OPTARG}" in
ot-reference-release)
# The ot-reference-release repository expects the executables produced by this build to have
# no file endings. We do not make this the default behavior because file extensions make using
# UniFlash easier.
printf '\n\nProducing executables for ot-reference-release...\n\n' >&2
ot_reference_release=true
shift 1
;;
*)
echo "Unknown option --${OPTARG}" >&2
exit 2
;;
esac
;;
h)
echo "${usage}" >&2
exit 2
;;
esac
done

if [[ $# == 0 ]]; then
echo "Please specify a LaunchPad: ${TI_LAUNCHPAD[*]}"
exit 1
Expand Down
9 changes: 7 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
if(NOT $ENV{TI_SYSCONFIG_ROOT} STREQUAL "")
set(TI_SYSCONFIG_INSTALL_DIR $ENV{TI_SYSCONFIG_ROOT} CACHE PATH "")
else()
set(TI_SYSCONFIG_INSTALL_DIR $ENV{HOME}/ti/sysconfig_1.14.0 CACHE PATH "")
set(TI_SYSCONFIG_INSTALL_DIR $ENV{HOME}/ti/sysconfig_1.15.0 CACHE PATH "")
endif()

if(WIN32)
Expand All @@ -47,6 +47,12 @@ if(TI_SIMPLELINK_KERNEL STREQUAL "freertos")
${CMAKE_CURRENT_BINARY_DIR}/syscfg/ti_drivers_config.h
${CMAKE_CURRENT_BINARY_DIR}/syscfg/ti_radio_config.c
${CMAKE_CURRENT_BINARY_DIR}/syscfg/ti_radio_config.h

# TI SimpleLink FreeRTOS configuration and build is not possible until
# configTICK_RATE_HZ is configurable and source directory set correctly.
#${CMAKE_CURRENT_BINARY_DIR}/syscfg/ti_freertos_config.c
#${CMAKE_CURRENT_BINARY_DIR}/syscfg/ti_freertos_portable_config.c
#${CMAKE_CURRENT_BINARY_DIR}/syscfg/FreeRTOSConfig.h
)
set(SYSCONFIG_OUTPUT_OTHER
${CMAKE_CURRENT_BINARY_DIR}/syscfg/syscfg_c.rov.xs
Expand Down Expand Up @@ -128,7 +134,6 @@ list(APPEND TI_PLATFORM_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(openthread-cc13xx_cc26xx
PUBLIC
cc13xx-cc26xx-sdk
-Wl,--undefined=__ccfg
-Wl,--gc-sections
-Wl,-Map=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<TARGET_PROPERTY:NAME>.map
${GENLIBS_INCLUDES}
Expand Down
2 changes: 1 addition & 1 deletion src/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#define configTOTAL_HEAP_SIZE ((size_t)(0x4000))

#elif defined(DeviceFamily_CC13X2X7_CC26X2X7)
#define configTOTAL_HEAP_SIZE ((size_t)(0x15000))
#define configTOTAL_HEAP_SIZE ((size_t)(0x14000))

#else
#define configTOTAL_HEAP_SIZE ((size_t)(0x8000))
Expand Down
52 changes: 37 additions & 15 deletions src/alarm_micro.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
/******************************************************************************
@file alarm.c
@brief TIRTOS platform specific alarm functions for OpenThread
Group: CMCU, LPC
$Target Device: DEVICES $
******************************************************************************
$License: BSD3 2017 $
******************************************************************************
$Release Name: PACKAGE NAME $
$Release Date: PACKAGE RELEASE DATE $
*****************************************************************************/
/*
* Copyright (c) 2017, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

/******************************************************************************
Includes
Expand Down Expand Up @@ -67,6 +79,16 @@ void platformAlarmMicroInit(void)

AlarmMicro_running = false;
}

uint64_t otPlatTimeGet(void)
{
struct timespec now;

clock_gettime(CLOCK_MONOTONIC, &now);

return (now.tv_sec * 1000000U) + ((now.tv_nsec / 1000U) % 1000000);
}

/**
* Function documented in platform/alarm-micro.h
*/
Expand Down
4 changes: 2 additions & 2 deletions src/arm-none-eabi-m4f.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-as)
set(CMAKE_RANLIB arm-none-eabi-ranlib)

set(COMMON_C_FLAGS "-mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mabi=aapcs -mthumb -fdata-sections -ffunction-sections -g -gdwarf-3 -gstrict-dwarf")
set(COMMON_C_FLAGS "-mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mabi=aapcs -mthumb -Os -fdata-sections -ffunction-sections -g -gdwarf-3 -gstrict-dwarf")

#set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=gnu99")
set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=c99")
set(CMAKE_CXX_FLAGS_INIT "${COMMON_C_FLAGS} -std=c++11 -fno-exceptions -fno-rtti")
set(CMAKE_ASM_FLAGS_INIT "${COMMON_C_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -nostartfiles -specs=nano.specs")
set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -nostartfiles -specs=nano.specs -specs=nosys.specs")
68 changes: 67 additions & 1 deletion src/openthread-core-cc13xx_cc26xx-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,81 @@
#ifndef OPENTHREAD_CORE_CC13X2_CC26X2_CONFIG_H_
#define OPENTHREAD_CORE_CC13X2_CC26X2_CONFIG_H_

#define OPENTHREAD_CONFIG_THREAD_VERSION OT_THREAD_VERSION_1_3
// When operating in a less than ideal RF environment, having a more forgiving configuration
// of OpenThread makes thread a great deal more reliable.
#define OPENTHREAD_CONFIG_TMF_ADDRESS_QUERY_MAX_RETRY_DELAY 120 // default is 28800
#define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT 15 // default is 3
#define OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_INDIRECT 1 // default is 0
#define OPENTHREAD_CONFIG_MAC_MAX_TX_ATTEMPTS_INDIRECT_POLLS 16 // default is 4

// Enable periodic parent search to speed up finding a better parent.
#define OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE 1 // default is 0
#define OPENTHREAD_CONFIG_PARENT_SEARCH_RSS_THRESHOLD -45 // default is -65
#define OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH 1 // default is 0
//
// Use smaller maximum interval to speed up reattaching.
#define OPENTHREAD_CONFIG_MLE_ATTACH_BACKOFF_MAXIMUM_INTERVAL (60 * 10 * 1000) // default 1200000 ms

#define OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE 0
#define OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE 0
#define OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE 0
#define OPENTHREAD_CONFIG_COAP_API_ENABLE 1
#define OPENTHREAD_CONFIG_COMMISSIONER_ENABLE 1
#define OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_DIAG_ENABLE 1
#define OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE 1
#define OPENTHREAD_CONFIG_DTLS_ENABLE 1
#define OPENTHREAD_CONFIG_DUA_ENABLE 1
#define OPENTHREAD_CONFIG_ECDSA_ENABLE 1
#define OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE 1
#define OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE 0
#define OPENTHREAD_CONFIG_JOINER_ENABLE 1
#define OPENTHREAD_CONFIG_LEGACY_ENABLE 0
#define OPENTHREAD_CONFIG_LINK_RAW_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_CSL_TRANSMITTER_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_FILTER_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE 1
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RX_TIMING_ENABLE 0
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE 0
#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_TIMING_ENABLE 0
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE 1
#define OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE 1
#define OPENTHREAD_CONFIG_MLR_ENABLE 1
#define OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE 0
#define OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE 1
#define OPENTHREAD_CONFIG_PING_SENDER_ENABLE 1
#define OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE 1
#define OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE 1
#define OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE 1
#define OPENTHREAD_CONFIG_SRP_SERVER_ENABLE 1
#define OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE 1
#define OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE 0
#define OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE 0

#define OPENTHREAD_CONFIG_THREAD_VERSION OT_THREAD_VERSION_1_3

// certification options
#define OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE 1
#define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 1
#define OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 1
#define OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE 1
#define OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE 1

#define OPENTHREAD_CONFIG_NCP_SPI_ENABLE 0
#define OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER 0
#define OPENTHREAD_ENABLE_NCP_VENDOR_HOOK 0
#define OPENTHREAD_CONFIG_NCP_HDLC_ENABLE 1

#define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 1

#define OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE 1

#define OPENTHREAD_CONFIG_PLATFORM_INFO "CC13XX_CC26XX"

#include <openthread/config.h>
Expand Down
27 changes: 10 additions & 17 deletions src/openthread.syscfg
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ var Watchdog1 = Watchdog.addInstance();
const deviceId = system.deviceData.deviceId;


/* TIRTOS7 */
/* TI SimpleLink FreeRTOS configuration and build is not possible until
* configTICK_RATE_HZ is configurable and source directory set correctly.
*
* Only generate the kernel configuration for tirtos7 for now.
*/
/* Kernel Configuration */
if (system.getRTOS() === "tirtos7") {
const tirtos7_release_syscfg_js = system.getScript("tirtos7_release.syscfg.js");
system.getScript("kernel_config_release.syscfg.js");
}


Expand Down Expand Up @@ -112,22 +117,10 @@ GPIO4.$name = "CONFIG_GPIO_RLED";
/* SPI for NCP */
SPI2.$name = "CONFIG_SPI_1";
SPI2.mode = "Four Pin SS Active Low";
SPI2.spi.misoPin.$assign = "DIO24"
SPI2.spi.mosiPin.$assign = "DIO25"
SPI2.spi.pociPin.$assign = "DIO24"
SPI2.spi.picoPin.$assign = "DIO25"
SPI2.spi.sclkPin.$assign = "DIO26"
SPI2.spi.ssPin.$assign = "DIO27"
SPI2.sclkPinInstance.$name = "CONFIG_PIN_SPI1_SCLK";
SPI2.sclkPinInstance.mode = "Input";
SPI2.sclkPinInstance.pull = "Pull Down";
SPI2.misoPinInstance.$name = "CONFIG_PIN_SPI1_MISO";
SPI2.misoPinInstance.mode = "Input";
SPI2.misoPinInstance.pull = "Pull Down";
SPI2.mosiPinInstance.$name = "CONFIG_PIN_SPI1_MOSI";
SPI2.mosiPinInstance.mode = "Input";
SPI2.mosiPinInstance.pull = "Pull Down";
SPI2.ssPinInstance.$name = "CONFIG_PIN_SPI1_CSN";
SPI2.ssPinInstance.mode = "Input";
SPI2.ssPinInstance.pull = "Pull Down";
SPI2.spi.csnPin.$assign = "DIO27"

GPIO5.$name = "CONFIG_SPINEL_INT";
GPIO5.mode = "Output";
Expand Down
Loading

0 comments on commit 1fbe76c

Please sign in to comment.