I have a working project written under KDS2.0, PE and MQX Lite.
I am trying to migrate it to KSDK1.3, KDS3.0 and MQX Lite - trying to get ready for a KW processor.
However, when using the Freescale OS abstraction layer and associated drivers, my project no longer fits into the RAM and ROM on the device (it did when I used KDS2.0, PE and MQXLite).
Is there a way to reduce the memory footprint (code and RAM) of code generated by KSDK3.0?
Any other ideas?
Thanks!
Hello Noam:
Besides of Iva's good suggestion about optimization, please also check that you add the NDEBUG macro. See this discussion:
Size Project with Processor Expert
Regards!
Jorge Gonzalez
Hi Jorge and Iva,
Adding NDEBUG did the trick. I'm back to porting.
As far as optimization goes:
Is it possible to use different optimization levels for KDSK/libraries generated code and my code?
if so, how would I do it?
Thank you SO MUCH for your quick and helpful responses.
Noam
Hi Noam,
sure, you can use different optimization levels for libraries and for your project.
In case of GCC, please take a look at Forcing/Checking Kinetis Compiler Optimization Level | MCU on Eclipse
also helpful for you could be Optimize Options - Using the GNU Compiler Collection (GCC) which describes all optimization flags.
I hope this helps you.
Best Regards,
Iva
Hi Noam,
please try to do Optimization separately for your project and libraries.
You can look here, http://cache.nxp.com/files/microcontrollers/doc/user_guide/KDSUG.pdf page 44
Specify the optimizations that you want the compiler to apply to the generated object code:
• None (-O0) - Disable optimizations. This setting is equivalent to specifying the -
O0 command-line option. The compiler generates unoptimized, linear assembly-
language code.
• Optimize (-O1) - The compiler performs all target-independent (that is, non-
parallelized) optimizations, such as function inlining. This setting is equivalent to
specifying the -O1 command-line option. The compiler omits all target-specific
optimizations and generates linear assembly-language code.
• Optimize more (-O2) - The compiler performs all optimizations (both
targetindependent and target-specific). This setting is equivalent to specifying
the -O2 command-line option. The compiler outputs optimized, non-linear,
parallelized assembly-language code.
• Optimize most (-O3) - The compiler performs all the level 2 optimizations, then
the low-level optimizer performs global-algorithm register allocation. This setting
is equivalent to specifying the that is usually faster than the code generated from
level 2 optimizations.
• Optimize size (-Os) - The compiler optimizes object code at the specified
Optimization Level such that the resulting binary file has a smaller executable
code size, as opposed to a faster execution speed. This setting is equivalent to
specifying the -Os command-line option.
• Optimize for debugging (-Og) - The compiler optimizes object code at the
specified Optimization Level such that the resulting binary file has a faster
execution speed, as opposed to a smaller executable code size.
After doing that you can print size of the project
In my case - I did Optimization for the KSDK demo without optimization None (-O0),
before optimization there was result
and after setting optimization for all libraries (building as well) and project with option Optimize size (-Os)
there was this result
Be careful and consistently test the functionality of your code