Changes between Version 1 and Version 2 of cc135x

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

added details for cc1352 products


  • cc135x

    v1 v2  
    13= Ti CC135x Sub-1GHz Internet of Things Radio
    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.
    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.
     8== Hardware
     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.
     26 -
     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.
     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.
     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.
     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.
     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).
     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
     48TI has excellent documentation for their SDK:
     49 * offline: In the SDK install directory under {{{docs}}}
     50 * [ SimpleLink CC13x2 26x2 SDK -]
     51  - Note that this link is pinned tot he 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
     55=== TI Code Composer Studio (CCS)
     56TI [ 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.
     58While it is not required that you use the CCS IDE you will need the compiler toolchain that is installed with it.
     60Installation (CCS9 installed on Ubuntu 18.04 bionic host):
     611. Download the 'offline installer' from TI (this is a compressed tarball):
     62  * [ Latest release]
     63  * [ 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
     67sudo apt install libc6:i386 libusb-0.1-4 libgconf-2-4 build-essential
     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
     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.
     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.
     82 * convert ELF (.out) to .bin:
     84$(GCC_ARMCOMPILER)/bin/arm-none-eabi-objcopy -S --gap-fill 0xff -O binary $(FILE).out $(FILE).bin
     86 * convert ELF (.out) to Intel Hex (.hex):
     88$(GCC_ARMCOMPILER)/bin/arm-none-eabi-objcopy -S -O ihex $(FILE).out $(FILE).hex
     93=== TI !SimpleLink SDK
     94The TI !SimpleLink SDK contains libraries, documentation and examples for the TI CC13xx parts.
     95 * [ SimpleLink SDK for CC13xx]
     96 * [ Download Site] - Latest Release
     97 * [ SimpleLink cc13x2-26x2-sdk-] - What is used on this page
     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
     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].
     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.
     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
     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).
     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 * [ SimpleLink MCU SDK Driver API Reference for SimpleLink SDK]
     129 - [ SimpleLink Academy]
     130 - [ Proprietary RF Wiki]
     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.
     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.
     140 * [ TI-RTOS Kernel (SimpleLink SDK]
     141 * [ TI-POSIX Users Guide (SimpleLink SDK]
     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.
     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 * [ EasyLink API Reference for SimpleLink SDK]
     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.
     154Examples can be found in the !SimpleLink SDK under Software -> !SimpleLink cc13x2 SDK -> Examples -> Development Tools -> CC1352 !LaunchPad -> !EasyLink.
     156For instructions on using the TI-RTOS examples refer to docs/proprietary-rf/proprietary-rf-users-guide.html
     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]).
     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.
     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 [ Sensor and Collector applications] for examples of this.
     168 * [ TI 15.4-Stack (SimpleLink SDK]
     171 * [ rfEasyLinkNp]:
     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
     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.
     187While SmartRF Studio can interactively configure !SimpleLink chips over JTAG this requires one of TI's Launchpad development boards.
     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.
     192 - [ home page]
     193 - [ Tutorial]
     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.
     200TI has several examples in the dmm subdirectory of the SimpleLink SDK.
     202For more information see the [ Latest TI DMM Users's Guide]
     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}}}
     211== Software Examples
     212The following software examples all assume:
     213 * [ CCS9.1.0.00010_linux-x64.tar.gz] - CCS9.1.0.0010 installed in home directory (see [#ccs above] for install instructions)
     214 * [ SimpleLink cc13x2-26x2-sdk-] - !SimpleLink SDK installed in home directory (see [#simplelink above] for install instructions)
     215 * Environment setup for GCC:
     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
     222Pre-built firmware for these examples is available at:
     223 *
     225Once you have a {{{*.out}}} binary file you can program the CC1352P via [#jtag JTAG programming].
     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 [ 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).
     235Examples (for more examples see !SimpleLink SDK):
     236 * Drivers (Simple Applications use the low level TI RF Driver API's):
     237  - [ 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.
     240make -C examples/nortos/CC1352P1_LAUNCHXL/drivers/rfPacketTx/gcc
     241ls examples/nortos/CC1352P1_LAUNCHXL/drivers/rfPacketTx/gcc/*.out
     243  - [ 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.
     245cd $COM_TI_SIMPLELINK_CC13X2_26X2_SDK_INSTALL_DIR/examples/nortos/CC1352P1_LAUNCHXL/drivers/rfPacketTx/gcc
     247ls *.out
     249 * !EasyLink (Higher Level API for RF applications):
     250  - [ 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.
     253make -C examples/nortos/CC1352P1_LAUNCHXL/easylink/rfEasyLinkTx/gcc
     254ls examples/nortos/CC1352P1_LAUNCHXL/easylink/rfEasyLinkTx/gcc/*.out
     256  - [ 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.
     259make -C examples/nortos/CC1352P1_LAUNCHXL/easylink/rfEasyLinkRx/gcc
     260ls examples/nortos/CC1352P1_LAUNCHXL/easylink/rfEasyLinkRx/gcc/*.out
     262  - [ 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:
     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
     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 [ EasyLink API AT commands] to send and receive packets. For example:
     271    - BoardRX: Initialize the radio and receive data
     276    - BoardTX: Initialize the radio and transmit 'hello'
     279AT+TX Hello World
     281 * BLE5-Stack (These lack Makefiles so must be built via Code Composer Studio):
     282  - [ 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  - [ 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 [ 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  - [ 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 [ 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  - [ 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  - [ 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  - [ 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.
     291== Programming
     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.
     298JTAG programming is supported with OpenOCD software on the following:
     299 * GW16122-B via the Gateworks [ 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
     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:
     305sudo add-apt-repository ppa:gateworks-software/packages
     306sudo apt update
     307sudo apt install openocd
     309 * Building from source:
     311apt install build-essential libusb-1.0-0-dev libftdi-dev autoconf libtool pkg-config git
     312git clone
     313cd openocd
     315./configure --enable-imx_gpio --enable-ftdi --enable-sysfsgpio
     316make install
     318  - The Gateworks OpenOCD git repo also has some additional patches we found necessary to make it reliably program the CC135x.
     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)]]
     324cat << EOF > gw16122.cfg
     326# Gateworks GW16122 CC1352P JTAG interface
     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)
     341interface ftdi
     342ftdi_device_desc "USB-JTAG"
     343ftdi_vid_pid 0x0403 0x6010
     344ftdi_layout_init 0x0058 0x007b
     345ftdi_layout_signal nSRST -oe 0x0020
     347adapter_khz 10000
     348transport select jtag
     349source [find target/ti_cc13x2.cfg]
     350reset_config none
     355  * Program {{{firmware.out}}}:
     357openocd -f ./gw16122.cfg -c "program firmware.out verify reset exit"
     359 - If using a GW5910* C revision or greater:
     360  [[CollapsibleStart(Config file)]]
     362cat << EOF > gw5910.cfg
     364# GW5910 CC1352P JTAG Interface mapping
     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
     371# PAD_DISP0_DAT23__GPIO5_IO17 RST# gpio-145
     372# PAD_EIM_A25__GPIO5__IO02 BOOT gpio-130
     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
     381adapter_khz 20000
     382source [find target/ti_cc13x2.cfg]
     384jtag_ntrst_delay 0
     385jtag_ntrst_assert_width 0
     386adapter_nsrst_delay 0
     387adapter_nsrst_assert_width 0
     389reset_config trst_only
     393  * Program {{{firmware.out}}}:
     395openocd -f ./gw5910.cfg -c "program firmware.out verify reset exit"
     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 * [ CC1352 datasheet]
     402 * [ CC13x2 TRM]
     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)
     407export GCC_ARMCOMPILER=~/ti/ccs910/ccs/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major
     409 * Create a bin file from out:
     411$(GCC_ARMCOMPILER)/bin/arm-none-eabi-objcopy -S --gap-fill 0xff -O binary firmware.out firmware.bin
     413 * Create a hex file from out:
     415$(GCC_ARMCOMPILER)/bin/arm-none-eabi-objcopy -S -O ihex firmware.out firmware.hex
     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:
     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
     426 - In your main application you can use DIO19 for RTS if needed
     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.
     430Once such application you can use out-of-the-box for updating firmware via serial bootloader is
     433 * GW16122-B:
     435apt install python python-serial python-magic python-pip
     436pip install intelhex # intelhex required if using .hex files
     437git clone
     438cd cc2538-bsl
     439./ -p /dev/ttyUSB0 -b 1000000 -e -w -v firmware.hex
     441  - You will need to configure and toggle chip reset and bootloader-enable manually via FTDI gpio. Contact for details
     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.
     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.
     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.
     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.
     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).
     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/ will generate an output binary file named <app_name>_oad.bin.
     459For more info on this process please consult the [ BLE5-Stack Users's Guide]
     462 - [ Bluetooth Low Energy Enhanced Over the Air Download]
     466== Identifying TTYs
     467The FTDI USB UART chips are supported by a the 'ftdi-sio' kernel driver/module that registers /dev/ttyUSB<n> devices.
     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:
     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
     474 * List only GW16122 devices and their TTY:
     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
     478 * List GW16122 serial numbers:
     480usb-devices | grep -A1 GW16122
     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
     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)
     495Hardware flow control (RTS/CTS) is only necessary if you load code onto the CC1352P that uses it.
     497There are several Linux terminal programs that can aid you in communicating with the UART such as {{{screen}}}, {{{picocom}}}, {{{minicom}}}.
     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
     507  - make sure you point to the correct /dev/ttyUSB* device managed by the ftdi_sio driver