Changes between Version 1 and Version 2 of cc135x


Ignore:
Timestamp:
11/27/2019 05:19:08 PM (5 years ago)
Author:
Tim Harvey
Comment:

added details for cc1352 products

Legend:

Unmodified
Added
Removed
Modified
  • cc135x

    v1 v2  
     1[[PageOutline]]
     2
    13= Ti CC135x Sub-1GHz Internet of Things Radio
    24
    3 This page describes the family of Texas Instruments CC1350 and CC1352P Sub-1GHz radio modules that are used on several Gateworks products, including the GW16122/GW5910.
    4 
    5 More information to come...
     5This page describes the family of Texas Instruments CC135x  Sub-1GHz radio modules that are used on several Gateworks products, including the GW16122/GW5910.
     6
     7[=#hardware]
     8== Hardware
     9
     10Hardware with the CC135x:
     11 - GW16122-B - CC1352P
     12  * connected to FTDI UART
     13   - CBUS0: JTAG_RST/CC_RST# output (has strong pull-up)
     14   - CBUS1: BOOT_BCKDR output (has strong pull-down)
     15   - CBUS2: CC_TMSC output (cJTAG)
     16   - CBUS3: CC_TCKC output (cJTAG)
     17 - GW16122-A - CC1350
     18  * CC1350 connected to a TI Tiva MCU for programming
     19 - GW5910-C - CC1352P
     20  * connected on the JTAG chain with the CPU and GSC
     21  * connected to IMX UART and SPI bus for bootloader access
     22 - TI Launchpad
     23  * these have an XDS110 JTAG Debugger on-board (implemented via the Tiva MCU chip). The XDS110 debugger exposes two USB ACM serial devices where the first one is tied directly to the CC13xx UART (pinout matching the 'serial downloader' pins specified in the TRM) and the second serial device is for JTAG programming. These boards can be programmed via the TI 'Uniflash' tool (GUI or stand-alone command-line) or the CCS IDE.
     24
     25References:
     26 - http://www.ti.com/product/CC1352R/technicaldocuments
     27
     28
     29
     30[=#software]
     31== Software
     32The TI !SimpleLink products have drivers built into ROM for low-level programming capability. TI also offers several API's and stacks that sit on top of these drivers depending on your needs and programming capability.
     33
     34TI also offers a real time operating system (RTOS) layer if desired and there also exist third party RTOS providers as well such as Contiki-ng and Zephyr.
     35
     36Here we will focus on the TI set of tools and options as that is your best option for on-line support via the TI Community forums.
     37
     38To create your own firmware for the CC1352P you use the TI !SimpleLink CC13x2 SDK which contains a toolchain for compiling code as well as a set of documentation and examples.
     39
     40For code development you must use TI's Code Composer Studio (CCS) (you use their compiler, but you don't have to use their IDE unless trying to import examples from the SDK).
     41
     42Note that the RF core and driver core are built into the chip's ROM but they can be patched via rf_patch_cpe_*.h files which define structures that can be set to the 'cpuPatchFxn, 'mcePatchFxn', and 'rfePatchFxn' fields of the FR_Mode struct passed to RF_open.
     43 - the patch files can be found in $SIMPLELINK_SDK/source/ti/devices/cc13x2_cc26x2_v1/rf_patches
     44 - rf_patch_cpu_prop.h - RF core patch for proprietary radio support ("PROP" API command set) in CC13x2
     45 - rf_patch_cpu_multi_protocol.h - RF core patch for multi-protocol support (all available API command sets) in CC13x2
     46 - rf_patch_{mce,rfe}_genfsk.h - RF core patch for Generic FSK support
     47
     48TI has excellent documentation for their SDK:
     49 * offline: In the SDK install directory under {{{docs}}}
     50 * [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&node=AOSQDVXMohlV5LElLx5wxA__pTTHBmu__3.20.00.68 SimpleLink CC13x2 26x2 SDK - 3.20.00.68]
     51  - Note that this link is pinned tot he 3.20.00.68 version of the SDK which is what was used when writing this documentation. You can hover over the menu item on the right and select a different version via the '...' menu button
     52
     53
     54[=#ccs]
     55=== TI Code Composer Studio (CCS)
     56TI [http://www.ti.com/tool/CCSTUDIO Code Composer Studio] is an integrated development environment (IDE) maintained by TI with pre-installed tools and libraries for software development across TI MCU's including an optimized C/C++ compiler, source code editor, project build environment, debugger, and profiler using the Eclipse software framework. CCS supports Windows, Mac OS and Linux 64bit hosts.
     57
     58While it is not required that you use the CCS IDE you will need the compiler toolchain that is installed with it.
     59
     60Installation (CCS9 installed on Ubuntu 18.04 bionic host):
     611. Download the 'offline installer' from TI (this is a compressed tarball):
     62  * [http://processors.wiki.ti.com/index.php/Download_CCS Latest release]
     63  * [http://software-dl.ti.com/ccs/esd/CCSv9/CCS_9_1_0/exports/CCS9.1.0.00010_linux-x64.tar.gz CCS9.1.0.00010_linux-x64.tar.gz] - what is referenced on this page
     641. Untar into desired destination directory
     651. Install the following pre-requisites of the installer
     66{{{#!bash
     67sudo apt install libc6:i386 libusb-0.1-4 libgconf-2-4 build-essential
     68}}}
     691. Run the installation GUI app (ccs_setup_*.bin) which allows you to choose your installation directory and what components you wish to install (default $HOME/ti)
     70 - for CC1352P development choose '!SimpleLink CC13xx and CC26xx Wireless MCUs'
     711. Once installed you can run CCS via the desktop icon.
     721. first install you will be asked to install xdctools then restart
     73
     74
     75[=#gcc]
     76=== TI GCC toolchain
     77The TI GCC toolchain is installed with Code Composer Studio and can be found where it installs in the {{{tools/compiler/gcc-arm-none-eabi*}}} directory.
     78
     79The compiler produces {{{.out}}} files which are regular ELF files that can only be flashed to the device with JTAG programming tools. This file format can be converted to a binary image or an Intel Hex file using objcopy if using the serial downloader.
     80
     81Examples:
     82 * convert ELF (.out) to .bin:
     83{{{#!bash
     84$(GCC_ARMCOMPILER)/bin/arm-none-eabi-objcopy -S --gap-fill 0xff -O binary $(FILE).out $(FILE).bin
     85}}}
     86 * convert ELF (.out) to Intel Hex (.hex):
     87{{{#!bash
     88$(GCC_ARMCOMPILER)/bin/arm-none-eabi-objcopy -S -O ihex $(FILE).out $(FILE).hex
     89}}}
     90
     91
     92[=#simplelink]
     93=== TI !SimpleLink SDK
     94The TI !SimpleLink SDK contains libraries, documentation and examples for the TI CC13xx parts.
     95 * [http://www.ti.com/tool/SIMPLELINK-CC13X2-26x2-SDK SimpleLink SDK for CC13xx]
     96 * [http://www.ti.com/tool/download/SIMPLELINK-CC13X2-26X2-SDK Download Site] - Latest Release
     97 * [http://www.ti.com/tool/download/SIMPLELINK-CC13X2-26X2-SDK/3.20.00.68 SimpleLink cc13x2-26x2-sdk-3.20.00.68] - What is used on this page
     98
     99If using revision control, the following project files should be checked into source control:
     100- .ccsproject - project info specific to CCS
     101- .cproject - Eclipse CDT project file
     102- .project - Eclipse CDT project file
     103- .settings folder - Eclipse folder
     104- makefile.defs (if using SYS/BIOS) - additional make rules
     105- do not check in \Debug or \Release\<config name>, .xdchelp, .config folder, .launches folder
     106
     107Some of the examples in the !SimpleLink directory have makefiles for the TI GCC compiler while others only support being built with TI's Code Composer Studio, IAR compiler, or their newer syscfg tool. Look for 'gcc' directories if you want to use the stand-alone GCC compiler. These examples require that you define the GCC_ARMCOMPILER env variable as specified [#gcc above].
     108
     109The !SimpleLink SDK provides examples and documentation for driver API's for the low-level drivers built into the chip ROM as well as higher-level abstraction API's such as the '!EasyLink' abstraction layer.
     110
     111The TI !SimpleLink SDK option allows you to jump in and code at various levels depending on your needs and comfort zone:
     112 - [#rf-driver low lever RF driver]
     113 - [#ti-rtos TI RTOS]
     114 - [#easylink EasyLink SDK]
     115 - [#ti-15.4 TI 802.15.4 stack] offloads the 802.15.4 layer from the CC135x CPU to the host CPU
     116
     117Other necessary TI tools and details:
     118 - [#rf-settings SmartRF Studio] is a Windows app that allows you to obtain configuration code for the various RF registers that control frequency, tx-power, bandwidth, and other low-level protocol details.
     119 - [#ccfg CCFG registers] control details such as MAC address and how the CC135x powers up (ie if it skips past its serial bootloader and how).
     120
     121
     122[=#rf-driver]
     123==== Low Level RF driver API
     124The RF driver offers very low-level API's to run radio operation commands on the TI RF core and send and receive raw packets. For driver documentation see:
     125 * offline: header files in the !SimpleLink SDK under {{{source/ti/drivers}}}
     126 * [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&node=AP24VgJ7gbuZWQrdF16tIg__pTTHBmu__3.20.00.68 SimpleLink MCU SDK Driver API Reference for SimpleLink SDK 3.20.00.68]
     127
     128References:
     129 - [http://www.ti.com/simplelinkacademy SimpleLink Academy]
     130 - [http://processors.wiki.ti.com/index.php/Category:Sub-1GHz Proprietary RF Wiki]
     131
     132
     133[=#ti-rtos]
     134==== TI Real Time Operating System (TI RTOS)
     135TI-RTOS accelerates development schedules by eliminating the need to create basic system software functions from scratch. TI-RTOS scales from a real-time multitasking kernel - TI-RTOS Kernel - to a complete RTOS solution including additional middleware components, device drivers and power management. TI-RTOS and TI's ultra low-power MCUs combine to enable developers to design applications with much longer battery life. By providing essential system software components pre-tested and pre-integrated, TI-RTOS enables developers to focus on differentiating their application.
     136
     137The TI RTOS is integrated within the !SimpleLink SDK and you can find details and examples for Threads, Semaphors, and Timers. For various examples you can choose to use the TI RTOS or choose the non-RTOS examples which have less complexity but less features.
     138
     139Documentation:
     140 * [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&node=AO4DAcZA7IpIn13ay3dB8A__pTTHBmu__3.20.00.68 TI-RTOS Kernel (SimpleLink SDK 3.20.00.68)]
     141 * [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&node=APmkrAf9-b5UUEth7NyHtA__pTTHBmu__3.20.00.68 TI-POSIX Users Guide (SimpleLink SDK 3.20.00.68)]
     142
     143
     144[=#easylink]
     145==== !EasyLink
     146The RF core has a dedicated driver called the TI-RTOS RF driver which is used for all interaction with the RF core. !EasyLink is a simple abstraction layer on top of the RF driver intended as a start point for customers creating a proprietary Sub-1GHz protocol or application.
     147
     148The !EasyLink API is documented both online and offline:
     149 * offline: in the SDK installation folder, under docs/proprietary-rf/proprietary-rf-users-guide/easylink/index.html
     150 * [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&node=AOFmdaK8impnxmEqGU3jkg__pTTHBmu__LATEST EasyLink API Reference for SimpleLink SDK 3.20.00.68]
     151
     152In the !EasyLink Network Processor project, the !EasyLink API is also exposed via an AT Command Interface such that it can be exercised over serial transport by a host software (running on an PC, MPU or MCU) or manually by using a serial terminal emulator.
     153
     154Examples can be found in the !SimpleLink SDK under Software -> !SimpleLink cc13x2 SDK -> Examples -> Development Tools -> CC1352 !LaunchPad -> !EasyLink.
     155
     156For instructions on using the TI-RTOS examples refer to docs/proprietary-rf/proprietary-rf-users-guide.html
     157
     158If you do not wish to use the !EasyLink abstraction layer, there is also the option to do simple packet RX/TX using the TI-RTOS RF driver directly (see [#rf-driver above]).
     159
     160On the other hand, if you wish to create a full stack-based network solution, consider using the TI 15.4-Stack (see [#ti-15.4 below]), available as part of the CC13x0 SDK.
     161
     162
     163[=#ti-15.4]
     164==== TI 15.4 Stack
     165TI has an SDK that implements 15.4 Stack if you wish to implement the 15.4 stack on the host CPU vs the CC13xx CPU. See the [http://dev.ti.com/tirex/content/simplelink_academy_cc13x2sdk_2_10_02_10/modules/154-stack/154-stack_01_sensor_collector/154-stack_01_sensor_collector.html Sensor and Collector applications] for examples of this.
     166
     167Documentation:
     168 * [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&node=ACA4JejIBOUb1EEBZyGp1g__pTTHBmu__3.20.00.68 TI 15.4-Stack (SimpleLink SDK 3.20.00.68)]
     169
     170Examples:
     171 * [http://dev.ti.com/tirex/content/simplelink_academy_cc13x2sdk_2_30_02_00/modules/prop_rf/prop_03_easylink_nwp/prop_03_easylink_nwp.html rfEasyLinkNp]:
     172{{{#!bash
     173export GCC_ARMCOMPILER=~/ti/ccs910/ccs/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/
     174cd ~/ti/simplelink_cc13x2_sdk_2_30_00_45
     175make -C kernel/tirtos/builds/CC1352P_4_LAUNCHXL/release/gcc # rfEasyLinkNp requires the TIRTOS kernel
     176make -C examples/rtos/CC1352P_4_LAUNCHXL/easylink/rfEasyLinkNp/tirtos/gcc
     177cd examples/rtos/CC1352P_2_LAUNCHXL/easylink/rfEasyLinkNp/tirtos/gcc
     178$GCC_ARMCOMPILER/arm-none-eabi-objcopy -S --gap-fill 0xff -O binary rfEasyLinkNp.out rfEasyLinkNp.bin
     179$GCC_ARMCOMPILER/arm-none-eabi-objcopy -S -O ihex rfEasyLinkNp.out rfEasyLinkNp.hex
     180}}}
     181
     182
     183[=#rf-settings]
     184==== RF Settings / SmartRF Studio
     185RF commands are used to set various RF properties via the RF Core API. These commands are passed via an RF_RadioSetup structure when calling RF_Open.
     186
     187While SmartRF Studio can interactively configure !SimpleLink chips over JTAG this requires one of TI's Launchpad development boards.
     188
     189The RF commands and properties can be obtained using the Windows based TI RFStudio application which allows selecting RF details (frequency, tx-power, channel bandwidth, etc) and exporting these to code snippets which define the structures that are passed to RF_Open.
     190
     191References:
     192 - [http://www.ti.com/tool/SMARTRFTM-STUDIO home page]
     193 - [http://www.ti.com/lit/ug/swru194b/swru194b.pdf Tutorial]
     194
     195
     196[=#dmm]
     197==== TI Dynamic Multi-protocol Manager (DMM)
     198The Dynamic Multi-protocol Manager (DMM) allows multiple wireless stacks (ie BLE5-Stack, TI 15.4, Zibgee or !EasyLink) to coexist and operate concurrently acting as an arbiter between the stacks and the shared RF core resource.
     199
     200TI has several examples in the dmm subdirectory of the SimpleLink SDK.
     201
     202For more information see the [http://dev.ti.com/tirex/explore/node?node=AEKDw4UXFWWpjzogXjgVAQ__pTTHBmu__LATEST Latest TI DMM Users's Guide]
     203
     204
     205[=#ccfg]
     206==== CCFG registers
     207The TI !SimpleLink chips have a CCFG register section defined in the Technical Reference Manual. These registers configure things such as MAC address, bootloader config, JTAG TAP/DAP configuration and some RF gain details. Many of the TI examples contain a {{{ccfg.c}}} file which includes {{{source/ti/devices/cc13x2_cc26x2_v1/startup_files/ccfg.c}}}
     208
     209
     210[=#examples]
     211== Software Examples
     212The following software examples all assume:
     213 * [http://software-dl.ti.com/ccs/esd/CCSv9/CCS_9_1_0/exports/CCS9.1.0.00010_linux-x64.tar.gz CCS9.1.0.00010_linux-x64.tar.gz] - CCS9.1.0.0010 installed in home directory (see [#ccs above] for install instructions)
     214 * [http://www.ti.com/tool/download/SIMPLELINK-CC13X2-26X2-SDK/3.20.00.68 SimpleLink cc13x2-26x2-sdk-3.20.00.68] - !SimpleLink SDK 3.20.00.68 installed in home directory (see [#simplelink above] for install instructions)
     215 * Environment setup for GCC:
     216{{{#!bash
     217export COM_TI_SIMPLELINK_CC13X2_26X2_SDK_INSTALL_DIR=~/ti/simplelink_cc13x2_26x2_sdk_3_20_00_68
     218export GCC_ARMCOMPILER=~/ti/ccs910/ccs/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major
     219export XDC_INSTALL_DIR=~/ti/xdctools_3_51_03_28_core
     220}}}
     221
     222Pre-built firmware for these examples is available at:
     223 * http://dev.gateworks.com/gwiot
     224
     225Once you have a {{{*.out}}} binary file you can program the CC1352P via [#jtag JTAG programming].
     226
     227
     228[=#ti-examples]
     229=== TI !SimpleLink SDK examples
     230The TI !SimpleLink examples fall into the following categories:
     231 * **nortos** - TI Drivers without an underlying operating system (OS) (there can be only one main thread which interrupts can preempt - typical 'multithreading' is not available).
     232 * **rtos** - TI-RTOS Kernel - a scalable real-time kernel designed to be used by applications that require real-time scheduling and synchronization or real-time instrumentation. It provides preemptive multi-threading, hardware abstraction, real-time analysis, and configuration tools. Note that the TI-RTOS Kennel used to be called SYS/BIOS and you can read more about it in the [http://www.ti.com/lit/pdf/spruex3 TI-RTOS Kernel User's Guide].
     233 * **syscfg** - The !SysConfig tool makes it easy to configure components like TI Drivers and device-specific components (such as the networking stack, !EasyLink, and !WiFi).
     234
     235Examples (for more examples see !SimpleLink SDK):
     236 * Drivers (Simple Applications use the low level TI RF Driver API's):
     237  - [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&devtools=LAUNCHXL-CC1352P1&node=ANdbVz9xDqq76q1tXzIxrw__pTTHBmu__3.20.00.68 rfPacketTx (nortos)]: Illustrates how to do simple packet transmission using the RF driver. This example is meant to be used with the rfPacketRx example. For every packet transmitted the GRN LED (Board_PIN_LED1) is 'toggled'. The frequency and other RF settings are in smartrf_settings.c defaulted to 868MHz 20dBm tx-power and can be modified using SmartFR Studio.
     238{{{#!bash
     239cd $COM_TI_SIMPLELINK_CC13X2_26X2_SDK_INSTALL_DIR
     240make -C examples/nortos/CC1352P1_LAUNCHXL/drivers/rfPacketTx/gcc
     241ls examples/nortos/CC1352P1_LAUNCHXL/drivers/rfPacketTx/gcc/*.out
     242}}}
     243  - [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&devtools=LAUNCHXL-CC1352P1&node=ALy2FGCuvTlRjYeng-prdA__pTTHBmu__3.20.00.68 rfPacketRx (nortos)]: Illustrates how to do simple packet transmission using the RF driver. This example is meant to be used with the rfPacketTx example. For every packet received the RED LED (Board_PIN_LED2) is 'toggled'. The frequency and other RF settings are in smartrf_settings.c defaulted to 868MHz and can be modified using SmartFR Studio.
     244{{{#!bash
     245cd $COM_TI_SIMPLELINK_CC13X2_26X2_SDK_INSTALL_DIR/examples/nortos/CC1352P1_LAUNCHXL/drivers/rfPacketTx/gcc
     246make
     247ls *.out
     248}}}
     249 * !EasyLink (Higher Level API for RF applications):
     250  - [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&devtools=LAUNCHXL-CC1352P1&node=AN5iP-onHCGjtV20BE22BQ__pTTHBmu__3.20.00.68 rfEasyLinkTx] (No RTOS): Illustrates how to do simple packet transmission using the !EasyLink API. This example is meant to be used with the rfEasyLinkxRx example. It toggles GRN LED every 100ms indicating a packet has been transmitted. After the 10th packet is transmitted the 11th transmission will be aborted toggling the RED LED then the cycle will continue. The frequency and other RF settings are in smartrf_settings.c defaulted to 868MHz 20dBm tx-power and can be modified using SmartFR Studio.
     251{{{#!bash
     252cd $COM_TI_SIMPLELINK_CC13X2_26X2_SDK_INSTALL_DIR
     253make -C examples/nortos/CC1352P1_LAUNCHXL/easylink/rfEasyLinkTx/gcc
     254ls examples/nortos/CC1352P1_LAUNCHXL/easylink/rfEasyLinkTx/gcc/*.out
     255}}}
     256  - [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&devtools=LAUNCHXL-CC1352P1&node=AOkiYdV967Azzq9UFvotBQ__pTTHBmu__3.20.00.68 rfEasyLinkRx] (No RTOS): Illustrates how to do simple packet reception using the !EasyLink API. This example is meant to be used with the rfEasyLinkxTx example. It toggles RED LED to indicate a packet has been received. The GRN LED will toggle indicating an abort which is expected to happen if a packet is not received within 300ms of the RX being scheduled (which should occur every 11th packet as dictated by rfEasyLinkTx above). Both GRN and RED LED's together indicates an error (which is not expected to happen under normal conditions). The frequency and other RF settings are in smartrf_settings.c defaulted to 868MHz 20dBm tx-power and can be modified using SmartFR Studio.
     257{{{#!bash
     258cd $COM_TI_SIMPLELINK_CC13X2_26X2_SDK_INSTALL_DIR
     259make -C examples/nortos/CC1352P1_LAUNCHXL/easylink/rfEasyLinkRx/gcc
     260ls examples/nortos/CC1352P1_LAUNCHXL/easylink/rfEasyLinkRx/gcc/*.out
     261}}}
     262  - [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&devtools=LAUNCHXL-CC1352P1&node=AFtEr4y0Wzh-VLf2wbYWFw__pTTHBmu__3.20.00.68 rfEasyLinkNP (TI Kernel RTOS)]: Exposes the !EasyLink API over an AT command interface such that it can be excercised by Host SW. Note that this requires the TI Kernel RTOS.
     263   * Building:
     264{{{#!bash
     265cd $COM_TI_SIMPLELINK_CC13X2_26X2_SDK_INSTALL_DIR
     266make -C kernel/tirtos/builds/CC1352P1_LAUNCHXL/release/gcc
     267make -C examples/rtos/CC1352P1_LAUNCHXL/easylink/rfEasyLinkNp/tirtos/gcc
     268ls examples/rtos/CC1352P1_LAUNCHXL/easylink/rfEasyLinkNp/tirtos/gcc/*.out
     269}}}
     270   * Once flashed on two different boards (Board_TX and Board_RX) you can connect to the tty of the CC1352P UART at 115200bd 8N1 and use the [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&devtools=LAUNCHXL-CC1352P1&node=AFtEr4y0Wzh-VLf2wbYWFw__pTTHBmu__3.20.00.68 EasyLink API AT commands] to send and receive packets. For example:
     271    - BoardRX: Initialize the radio and receive data
     272{{{#!bash
     273AT+I
     274AT+RX
     275}}}
     276    - BoardTX: Initialize the radio and transmit 'hello'
     277{{{#!bash
     278AT+I
     279AT+TX Hello World
     280}}}
     281 * BLE5-Stack (These lack Makefiles so must be built via Code Composer Studio):
     282  - [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&devtools=LAUNCHXL-CC1352P1&node=ADaGSlQIzV02syxJVpyQ5w__pTTHBmu__3.20.00.68 multi_role] -  demonstrates functioning in multiple simultaneous connection roles, master and slave simultaneously. A UART based API supports operations: Advertise, Discover, Connect. GATT Read, GATT Write, Connection Update, Disconnect. A UART API at 115200baud 8N1 will provide a simple menu (S2/DIO14 moves to the next menu item and S1/DIO15 selects the current menu item).
     283  - [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&devtools=LAUNCHXL-CC1352P1&node=ANX2p6buqXJrBKtIEs1zYg__pTTHBmu__3.20.00.68 simple_broadcaster]: Demonstrates non-connectable beacon applications (ie Apple iBeacon and Google Eddystone). This application uses the UART peripheral to display messages and is configured to broadcast sample advertising data out of the box via non-connectable advertisements. See [http://www.ti.com/lit/pdf/swra475 Bluetooth low energy Beacons Application Note (SWRA475)] for more information about Bluetooth low energy beacons. You can use a BLE Scanner such as the 'BLE Scanner' Android application to see the beacon which will be named 'SimpleBLEBroadcaster'.
     284  - [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&devtools=LAUNCHXL-CC1352P1&node=AISdpANsb4XiVuXfKEGg.A__pTTHBmu__3.20.00.68 simple_peripheral]: Implements a simple Bluetooth low energy peripheral device with GATT services and demonstrates the TI Simple Profile. This example can be a framework for developing many different peripheral-role applications and is used as a baseline for explaining the stack in the [http://dev.ti.com/tirex/explore/node?node=AOimuSWjap.4RuDbcp7OqA__pTTHBmu__LATEST BLE5-Stack Users's Guide]. A UART API at 115200baud 8N1 will provide a simple menu (S2/DIO14 moves to the next menu item and S1/DIO15 selects the current menu item).
     285  - [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&devtools=LAUNCHXL-CC1352P1&node=AL0yvwoNOwx7EDT71dyc3Q__pTTHBmu__3.20.00.68 simple_central]: Implements a simple Bluetooth low energy central device with GATT client functionality. By default the app is configured to filter and connect to peripheral devices with the TI Simple Profile UUID such as the {{{simple_peripheral}}} example. A UART API at 115200baud 8N1 will provide a simple menu (S2/DIO14 moves to the next menu item and S1/DIO15 selects the current menu item).
     286  - [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&devtools=LAUNCHXL-CC1352P1&node=AEfNyWl7WdIEMmkFKCRPlA__pTTHBmu__3.20.00.68 simple_peripheral_oad]: Demonstrates on-chip OAD functionality combined with the {{{simple_peripheral}}} example application. This app is configured to be managed and launched by the  Boot Image Manager (BIM) example app meaning this project does not include aCCFG section to configure the device at boot and therefore requires that the BIM project is programmed into the device first. See [#oad OAD] for more info.
     287  - [http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.20.00.68&devtools=LAUNCHXL-CC1352P1&node=ACBbg7e97.LtCgJpJS9i7A__pTTHBmu__3.20.00.68 project_zero]: Implements a simple Bluetooth low energy peripheral devices with GATT services also demonstrating how to integrate Over the Air (OAD) Download and three custom services. This app is configured to be managed and launched by the Boot Image Manager (BIM) example app meaning this project does not include a CCFG section to configure the device at boot and therefore requires that the BIM project is programmed into the device first. See [#oad OAD] for more info.
     288
     289
     290[=#programming]
     291== Programming
     292
     293
     294[=#jtag]
     295=== Via JTAG
     296The CC135x by default comes up in 2-wire cJTAG mode but does support 4-wire JTAG. There is a sequence that needs to be done in order to get it to 4-wire mode.
     297
     298JTAG programming is supported with OpenOCD software on the following:
     299 * GW16122-B via the Gateworks [https://shop.gateworks.com/index.php?route=product/product&product_id=155 GW11033] JTAG dongle attached to the 10-pin JTAG header J6 (make sure the board is powered via the miniPCIe connector; ie in a board powered on or via a USB to miniPCIe adapter plugged into a powered USB port)
     300 * GW5910-C via IMX6 GPIO
     301
     302Note that the OpenOCD package from Ubuntu lacks the necessary cc26xx flash driver so we must either build OpenOCD from source manually or use the Gateworks Ubuntu PPA:
     303 * Installing from Gateworks Ubuntu PPA:
     304{{{#!bash
     305sudo add-apt-repository ppa:gateworks-software/packages
     306sudo apt update
     307sudo apt install openocd
     308}}}
     309 * Building from source:
     310{{{#!bash
     311apt install build-essential libusb-1.0-0-dev libftdi-dev autoconf libtool pkg-config git
     312git clone https://github.com/Gateworks/openocd.git
     313cd openocd
     314./bootstrap
     315./configure --enable-imx_gpio --enable-ftdi --enable-sysfsgpio
     316make install
     317}}}
     318  - The Gateworks OpenOCD git repo also has some additional patches we found necessary to make it reliably program the CC135x.
     319
     320You will also need OpenOCD interface / board config files:
     321 - If using a GW16122-B+ and a GW16042 JTAG dongle plugged into J6:
     322  [[CollapsibleStart(Config file)]]
     323{{{#!bash
     324cat << EOF > gw16122.cfg
     325#
     326# Gateworks GW16122 CC1352P JTAG interface
     327#
     328# Layout: FTDI FT2232H
     329#   ADBUS0 TCK
     330#   ADBUS1 TDI
     331#   ADBUS2 TDO (input)
     332#   ADBUS3 TMS
     333#   ADBUS4 nTRST
     334#   ADBUS5 nSRST
     335#   ADBUS6 OE (active high) for TRST, TDI, TMS, TCK
     336#   ADBUS7 NC
     337#   ACBUS0-7 NC
     338#   BDBUS0 RXD
     339#   BDBUS1 TXD (input)
     340#
     341interface ftdi
     342ftdi_device_desc "USB-JTAG"
     343ftdi_vid_pid 0x0403 0x6010
     344ftdi_layout_init 0x0058 0x007b
     345ftdi_layout_signal nSRST -oe 0x0020
     346
     347adapter_khz 10000
     348transport select jtag
     349source [find target/ti_cc13x2.cfg]
     350reset_config none
     351EOF
     352}}}
     353[[CollapsibleEnd]]
     354
     355  * Program {{{firmware.out}}}:
     356{{{#!bash
     357openocd -f ./gw16122.cfg -c "program firmware.out verify reset exit"
     358}}}
     359 - If using a GW5910* C revision or greater:
     360  [[CollapsibleStart(Config file)]]
     361{{{#!bash
     362cat << EOF > gw5910.cfg
     363#
     364# GW5910 CC1352P JTAG Interface mapping
     365#
     366# PAD_DISP0_DAT14__GPIO5_IO08 TMS gpio-136
     367# PAD_DISP0_DAT15__GPIO5_IO09 TCK gpio-137
     368# PAD_DISP0_DAT16__GPIO5_IO10 TDO gpio-138
     369# PAD_DISP0_DAT17__GPIO5_IO11 TDI gpio-139
     370#
     371# PAD_DISP0_DAT23__GPIO5_IO17 RST# gpio-145
     372# PAD_EIM_A25__GPIO5__IO02 BOOT gpio-130
     373
     374interface imx_gpio
     375transport select jtag
     376imx_gpio_peripheral_base 0x020ac000
     377imx_gpio_speed_coeffs 100000 5
     378imx_gpio_jtag_nums 9 8 11 10
     379imx_gpio_trst_num 17
     380
     381adapter_khz 20000
     382source [find target/ti_cc13x2.cfg]
     383
     384jtag_ntrst_delay 0
     385jtag_ntrst_assert_width 0
     386adapter_nsrst_delay 0
     387adapter_nsrst_assert_width 0
     388
     389reset_config trst_only
     390EOF
     391}}}
     392[[CollapsibleEnd]]
     393  * Program {{{firmware.out}}}:
     394{{{#!bash
     395openocd -f ./gw5910.cfg -c "program firmware.out verify reset exit"
     396}}}
     397
     398[=#bootloader]
     399=== Via Serial bootloader
     400The TI !SimpleLink products have a ROM bootloader that supports 2-pin UART or 4-pin SPI via a serial protocol defined in the Techical Reference Manuals (TRM):
     401 * [http://www.ti.com/lit/ds/symlink/cc1352r.pdf CC1352 datasheet]
     402 * [http://www.ti.com/lit/ug/swcu185a/swcu185a.pdf CC13x2 TRM]
     403
     404A .bin file or .hex file is required when using the bootloader. These can be created with the gcc compiler:
     405 * Specify env var for TI GCC compiler (example: CCSv9)
     406{{{#!bash
     407export GCC_ARMCOMPILER=~/ti/ccs910/ccs/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major
     408}}}
     409 * Create a bin file from out:
     410{{{#!bash
     411$(GCC_ARMCOMPILER)/bin/arm-none-eabi-objcopy -S --gap-fill 0xff -O binary firmware.out firmware.bin
     412}}}
     413 * Create a hex file from out:
     414{{{#!bash
     415$(GCC_ARMCOMPILER)/bin/arm-none-eabi-objcopy -S -O ihex firmware.out firmware.hex
     416}}}
     417
     418This can be used to program application firmware as long as the CCFG registers define the configuration to keep the bootloader enabled:
     419 - GW16122-B+ connects the FTDI cbus0 to CC1352_RST# and the FTDI cbus1 to CC1352_DIO20 thus those can be used to reset and configure the serial bootloader with the following CCFG:
     420{{{
     421#define SET_CCFG_BL_CONFIG_BOOTLOADER_ENABLE    0xC5    // Enable ROM boot loader
     422#define SET_CCFG_BL_CONFIG_BL_LEVEL             0x1     // Active high to open boot loader backdoor
     423#define SET_CCFG_BL_CONFIG_BL_PIN_NUMBER        20      // DIO20
     424#define SET_CCFG_BL_CONFIG_BL_ENABLE            0xC5    // Enabled bootloader backdoor
     425}}}
     426 - In your main application you can use DIO19 for RTS if needed
     427
     428There are a number of software resources available for programming in this fashion however if you program firmware that does not have the above CCFG configuration you will no longer be able to access the bootloader and will have to use JTAG. Therefore using JTAG programming is likely recommended recommended.
     429
     430Once such application you can use out-of-the-box for updating firmware via serial bootloader is cc2538-bsl.py.
     431
     432Examples:
     433 * GW16122-B:
     434{{{#!bash
     435apt install python python-serial python-magic python-pip
     436pip install intelhex # intelhex required if using .hex files
     437git clone https://github.com/Gateworks/cc2538-bsl.git
     438cd cc2538-bsl
     439./cc2538-bsl.py -p /dev/ttyUSB0 -b 1000000 -e -w -v firmware.hex
     440}}}
     441  - You will need to configure and toggle chip reset and bootloader-enable manually via FTDI gpio. Contact support@gateworks.com for details
     442
     443As the GW5910-C can be programmed via OpenOCD via imx-gpio JTAG there really isn't any reason to want to use the Serial bootloader.
     444
     445
     446
     447[=#oad]
     448=== Over the Air Download (OAD) / Over The Air (OTA)
     449For generic OTA, the idea is to transmit FW over the air to the CC13xx. After finishing FW transmitting, the OTA application will check FW integrity and if the downloaded FW Is correct, the application should notify bootloader and reboot for bootloader to move FW to CC13xx to restart.
     450
     451TI provides OTA examples in the BLE Stack, TI 15.4 Stack, and !EasyLink example projects. This works by having a Boot Image Manager (BIM) which resides on the OAD target and is responsible for loading new images after a download has completed. The BIM executes on a device reset and determines if a firmware update needs to be applied. If no update is being applied then the BIM will transfer program execution to the main application image. Note that TI's BLE-Stack OAD Profile does not implement or perform any security or authentication mechanisms as part of the firmware update process - if this is something you need you will need to implement this yourself or look for another OAD process. TI recommends applications use Bluetooth LE Secure Connections (LESC) with Man-in-the-Middle (MITM) protection with peer devices when performing wireless firmware updates although the use of the LESC feature does not itself guarantee image authenticity.
     452
     453BIM is a fully executable application that is independent of any high level protocol stack or user application and is guaranteed to run on boot. BIM enables power loss fault tolerance during OAD... if the device power is lost during OAD the BIM will still be able to run from reset and revert to a working image if one is available. The BIM is intended to reside permanently on the chip and cannot be updated via the OAD process. BIM executes before kernel initialization takes place so the design is single threaded and bare metal. Hardware access is accomplished through driverlib. As a separate application, BIMI requires its own interrupt vector table and linker file and will produce a fully executable image that must be merged with the user application image in order to create a functional OAD enabled firmware system.
     454
     455The TI BIM comes in two forms: 'on-chip' for Storing the firmware update in the internal flash and 'off-chip' for storing the firmware image in an external FLASH chip. Note that the Gateworks CC135x products do not have external flash devices connected to the CC135x however one could implement their own OAD process that uses the baseboard's mechanisms for storage and firmware update (ie JTAG).
     456
     457To create an OAD image you use the TI OAD Image Tool which is distributed in both source and binary form (Linux, Windows, Mac) and is run as a post build step to an OAD application. The tool located in <SDK_DIR>/tools/common/aod/oad_image_tool.py will generate an output binary file named <app_name>_oad.bin.
     458
     459For more info on this process please consult the [http://dev.ti.com/tirex/explore/node?node=AOimuSWjap.4RuDbcp7OqA__pTTHBmu__LATEST BLE5-Stack Users's Guide]
     460
     461References:
     462 - [http://dev.ti.com/tirex/content/simplelink_academy_cc13x2sdk_2_30_02_00/modules/ble5stack/ble_enhanced_oad/ble_enhanced_oad.html Bluetooth Low Energy Enhanced Over the Air Download]
     463
     464
     465[=#tty]
     466== Identifying TTYs
     467The FTDI USB UART chips are supported by a the 'ftdi-sio' kernel driver/module that registers /dev/ttyUSB<n> devices.
     468
     469Because this is a commonly used chip including the one used in the Gateworks JTAG dongles it can be helpful to have some commands to help you identify which tty is which device:
     470 * List all USB devices that provide a ttyUSB:
     471{{{#!bash
     472for i in $(ls -1d /sys/bus/usb/devices/*); do [ -r $i/interface ] && { echo $(cat $i/interface):$(ls -d $i/ttyUSB* 2>/dev/null); }; done
     473}}}
     474 * List only GW16122 devices and their TTY:
     475{{{#!bash
     476for i in $(ls -1d /sys/bus/usb/devices/*); do [ -r $i/interface ] && { echo $(cat $i/interface):$(ls -d $i/ttyUSB* 2>/dev/null); }; done | grep GW16122
     477}}}
     478 * List GW16122 serial numbers:
     479{{{#!bash
     480usb-devices | grep -A1 GW16122
     481}}}
     482
     483
     484[=#uart]
     485[=#picocom]
     486== Serial UART Access
     487The GW5910 has the IMX6 UART3 connected as full-duplex to the CC1352P thus you can access it via /dev/ttymxc2
     488
     489The GW16122 has an FTDI FT231X USB Full Speed UART connected to it via the following pinout:
     490 * FT231X TXD -> DIO_12 (UART_RX)
     491 * FT231X RXD <- DIO_13 (UART_TX)
     492 * FT231X RTS# -> DIO_18 (UART_RTS)
     493 * FT231X CTS# <- DIO_19 (UART_CTS)
     494
     495Hardware flow control (RTS/CTS) is only necessary if you load code onto the CC1352P that uses it.
     496
     497There are several Linux terminal programs that can aid you in communicating with the UART such as {{{screen}}}, {{{picocom}}}, {{{minicom}}}.
     498
     499Examples:
     500{{{#!bash
     501# Find the tty associated with the GW16122 device in your system
     502TTY=/dev/$(for i in $(ls -1d /sys/bus/usb/devices/*); do [ -r $i/interface ] && { [[ "$(cat $i/interface)" =~ "GW16122" ]] && basename $(ls -d $i/ttyUSB*); }; done)
     503echo $TTY
     504apt install picocom
     505picocom --baud 115200 $TTY
     506}}}
     507  - make sure you point to the correct /dev/ttyUSB* device managed by the ftdi_sio driver