Skip to content

Instantly share code, notes, and snippets.

@leoheck
Created March 13, 2017 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leoheck/d0a08e221f792ca5ff4baf26c56b639b to your computer and use it in GitHub Desktop.
Save leoheck/d0a08e221f792ca5ff4baf26c56b639b to your computer and use it in GitHub Desktop.
Script to refactor CCSv7 (Code Composer Studio) to run in linux
#!/bin/bash
# Leandro S. Heck (leoheck@gmail.com)
# PATHS IN MY HOST, CHANGE THIS ACCORDINGNLY
proj_name="seeds"
proj_path="/home/lheck/Desktop/$proj_name"
ccstudio_path="/repo/tools/TI/css/7.1.0/ccsv7"
workspace_path="/home/lheck/workspace_v7"
ti_path="/home/lheck/ti"
echo
echo "#> UPDATE THESE VARIABLES FOR YOUR SYSTEM"
echo
echo " Project name: $proj_name"
echo " FULL Project path: $proj_path"
echo " CCStudio path: $ccstudio_path"
echo " TI Plugins path: $ti_path"
echo "CCS Workspace path: $workspace_path"
echo
ERR=0
if [[ ! -d $proj_path ]]; then
echo "$proj_path folder is missing";
ERR=1
fi
if [[ ! -d $ccstudio_path ]]; then
echo "$ccstudio_path folder is missing";
ERR=1
fi
if [[ ! -d $workspace_path ]]; then
echo "$workspace_path folder is missing";
ERR=1
fi
if [[ ! -d $ti_path ]]; then
echo "$ti_path folder is missing";
ERR=1
fi
if [[ $ERR == 1 ]]; then
exit 1
fi
# Scape slashes for sed
proj_path=$(echo "$proj_path" | sed "s|\/|\\/|g")
ccstudio_path=$(echo "$ccstudio_path" | sed "s|\/|\\/|g")
workspace_path=$(echo "$workspace_path" | sed "s|\/|\\/|g")
ti_path=$(echo "$ti_path" | sed "s|\/|\\/|g")
# CAMINHOS PRA ARRUMAR
# C:/Users/arthu/seeds -------------------------------------> $proj_path
# C:/ti/ccsv7 ----------------------------------------------> $ccstudio_path
# C:/ti/tirtos_ ---------------------------------------------> $ti_path/tirtos_cc13xx_cc26xx_2_20_01_08
# C:/ti/simplelink -----------------------------------------> $ti_path/simplelink/
# C:/ti/tirex-content/xdctools_3_32_00_06_core/packages ----> $ti_path/xdctools_3_32_01_22_core/packages/
# C:/Users/arthu/Documents/Bluetooth Developer Studio/PluginOutput/SeedsProfile_TI_SDK22 ???
echo "Project path..."
find ./bitgait-peripheral -type f -exec sed -i "s|C:\/Users\/arthu\/seeds|$proj_path|g" {} \;
find ./bitgait-peripheral -type f -exec sed -i "s|C:\/Users\\\arthu\\\seeds|$proj_path|g" {} \;
find ./bitgait-peripheral -type f -exec sed -i "s|C:\\\Users\\\arthu\\\seeds|$proj_path|g" {} \;
echo "Project temp path..."
find ./bitgait-peripheral -type f -exec sed -i "s|C:\/Users\/arthu\/AppData\/Local\/Temp|\/tmp\/$USER\/$proj_name|g" {} \;
find ./bitgait-peripheral -type f -exec sed -i "s|C:\\\Users\\\arthu\\\AppData\\\Local\\\Temp|\/tmp\/$USER/$proj_name|g" {} \;
echo "CCSv7 workspace path..."
find ./bitgait-peripheral -type f -exec sed -i "s|C:\/Users\/arthu\/workspace_v7|$workspace_path|g" {} \;
find ./bitgait-peripheral -type f -exec sed -i "s|C:\\\Users\\\arthu\\\workspace_v7|$workspace_path|g" {} \;
echo "CCSv7 path..."
find ./bitgait-peripheral -type f -exec sed -i "s|C:\/ti\/ccsv7|$ccstudio_path|g" {} \;
find ./bitgait-peripheral -type f -exec sed -i "s|C:\\\ti\\\ccsv7|$ccstudio_path|g" {} \;
echo "TI RTOS path..."
find ./bitgait-peripheral -type f -exec sed -i "s|C:\/ti\/tirtos_|$ti_path\/tirtos_|g" {} \;
find ./bitgait-peripheral -type f -exec sed -i "s|C:\\\ti\\\tirtos_|$ti_path\/tirtos_|g" {} \;
echo "Simplelink path..."
find ./bitgait-peripheral -type f -exec sed -i "s|C:\/ti\/simplelink|$ti_path\/simplelink|g" {} \;
find ./bitgait-peripheral -type f -exec sed -i "s|C:\\\ti\\\simplelink|$ti_path\/simplelink|g" {} \;
echo "XDC Tools path..."
find ./bitgait-peripheral -type f -exec sed -i "s|C:\/ti\/tirex-content\/xdctools_3_32_00_06_core|$ti_path\/xdctools_3_32_01_22_core|g" {} \;
find ./bitgait-peripheral -type f -exec sed -i "s|C:\\\ti\\\tirex-content\\\xdctools_3_32_00_06_core|$ti_path\/xdctools_3_32_01_22_core|g" {} \;
find ./bitgait-peripheral -type f -exec sed -i "s|C:\/ti\/xdctools_3_32_00_06_core|$ti_path\/xdctools_3_32_01_22_core|g" {} \;
# echo "Bluetooth dev path... (missing for me)"
# find ./bitgait-peripheral -type f -exec sed -i "s|C:\/Users\/arthu\/Documents\/Bluetooth Developer Studio|$ti_path\/bluetooth|g" {} \;
echo "Fixing CC1350 config path..."
cc1350_cfg="$ti_path/simplelink/ble_sdk_2_02_01_18"
cc1350_cfg=$(echo "$cc1350_cfg" | sed "s|\/|\\/|g") # fix slashes
# sed -i "s|\.\.\/\.\.\/\.\.\/\.\.\/\.\.|$cc1350_cfg|g" bitgait-peripheral/iar/config/app_ble.cfg #missing file
sed -i "s|\.\.\/\.\.\/\.\.\/\.\.\/\.\.|$cc1350_cfg|g" bitgait-peripheral/ccs/config/app_ble.cfg
# Fix commands
echo "Changing to linux commands..."
find bitgait-peripheral -type f -exec sed -i "s|SHELL.*|SHELL = bash|g" {} \;
find bitgait-peripheral -type f -exec sed -i "s|RM.*DEL.*|RM = rm \-f|g" {} \;
find bitgait-peripheral -type f -exec sed -i "s|RMDIR.*RMDIR.*|RMDIR = rm \-rf|g" {} \;
# Fix case of headers
echo "Fixing headers..."
find bitgait-peripheral -type f -exec sed -i "s|ICall.h|icall.h|g" {} \;
find bitgait-peripheral -type f -exec sed -i "s|Board.h|board.h|g" {} \;
find bitgait-peripheral -type f -exec sed -i "s|OSAL.h|osal.h|g" {} \;
find bitgait-peripheral -type f -exec sed -i "s|rf.h|RF.h|g" {} \;
find bitgait-peripheral -type f -exec sed -i "s|driverLib\/timer.h|driverlib\/timer.h|g" {} \;
find bitgait-peripheral -type f -exec sed -i "s|hal_UART.h|hal_uart.h|g" {} \;
# ACHO QUE NAO PRECISA MAIS DISSO - VERIFICAR!!
# Fix Bigait-Peripheral_Stack lib_linker.cmd
# "/home/lheck/ti/simplelink/ble_sdk_2_02_01_18/blelib/host/host_pxxx.a"
# "/home/lheck/ti/simplelink/ble_sdk_2_02_01_18/blelib/ctrl/cc1350/cc1350_ctrl_pxxx.a"
# "/home/lheck/ti/simplelink/ble_sdk_2_02_01_18/blelib/hci_tl/cc26xx/cc26xx_hci_tl_none.a"
# sed -i "s|\\\\|/|g" ./bitgait-peripheral/ccs/config/lib_linker.cmd
sed -i "s|\\\|\/|g" ./bitgait-peripheral/ccs/config/lib_linker.cmd # Fix slashes orientation (missing)
# Make clean
# find bitgait-peripheral -name makefile -printf "make clean -C %h\n" | sh
# bitgait-peripheral_stack: PROJECT_LOC=/home/lheck/Desktop/seeds/src/ti_boards/bitgait-peripheral/ccs/stack
# REMOVE PATH VARIABLES:
# - ORG_PROJ_DIR1 ------------------------------------------> Remover
# - copy_PARENT --------------------------------------------> Remover
# CHANGE LINKED RESOURCES:
# - copy_PARENT/ccs/config/lib_linker.cmd ------------------> PARENT-3-PROJECT_LOC/../../../bitgait-peripheral/ccs/config/lib_linker.cmd
# - ORG_PROJ_DIR1/build_config.opt -------------------------> PARENT-3-PROJECT_LOC/../../../bitgait-peripheral/iar/stack/build_config.opt
# - copy_PARENT/ccs/config/ccs_compiler_defines.bcfg -------> PARENT-3-PROJECT_LOC/../../../bitgait-peripheral/ccs/config/ccs_compiler_defines.bcfg
# - copy_PARENT/ccs/config/ccs_linker_defines.cmd ----------> PARENT-3-PROJECT_LOC/../../../bitgait-peripheral/ccs/config/ccs_linker_defines.cmd
echo "Some weird project refs..."
find ./bitgait-peripheral/ -type f -exec sed -i "s|copy_PARENT\/ccs\/config\/lib_linker.cmd|PARENT-3-PROJECT_LOC\/bitgait-peripheral\/ccs\/config\/lib_linker.cmd|g" {} \;
find ./bitgait-peripheral/ -type f -exec sed -i "s|ORG_PROJ_DIR1\/build_config.opt|PARENT-3-PROJECT_LOC\/bitgait-peripheral\/iar\/stack\/build_config.opt|g" {} \;
find ./bitgait-peripheral/ -type f -exec sed -i "s|copy_PARENT\/ccs\/config\/ccs_compiler_defines.bcfg|PARENT-3-PROJECT_LOC\/bitgait-peripheral\/ccs\/config\/ccs_compiler_defines.bcfg|g" {} \;
find ./bitgait-peripheral/ -type f -exec sed -i "s|copy_PARENT\/ccs\/config\/ccs_linker_defines.cmd|PARENT-3-PROJECT_LOC\/bitgait-peripheral\/ccs\/config\/ccs_linker_defines.cmd|g" {} \;
# TEMPORARY FIX ISSUE WITH NAMES
find ./bitgait-peripheral/ -type f -exec sed -i "s|\/home\/$USER|\/$USER|g" {} \;
find ./bitgait-peripheral/ -type f -exec sed -i "s|\/$USER|\/home\/$USER|g" {} \;
find ./bitgait-peripheral/ -type f -exec sed -i "s|\/\/home|\/home|g" {} \;
# FIX post build frontier.exe in bitgait-peripheral/ccs/stack/FlashROM/makefile
# echo "Fixing some executables..."
# sed -i "s|^.*lib_search.exe\"|\t-python $ti_path\/simplelink\/ble_sdk_2_02_01_18\/tools\/lib_search\/src\/lib_search.py|g" bitgait-peripheral/ccs/stack/FlashROM/makefile
# sed -i "s|^.*frontier.exe|\t-python $ti_path\/simplelink\/ble_sdk_2_02_01_18\/tools\/frontier\/src\/frontier.py|g" bitgait-peripheral/ccs/stack/FlashROM/makefile
echo "Fixing some executables... (in projects)"
# find ./bitgait-peripheral/ -type f -exec sed -i "s|frontier.exe|src\/frontier.py|g" {} \;
frontier_py="/home/lheck/ti/simplelink/ble_sdk_2_02_01_18/tools/frontier/src/frontier.py"
frontier_exe="/home/lheck/ti/simplelink/ble_sdk_2_02_01_18/tools/frontier/frontier.exe"
frontier_exe_ori="/home/lheck/ti/simplelink/ble_sdk_2_02_01_18/tools/frontier/frontier.exe.ori"
if [[ ! -f $frontier_exe_ori ]]; then
mv $frontier_exe $frontier_exe_ori
frontier_script="
#!/bin/bash
# FAKING THIS EXE
#echo
#echo \"PARAMS:\"
#echo \"\$*\" | tr \' \' \'\\n\'
#echo
python $frontier_py \"\$*\"
"
echo "$frontier_script" > $frontier_exe
chmod +x $frontier_exe
fi
libsearch_py="/home/lheck/ti/simplelink/ble_sdk_2_02_01_18/tools/lib_search/src/lib_search.py"
libsearch_exe="/home/lheck/ti/simplelink/ble_sdk_2_02_01_18/tools/lib_search/lib_search.exe"
libsearch_exe_ori="/home/lheck/ti/simplelink/ble_sdk_2_02_01_18/tools/lib_search/lib_search.exe.ori"
if [[ ! -f $libsearch_exe_ori ]]; then
mv $libsearch_exe $libsearch_exe_ori
libsearch_script="
#!/bin/bash
# FAKING THIS EXE
#echo
#echo \"PARAMS:\"
#echo \"\$*\" | tr \' \' \'\\n\'
#echo
#python $libsearch_py \"\$*\"
"
echo "$libsearch_script" > $libsearch_exe
chmod +x $libsearch_exe
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment