Jump to content

Modifying Energia compiler options

Recommended Posts

Hi all,


I was wondering if modifying the compiler flags was easily possible? 


I have a program that is really tiptoe-ing the maximum program size for my FR5739, and when I add some extra functionality, it goes overboard by 1-2k. 


I think some of this is due to some extra bloat that Energia adds, but for the simplicity of getting up and running, alongside the sweet already-created libraries, it's totally worth it. 


So, before I go out and re-design a board with a different chip, I was wondering if there were some freebies I should look into. I think I've removed as much extra code as is feasible, and played around with adding/removing libraries, but the impact is negligible. 


One thing I would like to try is the msp430-strip command... I don't know what that will do, but I've seen that with --strip-unneeded -g -x, the results on the .o files seems to be good... I don't yet know how this will translate to the actual elf or hex files though.


Has anyone tried this before?




Link to post
Share on other sites

You should be able to run the energia toolchain manually, which should give the options that you want ( without the energia "IDE").


I briefly looked at the code myself, Energia uses its own "build system" which seems to be hard coded java. Perhaps Robert will chime in an enlighten us both.




However, knowing what libraries you're using how you're using them, and knowing what you want to accomplish would help us get a better idea of whats going on. Things like using floating point numbers, when you really do not need to can sometimes add a lot of bloat for instance. But really depends on what you're doing really.

Link to post
Share on other sites

As @@Rei Vilo mentioned, if you are using floats and you do not absolutely need them then you can save 6k of flash.

As for the strip command, that will only strip symbols and will not do anything to the actual size that gets loaded into flash. 

Energia already calls GCC with -Os (optimize for size) so not much you can do there either. Your best bet is to find out if you are using floating points and if you are then re-write those parts to use integers.

@@Rei Vilo has a really nice examples of how to emulate floating point in his example sketches here: https://github.com/energia/Energia/tree/master/examples

Link to post
Share on other sites

Independent of the actual issue that @@SJoshi runs into, I think it would be a good idea to have a way for advanced users to inject compiler and linker options without having to recompile Energia. Besides debugging (I'd love to have map and assembler output when tweaking a library for size or performance) this could also come handy when adding support for new CPUs.


The most obvious way (with my limited understanding of Energia) would be additional settings in the boards.txt files, e.g. as *.build.compileroptions and *.build.linkeroptions. Just append the strings entered here to the calls to compiler and linker.


Any thoughts?

Link to post
Share on other sites

Hey all, thanks for the advice, comments, and thoughts. 


For those interested, I tried the following things:

1. msp430-strip stripped symbols, making the objects smaller, but did not affect the loaded flash size  :-(

2. @@Rickta59 I actually ran across that makefile while Googling around, looks really good. As it happened, I turned on verbose mode in Energia, and rolled my own build script.

3. As was mentioned earlier, removing floats from the code yielded the best results at a whopping 6kB savings! 


So, that's pretty awesome, but annoying that I had to eliminate them. Doing trig from now on might be a bit more interesting   8-)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...