This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[Cortex-M3] Things to try in order to shrink image size

Hi,

I need to reduce a image size to a minimum. The project is a CANBUS Bootstrap that must fit under 4KB and be written in C.

I'm using MicroLIB, Link-Time Code Generation, -O3, ZI init.

What other compiler/assembler/linker settings could I possibly apply in order to shrink the image?

Thanks.

  • Before trying to shrink the image, what steps have you taken to ensure that your code generates an image that is as small as possible in the first place?

    user.it.uu.se/.../engblom-esc-sf-2001.pdf

  • It's a good thing to point out but a different topic... The written code in in good shape. I'm NOT a fan of the GIGO methodology (Garbage In Garbage Out) ;-)

  • I don't think it's reallistic to insist on both of them!

    I guess the "fit under 4KB" is the real hard requirement - fixed by the hardware?

    So the other one really needs to be, "written in C where possible".

  • This is something that comes from the punched card programming era. The 4KB requirement is analogous to the first card in a program deck, the card responsible for the bootstrap process. The "what to do" and "how to do" will come via CANBUS. The what and how to do is placed and executed in RAM, just like a mainframe, the trick gives me an extra 5KB. This will be embedded in 16 and 32KB devices. Size is really an issue.

  • I don't think you'll be able to shrink the image further by tweaking compiler/linker settings. The image is small enough by itself, it should be fairly easy to see where space savings can come from by simply looking at linker map file.
    Maybe you could try something more radical, like using Forth? Some people say Forth code can be very compact. I never tried it, though.

  • I spent some more time looking at compiler/linker settings and end up finding compiler --remove_unneeded_entities and linker/compiler --feedback. Those options remove unused sections while still allow me to work with -O0.

    The map file looks pretty small from the Compiler/Libraries point of view so not really much to do on settings.

    The system setup and mechanism to send/receive CAN messages are generating a 2400 bytes image (-O3). I believe the final app will fit under 4KB...

    Thank you.