Flash optimization

The following tips may be useful for reducing the footprint of Proprietary RF. In general, there is a feature vs. flash footprint trade-off. Each of the improvements below offer a cost in terms of feature removal.

  • Verify that your application uses the optimize for flash size compiler optimization settings (For TIClang it is implemented with the -z flag).

  • Use the syscfg file to choose only necessary functionality to pull in the smallest part possible of the library for the given use case. For example, to use the I2C driver first locate I2C within .syscfg, and click on ADD; also reference Useage Synopsis, Examples, and Configuration Options for help on implementing I2C, or other functionality in .syscfg into your project. With Proprietary RF you may want to add another PHY, carefully consider the extra memory footprint required to use 2 PHYs.


RAM optimization

The following tips may be useful for reducing the RAM footprint of the Proprietary RF. It is important to remember that often removing RAM results in reduced throughput or features, the tradeoffs listed below should be evaluated carefully.

  • An example of a configuration that affects RAM overhead can be found in the example rfPacketRx, more specifically how the RX buffer is configured. Depending on the needs of your project you may increase, or decrease the size of the buffer in the code, which in turn affects the ram. A larger RX buffer costs more RAM overhead, but allows for larger packets (or a larger number of packets) to be received, which could reduce the overhead in terms of over-the-air efficiency.

/* Packet RX Configuration */
#define MAX_LENGTH              (30U) // Max packet length
#define NUM_DATA_ENTRIES        (2U)  // Number of data entries

/* RCL buffer length */
#define BUFF_STRUCT_LENGTH      (2048U)
  • Ensure read-only data is const. Objects that never change (data tables, application structures, initialized string buffers) should be marked const to enable the linker to place the objects in (read-only) flash rather than (read-write) RAM.

  • Remove dependencies on software timers. Disabling FreeRTOS software timers through SysConfig, can save ~1kB of RAM.

  • Avoid snprintf(). The C runtime library allocates a couple hundred bytes of RAM for temporary buffers.


The above RAM estimations may vary by release, and are not an exhaustive list. It is intended as a way to allow the developer to profile the RAM requirements based on the desired settings.

Optimization in CCS

Compiler optimization (TIClang + CCS)

The compiler itself has multiple optimization levels, you can change the optimization level by right-clicking on the project, navigating to build → Arm Compiler → Optimization, then locate “Select optimization paradigm/level”. In the dropdown menu there are many optimization levels to choose from, each one has some differences. Depending on what optimization level is selected there can be an increase or decrease in either compile speed or size.

For more in depth detail on the specific optimizations performed at each level please visit TIClang compiler Optimization Options.

  • Optimization level “0” disables any optimizations by the compiler.

  • Optimization level “1” enables a restricted set of optimizations, allowing for a better debug experience.

  • Optimization level “2” enables all optimizations from 1, plus inter-procedural and other optimization with an eye towards preserving a reasonable compile time.

  • Optimization level “3” enables all optimizations at 2, plus optimization that take longer to perform, trading an increase in compile time for potential performance improvements.

  • Optimization level “fast” enables all optimizations from 3, plus aggressive optimizations that may relative performance gains, but may also violate strict compliance with language standards.

  • Optimization level “s” enables all optimizations from 2 plus additional optimizations intended to reduce code size while mitigating negative effects on performance.

  • Optimization level “z” enables all optimizations from 2 plus additional optimizations to reduce code size with the risk of sacrificing performance.

  • Optimization level “g” enables most optimizations from 1, but may disable some to improve debug experience.

Single-File Optimizations in CCS

  1. Right-click on the file in the workspace

  2. Click on properties

  3. Build

  4. Arm Compiler

  5. Optimization

Optimization in IAR

If you are using an IAR you will have to flow a different procedure to change optimizations.

Project OptionsC/C++ CompilerOptimizations


Single-File Optimizations in IAR


The following is specific for the IAR workspace, not CCS.

  1. Right-click on the file in the Workspace pane.

  2. Choose Options.

  3. Check Override inherited Settings.

  4. Choose the optimization level.

Single-Function Optimizations in IAR


Pragmas are very specific to the toolchain, and may lead to non-reusable code. Be careful where you use these.

Use #pragma optimize=none before the function definition to deoptimize the entire function, that is, as follows.

Listing 9. Function-level optimization setting in IAR
#pragma optimize=none
static void myFunction(int number)
    // ...
    return yourFunction(other_number);