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.

RTOS/CC2640R2F: RAM shortish - optimization advise

Part Number: CC2640R2F
Other Parts Discussed in Thread: CC2650, SYSBIOS

Tool/software: TI-RTOS

Hi

We are getting short of RAM in our SW.


Our setup:

- CC2640R2F
- Stack in ROM.
- BIOS in FLASH
- Currently Application and Stack in 2 binaries (Stack not yet in library - but does this really help us save RAM?)


Can you confirm this assumption from us? "From the 20K chip RAM, the BLE Stack and ROM uses 3936 bytes (-D ICALL_RAM0_START=0x200040a0)"
Is there anything we can do about this value?

If this is fixed we have appr 16 KB RAM left for our "application".


Here is a part of our MAP-file pointing out the RAM-consumption for our application (we have hidden our object's names - and those are of course our responsibility), and we wonder if there is anything that one can see that one can optimize? We feel that from the 16 KB RAM left (see the ICALL_RAM0_START above) the TI code (stack, bios, gap/gatt) we are really left with small fractions.

Things that we wonder about are e.g.:

app_ble_prm3:        appr 3 KB
devinfoservice:      500 bytes (is this mandantory according to BT spec?)
icall:               280 bytes
peripheral:          800 bytes (source taken from the example code, needed for GAP, but we have not made any attempt to modify it - maybe we can optimize this?)
RFCC26XX_singleMode: 550 bytes

We have an idle task stack size of 512 bytes, but we believe that this can be cut in half? When we run our code it looks like a high-water mark on this stack usage is appr 170 bytes. Maybe we don't need the idel task at all?

We have also have noticed that If pairing should work we need to allocate at least 2800 bytes to heap (HEAPMGR_SIZE=2800)

Questions (again);

? 1 ? Is it true that we have appr 16 KB for the Application (after the ROM stack has taken its share)? Can we do anything to increase this figure?
? 2 ? The 5 sw objects lifted out from the MAP above, does it seem plausible regarding the RAM consumption? Can we do anything to decrease those figures?
? 3 ? Do we really need the idle task? If so, we think we can at least strip away 256 bytes from its stack.
? 4 ? Is the HEAP size of 2800 reasonable? We need pairing to work.


the MAP file...

*******************************************************************************
*** MODULE SUMMARY
***

    Module                           ro code  ro data  rw data
    ------                           -------  -------  -------
C:\Data\GIT\MowerBLE\SW\Bluetooth\Peripheral\App\Config\configPkg\package\cfg: [1]
    app_ble_prm3.orm3                  1 100    1 416    3 158
    ----------------------------------------------------------
    Total:                             1 100    1 416    3 158

C:\Data\GIT\MowerBLE\SW\Bluetooth\Peripheral\App\HVHMIBoard\Obj: [2]
    XXXXXXXXXXXXXX0.o                    148                56
    XXXXXXXXXXXXXX1.o                  2 496      360      677
    XXXXXXXXXXXXXX2.o                    592       96        4
    XXXXXXXXXXXXXX3.o                  1 844      591      964
    XXXXXXXXXXXXXX4.o                    388                92
    XXXXXXXXXXXXXX5.o                    136                12
    ECCROMCC26XX.o                     1 184                 5
    XXXXXXXXXXXXX10.o                  2 500      716       29
    XXXXXXXXXXXXX11.o                    872      108       24
    XXXXXXXXXXXXX12.o                     80                 4
    XXXXXXXXXXXXX13.o                  6 720       32    1 181
    XXXXXXXXXXXXX14.o                    328       28      264
    XXXXXXXXXXXXX15.o                    240               288

    XXXXXXXXXXXXX17.o                  1 310      272      420
    XXXXXXXXXXXXX18.o                    136               664
    XXXXXXXXXXXXX19.o                    388       51      248
    XXXXXXXXXXXXX20.o                    376               281
    XXXXXXXXXXXXX21.o                    156                 8
    TRNGCC26XX.o                         352                 1
    XXXXXXXXXXXXX22.o                    184                16
    XXXXXXXXXXXXX23.o                  1 888       28      656
    Watchdog.o                            44                 4
    ble_user_config.o                     34      226       16
    board.o                                        64      129
    ccfg_appBLE.o                                  88
    devinfoservice.o                     404      232      494
    gatt_uuid.o                                     8
    gattservapp_util.o                   788
    icall.o                            3 484       30      280
    icall_api_lite.o                      88                 8
    icall_cc2650.o                       316        2        5
    icall_user_config.o                            94       16
    main.o                                76        7       16
    peripheral.o                       4 312       20      801
    XXXXXXXXXXXXX25.o                    224             1 113
    ----------------------------------------------------------
    Total:                            36 552    3 513    8 776

C:\Data\GIT\MowerBLE\SW\Bluetooth\simplelink_SDK\source\ti\blestack\rom\ble_rom_releases\cc26xx_r2\Final_Release: [3]
    ----------------------------------------------------------
    Total:

command line: [4]
    ----------------------------------------------------------
    Total:

boot.arm3: [5]
    boot.orm3                             22
    cmain.orm3                            26
    cstartup_M.orm3                       22
    iar_xdc_init.orm3                     32
    ----------------------------------------------------------
    Total:                               102

dl7M_tln.a: [6]
    abort.o                                6
    div.o                                 14
    low_level_init.o                       4
    rand.o                                         55      140
    snprintf.o                            68
    sprintf.o                             52
    srand.o                               32
    strrchr.o                             24
    vsnprint.o                            60
    xprintffull_nomb.o                 3 538
    xsnprout.o                            26
    xsprout.o                             10
    xtls.o                                 2
    ----------------------------------------------------------
    Total:                             3 836       55      140

dpl_cc26x0r2.arm3: [7]
    HwiP_tirtos.orm3                       8
    PowerCC26XX_tirtos.orm3              220
    ----------------------------------------------------------
    Total:                               228

driverlib.lib: [8]
    adi.o                                 48
    chipinfo.o                            54
    cpu.o                                 24
    driverlib_release.o                                      1
    interrupt.o                           48               200
    ioc.o                                104
    osc.o                                252                20
    rfc.o                                162
    setup.o                              292
    sys_ctrl.o                           676                 8
    uart.o                               152
    ----------------------------------------------------------
    Total:                             1 812               229

drivers_cc26x0r2.arm3: [9]
    CryptoCC26XX.orm3                  1 086                29
    List.orm3                             60
    PowerCC26XX.orm3                   1 928      107      272
    PowerCC26XX_calibrateRCOSC.orm3    1 184
    ----------------------------------------------------------
    Total:                             4 258      107      301

m7M_tl.a: [10]
    DblAdd.o                             212
    DblCmpGe.o                            46
    DblCmpLe.o                            46
    DblDiv.o                             598
    DblMul.o                             418
    DblSub.o                             384
    DblToI32.o                            88
    I32ToDbl.o                            48
    xdnorm.o                              68
    xdscale.o                            268
    ----------------------------------------------------------
    Total:                             2 176

rf_singleMode_cc26x0r2.arm3: [11]
    RFCC26XX_singleMode.orm3           4 264               551
    ----------------------------------------------------------
    Total:                             4 264               551

rt7M_tl.a: [12]
    ABImemclr.o                            6
    ABImemclr4.o                           6
    ABImemcpy_unaligned.o                118
    ABImemset.o                          102
    ABImemset48.o                         50
    I64DivMod.o                          238
    I64DivZer.o                            2
    data_init.o                           40
    lz77_init_single.o                   120
    memchr.o                              88
    strchr.o                              22
    strcmp_unaligned.o                    66
    strcpy_unaligned.o                    68
    strlen.o                              54
    zero_init3.o                          64
    ----------------------------------------------------------
    Total:                             1 044

shb_l.a: [13]
    exit.o                                20
    ----------------------------------------------------------
    Total:                                20

sysbios.arm3: [14]
    BIOS.o                             6 640
    m3_Hwi_asm_iar.obj                   268
    m3_Hwi_asm_switch_iar.obj            104
    m3_TaskSupport_asm_iar.obj           108
    ----------------------------------------------------------
    Total:                             7 120

    Gaps                                   9        8        1
    Linker created                        16       40    1 024
--------------------------------------------------------------
    Grand Total:                      62 537    5 139   14 180



  • Hi,

    You can put the device info profile or something that does not need to be accessed often from CM3 into the AUX RAM(if you are not using sensor controller engine).

    Another alternative will be using GPRAM as RAM (disable cache), then you will have higher sleep current. Since you are already thinking about disabling Idle function, then I guess this would be fine for you too.
  • Hi Christin.

    Thanks for your input but we still need answer on the questions we wrote.

    Regarding the aux RAM we tried to figure it out by checking the "Technical Reference Manual". But still we don't really understand what it is.
    Could you please answer the questions above and also describe:
    ? 5 ? What is Aux RAM? (is it the 2Kb SRAM in Sensor controller? )
    ? 6 ? How big is Aux RAM?
    ? 7 ? What will we miss if we disable the Idle task?
  • Hi all,

    (I'm a collegue to "Harsmar", who wrote the original question.)

    We saw this forum post regarding the AUX-RAM;

    https://e2e.ti.com/support/wireless_connectivity/bluetooth_low_energy/f/538/p/567048/2084842#2084842

    It seems that with small adoptions (we use IAR embedded Workbench, so the linker file looked slightly different, and the placement of certain variables in this "scratchpad RAM section" looked a bit different for us in the source code) we got it to work quite smoothly. This gave us 2KB that we can use for buffers where the slower memory access doesn't affect us.

    But the original questions regarding the RAM are still interesting to us...

    BR, Christian

  • Hello Christian,
    AUX RAM is another name for the Sensor Controller RAM which is 2 kB. You can disable the idle task if you don't need any power saving. For more details on the idle task you can post a question in the TI-RTOS Forum. The experts there have more detailed knowledge on the TI-RTOS kernel and the idle task implementation.
  • Hi All,

    I have one doubt one RAM usage,

    As I saw in map file from drivers_cc26x0r2.arm3 file cryptoCC26xx is consuming 1 078 bytes, which I want to exclude. Can anyone suggest me how I can build my own drivers_cc26x0r2.arm3 file where I can exclude the cryptoCC26xx, so that I can save 1078 bytes of memory.

    Is there any documentation where I can find clear description about the drivers how I can rebuilt.

    Thanks,

    Siva.

  • Hello Siva,

    Please refer to the Optimizing Bluetooth low energy Stack Memory Usage chapter in the SDG.

    You can disable the GAPBondMgr (if not needed) by commenting out -DGAP_BOND_MGR in build_config.opt in the stack project.