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.

CCS/CC2640R2F: CC2640R2F SimpleLink SDK Simple Peripheral Example Flash code size

Part Number: CC2640R2F

Tool/software: Code Composer Studio

My company is designing a new product based on CC2640R2F. It's a pretty simple design: portable medical device with BTLE simple peripheral behavior. We don't really need the features of BT5 bu we decided to start the design with BT5 for long term support reasons.

We started the design using the BT5 stack and the simple peripheral example in SDK 1.40.0.45. Now our firmware is almost complete and we are a bit afraid of the small remaining amount of Flash. We checked back the non-modified sample peripheral example and using BT5, it's also using a great part of the available Flash.

TI released now a new SDK (2.20.0.49). We have to decide if we go in production with stack from SDK 1.40 ou 2.20. We tried to port our application to the new SDK stack and problem: not enough Flash space!

We went back to the unmodified Sample peripheral example and we built it using both SDKs and using either BT4.2 or BT5. Here are the results:

- SDK 1.40.0.45, Unmodified Simple Peripheral Example, BT4.2 Stack: Flash usage  = 64.9KBytes (from 127KBytes total Flash)

- SDK 1.40.0.45, Unmodified Simple Peripheral Example, BT5 Stack: Flash usage  = 95.3KB (from 127KBytes total Flash)

- SDK 2.20.0.49, Unmodified Simple Peripheral Example, BT4.2 Stack: Flash usage  = 70.5KBytes (from 127KBytes total Flash) 

- SDK 2.20.0.49, Unmodified Simple Peripheral Example, BT5 Stack: Flash usage  = 116KB (from 127KBytes total Flash)

I can provide the output map files from CCS 8.0 that was used for building of these projects.

Here are my questions:

1. Do we have to migrate from SDK 1.40 to SDK 2.20 for stability or any other reason (knowing that we won't use any BT5 feature) ?

2. Why is the SDK 2.20 using so much more Flash memory for the same functionality? With BT5, this SDK is almost unusable because the remaining Flash space for application is too small!

3. Is there a way the reduce Flash usage for SDK 1.4 and/or SDK 2.2 knowing that we are only a simple peripheral?

4. Do you have plans to reduce memory footprints of these stacks?

5. What is the impact in terms of BT5 certification of removing 4.1 or 4.2 features using parameters BLE_V41_FEATURES or BLE_V42_FEATURES (which is a possible parameter for reducing the memory footprint)?

6. Do you gave an extended list of stack parameters for SDK 2.2?

Thank for supporting us!

  • I will answer what I can and will loop into my colleagues to answer the rest of your questions.

    1. There are bug fixes in the STACK, which you can find the overview regarding this in the BLE STACK release note. It recommended to integrate to a newer SDK.

    You can find the release note from [WhereYouInstalledTheSDK]/simplelink_cc2640r2_sdk_2_20_00_49/docs/ble5stack/release_notes_ble5stack_1_01_02_49.html

    2. The reason for flash increase on BT5 SDK 2.20 is that we have added Long Range (LE Coded PHY) and Advertising Extensions (AE).

    3. You can

    1. Disable display driver--> Can be configure through cc2640r2lp_app_FlashROM_StackLibrary.opt file. (You can find the information in our user's guide: Run-Time Bluetooth low energy Protocol Stack Configuration) 

    2. Remove gapbond mgr if you don't need pairing/bonding from the STACK config and also comment out all the code in simple_peripheral regarding pairing/bonding.

    3. Remove all the key press functions if you don't need it.

    4. Remove advertising extension code

    6. I am not sure what you meant by this, can you be more specific regarding what parameters you are looking for?

  • Thanks!

    Regarding question 3: Do you have instruction of how to remove Advertising Extension code and/or Long Range?

    Regarding question 6: I meant parameters such as GATT_NO_CLIENT or -DHOST_CONFIG=PERIPHERAL_CFG in build_config.cfg

  • Hey,

    4. Do you have plans to reduce memory footprints of these stacks?
    Yes, ongoing.

    5. What is the impact in terms of BT5 certification of removing 4.1 or 4.2 features using parameters BLE_V41_FEATURES or BLE_V42_FEATURES
    Optional features are not needed for qualification.
  • Hi,

    When looking at the build_config.opt file for the SDK 2.2 (BT5 stack), here is what I get:

    BLE_V41_FEATURES Configure the stack to use features from the BLE 4.1 Specification
    L2CAP_COC_CFG - Enable L2CAP Connection Oriented Channels

    BLE_V42_FEATURES Configure the stack to use features from the BLE 4.2 Specification
    The following BLE 4.2 features are enabled by default and cannot
    be disabled.
    EXT_DATA_LEN_CFG - Enable the Extended Data Length Feature in the Controller
    SECURE_CONNS_CFG - Enable Secure Connections Pairing Procedure
    PRIVACY_1_2_CFG - Enable Enhanced Privacy

    BLE_V50_FEATURES Configure the stack to use features from the BLE 5.0 Specification
    The following BLE 5.0 features are enabled by default and cannot
    be disabled.
    PHY_2MBPS_CFG - Enable 2 Mbps data rate in the Controller
    HDC_NC_ADV_CFG - Enable High Duty Cycle Non-Connectable Advertising
    CHAN_ALGO2_CFG - Enable Channel Selection Algorithm 2

    So it seems that most of the options (4.2 and 5.0) can't be disabled. Do you confirm there are no way to reduce stack size with these options?
  • The code is under static void SimplePeripheral_processGapMessage(gapEventHdr_t *pMsg) function.

    In the GAP_DEVICE_INIT_DONE_EVENT, you need to comment out the code that involves AE. Ex:

            // Load advertising data for set #2 that is statically allocated by the app
            status = GapAdv_loadByHandle(advHandleLongRange, GAP_ADV_DATA_TYPE_ADV,
                                         sizeof(advertData), advertData);
            SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);
    
            // Load scan response data for set #2 that is statically allocated by the app
            status = GapAdv_loadByHandle(advHandleLongRange, GAP_ADV_DATA_TYPE_SCAN_RSP,
                                         sizeof(scanRspData), scanRspData);
            SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);
    
            // Set event mask for set #2
            status = GapAdv_setEventMask(advHandleLongRange,
                                         GAP_ADV_EVT_MASK_START_AFTER_ENABLE |
                                         GAP_ADV_EVT_MASK_END_AFTER_DISABLE |
                                         GAP_ADV_EVT_MASK_SET_TERMINATED);
    
            // Enable long range advertising for set #2
            status = GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0);
            SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);
    

    However, you can't remove the actual functionality regarding AE/LRM from the stack.

  • I did a quick check on map file after disabling logging, remove code regarding AE and gapbondmgr. Also exclude gapbondmgr from STACK build.
    Here is what i got:
    88 375 bytes of readonly code memory
    10 842 bytes of readonly data memory
    7 659 bytes of readwrite data memory

    Will this be enough for you for now?
  • Hello,

    What do you mean with "disabling logging"?

    For our project, we need to keep gapbondmgr.

    What's the result if you keep it and throw AE and "logging"?