Why does code become twice as large in mcuxpresso

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

Why does code become twice as large in mcuxpresso

Jump to solution
916 Views
Kratz
Contributor IV

I am converting a working bare metal project from IAR kickstarter to MCUXpresso to take advantage of the unlimited code size.  Without making any changes to the program other than using the macros provided the code doubled in size. When contrasting at the IAR and MCUXpresso .map files I noticed the lines on IAR are 16 bits wide and 32 bits wide in Xpresso.  The instruction size becomes just more than twice as large.  What setting needs to be changed in Xpresso?

name                              location & width    instruct size  (IAR)

get_key_status               0x1a59                 0x66             Code  Gb  io.o [1]

name                           location & width    instruct size  (Xpresso)

.text.get_key_status  0x00000728            0xe8             ./source/io.o   0x00000728  get_key_status 

0 Kudos
1 Solution
831 Views
converse
Senior Contributor V

1. It looks like you have built MCUXpresso with debug and no optimisation. This greatly affects the code size. By default, MCUXpresso provides two type of build: Debug and Release. Debug builds with all debug information and no/minimal optimisation to aid debugging. Release builds include optimisation - but you can change the optimisation level to suit you needs (speed vs size) - see this FAQ for more information

https://community.nxp.com/thread/388981 

2. I don't know where you got instruction size from. All Cortex-M parts (M0, M1, M3, M4, M33, M7 etc) are Thumb processors which use 16-bit instruction width. MCUXpresso builds the correct instructions

View solution in original post

2 Replies
831 Views
Kratz
Contributor IV

You are correct that the optimization was the issue. The code size reduced from 37K down to 28.5K. Thank you!!!

0 Kudos
832 Views
converse
Senior Contributor V

1. It looks like you have built MCUXpresso with debug and no optimisation. This greatly affects the code size. By default, MCUXpresso provides two type of build: Debug and Release. Debug builds with all debug information and no/minimal optimisation to aid debugging. Release builds include optimisation - but you can change the optimisation level to suit you needs (speed vs size) - see this FAQ for more information

https://community.nxp.com/thread/388981 

2. I don't know where you got instruction size from. All Cortex-M parts (M0, M1, M3, M4, M33, M7 etc) are Thumb processors which use 16-bit instruction width. MCUXpresso builds the correct instructions