Transitioning from Development to Production Code#

While your project is in development, you will typically set:

  • Over sized configuration values, so that you don't have to constantly increase them to fit your needs as your application grows.

  • More verbose logging, so that you can quickly pinpoint any error or abnormal behavior.

  • Stricter error handling, so that you don't, for example, overlook important validations.

As you move towards a production release, you may want to fine tune these values in order to reach your optimization goals.

Here are some typical values to consider.

Kernel Services Configuration#

Kernel Services Configuration

Removing Unnecessary Tasks#

Task

#define (os_cfg.h)

Approximate savings

Remarks

Timer Task

OS_CFG_TMR_EN

2500 bytes code/ROM 200 bytes RAM

Save code space and RAM by disabling this task if software timers are not required.

Stats Task

OS_CFG_STAT_TASK_EN

3000 bytes code/ROM 400 bytes RAM

Save code space and RAM by disabling this task if kernel statistics are not required.

Note that each of the above tasks also uses a stack size of 256 elements by default. This provides an additional 1024 bytes of RAM saving for each disabled task.

Disabling Unnecessary Services#

When scraping for small amounts of RAM or code space, some very specific services can be disabled. Among the most interesting of these small improvements are:

  • OS_CFG_TASK_DEL_EN

  • OS_CFG_TASK_Q_EN

  • OS_CFG_TASK_STK_REDZONE_EN

Adjusting Heap Size#

If every unnecessary features have been disabled and the amount of RAM available is almost reached, consider lowering the heap size. Finding the appropriate value may not be an easy task. The amount of heap space required is influenced not only by your application design, but also by other Micrium OS modules such as Net, USB, and File System. Familiarize yourself with each stack's compile-time and run-time configuration options. Look for settings related to size (e.g., stack size, number of cached items) or optional features to disable.

Adjusting Stack Sizes#

Depending on how your application is constructed, it may be possible to reduce the size of one or more task stacks and therefore save RAM. Stack usage can be monitored using kernel-aware tools build into some toolchains. Alternatively, Micrium's µC/Probe can be used to display that information while subjecting the target to its known worse case conditions. µC/Probe will report (graphically) the stack usage of each task.