Code Optimisation

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

Code Optimisation

Jump to solution
749 Views
syed_idris
Contributor III

Hi,
We are using KL03 chip with KDS 3.1.0 and PE , "debug console" and "fsl-i2c" components from PE are used, In the code when I am adding some mathematical calculations of float values, the memory is getting overflowed and showing errors as

 

make: *** [test.elf] Error 1 
region `m_text' overflowed by 1092 bytes 
region m_text overflowed with text and data 
test.elf section `.text' will not fit in region `m_text' 

 

  • How to optimize the code so that we can get same code working ?
  • How to use the optimization levels as available in project properties ?
Labels (1)
Tags (3)
0 Kudos
1 Solution
462 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi syed idris 

The problem is because of  the code size in .text is too big to fit in m_text section. Unfortunately Processor expert comes with overhead due to the implement of code that is no used, it will increase your size code and it’ll be a little difficult to reduce 1092 bytes your size code.

 You can try the -Os in the settings options

BalaSNXPDoubt1.jpg

Can you share your project? if you are no using OSA components other options are; Instead of using Peripheral Driver, use just HAL APIs. PD functions have OSA support and it's not suitable for optimum code size, but sure, this highly depends in your application, when HAL APIs are used, the OSA can be removed then to reduce size. Also you can remove utilities under platform, the debug utility can be removed to reduce size.

You can also check the post: https://mcuoneclipse.com/2012/11/11/optimizing-the-kinetis-gcc-startup/ 

Hope this information help you
Have a great day,
Jorge Alcala

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

1 Reply
463 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi syed idris 

The problem is because of  the code size in .text is too big to fit in m_text section. Unfortunately Processor expert comes with overhead due to the implement of code that is no used, it will increase your size code and it’ll be a little difficult to reduce 1092 bytes your size code.

 You can try the -Os in the settings options

BalaSNXPDoubt1.jpg

Can you share your project? if you are no using OSA components other options are; Instead of using Peripheral Driver, use just HAL APIs. PD functions have OSA support and it's not suitable for optimum code size, but sure, this highly depends in your application, when HAL APIs are used, the OSA can be removed then to reduce size. Also you can remove utilities under platform, the debug utility can be removed to reduce size.

You can also check the post: https://mcuoneclipse.com/2012/11/11/optimizing-the-kinetis-gcc-startup/ 

Hope this information help you
Have a great day,
Jorge Alcala

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------