Skip to content

Commit

Permalink
Add TI SimpleLink SDK support
Browse files Browse the repository at this point in the history
* remove legacy no-rtos examples
* update build system
* internalize mbedtls dependency
  • Loading branch information
srickardti committed Dec 9, 2022
1 parent 89cfd4a commit bcfd1ab
Show file tree
Hide file tree
Showing 336 changed files with 10,583 additions and 182,099 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build
output
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[submodule "openthread"]
path = openthread
url = https://github.com/openthread/openthread.git
[submodule "third_party/freertos/repo"]
path = third_party/freertos/repo
url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
[submodule "third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx"]
path = third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx
url = https://github.com/TexasInstruments/cc13xx_cc26xx_sdk.git
[submodule "mbedtls"]
path = third_party/mbedtls/repo
url = https://github.com/Mbed-TLS/mbedtls.git
42 changes: 25 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,42 @@
cmake_minimum_required(VERSION 3.10.2)
project(ot-cc13x2-cc26x2 VERSION 0.2.0)

set(TI_PLATFORM_VALUES
"cc1352"
"cc2652"
)
set_property(CACHE TI_PLATFORM PROPERTY STRINGS ${TI_PLATFORM_VALUES})
if(NOT TI_PLATFORM IN_LIST TI_PLATFORM_VALUES)
message(FATAL_ERROR "Please select a supported platform: ${TI_PLATFORM_VALUES}")
if(NOT DEFINED TI_SIMPLELINK_KERNEL)
set(TI_SIMPLELINK_KERNEL "freertos" CACHE STRING "")
endif()

set(OT_PLATFORM_LIB "openthread-${TI_PLATFORM}")
include(boards.cmake)

set(OT_PLATFORM_LIB "openthread-cc13xx_cc26xx")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)

set(FREERTOS_CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(OT_MBEDTLS_CONFIG_FILE "\"mbedtls-config-cc13x2_cc26x2.h\"")
set(OT_EXTERNAL_MBEDTLS "ti-mbedtls" CACHE STRING "Use TI hardware accelerated mbedtls" FORCE)
set(OT_BUILTIN_MBEDTLS_MANAGEMENT ON CACHE BOOL "Have OpenThread manage mbedtls")
set(OT_BUILD_EXECUTABLES OFF CACHE BOOL "Build OpenThread executables")
option(TI_BUILD_EXECUTABLES "Build executables" ON)

add_subdirectory(openthread)

if(TI_SIMPLELINK_KERNEL STREQUAL "freertos")
add_subdirectory(third_party/freertos)
endif()

add_subdirectory(third_party/ti_simplelink_sdk)
add_subdirectory(third_party/mbedtls)
add_subdirectory(src)
add_subdirectory(examples)

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

target_include_directories(ot-config INTERFACE
${PROJECT_SOURCE_DIR}/src/${TI_PLATFORM}
${PROJECT_SOURCE_DIR}/src/${TI_PLATFORM}/crypto
${PROJECT_SOURCE_DIR}/third_party/ti/devices/cc13x2_cc26x2
${PROJECT_SOURCE_DIR}/src
)

add_subdirectory(src/${TI_PLATFORM})
add_subdirectory(third_party)
134 changes: 114 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,136 @@

---

# OpenThread on CC13x2/CC26x2 Examples
# OpenThread CC13XX_CC26XX Example

This repo contains example platform drivers for the [Texas Instruments CC1352R1][cc1352r1] and [Texas Instruments CC2652R1][cc2652r1].
This directory contains the platform drivers necssary to run OpenThread on the Texas Instruments CC13XX_CC26XX family of
Connected MCUs. These drivers use the TI SimpleLink™ SDK for the RTOS enabled platform drivers. The example applications
build with FreeRTOS to enable an environment for the standard device drivers to operate.

[cc1352r1]: http://www.ti.com/tool/launchxl-cc26x2r1
[cc2652r1]: http://www.ti.com/tool/launchxl-cc26x2r1
## Toolchain

The example platform drivers are intended to present the minimal code necessary to support OpenThread. As a result, the example platform drivers do not necessarily highlight the platform's full capabilities. Consult the [SimpleLink CC26X2R1 SDK][cc26x2r1-sdk] for more development option. The platform drivers were built for the [CC1352R1 LAUNCHXL][cc1352r1-launchxl], usage on other boards with a cc1352r1 may require changes to the peripheral drivers.
In a Bash terminal, follow these instructions to install the GNU toolchain and other dependencies.

[cc1352r1-launchxl]: http://www.ti.com/tool/launchxl-cc26x2r1
[cc26x2r1-sdk]: http://www.ti.com/tool/simplelink-cc26x2-sdk
```bash
$ cd <path-to-ot-cc13x2-cc26x2>
$ ./script/bootstrap
```

To learn more about building and running the examples please check:
## Building

- [OpenThread on CC1352R1 examples][cc1352r1-page]
- [OpenThread on CC2652R1 examples][cc2652r1-page]
In a Bash terminal, follow these instructions to build the cc13xx_cc26xx examples. Where the SimpleLink board is a
reference development kit available on ti.com.

[cc1352r1-page]: ./src/cc1352/README.md
[cc2652r1-page]: ./src/cc2652/README.md
```bash
$ cd <path-to-ot-cc13x2-cc26x2>
$ ./script/build LP_CC2652R7
```

# Contributing
## Flash Binaries

We would love for you to contribute to OpenThread and help make it even better than it is today! See our [Contributing Guidelines](https://github.com/openthread/openthread/blob/main/CONTRIBUTING.md) for more information.
If the build completed successfully, the `elf` files may be found in `<path-to-ot-cc13x2-cc26x2>/build/bin/`. These
files do not have any file extension.

Contributors are required to abide by our [Code of Conduct](https://github.com/openthread/openthread/blob/main/CODE_OF_CONDUCT.md) and [Coding Conventions and Style Guide](https://github.com/openthread/openthread/blob/main/STYLE_GUIDE.md).
Loading the built image onto a LaunchPad is supported through two methods; Uniflash and Code Composer Studio (CCS).
UniFlash can be used to load the image. Code Composer Studio can be used to load the image and debug the source code.

### Code Composer Studio

Programming with CCS will allow for a full debug environment within the IDE. This is accomplished by creating a target
connection to the XDS110 debugger and starting a project-less debug session. The CCS IDE will attempt to find the source
files on the local machine based on the debug information embedded within the ELF. CCS may prompt you to find the source
code if the image was built on another machine or the source code is located in a different location than is recorded
within the ELF.

Download and install [Code Composer Studio][ccs].

First open CCS and create a new workspace.

Create a target connection (sometimes called the CCXML) for your target SoC and debugger as described in the [Manual
Method][ccs_manual_method] section of the CCS User's Guide.

Next initiate a project-less debug session as described in the [Manual Launch][ccs_manual_launch] section of the CCS
User's Guide.

CCS should switch to the debug view described in the [After Launch][ccs_after_launch] section of the User's Guide. The
SoC core will likely be disconnected and symbols will not be loaded. Connect to the core as described in the [Debug
View][ccs_debug_view] section of the User's Guide. Once the core is connected, use the `Load` button on the toolbar to
load the ELF image.

Note that the default configuration of the CCXML uses 2-wire cJTAG instead of the full 4-wire JTAG connection to match
the default jumper configuration of the LaunchPad.

[ccs]: https://www.ti.com/tool/CCSTUDIO
[ccs_after_launch]: https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html?configuration#after-launch
[ccs_debug_view]: https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html?configuration#debug-view
[ccs_manual_launch]: https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html?configuration#manual-launch
[ccs_manual_method]: https://software-dl.ti.com/ccs/esd/documents/users_guide/ccs_debug-main.html?configuration#manual-method

### UniFlash

Uniflash is Texas Instrument's uniform programming tool for embedded processors. This will allow you to erase, flash,
and inspect the SoC without setting up a debugging environment.

Download and install [UniFlash][uniflash].

First open UniFlash. Debug probes connected to the computer will usually be displayed under the Detected Devices due to
the automatic device detection feature. If your device does not show up in this view it my be disconnected, or you may
have to create a New Configuration. If you already have a CCXML for your SoC and debug connection you can use that in
the section at the bottom. Once your device is selected, click the `Start` button within the section to launch the
session.

Select the ELF image to load on the device with the `Browse` button. Make sure to deselect the binary check-box,
Uniflash assumes a file without an extension is a binary file and not an elf. Click the `Load Image` button to load the
executable image onto the device. You should be able to see the log output over the XDS110 User UART.

Note that programming the device through JTAG sets the Halt-in-Boot flag and may cause issues when performing a software
reset. This flag can be reset by power-cycling the LaunchPad.

[uniflash]: https://www.ti.com/tool/download/UNIFLASH

## Interact

By default the terminal output will be sent to the Application/User UART. This can be found in Windows in the Device
Manager or in Linux as the `/dev/ttyACM0` device. Open a terminal emulator to that port to see the output with the
following options:

| Parameter | Value |
| ------------ | -------- |
| Speed (baud) | `115200` |
| Data bits | `8` |
| Stop bits | `1` |
| Parity | `None` |
| Flow control | `None` |

1. Open terminal to the com port associated with the User UART.
2. Type `help` for list of commands.
3. See [OpenThread CLI Reference README.md][cli] to learn more.

[cli]: https://github.com/openthread/openthread/blob/main/src/cli/README.md

## TI Support

For technical support, please consider creating a post on TI's [E2E forum][e2e]. Additionally, we welcome any feedback.

[e2e]: https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread

# License

OpenThread is released under the [BSD 3-Clause license](https://github.com/openthread/ot-cc13x2-cc26x2/blob/main/LICENSE). See the [`LICENSE`](https://github.com/openthread/ot-cc13x2-cc26x2/blob/main/LICENSE) file for more information.
OpenThread is released under the [BSD 3-Clause
license](https://github.com/openthread/ot-cc13x2-cc26x2/blob/main/LICENSE). See the
[`LICENSE`](https://github.com/openthread/ot-cc13x2-cc26x2/blob/main/LICENSE) file for more information.

Please only use the OpenThread name and marks when accurately referencing this software distribution. Do not use the marks in a way that suggests you are endorsed by or otherwise affiliated with Nest, Google, or The Thread Group.
Please only use the OpenThread name and marks when accurately referencing this software distribution. Do not use the
marks in a way that suggests you are endorsed by or otherwise affiliated with Nest, Google, Texas Instruments or The
Thread Group.

# Need help?

OpenThread support is available on GitHub:

- Bugs and feature requests pertaining to the OpenThread on CC13x2/CC26x2 Examples — [submit to the openthread/ot-cc13x2-cc26x2 Issue Tracker](https://github.com/openthread/ot-cc13x2-cc26x2/issues)
- OpenThread bugs and feature requests — [submit to the OpenThread Issue Tracker](https://github.com/openthread/openthread/issues)
- Community Discussion - [ask questions, share ideas, and engage with other community members](https://github.com/openthread/openthread/discussions)
- Bugs and feature requests pertaining to the OpenThread on CC13x2/CC26x2 Examples — [submit to the
openthread/ot-cc13x2-cc26x2 Issue Tracker](https://github.com/openthread/ot-cc13x2-cc26x2/issues)
- OpenThread bugs and feature requests — [submit to the OpenThread Issue
Tracker](https://github.com/openthread/openthread/issues)
- Community Discussion - [ask questions, share ideas, and engage with other community
members](https://github.com/openthread/openthread/discussions)
106 changes: 106 additions & 0 deletions boards.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#

set(TI_BOARD_VALUES
"CC1352P1_LAUNCHXL"
"CC1352P_2_LAUNCHXL"
"CC1352P_4_LAUNCHXL"
"CC1352R1_LAUNCHXL"
"CC26X2R1_LAUNCHXL"
"LP_CC1352P7_1"
"LP_CC1352P7_4"
"LP_CC2652PSIP"
"LP_CC2652R7"
"LP_CC2652RB"
"LP_CC2652RSIP"
)

set_property(CACHE TI_SIMPLELINK_BOARD PROPERTY STRINGS ${TI_BOARD_VALUES})

if(TI_SIMPLELINK_BOARD STREQUAL "CC1352P1_LAUNCHXL")
set(TI_SIMPLELINK_FAMILY "cc13x2_cc26x2" )
set(TI_SIMPLELINK_STARTUP "cc13x2_cc26x2" )
set(TI_SIMPLELINK_ISA "m4f" )

elseif(TI_SIMPLELINK_BOARD STREQUAL "CC1352P_2_LAUNCHXL")
set(TI_SIMPLELINK_FAMILY "cc13x2_cc26x2" )
set(TI_SIMPLELINK_STARTUP "cc13x2_cc26x2" )
set(TI_SIMPLELINK_ISA "m4f" )

elseif(TI_SIMPLELINK_BOARD STREQUAL "CC1352P_4_LAUNCHXL")
set(TI_SIMPLELINK_FAMILY "cc13x2_cc26x2" )
set(TI_SIMPLELINK_STARTUP "cc13x2_cc26x2" )
set(TI_SIMPLELINK_ISA "m4f" )

elseif(TI_SIMPLELINK_BOARD STREQUAL "CC1352R1_LAUNCHXL")
set(TI_SIMPLELINK_FAMILY "cc13x2_cc26x2" )
set(TI_SIMPLELINK_STARTUP "cc13x2_cc26x2" )
set(TI_SIMPLELINK_ISA "m4f" )

elseif(TI_SIMPLELINK_BOARD STREQUAL "CC26X2R1_LAUNCHXL")
set(TI_SIMPLELINK_FAMILY "cc13x2_cc26x2" )
set(TI_SIMPLELINK_STARTUP "cc13x2_cc26x2" )
set(TI_SIMPLELINK_ISA "m4f" )

elseif(TI_SIMPLELINK_BOARD STREQUAL "LP_CC1352P7_1")
set(TI_SIMPLELINK_FAMILY "cc13x2x7_cc26x2x7")
set(TI_SIMPLELINK_STARTUP "cc13x2_cc26x2" )
set(TI_SIMPLELINK_ISA "m4f" )

elseif(TI_SIMPLELINK_BOARD STREQUAL "LP_CC1352P7_4")
set(TI_SIMPLELINK_FAMILY "cc13x2x7_cc26x2x7")
set(TI_SIMPLELINK_STARTUP "cc13x2_cc26x2" )
set(TI_SIMPLELINK_ISA "m4f" )

elseif(TI_SIMPLELINK_BOARD STREQUAL "LP_CC2652PSIP")
set(TI_SIMPLELINK_FAMILY "cc13x2_cc26x2" )
set(TI_SIMPLELINK_STARTUP "cc13x2_cc26x2" )
set(TI_SIMPLELINK_ISA "m4f" )

elseif(TI_SIMPLELINK_BOARD STREQUAL "LP_CC2652R7")
set(TI_SIMPLELINK_FAMILY "cc13x2x7_cc26x2x7")
set(TI_SIMPLELINK_STARTUP "cc13x2_cc26x2" )
set(TI_SIMPLELINK_ISA "m4f" )

elseif(TI_SIMPLELINK_BOARD STREQUAL "LP_CC2652RB")
set(TI_SIMPLELINK_FAMILY "cc13x2_cc26x2" )
set(TI_SIMPLELINK_STARTUP "cc13x2_cc26x2" )
set(TI_SIMPLELINK_ISA "m4f" )

elseif(TI_SIMPLELINK_BOARD STREQUAL "LP_CC2652RSIP")
set(TI_SIMPLELINK_FAMILY "cc13x2_cc26x2" )
set(TI_SIMPLELINK_STARTUP "cc13x2_cc26x2" )
set(TI_SIMPLELINK_ISA "m4f" )

else()
if(TI_PLATFORM STREQUAL "cc13xx_cc26xx"
AND NOT TI_SIMPLELINK_BOARD IN_LIST TI_BOARD_VALUES)
message(FATAL_ERROR "Please select a supported board: ${TI_BOARD_VALUES}")
endif()
endif()

3 changes: 3 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if(TI_BUILD_EXECUTABLES)
add_subdirectory(apps)
endif()
42 changes: 42 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Examples Directory

This directory should be a faithful copy of the examples directory from
OpenThread with a few changes to support the specific build requirements for
the TI SimpleLink devices. These include;

1. Addition of the `*.out` suffix to executables
2. Enabling RTOS operation

## Adding out to the Executable

Both CCS and Uniflash recognize files with the `*.out` suffix as programmable
files. An executable file with no extension is not always recognized by default
in the file explorer of the loading programs. And when loading a file with no
suffix Uniflash will default to interpreting the file as a binary image. While
an extension of `*.elf` may be more descriptive, it is not recognized by
default in some programs.

## Enabling an RTOS

The SimpleLink drivers require a kernel running underneath them for certain
primitives like semaphores. This requires the `main()` function to be used to
setup the drivers and start the kernel. It is not easy to re-write the
SimpleLink SDK `ResetISR` to create a new entry point. Instead two files have
been added to each example, one to bootstrap TI-RTOS and one to bootstrap
FreeRTOS. The `main()` function in the example applications have been re-named
to `app_main()` to follow the conventions set in the SimpleLink SDK.

### Possible changes

Currently the `otSysProcessDrivers()` in `src/system.c` pends on a processing
queue for driver events. Once a driver generates an event and places that on
the queue, the function will continue to process this event. The two examples
in this repository also define `otTaskletsSignalPending()` and handle
processing tasklets within their main loops. This is handled by checking if
there are any pending tasklets before pending on the queue and returning if
there are any.

A weak implementation of the `otTaskletsSignalPending()` function is provided
in the `system.c` file if the application code does not handle this
functionality.

Loading

0 comments on commit bcfd1ab

Please sign in to comment.