1## 2## ______ _ 3## / _____) _ | | 4## ( (____ _____ ____ _| |_ _____ ____| |__ 5## \____ \| ___ | (_ _) ___ |/ ___) _ \ 6## _____) ) ____| | | || |_| ____( (___| | | | 7## (______/|_____)_|_|_| \__)_____)\____)_| |_| 8## (C)2013-2017 Semtech 9## ___ _____ _ ___ _ _____ ___ ___ ___ ___ 10## / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 11## \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 12## |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 13## embedded.connectivity.solutions.============== 14## 15## License: Revised BSD License, see LICENSE.TXT file included in the project 16## Authors: Johannes Bruder ( STACKFORCE ), Miguel Luis ( Semtech ) 17## 18## Collection of functions to generate different GDB debugging configurations 19## 20 21# Get the path of this module 22set(CURRENT_MODULE_DIR ${CMAKE_CURRENT_LIST_DIR}) 23 24 25#--------------------------------------------------------------------------------------- 26# Set tools 27#--------------------------------------------------------------------------------------- 28set(GDB_BIN ${TOOLCHAIN_BIN_DIR}/${TOOLCHAIN}-gdb${TOOLCHAIN_EXT}) 29if(NOT OPENOCD_BIN) 30 if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux) 31 set(OPENOCD_BIN "/usr/bin/openocd" CACHE STRING "OpenOCD executable") 32 elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin) 33 set(OPENOCD_BIN "/usr/local/bin/openocd" CACHE STRING "OpenOCD executable") 34 elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows) 35 set(OPENOCD_BIN "C:/openocd/bin/openocd.exe" CACHE STRING "OpenOCD executable") 36 endif() 37endif() 38 39#--------------------------------------------------------------------------------------- 40# Generates a GDB run script for debugging with STLINKv1/v2/v2-1 programmer and texane stlink tool. 41# More infos check: https://github.com/texane/stlink 42#--------------------------------------------------------------------------------------- 43function(generate_run_gdb_stlink TARGET) 44 get_target_property( TARGET_NAME ${TARGET} NAME ) 45 configure_file(${CURRENT_MODULE_DIR}/stlink-run.gdb.in ${PROJECT_BINARY_DIR}/stlink-run.gdb @ONLY) 46endfunction() 47 48#--------------------------------------------------------------------------------------- 49# Generates a GDB run script for debugging with any supported programmer and openOCD. 50#--------------------------------------------------------------------------------------- 51function(generate_run_gdb_openocd TARGET) 52 get_target_property( TARGET_NAME ${TARGET} NAME ) 53 configure_file(${CURRENT_MODULE_DIR}/openocd-run.gdb.in ${PROJECT_BINARY_DIR}/openocd-run.gdb @ONLY) 54endfunction() 55 56#--------------------------------------------------------------------------------------- 57# Generates a Visual Studio Code launch configuration for debugging with openOCD. 58#--------------------------------------------------------------------------------------- 59function(generate_vscode_launch_openocd TARGET) 60 get_target_property( TARGET_NAME ${TARGET} NAME ) 61 62 # Available OpenOCD interfaces 63 # Use stlink-v2-1.cfg when stlink interface is built in. Otherwise use stlink-v2.cfg 64 set(OPENOCD_INTERFACE_LIST stlink-v2-1.cfg stlink-v2.cfg) 65 set(OPENOCD_INTERFACE stlink-v2.cfg CACHE STRING "Default OPENOCD Interface is stlink-v2.cfg") 66 set_property(CACHE OPENOCD_INTERFACE PROPERTY STRINGS ${OPENOCD_INTERFACE_LIST}) 67 68 # Available OpenOCD targets 69 set(OPENOCD_TARGET_LIST stm32l0.cfg stm32l1.cfg) 70 set(OPENOCD_TARGET stm32l1.cfg CACHE STRING "Default OPENOCD Target is stm32l1.cfg") 71 set_property(CACHE OPENOCD_TARGET PROPERTY STRINGS ${OPENOCD_TARGET_LIST}) 72 73 # Available OpenOCD targets 74 set(OPENOCD_BOARD_LIST atmel_saml21_xplained_pro.cfg ) 75 set(OPENOCD_BOARD atmel_saml21_xplained_pro.cfg CACHE STRING "Default OPENOCD board is atmel_saml21_xplained_pro.cfg") 76 set_property(CACHE OPENOCD_BOARD PROPERTY STRINGS ${OPENOCD_BOARD_LIST}) 77 78 # Set the OPENOCD_TARGET and OPENOCD_INTERFACE variables according to BOARD 79 if(BOARD STREQUAL NAMote72 OR BOARD STREQUAL NucleoL152) 80 set(OPENOCD_INTERFACE stlink-v2-1.cfg) 81 set(OPENOCD_TARGET stm32l1.cfg) 82 elseif(BOARD STREQUAL NucleoL073 OR BOARD STREQUAL B-L072Z-LRWAN1) 83 set(OPENOCD_INTERFACE stlink-v2-1.cfg) 84 set(OPENOCD_TARGET stm32l0.cfg) 85 elseif(BOARD STREQUAL NucleoL476) 86 set(OPENOCD_INTERFACE stlink-v2-1.cfg) 87 set(OPENOCD_TARGET stm32l4x.cfg) 88 elseif(BOARD STREQUAL SKiM880B OR BOARD STREQUAL SKiM980A) 89 set(OPENOCD_INTERFACE stlink-v2.cfg) 90 set(OPENOCD_TARGET stm32l1.cfg) 91 elseif(BOARD STREQUAL SKiM881AXL) 92 set(OPENOCD_INTERFACE stlink-v2.cfg) 93 set(OPENOCD_TARGET stm32l0.cfg) 94 elseif(BOARD STREQUAL SAMR34) 95 set(OPENOCD_INTERFACE cmsis-dap.cfg) 96 set(OPENOCD_TARGET at91samdXX.cfg) 97 endif() 98 99 100 configure_file(${CURRENT_MODULE_DIR}/launch.json.in ${CMAKE_SOURCE_DIR}/.vscode/launch.json @ONLY) 101endfunction() 102