[CMake] CMakeLists.txt : Link options not working properly

2019-12-06 Thread samyuktar
Hello,

I am using the TI-CGT compiler and have been successful in getting all my
source files to compile. However, I am unable to get the link command to
successfully link, and I have crafted a manual link command which I have to
then manually enter into the terminal once the build compiles all the files
and fails at the link stage. 
I derived the link command from Code Composer Studio and took guidance for
what libraries are missing. However when I tried to add this to the
target_link_libraries in CMake, that didn't work.

Here is my manual link command:

"/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/bin/armcl"
-mv7M4 --code_state=16 --float_support=FPv4SPD16 -me
--define=DeviceFamily_CC13X2 -g --diag_warning=225 --diag_warning=255
--diag_wrap=off --display_error_number --gen_func_subsections=on -z
-m"lwipthreads_CC1352P1_LAUNCHXL_tirtos_ccs.map"
-i"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/source"
-i"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/kernel/tirtos/packages"
-i"/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/lib"
--diag_wrap=off --display_error_number --warn_sections
--xml_link_info="lwipthreads_CC1352P1_LAUNCHXL_tirtos_ccs_linkInfo.xml"
--rom_model --output_file="lwipthreads_CC1352P1_LAUNCHXL_tirtos_ccs.out" 
"CMakeFiles/test.out.dir/main_tirtos.c.obj"
"../CC1352P1_LAUNCHXL_TIRTOS.cmd"
-l"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/source/ti/grlib/lib/ccs/m4f/grlib.a"
-lliblwipcontribapps.a  -lliblwipboard.a -lliblwipcore.a
-lliblwipcontribporttirtos.a -l"ti/display/lib/display.aem4f"
-l"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/source/third_party/spiffs/lib/ccs/m4f/spiffs_cc26xx.a"
-l"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/source/ti/drivers/rf/lib/rf_multiMode_cc13x2.aem4f"
-l"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/source/ti/drivers/lib/drivers_cc13x2.aem4f"
-l"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/kernel/tirtos/packages/ti/dpl/lib/dpl_cc13x2.aem4f"
-l"../linker.cmd"
-l"/Applications/ti_ccs9/simplelink_cc13x2_26x2_sdk_3_20_00_68/source/ti/devices/cc13x2_cc26x2/driverlib/bin/ccs/driverlib.lib"
-llibc.a


Here, liblwipcore.a, liblwipcontribporttirtos.a, liblwipboard.a,
liblwipcontribapps.a, are libraries that I have made using my
CMakeLists.txt. The rest are standard libraries coming from TI's SDK.

The other thing is that I am unable to add the
../CC1352P1_LAUNCHXL_TIRTOS.cmd in the CMakeLists.txt the way that I need it
in the linker command that I added above. This file has some information
about sections for .data, .code, .bss, flash memory partitions and the
system memory map etc. so it is definitely required by the CC1352P1 board to
be able to run this on the board. 

Here is what I have in CMakeLists.txt for the link step :

set( cc1352p1_libs
${TIRTOS_SDK}/source/ti/display/lib/display.aem4f
${TIRTOS_SDK}/source/ti/grlib/lib/ccs/m4f/grlib.a
${TIRTOS_SDK}/source/third_party/spiffs/lib/ccs/m4f/spiffs_cc26xx.a
${TIRTOS_SDK}/source/ti/drivers/rf/lib/rf_multiMode_cc13x2.aem4f
${TIRTOS_SDK}/source/ti/drivers/lib/drivers_cc13x2.aem4f
${TIRTOS_SDK}/kernel/tirtos/packages/ti/dpl/lib/dpl_cc13x2.aem4f
   
${TIRTOS_SDK}/source/ti/devices/cc13x2_cc26x2/driverlib/bin/ccs/driverlib.lib
#   ${TIRTOS_SDK}/source/third_party/fatfs/lib/ccs/m4/fatfs.a
   
/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/lib/rtsv7M4_T_le_v4SPD16_eabi.lib
${LWIP_DIR}/linker.cmd
)

set( cc1352p1_lib_dirs
${TIRTOS_SDK}/source/ti/display/lib
${TIRTOS_SDK}/source/ti/grlib/lib/ccs/m4f
${TIRTOS_SDK}/source/third_party/spiffs/lib/ccs/m4f
${TIRTOS_SDK}/source/ti/drivers/rf/lib
${TIRTOS_SDK}/source/ti/drivers/lib
${TIRTOS_SDK}/kernel/tirtos/packages/ti/dpl/lib
${TIRTOS_SDK}/source/ti/devices/cc13x2_cc26x2/driverlib/bin/ccs
${TIRTOS_SDK}/source/third_party/fatfs/lib/ccs/m4
   
/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/lib
)

add_link_options(test.out ../CC1352P1_LAUNCHXL_TIRTOS.cmd)
target_link_libraries(test.out  lwipcontribapps lwipboard
lwipcontribporttirtos  lwipcontribexamples lwipcore
${CMAKE_COMPILER_PATH}/lib/libc.a ${cc1352p1_libs})
add_definitions( ${LWIP_COMPILE_OPTIONS}) #   ${LWIP_BIOS_OPTS} )

Here's the error that I get when I say make:

>> WARNING: invalid linker option
>> --warn_sections--xml_link_info=gpiointerrupt_CC1352P1_LAUNCHXL_tirtos_ccs_linkInfo.xml
>> (ignored)

error #10056: symbol "free" redefined: first defined in
  
"/Users/sramnath/ccs_workspaces/sdk_3_2/spiEthernet/tirtos_builds_CC1352P1_L
   AUNCHXL_release_ccs/Debug/configPkg/package/cfg/release_pem4f.oem4f";
   redefined in
  
"/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/lib/rt
   sv7M4_T_le_v4SPD16_eabi.lib"
error #10056: symbol "realloc" redefined: first defined in
  

[CMake] Using CMake with TI armcl and armar

2019-11-07 Thread samyuktar
Hi,

I want to include some open-source stacks in my code for the CC1352P1, so
I'm trying to use cmake with armcl compiler and armar archiver.

Here is my code:

cmake_minimum_required(VERSION 3.10)
  
set (CMAKE_CONFIGURATION_TYPES "Debug;Release")

project(lwIP)

# Example lwIP application
set(LWIP_DIR "/Users/sramnath/lwip_blinky/lwip")

set (LWIP_DEFINITIONS LWIP_DEBUG=1)

set(CMAKE_VERBOSE_MAKEFILE ON)

#include(CMakeForceCompiler)
# this one is important
set(CMAKE_SYSTEM_NAME Generic)

set (cc1352p1_board_SRCS
${LWIP_DIR}/CC1352P1_LAUNCHXL_TIRTOS.cmd
${LWIP_DIR}/CC1352P1_LAUNCHXL_fxns.c
${LWIP_DIR}/CC1352P1_LAUNCHXL.c
${LWIP_DIR}/ccfg.c
)

set (LWIP_INCLUDE_DIRS
"${LWIP_DIR}/src/include"
"${LWIP_DIR}"
"${LWIP_DIR}/contrib/"
"${LWIP_DIR}/contrib/ports/tirtos/include"
"${LWIP_DIR}/contrib/examples/test"
#"/Users/sramnath/lwip_out/lwip/contrib/ports/tirtos"
"${LWIP_DIR}/contrib/ports/tirtos"
"${LWIP_TIRTOS_SRCS}"
)

set (LWIP_BIOS_OPTS
"--define=ti_sysbios_BIOS_swiEnabled__D=TRUE"
"--define=ti_sysbios_BIOS_taskEnabled__D=TRUE"
"--define=ti_sysbios_BIOS_clockEnabled__D=TRUE"
"--define=ti_sysbios_BIOS_runtimeCreatesEnabled__D=TRUE"
"--define=ti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS"
"--define=ti_sysbios_knl_Swi_DISABLE_ALL_HOOKS"
"--define=ti_sysbios_BIOS_smpEnabled__D=FALSE"
"--define=ti_sysbios_Build_useHwiMacros"
"--define=ti_sysbios_knl_Swi_numPriorities__D=6"
"--define=ti_sysbios_knl_Task_deleteTerminatedTasks__D=FALSE"
"--define=ti_sysbios_knl_Task_numPriorities__D=16"
"--define=ti_sysbios_knl_Task_checkStackFlag__D=FALSE"
"--define=ti_sysbios_knl_Task_initStackFlag__D=TRUE"
"--define=ti_sysbios_knl_Task_DISABLE_ALL_HOOKS"
   
"--define=ti_sysbios_knl_Clock_TICK_SOURCE=ti_sysbios_knl_Clock_TickSource_TIMER"
   
"--define=ti_sysbios_knl_Clock_TICK_MODE=ti_sysbios_knl_Clock_TickMode_DYNAMIC"
   
"--define=ti_sysbios_hal_Core_delegate_getId=ti_sysbios_hal_CoreNull_getId__E"
   
"--define=ti_sysbios_hal_Core_delegate_interruptCore=ti_sysbios_hal_CoreNull_interruptCore__E"
   
"--define=ti_sysbios_hal_Core_delegate_lock=ti_sysbios_hal_CoreNull_lock__E"
   
"--define=ti_sysbios_hal_Core_delegate_unlock=ti_sysbios_hal_CoreNull_unlock__E"
"--define=ti_sysbios_hal_Core_numCores__D=1"
"--define=ti_sysbios_hal_CoreNull_numCores__D=1"
"--define=ti_sysbios_utils_Load_taskEnabled__D=TRUE"
"--define=ti_sysbios_utils_Load_swiEnabled__D=FALSE"
"--define=ti_sysbios_utils_Load_hwiEnabled__D=FALSE"
"--define=ti_sysbios_family_arm_m3_Hwi_dispatcherSwiSupport__D=TRUE"
   
"--define=ti_sysbios_family_arm_m3_Hwi_dispatcherTaskSupport__D=TRUE"
   
"--define=ti_sysbios_family_arm_m3_Hwi_dispatcherAutoNestingSupport__D=TRUE"
"--define=ti_sysbios_knl_Semaphore_supportsEvents__D=FALSE"
"--define=ti_sysbios_knl_Semaphore_supportsPriority__D=FALSE"
"--define=xdc_runtime_Assert_DISABLE_ALL"
"--define=xdc_runtime_Log_DISABLE_ALL"
)

set(CCS_PATH "/Applications/ti_ccs9/ccs9/ccs")
# set(CMAKE_MAKE_PROGRAM ${CCS_PATH}/utils/bin/gmake CACHE PATH "make
program" FORCE)
set(CG_TOOL_ROOT ${CCS_PATH}/tools/compiler/ti-cgt-arm_18.12.2.LTS)

# specify the cross compiler
SET(CMAKE_C_COMPILER_FLAGS "")
# SET(CMAKE_C_COMPILER   "${CG_TOOL_ROOT}/bin/armcl ${cc1352p1_board_SRCS}"
CACHE PATH "c compiler")
SET(CMAKE_C_COMPILER  
"/Applications/ti_ccs9/ccs9/ccs/tools/compiler/ti-cgt-arm_18.12.2.LTS/bin/armcl")



SET(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER}  CACHE PATH "cxx compiler")
#SET(CMAKE_ASM_COMPILER ${CG_TOOL_ROOT}/bin/armasm  CACHE PATH "assembler")
SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}  CACHE PATH "assembler")
SET(CMAKE_LINKER ${CMAKE_C_COMPILER} CACHE PATH "linker")


# Add the default include and lib directories for tool chain
include_directories(${CG_TOOL_ROOT}/include)
link_directories(${CG_TOOL_ROOT}/lib)
message("link_directories(${CG_TOOL_ROOT}/lib)")

# set target environment
set(CMAKE_FIND_ROOT_PATH ${CG_TOOL_ROOT})

# specifiy target cpu flags
set(PLATFORM_CONFIG_C_FLAGS"-mv7M4 --code_state=32
--float_support=VFPv3D16 --abi=eabi -me -g --diag_warning=225
--display_error_number --diag_wrap=off --enum_type=packed
--include_path=${CG_TOOL_ROOT}/include --define=_RM46x_
--define=_VFP_SUPPORT_=1" CACHE STRING "platform config c flags")
set(PLATFORM_CONFIG_L_FLAGS"-i ${CG_TOOL_ROOT}/lib --reread_libs
--warn_sections --rom_model")

# combine flags to C and C++ flags
SET(CMAKE_C_FLAGS "${PLATFORM_CONFIG_C_FLAGS} ${CMAKE_C_FLAGS}" CACHE STRING
"platform config c flags")
SET(CMAKE_CXX_FLAGS "${PLATFORM_CONFIG_C_FLAGS} ${CMAKE_CXX_FLAGS}" CACHE
STRING "platform config cxx flags")
SET(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}")
SET(LIB "-l rtsv7R4_T_le_v3D16_eabi.lib")
SET(CMD_SRCS
"/Users/sramnath/lwip_blinky/lwip/CC1352P1_LAUNCHXL_TIRTOS.cmd")