This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2650: BLE-STACK 2.2.3: compilation failure with TI ARM CGT 19.6.0.STS due to change in ltoa() (with patch to fix)

Part Number: CC2650
Other Parts Discussed in Thread: BLE-STACK

1. Install BLE-STACK 2.2.3 from http ://www.ti.com/tool/BLE-STACK

2. Install TI ARM CGT 19.6.0.STS compiler

3. Import an example project with app and stack into workspace (with copy selected in import dialog), e.g. examples/cc2650lp/simple_broadcaster/ccs

4. Select properties of the stack project and choose TI ARM CGT 19.6.0.STS compiler

5. Clean and build the stack project and get this error:

"/opt/ccstudio/ble_sdk_2_02_03_08/src/components/osal/src/common/osal.c", line 408: error #167: too few arguments in function call"/opt/ccstudio/ble_sdk_2_02_03_08/src/components/osal/src/common/osal.c", line 408: error #167: too few arguments in function call

Full compiler invocation:

$ pwd
/tmp/workspace_v91-2/simple_broadcaster_cc2650lp_stack/FlashROM
$ "/opt/ccstudio/ccs/tools/compiler/ti-cgt-arm_19.6.0.STS/bin/armcl" --cmd_file="/opt/ccstudio/ble_sdk_2_02_03_08/examples/cc2650lp/simple_broadcaster/ccs/stack/../../iar/stack/../../../../../src/config/build_components.opt" --cmd_file="/opt/ccstudio/ble_sdk_2_02_03_08/examples/cc2650lp/simple_broadcaster/ccs/stack/../../iar/stack/build_config.opt"  -mv7M3 --code_state=16 -me -O4 --opt_for_speed=0 --include_path="/opt/ccstudio/ccs/tools/compiler/ti-cgt-arm_19.6.0.STS/include" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/examples/simple_broadcaster/cc26xx/stack" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/common/cc26xx" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/components/hal/src/target/_common" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/components/hal/src/target" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/components/hal/src/target/_common/cc26xx" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/components/hal/src/inc" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/components/osal/src/inc" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/components/services/src/saddr" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/components/services/src/nv/cc26xx" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/components/services/src/nv" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/components/icall/src/inc" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/inc" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/rom" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/controller/cc26xx/inc" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/components/services/src/aes/cc26xx" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/components/npi/src" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/common/cc26xx/npi/stack" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/inc" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/icall/inc" --include_path="/opt/ccstudio/ble_sdk_2_02_03_08/src/profiles/roles" --include_path="/opt/ccstudio/tirtos_cc13xx_cc26xx_2_21_01_08/products/cc26xxware_2_24_03_17272" --define=CC26XX --define=CC26XXWARE --define=DATA= --define=DEBUG --define=EXT_HAL_ASSERT --define=FLASH_ROM_BUILD --define=INCLUDE_AES_DECRYPT --define=NEAR_FUNC= --define=OSAL_CBTIMER_NUM_TASKS=1 --define=OSAL_SNV=1 --define=POWER_SAVING --define=USE_ICALL --define=xDEBUG_ENC --define=xDEBUG_GPIO --define=xDEBUG_SW_TRACE --define=xPM_DISABLE_PWRDOWN --define=xTESTMODES --define=xTEST_BLEBOARD --c99 --diag_suppress=48 --diag_suppress=16004 --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi --preproc_with_compile --obj_directory="OSAL"  "/opt/ccstudio/ble_sdk_2_02_03_08/src/components/osal/src/common/osal.c
"/opt/ccstudio/ble_sdk_2_02_03_08/src/components/osal/src/common/osal.c", line 408: error #167: too few arguments in function call
1 error detected in the compilation of "/opt/ccstudio/ble_sdk_2_02_03_08/src/components/osal/src/common/osal.c".

This error is due to a change to the ltoa prototype  in the TI CGT ARM 19.6.0.STS documented in the TI Incident Report SDSCM00052006:
cqweb.ext.ti.com/.../SDSCM00052006

Patch is attached to fix this error. The patch updates the code in the BLE Stack to invoke ltoa for TI ARM compiler in the same way as for GNUC compiler.

Please file a bug report in the TI system in order to incorporate this fix in the next release of BLE-STACK v2.2.x. Thank you.

--- a/src/components/osal/src/common/osal.c     2021-08-31 13:53:54.000000000 -0400
+++ b/src/components/osal/src/common/osal.c     2019-08-31 14:44:58.642768985 -0400
@@ -404,10 +404,8 @@
  */
 unsigned char * _ltoa(unsigned long l, unsigned char *buf, unsigned char radix)
 {
-#if defined (__TI_COMPILER_VERSION) || defined (__TI_COMPILER_VERSION__)
-  return ( (unsigned char*)ltoa( l, (char *)buf ) );
-#elif defined( __GNUC__ )
-  return ( (char*)ltoa( l, buf, radix ) );
+#if defined (__TI_COMPILER_VERSION) || defined (__TI_COMPILER_VERSION__) || defined( __GNUC__ )
+  return ( (unsigned char*)ltoa( l, (char *)buf, radix ) );
 #else
   unsigned char tmp1[10] = "", tmp2[10] = "", tmp3[10] = "";
   unsigned short num1, num2, num3;

--- a/src/components/osal/src/common/osal.c	2021-08-31 13:53:54.000000000 -0400
+++ b/src/components/osal/src/common/osal.c	2019-08-31 14:44:58.642768985 -0400
@@ -404,10 +404,8 @@
  */
 unsigned char * _ltoa(unsigned long l, unsigned char *buf, unsigned char radix)
 {
-#if defined (__TI_COMPILER_VERSION) || defined (__TI_COMPILER_VERSION__)
-  return ( (unsigned char*)ltoa( l, (char *)buf ) );
-#elif defined( __GNUC__ )
-  return ( (char*)ltoa( l, buf, radix ) );
+#if defined (__TI_COMPILER_VERSION) || defined (__TI_COMPILER_VERSION__) || defined( __GNUC__ )
+  return ( (unsigned char*)ltoa( l, (char *)buf, radix ) );
 #else
   unsigned char tmp1[10] = "", tmp2[10] = "", tmp3[10] = "";
   unsigned short num1, num2, num3;

P.S. This is not relevant to the bug report, but I am running this on Linux. To see how to instlal from the Windows installer and onto Linux and apply necessary patches, see ti-ble-sdk Arch Linux package on AUR.