Reducing RAM consumption on KL26Z with sensor fusion

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reducing RAM consumption on KL26Z with sensor fusion

558 Views
remibeges
NXP Employee
NXP Employee

I started developing with the sensor fusion library on a KL26Z, added just a portion of code but I am already hitting limits in terms of RAM usage.

By building the example project FSFK_KL26Z, I printed code size information and RAM occupation (data + bss) is 15616 bytes. But the KL26Z limit is 16kB of RAM so that does not leave much space for my application.

'Invoking: Cross ARM GNU Print Size'

arm-none-eabi-size --format=berkeley -x --totals "FSFK_KL26Z.elf"

   text   data    bss    dec    hex filename

0x1569c   0xa0 0x3c60 103324  1939c FSFK_KL26Z.elf

0x1569c   0xa0 0x3c60 103324  1939c (TOTALS)

'Finished building: FSFK_KL26Z.siz'

Are there any compiler options I can select to drastically reduce RAM consumption ?

Or should I target another processor such as KL46Z instead ?

Thank you

Labels (1)
0 Kudos
3 Replies

382 Views
BlackNight
NXP Employee
NXP Employee

Hello,

the question is: what is consuming your memory (more than expected I think)?

What about the heap and stack size allocated in the linker file?

Do you need the heap (or that size)?

Erich

0 Kudos

382 Views
remibeges
NXP Employee
NXP Employee

Well, I suppose the sensor fusion algorithms require a bit of RAM, but I need to check exactly how much. This RAM consumption may very well come from somewhere else

I am not very familiar on this topic yet, but so far I am not using dynamic allocation so heap size should be and is zero

/* Generate a link error if heap and stack don't fit into RAM */
__heap_size = 0x00;                    /* required amount of heap  */
__stack_size = 0x0400;                 /* required amount of stack */

MEMORY {
  m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x000000C0
  m_text      (RX) : ORIGIN = 0x00000410, LENGTH = 0x0001FBF0
  m_data      (RW) : ORIGIN = 0x1FFFF000, LENGTH = 0x00004000
  m_cfmprotrom  (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
}

If I remember right, I saw on MCU on eclipse website that you can print specific ram consumption per function. I'll try that to investigate

0 Kudos

382 Views
BlackNight
NXP Employee
NXP Employee

1 kB (0x400) for the stack might be too much. But that will depend on what you do (e.g. printf() will need a lot of space).

The other thing: are you already using nano-lib? This one is optimized for (code) size.

Otherwise you can spot in the .map file (in the DEBUG folder, where the .elf is) the big usage of RAM? Probably some buffers of some size?

Erich

0 Kudos