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/CC2640: SRAM size limit detection

Part Number: CC2640

Tool/software: Code Composer Studio

I am working on extended project_zero app on CC2640. After I increase a static variable size from 128 to 256, app hang on characteristic writing.

static uint8_t received_string[128]; // worked

static uint8_t received_string[256]; // app hang on characteristic writing

I guess it over the SRAM limit of 20KB. I checked by CSS -> View -> Memory Allocation, SRAM usage is 13,000(75%), FLASH usage is 61%.

It shows 7K SRAM is free.

I have these questions.

  • Does CSS show error message if SRAM usage over 20KB?
  • SRAM items like .data .bss .stack can increase on runtime?
  • How to detect max runtime stack usage 

  • Toru Ishihara said:
    Does CSS show error message if SRAM usage over 20KB?

    CCS will generate error at build time if the size of compiler generated sections exceeds the available memory as indicated in the linker command file. 

    Toru Ishihara said:
    How to detect max runtime stack usage 

    Please take a look at the BLE Debugging Guide for tips on debugging and handling heap and stack overflow issues.

  • On some cases CCS does not generate error at build time.

    I tested blestack project_zero_cc2640r2lp_app sample.

    Case 1) Change 'project_zero.c'::received_string[10*1024]

    Case 2) Change 'project_zero.c'::received_string[5*1024]

    On case 1, I got linker error #10099-D "program will not fit".

    But on case 2, build success, runtime crash somewhere in app, no BLE advertisement, memory allocation view shows SRAM usage 89%.

    Actually I had no easy way to know SRAM full cause runtime crash.

    Test environment : LAUNCHXL-CC2640R2, CCS 8.3.0.00009, Windows10 

  • Yes, that is correct. Some issues, especially stack overflow errors are only manifested at runtime and not build time. You would need to use RTOS debugging tools to determine if runtime stack overflow is happening and if so, ensure that sufficient stack size is being allocated.

  • Which RTOS debugging tool is useful for determine memory overflow?

    I use CCS -> View -> Memory Allocation, but memory overflows happen even SRAM usage is 75%.