SJoshi 1 Posted May 5, 2013 Share Posted May 5, 2013 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? Thanks, -SJ chicken 1 Quote Link to post Share on other sites
yyrkoon 250 Posted May 6, 2013 Share Posted May 6, 2013 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. EDIT 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. Quote Link to post Share on other sites
Rei Vilo 695 Posted May 6, 2013 Share Posted May 6, 2013 Is your sketch using real numbers? You can save ~6KB by using integers only. For more information about using makefiles for the MSP430FR5739, you can pay a visit to embedXcode and to GitHub for more details. Quote Link to post Share on other sites
energia 484 Posted May 6, 2013 Share Posted May 6, 2013 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 SJoshi 1 Quote Link to post Share on other sites
chicken 630 Posted May 6, 2013 Share Posted May 6, 2013 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? Quote Link to post Share on other sites
Rickta59 589 Posted May 6, 2013 Share Posted May 6, 2013 https://github.com/elpaso/energia-makefile ... this will allow you to tweak to your hearts content. Quote Link to post Share on other sites
SJoshi 1 Posted May 6, 2013 Author Share Posted May 6, 2013 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-) Quote Link to post Share on other sites
Rickta59 589 Posted May 7, 2013 Share Posted May 7, 2013 Doing trig from now on might be a bit more interesting 8-) You might take a look at libfixmath https://code.google.com/p/libfixmath/ Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.