MCF52259 Code optimization.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MCF52259 Code optimization.

973件の閲覧回数
payyans4u
Contributor I

Hi I am working on MCF52259 in CW 7.2 environment with MQX 3.7 RTOS...My controller has an internal flash of 512 KB...After compilation of my project i found that the output files generated .

1.intflash.elf(.bin format) size 150 KB

2.intflash.elf(S19 format) size 321 KB

 

And more than half of the  coding to do,m left clueless on how i will be able to accomodate all that in the Internal Flash.(No external Flash used)..

 

I treid optimizing the code with the options present in the code generation tab of CW like

 

1.Global optimizat ion set to Level 4(Max).

2.Checked in Register Coloring and PeepHole Under the ColdFire Processor tab

 

 

But i found the above has no effect on the size...

 

Presently i am using the TWR board from freescale....I want to know whether the size of code it would be different when i bring up my own Board .

 

Any Suggestion and help is highly appreciated...

 

Thanks

Vivek

ラベル(1)
0 件の賞賛
返信
6 返答(返信)

659件の閲覧回数
scifi
Senior Contributor I

payyans4u wrote:

And more than half of the  coding to do,m left clueless on how i will be able to accomodate all that in the Internal Flash.(No external Flash used).. 


It will take A LOT of coding to fill 512 Kbytes of flash.

In my experience, poor program structure can fill memory much faster than poor compiler optimization. So, the biggest savings in terms of code size should come from better program structuring. Actually, Tom has already said that.

0 件の賞賛
返信

659件の閲覧回数
FridgeFreezer
Senior Contributor I

To add to what those above have said, you need to look at the wisdom of the ancients - 512k is a huge amount of space, but with modern coding aimed at PC's with gigabytes of space there is often little attention paid to efficient coding, data structures, etc.

 

Some OLD programming books may be what you need, stuff relating to 8-bit micros, where you get down to CPU instructions per function. There's loads of stuff out there about optimization.

0 件の賞賛
返信

659件の閲覧回数
FridgeFreezer
Senior Contributor I

A few tips here, albeit from the more common performance optimization side rather than size-optimization, but much of it is two sides of the same coin (smaller == faster):

http://www.codeproject.com/KB/cpp/C___Code_Optimization.aspx

0 件の賞賛
返信

659件の閲覧回数
CrasyCat
Specialist III

Hello

 

   It is not clear from your message how you evaluated the application size.

   Did you check the generated .xMAP file to retrieve the actual size of the code in internal flash?

 

   This file contains the relevant information when it goes around evaluating an application code or data size.

 

CrasyCat

0 件の賞賛
返信

659件の閲覧回数
payyans4u
Contributor I

I  have checked the map file as well....it shows 150 KB in line with the .bin file generated...

 

 

I want to know whether there is any other method to reduce code size

0 件の賞賛
返信

659件の閲覧回数
TomE
Specialist II

> I want to know whether there is any other method to reduce code size

 

Write less code. Write your functions more efficiently. Find out what libraries are being included that you don't need, and don't call them.

 

Look in the Map file and find out what is using the most memory.

 

How much is your OS taking? Is there a network stack? How big is that? Is there a File System? Ditto.

 

How much memory are the libraries taking?

 

You wrote:

 

> internal flash of 512 KB.. ... And more than half of the  coding to do,m left clueless on how

> i will be able to accomodate all that in the Internal Flash

 

It is unlikely you have written 150k of code. The OS and other stacks probably take up most of that. The part that is "your project" may only make up a small part of that, and if you double that small part then there's a lot of room left between 512k and 150k.

 

I don't think you've got a "memory problem" at all. When you get to 511k, then you've got a "memory problem" :smileyhappy:

 

Are you writing in C or C++? You may be pulling in some big libraries that you don't really need. For instance, one "printf" statement can pull in a relatively huge library in order to handle every possible variation of floating point printing. If you're performing any floating point operations, they can pull in maths libraries too. Do you need floats? Get rid of all of them if you don't.

 

Your development environment may give you the option of a "small integer only printf library" that may save you some room. Ask in the forum specific to your development environment for that (AFTER reading the documentation then searching the forum for "library" and "printf" and so on).


For instance, the following shows how to save a MEGABYTE by loading different libraries:

 

https://community.freescale.com/message/50343#50343

 

Tom

 

0 件の賞賛
返信