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.

LAUNCHXL-CC2640R2: Migration of ProjectZero based application from blestack to ble5stack

Part Number: LAUNCHXL-CC2640R2
Other Parts Discussed in Thread: CC2640R2F, CC2642R, , CC2640R2L


I have developed my application on ProjectZero example from blestack. Now I want to add ble v5 features to this project. The Migration guide suggests that the best way to do this is to take the same base project from ble5stack and add application level code to it.

When I include the project_zero example and build it, the memory allocation view shows that the FLASH is filled 123k (97%) and the SRAM is filled ~11k (65%) already. On the other hand, the project_zero example in blestack only consumes ~78k (or 61%) of FLASH and 10.6k (or 61%) of SRAM out of the box.

blestack > project_zero Memory Allocation:

ble5stack > project_zero Memory Allocation:

How should I port my application code from blestack to ble5stack?

  • Hi Ryan,

    I did reference that article. However, the first step in the guide is to get the same base project from BLE5-Stack and add application to it. My application code consumes about 2kB of SRAM and 18kB of Flash over the existing code of project zero (the blestack one).

    In the project_zero base project from BLE5-Stack, I do not have the required amount of flash space as the base code out of the box is already 96% filled up. It already consumes 126kB out of 127kB of FLASH size. Hence, I could not even get started with the porting guide you referenced.

    Another confusion I have is, when I increase the optimization from the default "2 - Global Optimizations" to "3 - Interprocedure Optimizations" by going into project properties > ARM Compiler > optimization, it shows the following error at the end of the build:

    Building file: "../Startup/main.c"
    Invoking: ARM Compiler
    "C:/ti/ti-cgt-arm_16.9.1.LTS/bin/armcl" --cmd_file="D:/SVN_projects/Smart_diaper_software/workspace/ble5_project_zero_cc2640r2lp_app/TOOLS/defines/ble5_project_zero_cc2640r2lp_app_FlashROM_StackLibrary.opt" --cmd_file="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/config/build_components.opt" --cmd_file="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/config/factory_config.opt" --cmd_file="D:/SVN_projects/Smart_diaper_software/workspace/ble5_project_zero_cc2640r2lp_stack_library/TOOLS/build_config.opt"  -mv7M4 --code_state=16 -me -O3 --opt_for_speed=0 --include_path="D:/SVN_projects/Smart_diaper_software/workspace/ble5_project_zero_cc2640r2lp_app" --include_path="D:/SVN_projects/Smart_diaper_software/workspace/ble5_project_zero_cc2640r2lp_app/Application" --include_path="D:/SVN_projects/Smart_diaper_software/workspace/ble5_project_zero_cc2640r2lp_app/Startup" --include_path="D:/SVN_projects/Smart_diaper_software/workspace/ble5_project_zero_cc2640r2lp_app/PROFILES" --include_path="D:/SVN_projects/Smart_diaper_software/workspace/ble5_project_zero_cc2640r2lp_app/Include" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/examples/rtos/CC2640R2_LAUNCHXL/ble5stack/project_zero/src/extra" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/controller/cc26xx/inc" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/inc" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/rom" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/common/cc26xx" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/icall/inc" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/target" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/hal/src/target/_common" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/hal/src/target/_common/cc26xx" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/hal/src/inc" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/heapmgr" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/icall/src/inc" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/osal/src/inc" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/services/src/saddr" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/services/src/sdata" --include_path="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/devices/cc26x0r2" --include_path="C:/ti/ti-cgt-arm_16.9.1.LTS/include" --define=DeviceFamily_CC26X0R2 --define=uartlog_FILE="\"main.c\"" --define=UARTLOG_ENABLE -g --c99 --gcc --diag_warning=225 --diag_wrap=off --display_error_number --gen_func_subsections=on --abi=eabi --preproc_with_compile --preproc_dependency="Startup/main.d_raw" --obj_directory="Startup" --cmd_file="configPkg/compiler.opt"  "../Startup/main.c"
    Finished building: "../Startup/main.c"
    Building target: "ble5_project_zero_cc2640r2lp_app.out"
    Invoking: ARM Linker
    "C:/ti/ti-cgt-arm_16.9.1.LTS/bin/armcl" --cmd_file="D:/SVN_projects/Smart_diaper_software/workspace/ble5_project_zero_cc2640r2lp_app/TOOLS/defines/ble5_project_zero_cc2640r2lp_app_FlashROM_StackLibrary.opt" --cmd_file="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/config/build_components.opt" --cmd_file="C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/config/factory_config.opt" --cmd_file="D:/SVN_projects/Smart_diaper_software/workspace/ble5_project_zero_cc2640r2lp_stack_library/TOOLS/build_config.opt"  -mv7M4 --code_state=16 -me -O3 --opt_for_speed=0 --define=DeviceFamily_CC26X0R2 --define=uartlog_FILE="\"\"" --define=UARTLOG_ENABLE -g --c99 --gcc --diag_warning=225 --diag_wrap=off --display_error_number --gen_func_subsections=on --abi=eabi -z -m"" --heap_size=0 --stack_size=256 -i"C:/ti/ti-cgt-arm_16.9.1.LTS/lib" -i"C:/ti/ti-cgt-arm_16.9.1.LTS/include" --reread_libs --define=CC26X0ROM=2 --diag_suppress=16002-D --diag_suppress=10247-D --diag_suppress=10325-D --diag_suppress=10229-D --diag_suppress=16032-D --diag_wrap=off --display_error_number --warn_sections --xml_link_info="ble5_project_zero_cc2640r2lp_app_linkInfo.xml" --rom_model -o "ble5_project_zero_cc2640r2lp_app.out" "./Application/project_zero.obj" "./Application/util.obj" "./Application/services/button_service.obj" "./Application/services/data_service.obj" "./Application/services/led_service.obj" "./Drivers/ECC/ECCROMCC26XX.obj" "./Drivers/TRNG/TRNGCC26XX.obj" "./ICall/icall.obj" "./ICall/icall_cc2650.obj" "./ICall/icall_user_config.obj" "./ICallBLE/ble_user_config.obj" "./ICallBLE/icall_api_lite.obj" "./PROFILES/devinfoservice.obj" "./PROFILES/gatt_uuid.obj" "./PROFILES/gattservapp_util.obj" "./Startup/CC2640R2_LAUNCHXL.obj" "./Startup/CC2640R2_LAUNCHXL_fxns.obj" "./Startup/UartLog.obj" "./Startup/ccfg_app_ble.obj" "./Startup/main.obj" -l"configPkg/linker.cmd"  -l"C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/devices/cc26x0r2/driverlib/bin/ccs/driverlib.lib" -l"C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/kernel/tirtos/packages/ti/dpl/lib/dpl_cc26x0r2.aem3" -l"C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/drivers/lib/drivers_cc26x0r2.aem3" -l"C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/drivers/rf/lib/rf_singleMode_cc26x0r2.aem3" -l"C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/display/lib/display.aem3" -l"C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/grlib/lib/ccs/m3/grlib.a" -l"D:/SVN_projects/Smart_diaper_software/workspace/ble5_project_zero_cc2640r2lp_stack_library/FlashROM_Library/ble_r2.symbols" -l"D:/SVN_projects/Smart_diaper_software/workspace/ble5_project_zero_cc2640r2lp_stack_library/FlashROM_Library/lib_linker.cmd" -l"D:/SVN_projects/Smart_diaper_software/workspace/ble5_project_zero_cc2640r2lp_stack_library/FlashROM_Library/ble5_project_zero_cc2640r2lp_stack_library.lib" -l"C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/common/cc26xx/ccs/cc26xx_app.cmd" -llibc.a 
    "C:/ti/simplelink_cc2640r2_sdk_4_20_00_04/source/ti/ble5stack/common/cc26xx/ccs/cc26xx_app.cmd", line 277: error #10099-D: program will not fit into available memory.  placement with alignment fails for section ".cinit" size 0x1da7 .  Available memory ranges:
       FLASH        size: 0x1f000      unused: 0x11d6       max hole: 0x1000    
       FLASH_LAST_PAGE   size: 0x1000       unused: 0xfa8        max hole: 0xfa8     
    error #10010: errors encountered during linking; "ble5_project_zero_cc2640r2lp_app.out" not built
    >> Compilation failure
    makefile:190: recipe for target 'ble5_project_zero_cc2640r2lp_app.out' failed
    gmake[1]: *** [ble5_project_zero_cc2640r2lp_app.out] Error 1
    makefile:183: recipe for target 'all' failed
    gmake: *** [all] Error 2
    **** Build Finished ****

    I have already set the speed vs. size trade off to 0(size), so I don't understand why a higher optimization level of 3 gives an error saying "error #10099-D: program will not fit into available memory." but a relatively lower optimization level of 2 is able to built without errors.

    Please explain why this is happening.


  • Hi,

    Because of Flash limitations, the ble5stack on CC2640R2F is not made for complex applications.

    The link issue you are experiencing seems to be caused to this same flash limitation.

    Please reference our Flash optimization guide and consider moving to CC2642R if needed.

    Best regards,

  • Hi,

    Actually the above output is when I have not added any of my application code. The link issue there come up only when I change the Optimization level from 2(default setting in ble5_ProjectZero example code) to level 3.

    As I have chosen optimization for size, by increasing the optimization level, I was expecting the size to go down. However, the output indicates the complete opposite. The binary size goes beyond the possible boundary only after increasing the optimization level from 2 to 3.

    Am I missing something?

    Shouldn't the size have gone down if I increase the optimization level?

  • Hi,

    I cannot reproduce your observation with the out-of-the-box example. I have attached the map files I got:

    Best regards,

  • Hi,

    I reviewed the map files in you reply. From what I see, those map files are corresponding the project_zero base project from blestack. Kindly also try the same for the project_zero base project from ble5stack (the default name should be

    Also, please use Simplelink SDK version 4.40 and TI compiler version 20.2.3.LTS if possible, as that is what I am using too.

    Let me know if you are able to generate map files with optimization level 3 and 4.


  • Hi,

    Sorry for the confusion between the projects.

    I asked our R&D team to clarify the question.

    For CC2640R2F, with BLE5, the project_zero example should be compiled with optimization level O2.

    A note will be added in the readme of the example to avoid future confusion - thank you for taking time to report the issue.

    Best regards,

  • Hi Clement,

    I'm sorry I wasn't able to reply to your last reply, So I had to reply here.

    I just need to clarify one more thing. Does that mean that the ble5_project_zero example project CANNOT be compiled with optimization level O3 and O4? (which is strange) Or is there a way to do that by changing some configuration? I actually need to compile the project with higher optimization as I need Flash and SRAM space to write my application. That is why it is particularly important to me.

    Also, the LAUNCHXL-CC2640R2 development board has CC2640R2F and that is what we were talking about until now. But I also have custom hardware, and the MCU used in my custom board is CC2640R2L.

    For CC2640R2F, with BLE5, the project_zero example should be compiled with optimization level O2.

    Is this also valid for CC2640R2L?

  • Hi,

    We do not provide support for O3 and O4 optimization for ble5_project_zero on CC2640R2 (including C2640R2L and CC2640R2F).

    I cannot comment rather if changing some configurations would allow to build with this optimization level.

    Best regards,