Some new compiler options?

openTx has introduced a range of new features, ideas and bling. It is fast becoming the firmware of choice for many users. openTx will run on ALL current hardware platforms, including the gruvin9x and sky9x boards. Work has already started to support the new FrSky X9D radio!
Post Reply
nischris
Posts: 48
Joined: Sat Feb 08, 2014 10:39 pm
Country: -

Some new compiler options?

Post by nischris »

Hi
During my investigations into my wee 'DDC' project, I noticed that the build size (I always build for Taranis btw) didn't seem to reduce even though I removed all references to a particular object file. It seemed that if the code was compiled, it was included in the output image. I wondered why, and started looking at some of the compiler options.
I found that if I included these compiler options...

CPPFLAGS += -fdata-sections -ffunction-sections

and included this linker option...

$(CC) $(OBJS) allsrc.o -mcpu=cortex-m3 -mthumb -nostartfiles -lm -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch,--gc-sections -o $@

the unreferenced code was removed as desired.

As an experiment, I did a before and after on the regular firmware (no DDC code included), and I found that the image size dropped from 273344 bytes to 256196 bytes (slightly modified master branch), which seemed to be quite a saving.

The smaller image seems to run just fine btw.

I thought I might mention this as I read comments about people saving a few bytes of code here and there. I appreciate that things are not too tight right now on Taranis.

Maybe these options have been tried before and been ruled out for some reason. I didn't find any mention of them after doing a search on the forum though. If they have been ruled out, does anybody know why?

I have no idea if using these same options would work on other processors, so I'll leave it to others to decide if it's worth including them for this or other platforms. Just thought I'd mention my findings.

bertrand35
9x Developer
Posts: 2764
Joined: Fri Dec 30, 2011 11:11 pm
Country: -

Re: Some new compiler options?

Post by bertrand35 »

Right. We don't use the whole flash size, so we didn't need these options. But I will add them later today.
Post Reply

Return to “openTx”