cant build stmhal with Linaro toolchain

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
miltmobley
Posts: 30
Joined: Mon Mar 07, 2016 11:44 pm

cant build stmhal with Linaro toolchain

Post by miltmobley » Tue Mar 08, 2016 12:30 am

Hi, I made a first attempt to build stmhal on a Linux Mint system with a Linaro toolchain,
specifically gcc-linaro-4.9-2015.02-3-x86_64_arm-linux-gnueabihf,
and got some errors.

The definition of HUGE in micropython/lib/libm/fd_libm.h (~line 88) gets a 'redefined' error,
since HUGE was previously defined in arm-linux-gnueabihf/libc/usr/include/math.h,
which is included at the top of fd_libm.h.

I can hide this error by undefining HUGE in fd_libm.h just before it is declared there,
but is there a better solution? If all the other names that are defined in the same block
are also defined elsewhere, the entire block could be ifdef'd out, hopefully only when
the use of Linaro toolchains is detected.

I also get a number of errors like "unknown type name '__int32_t'" in various files. This and other names are defined in gcc-linaro-4.9-2015.02-3-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/include/bits/types.h,
but for some reason are not visible via math.h.

Are these problems toolchain specific? If so, what toolchain was used to build the original versions?
'arm-none-eabi-gcc' seems vague, since armhf.com, launchpad.net and others have been publishing arm toolchains
with similar names in recent years.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: cant build stmhal with Linaro toolchain

Post by pfalcon » Tue Mar 08, 2016 5:43 am

As its name suggests, Linaro toolchain targets building for Linux OS. For bare-metal targeting, https://launchpad.net/gcc-arm-embedded is recommended.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

miltmobley
Posts: 30
Joined: Mon Mar 07, 2016 11:44 pm

Re: cant build stmhal with Linaro toolchain

Post by miltmobley » Tue Mar 08, 2016 7:08 pm

Thanks for your reply.True, Linaro has a Linux focus, but also provides a bare metal toolchain, the one I used.
I also tried the standard one provided by Linux Mint via Synaptic, which has different problems.
I will try the launchpad one next.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: cant build stmhal with Linaro toolchain

Post by dhylands » Tue Mar 08, 2016 8:23 pm

The linaro toolchain assumes that it's using glibc and will have a bunch of builtin assumptions related to that.

The arm-none-eabi toolchains assume that you're using newlib (or something similar) and don't try to use the glibc headers when building.

miltmobley
Posts: 30
Joined: Mon Mar 07, 2016 11:44 pm

Re: cant build stmhal with Linaro toolchain

Post by miltmobley » Wed Mar 09, 2016 8:13 pm

Hi all, I downloaded the launchpad tool chain. Now all the files seem to compile,
but the link fails with a dozen or so messages like:
objcomplex.c:(.text.complex_print+0x52): undefined reference to `__isnanf'

Also not found were __finitef and sincosf.

I couldn't find any references to __isnanf in the micropython source, and in the ARM tool chain.
I downloaded the source for the tool chain, but much of the code is delivered in .gz and .bz2 archives,
which Linux find doesn't seem to be able to inspect.

My next step is to put the tool chain source into an Eclipse project in the hopes that Eclipse search tool will
be able to inspect the archives. Otherwise, I will have to unpack the archives to search their contents for the
definitions of __isnanf, etc., to figure out why the linker can't find them.

Is this a known problem, and is there a simple solution?

BTW, my reason for building micropython from source is to familiarize myself with the code while waiting for a
pyboard to arrive. I also guessed that it would be a necessary step to add new drivers, since there is no os.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: cant build stmhal with Linaro toolchain

Post by dhylands » Thu Mar 10, 2016 12:37 am

Did you remove the build drectory? (i.e. make clean or rm -rf build-PYBV10)

Otherwise it will contain objects built by the old toolchain which will cause issues with the new toolchain.

miltmobley
Posts: 30
Joined: Mon Mar 07, 2016 11:44 pm

Re: cant build stmhal with Linaro toolchain

Post by miltmobley » Thu Mar 10, 2016 4:42 am

Thanks, that fixed the problem, now the build completes.

Post Reply