Our code size is more than available memory and is there any option available to optimize code size?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Is there any option we can add in to make file to enable code optimization?

For application the available code size is 26K or 30K?

When I compile the code it is giving me total RAM foot print 23580 bytes and I have  added below trace function at the end of application create function ble_trace1("Free bytes = %d.\r\n", cfa_mm_MemFreeBytes()); . On debug trace it is saying that 7336 bytes free memory available. Please confirm.

0 Likes
1 Solution

> user stack(1024bytes) = Dynamic allocation section and it starts after Application code/data section

Yes, default application thread stack size is 1024 bytes an is allocated after the application code is copied into internal SRAM.

> What information goes in to stack ? Application function call  pointers and local variables.

Yes, and this is a descending stack.

See Re: Porting an app from the 20732S to the 20736S towards the end of the discussion. The app can check if the app thread stack overflowed at some point in the past before the call to the API described in this. But this should be treated as a postmortem step, so if the overflow clobbered other thread stacks/data, then the app may crash long before it gets back to your application's thread context.

View solution in original post

6 Replies
TeUs_2192001
Level 1
Level 1

The available free RAM for your program on the 20736/37 should be just under 30K (28K I believe)

20732 is closer to 17K

Unfortunately, there is not a make file option to enable code optimization.

Here's a thread you may find useful: BCM20732 Memory Map Architecture

0 Likes
Anonymous
Not applicable

What is the maximum stack size?

A: The app thread stack size is 1K (1024 bytes).

Is this stack is included in 28K RAM or extra?. Where is the stack located? At the end of RAM foot print?

0 Likes
Anonymous
Not applicable

To make sure that I understand correctly  

user stack(1024bytes) = Dynamic allocation section and it starts after Application code/data section.

On power-up, Is stack pointer is initialized to beginning address of the stack section (and address increments) or end address of the stack section(and address decrements).

What information goes in to stack ? Application function call  pointers and local variables.

Sorry for so many questions but want to make sure that we are with in available stack size and it is not overflowing.   

  

0 Likes

I will ask one of the developers to respond as you have exceeded my knowledge of the inner-workings of the stack.

0 Likes

> user stack(1024bytes) = Dynamic allocation section and it starts after Application code/data section

Yes, default application thread stack size is 1024 bytes an is allocated after the application code is copied into internal SRAM.

> What information goes in to stack ? Application function call  pointers and local variables.

Yes, and this is a descending stack.

See Re: Porting an app from the 20732S to the 20736S towards the end of the discussion. The app can check if the app thread stack overflowed at some point in the past before the call to the API described in this. But this should be treated as a postmortem step, so if the overflow clobbered other thread stacks/data, then the app may crash long before it gets back to your application's thread context.