Skip to content

Instantly share code, notes, and snippets.

@leoheck
Forked from hwhw/cc2538-and-openocd.md
Last active January 13, 2023 15:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoheck/fe802c21262e4f1f8a7fe668a2faf364 to your computer and use it in GitHub Desktop.
Save leoheck/fe802c21262e4f1f8a7fe668a2faf364 to your computer and use it in GitHub Desktop.
Flashing CC13*2 using OpenOCD

Flashing CC13x2 with OpenOCD Using XDS110 and JTAG.

Install OpenOCD version 0.11.0 (or maybe higher)

You can also build it yourself.

Boards setup

If you are using Launchpads to experiment this setup, you are going to need to prepare them as it is being shown in this image.

jtag_chain2

CC1352 Chain Setup

The scan chain can be easily created with N devices using my custom script ti_cc1352_chain.cfg.

# Leandro Heck
# leoheck@gmail.com

# This example uses ti_cc26x0.cfg to create a daisy chain of equal devices 

# set _N_CPUS 1
# set _BIN_FILE "/home/lheck/workspace_v11/timerled_CC1352R1_LAUNCHXL_tirtos_ccs/Debug/timerled_CC1352R1_LAUNCHXL_tirtos_ccs.bin"
# set _CHIP_PREFIX "cc1352"

if { [info exists CHIP_PREFIX] } {
    set _CHIP_PREFIX ${CHIP_PREFIX}
} else {
    set _CHIP_PREFIX "cc1352"
}

if { [info exists N_CPUS] } {
    set _N_CPUS ${N_CPUS}
} else {
    set _N_CPUS 1
}

if { [info exists BIN_FILE] } {
    set _BIN_FILE ${BIN_FILE}
} else {
    puts "You must set the BIN_FILE"
    exit
}

proc create_target {target_name} {
    set CHIPNAME ${target_name}
    set WORKAREASIZE 0x7000
    set JRC_TAPID 0x0BB4102F
    source [find target/ti_cc26x0.cfg]
}

proc flash_target {target_name bin_file} {
    targets ${target_name}.cpu
    reset init
    program ${bin_file} verify
}

proc create_all_targets {n_cpus _CHIP_PREFIX} {
    for {set i 0} {${i} < ${n_cpus}} {incr i} {
        set target "${_CHIP_PREFIX}_$i"
        create_target ${target}
    }
}

proc flash_all_targets {n_cpus _CHIP_PREFIX bin_file} {
    for {set i 0} {${i} < ${n_cpus}} {incr i} {
        set target "${_CHIP_PREFIX}_$i"
        flash_target ${target} ${bin_file}
    }
}

create_all_targets ${_N_CPUS} ${_CHIP_PREFIX}

init

flash_all_targets ${_N_CPUS} ${_CHIP_PREFIX} ${_BIN_FILE}

# scan_chain
targets

reset run

# exit

Flashing N boards

The last step is to launch openocd with the following command using the previows ./ti_cc1352_chain.cfg script.

openocd \
  -c " \
    # The interface here is he XDS110
    source [find interface/xds110.cfg]
    reset_config
    transport select jtag
    adapter speed 1000
    set N_CPUS 2
    set BIN_FILE program.bin
    source ./ti_cc1352_chain.cfg
  "
# Leandro Heck
# leoheck@gmail.com
# This example uses ti_cc26x0.cfg to create a daisy chain of equal devices
# set _N_CPUS 1
# set _BIN_FILE "/home/lheck/workspace_v11/timerled_CC1352R1_LAUNCHXL_tirtos_ccs/Debug/timerled_CC1352R1_LAUNCHXL_tirtos_ccs.bin"
# set _CHIP_PREFIX "cc1352"
if { [info exists CHIP_PREFIX] } {
set _CHIP_PREFIX ${CHIP_PREFIX}
} else {
set _CHIP_PREFIX "cc1352"
}
if { [info exists N_CPUS] } {
set _N_CPUS ${N_CPUS}
} else {
set _N_CPUS 1
}
if { [info exists BIN_FILE] } {
set _BIN_FILE ${BIN_FILE}
} else {
puts "You must set the BIN_FILE"
exit
}
proc create_target {target_name} {
set CHIPNAME ${target_name}
set WORKAREASIZE 0x7000
set JRC_TAPID 0x0BB4102F
source [find target/ti_cc26x0.cfg]
}
proc flash_target {target_name bin_file} {
targets ${target_name}.cpu
reset init
program ${bin_file} verify
}
proc create_all_targets {n_cpus _CHIP_PREFIX} {
for {set i 0} {${i} < ${n_cpus}} {incr i} {
set target "${_CHIP_PREFIX}_$i"
create_target ${target}
}
}
proc flash_all_targets {n_cpus _CHIP_PREFIX bin_file} {
for {set i 0} {${i} < ${n_cpus}} {incr i} {
set target "${_CHIP_PREFIX}_$i"
flash_target ${target} ${bin_file}
}
}
create_all_targets ${_N_CPUS} ${_CHIP_PREFIX}
init
flash_all_targets ${_N_CPUS} ${_CHIP_PREFIX} ${_BIN_FILE}
# scan_chain
targets
reset run
# exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment