Optimising code to reduce size

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

Optimising code to reduce size

408 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OldisGold on Mon Jun 22 10:20:51 MST 2015
Hi,

I am using LPC54102 Sensor processing solution evaluation kit and sensorhub bsx lite project from LPC Open. The example works fine but when I generated a hex file to check the code size it is over 350 kB. I want to optimize the code for size.

Question: Can I optimise the code for size by removing board.h files. ?

0 Kudos
4 Replies

363 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Tue Jun 23 00:38:24 MST 2015
You should look into the .map file to see whether there are parts of the software which use a lot of space and can be removed (because you don't need them in your project). But you can't do this blindly, you need to understand what you are doing.
0 Kudos

363 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Mon Jun 22 14:21:26 MST 2015
I would like to know if it is possible to work without the board and kernel parts in the code ?

I don't know, but would have thought it unlikely.
0 Kudos

363 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OldisGold on Mon Jun 22 13:47:40 MST 2015
Hi Thanks for the links. I searched in the forum but could not find a solution where the projects were built without importing board.

I just discovered the size of the binary(not the hex) is 130 kB. I tried setting the compiler optimisation to -Os but there is very less reduction in size(about 5kB).
Also in my case the debug build is not too big for flash. I am working on trying to reduce the binary size to as small as possible.

I would like to know if it is possible to work without the board and kernel parts in the code ?
0 Kudos

363 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Mon Jun 22 12:42:13 MST 2015
Are you sure that is the size of the image in flash, or just the size of the hex file on disk? They are very different things.

Have you read
http://www.lpcware.com/content/faq/lpcxpresso/compiler-optimization
And
http://www.lpcware.com/content/faq/lpcxpresso/debug-build-too-big-fit-flash
0 Kudos