Build instructions for OpenTX

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
User avatar
dvogonen
Posts: 453
Joined: Tue Jan 31, 2012 9:38 pm
Country: Sweden
Location: Stockholm

Build instructions for OpenTX

Post by dvogonen »

Since I had to set up a new build machine I took the time to document the build instructions for OpenTX. They can be found here:
OpenTX build Instructions

aadamson
Posts: 123
Joined: Fri Oct 18, 2013 6:47 pm
Country: -

Re: Build instructions for OpenTX

Post by aadamson »

So I know the official build environment is a different compiler, but everyone keeps talking about the official (yes developed by the people at ARM) gnu gcc (launchpad) compiler.

I use this on about a dozen over ARM projects.

But the output file size is *dramatically* different when built with it vs the version the build team uses. Why is this? It is because the lanchpad compiler uses the newlib libraries and all the startup code is added to support those?

I think it's time to see if I can built this without all of that and get the size down... the launchpad compiler builds the TARANIS sources to 221864 when built with just "make PCB=TARANIS" on the built version that came out with the c9x 1.5 version...

Anyone know why this is?
Romolo
9x Developer
Posts: 1109
Joined: Sat Dec 31, 2011 12:11 am
Country: -
Location: Massa (MS), Tuscany, Italy

Re: Build instructions for OpenTX

Post by Romolo »

I compiled the toolchain by myself, and I'm on gcc 4.7.2 with newlib 1.20.0
I also noticed the huge difference passing from yagarto to launchpad...
For this reason I continue compiling by myself keeping the same size.
I tested also 4.7.3 compiled by myself and i got the same exact size.
aadamson
Posts: 123
Joined: Fri Oct 18, 2013 6:47 pm
Country: -

Re: Build instructions for OpenTX

Post by aadamson »

Romolo,

Thanks for the confirmation... I'm using the 4.7.4 version from launchpad (the official ARM supported version).

I've noticed this prior when the software uses console IO functions like printf - which a quick look at the code showed, and the build didn't use a newlib stub, but instead used the start files.... I've found I could shave a good portion of bytes (close to 30K in some cases) off the files size if I went to the newlib_stub file (I don't have one for an F2), and then built with -nostartfiles build switch...

This uses the CoOS so I don't know how all that factors in, but I'll look around and see if I can find a newlib_stub for the F2 and see if building with that vs. the start files causes any change to file size... Course who knows what *function* change that might make :)... but hey its a science experiment at the moment... not about to fly it just see what happens :)
bertrand35
9x Developer
Posts: 2764
Joined: Fri Dec 30, 2011 11:11 pm
Country: -

Re: Build instructions for OpenTX

Post by bertrand35 »

Which printf are you speaking about? All traces should be removed by the compiler when not compiled in DEBUG mode. Have a look to debug.h, you will see all the #define there

aadamson
Posts: 123
Joined: Fri Oct 18, 2013 6:47 pm
Country: -

Re: Build instructions for OpenTX

Post by aadamson »

bertrand35 wrote:Which printf are you speaking about? All traces should be removed by the compiler when not compiled in DEBUG mode. Have a look to debug.h, you will see all the #define there
Bertrand, I don't know, I've not dug into it, I just did a grep against the code and saw printf's... That's good if they are off by default... that means I should be able to build this with a newlib_stub and on the latest gnu gcc maybe get the size smaller... something is adding about 30+k to the size vs. the compiler you all use.

But I like using the compiler that ARM maintains and contributes too. :)

Alan
Romolo
9x Developer
Posts: 1109
Joined: Sat Dec 31, 2011 12:11 am
Country: -
Location: Massa (MS), Tuscany, Italy

Re: Build instructions for OpenTX

Post by Romolo »

4.7.3 (home compiled) increases size a little compared to 4.7.2
4.7.2 opentx.bin=187604
4.7.3 opentx.bin=188172

but still doesn't add 30k+
aadamson
Posts: 123
Joined: Fri Oct 18, 2013 6:47 pm
Country: -

Re: Build instructions for OpenTX

Post by aadamson »

are you building it with the launchpad arm gcc? Maybe give me the preferred build line and I'll try to match you with the launchpad 4.7.4 environment

I've been building with one you offered prior...
make PCB=TARANIS EXT=FRSKY SDCARD=YES PPM_CENTER_ADJUSTABLE=YES FLIGHT_MODES=YES AUTOSWITCH=YES PPM_LIMITS_SYMETRICAL=YES AUTOSOURCE=YES DBLKEYS=YES HELI=YES TEMPLATES=YES PPM_UNIT=PERCENT_PREC1 GVARS=YES FAI=CHOICHE TRANSLATIONS=EN
update, just built the latest version with 4.7.4 launchpad gnu gcc

with the above line, opentx.bin is 227408 and the makefile already does a -nostartfiles so it's built as small as possible with the -02 etc... now if I'm including something above that shouldn't be, well, there's the 30k

Alan
User avatar
dvogonen
Posts: 453
Joined: Tue Jan 31, 2012 9:38 pm
Country: Sweden
Location: Stockholm

Re: Build instructions for OpenTX

Post by dvogonen »

Just a detail. Shouldn't the FAI property be CHOICE rather than CHOICHE? Not that it should matter for the space.

By the way, I made some test builds in my environment. I use the Launchpad toolchain.
As expected I got the exact same binary sizes as have been reported. It is really strange that the "official" Launchpad toolchain uses so much more memory.
make PCB=TARANIS => 221872 bytes
make using the build string above => 227408 bytes
Romolo
9x Developer
Posts: 1109
Joined: Sat Dec 31, 2011 12:11 am
Country: -
Location: Massa (MS), Tuscany, Italy

Re: Build instructions for OpenTX

Post by Romolo »

aadamson wrote:are you building it with the launchpad arm gcc? Maybe give me the preferred build line and I'll try to match you with the launchpad 4.7.4 environment

I've been building with one you offered prior...
make PCB=TARANIS EXT=FRSKY SDCARD=YES PPM_CENTER_ADJUSTABLE=YES FLIGHT_MODES=YES AUTOSWITCH=YES PPM_LIMITS_SYMETRICAL=YES AUTOSOURCE=YES DBLKEYS=YES HELI=YES TEMPLATES=YES PPM_UNIT=PERCENT_PREC1 GVARS=YES FAI=CHOICHE TRANSLATIONS=EN
update, just built the latest version with 4.7.4 launchpad gnu gcc

with the above line, opentx.bin is 227408 and the makefile already does a -nostartfiles so it's built as small as possible with the -02 etc... now if I'm including something above that shouldn't be, well, there's the 30k

Alan
With gcc 4.7.3 and your command line:
opentx.bin = 193088
aadamson
Posts: 123
Joined: Fri Oct 18, 2013 6:47 pm
Country: -

Re: Build instructions for OpenTX

Post by aadamson »

And that's the yagato ucc right?

Not the ARM developed version from here - https://launchpad.net/gcc-arm-embedded

BTW, that's *your* command line, you offered it to someone a while back and I just found it and have been using it.

So what's adding the 30K between the 2 compilers... .that's very strange... I only see this normally if the startup file stuff is being included for console support. I guess I'll go look at the listing files. If you like, send me a PM with your listing files and I'll try to compare them?

Would be nice to use the ARM supported toolset seeing as it's one of the more active developed versions.
Last edited by aadamson on Sat Nov 02, 2013 3:04 pm, edited 1 time in total.
User avatar
MikeB
9x Developer
Posts: 17990
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Build instructions for OpenTX

Post by MikeB »

Just for info, I seem to be still using the Yagarto ARM compiler V4.6.0. I tried the V4.7.3 download and ersky9x got one to two hundred bytes larger.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Romolo
9x Developer
Posts: 1109
Joined: Sat Dec 31, 2011 12:11 am
Country: -
Location: Massa (MS), Tuscany, Italy

Re: Build instructions for OpenTX

Post by Romolo »

Not exactly yagarto
is gcc compiled by myself under linux using yagarto build script
alessiomorale
Posts: 2
Joined: Wed Nov 06, 2013 1:36 pm
Country: -

Re: Build instructions for OpenTX

Post by alessiomorale »

Hi guys,
i had the very same problem with OP firmware (passing from CodeSourcery to Arm mantained GCC) for CortexM3 target, and the issue was mainly due to compilation options for newlib.
Since the last 2012 release of Arm mantained GCC it is possible to use the "nano" version of newlib using the

Code: Select all

--specs=nano.specs
gcc flag. It is optimized for size and is tailored toward small microcontrollers.

Before newlib nano i was using a custom newlib compiled using the following options (miming the one used by codesourcery arm gcc toolkit):

Code: Select all

./configure --build=i686-pc-linux-gnu --target=arm-none-eabi --prefix=/Volumes/HD2/compilers/Newlib_thumb_cortex_m3/build --host=i686-pc-linux-gnu --enable-newlib-io-long-long --enable-newlib-register-fini --disable-nls --enable-newlib-reent-small --disable-libgloss --disable-newlib-supplied-syscalls  CFLAGS="-DPREFER_SIZE_OVER_SPEED -Os"
Cheers,
Alessio
aadamson
Posts: 123
Joined: Fri Oct 18, 2013 6:47 pm
Country: -

Re: Build instructions for OpenTX

Post by aadamson »

alessiomorale wrote:Hi guys,
i had the very same problem with OP firmware (passing from CodeSourcery to Arm mantained GCC) for CortexM3 target, and the issue was mainly due to compilation options for newlib.
Since the last 2012 release of Arm mantained GCC it is possible to use the "nano" version of newlib using the

Code: Select all

--specs=nano.specs
gcc flag. It is optimized for size and is tailored toward small microcontrollers.

Before newlib nano i was using a custom newlib compiled using the following options (miming the one used by codesourcery arm gcc toolkit):

Code: Select all

./configure --build=i686-pc-linux-gnu --target=arm-none-eabi --prefix=/Volumes/HD2/compilers/Newlib_thumb_cortex_m3/build --host=i686-pc-linux-gnu --enable-newlib-io-long-long --enable-newlib-register-fini --disable-nls --enable-newlib-reent-small --disable-libgloss --disable-newlib-supplied-syscalls  CFLAGS="-DPREFER_SIZE_OVER_SPEED -Os"
Cheers,
Alessio
Alessio,

So is that --spec. option a compiler option or a linker option? I'd like to try this... I'll assume a linker option? Course you can use gcc as a front end for the linker as well. So I guess it doesn't matter.

For those others, the comments are an interesting read...

https://answers.launchpad.net/gcc-arm-e ... ion/224614

Alan
alessiomorale
Posts: 2
Joined: Wed Nov 06, 2013 1:36 pm
Country: -

Re: Build instructions for OpenTX

Post by alessiomorale »

Hi Alan,
it is an architecture options and need to be passed to both compiler and linker.

Alessio
aadamson
Posts: 123
Joined: Fri Oct 18, 2013 6:47 pm
Country: -

Re: Build instructions for OpenTX

Post by aadamson »

alessiomorale wrote:Hi Alan,
it is an architecture options and need to be passed to both compiler and linker.

Alessio
I added this to the build options and it made no difference to the build size. Arm gnu gcc still builds to 228k :(

Post Reply

Return to “openTx”