Skip to content

F´ on Constrained Memory Devices

M Starch edited this page Sep 18, 2019 · 1 revision

These notes come from various attempts to run F´ on memory-constrained devices. The majority of these notes were taken when running on the Teensy 3.2. It is a 32-bit ARM processor with 256KB program memory, and 64KB of RAM. For reference, this data was collected using the following branch: https://github.com/LeStarch/fprime/tree/lestarch-teensyduino.

Static Memory Usage

There are two major components to static memory usage. This consists of the .BSS and .data sections of the image. These can be observed by running the size utility on the final ELF image. For an un-optimized F´ installation, these distributions look like the following:

BSS: 45776 B DATA: 2776 B

Which amounts to ~50KB of RAM before any stack or heap has been used. Therefore, this should be adjusted to be as minimal as possible. The following settings can be adjusted to minimize this usage:

AcConstants.ini: https://github.com/LeStarch/fprime/blob/lestarch-teensyduino/Fw/Cfg/AcConstants.ini

These settings should be dropped to as low as needed to run the system. This means specifying exact numbers for rate group counts. It may also be noted here that Health takes static RAM, and could be removed entirely from the topology.

TlmChanImplCfg.hpp: https://github.com/LeStarch/fprime/blob/lestarch-teensyduino/Svc/TlmChan/TlmChanImplCfg.hpp

TlmChan is a double-buffered, hashed data structure used for downlinking telemetry. Cutting these values to a minimum can safe considerable space. At minimum, the bucket count must be the size of the number of channels in the topology.

ActiveLoggerImplCfg.cpp: https://github.com/LeStarch/fprime/blob/lestarch-teensyduino/Svc/ActiveLogger/ActiveLoggerImplCfg.hpp

This specifies the depths of the queues handled in the ActiveLogger. Reduce these to the minimum needed for running the logger.

CommandDispatcherImplCfg.hpp: https://github.com/LeStarch/fprime/blob/lestarch-teensyduino/Svc/CmdDispatcher/CommandDispatcherImplCfg.hpp

This specifies the table size used for commands. Reduce to the number of commands in the system.

Real-time Memory Usage

The above F´ deployment was tested using a stack/heap detector to give an approximation for the run-time memory usage of the above deployment.

Stack Usage: stack usage was found to be ~1KB - 1.5KB during steady state operation. This is due to normal stack frame usage. Reducing this footprint has not be extensively explored.

Heap Usage: heap usage was found to be ~12KB. This heap usage is due to dynamic memory, most of which is allocated in memory backing the queue components under Os. The easiest way to reduce this (substantially) is to reduce the queue-depth of active components. This is done using the depth argument of the init() call in Topology.cpp. Reduce this depth to as low as possible without risking loss of messages.

Clone this wiki locally