0

I ssh into my Raspbmc installation through my iPad (I don't have a keyboard). I was looking into developing for Arduino on the Pi, as I don't have my primary PC with me right now.

I installed PlatformIO on the Pi and wrote test code to flash LEDs which compiled, uploaded and worked fine on the Uno board.

I then added some Serial code to the Arduino sketch which again compiled and worked fine.

The problem occurred when I started using math.h code (trigo mostly) in the sketch along with the serial code. math.h and the Serial code work fine independent of each other, but the sketch fails to compile when I use both together.

I feel this is more suited on the Pi network rather than the Arduino network since its a gcc error.

I'm on a Model B board running Raspbmc Wheezy and the latest version of PlatformIO.

This is the output:

Processing autogen_uno environment:
Auto-detected UPLOAD_PORT: /dev/ttyACM0
avr-g++ -o .pioenvs/autogen_uno/firmware.elf -Os -Wl,--gc-sections -mmcu=atmega328p .pioenvs/autogen_uno/src/test.o -L.pioenvs/autogen_uno .pioenvs/autogen_uno/libFrameworkArduino.a -lm
/home/pi/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/4.5.1/../../../../avr/lib/avr5/libm.a(fp_powsodd.o):../../../../../source/avr-libc-1.8.0/libm/fplib/fp_powsodd.S:59: relocation truncated to fit: R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in /home/pi/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/4.5.1/avr5/libgcc.a(_mul_sf.o)
/home/pi/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/4.5.1/../../../../avr/lib/avr5/libm.a(fp_powsodd.o):../../../../../source/avr-libc-1.8.0/libm/fplib/fp_powsodd.S:69: relocation truncated to fit: R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in /home/pi/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/4.5.1/avr5/libgcc.a(_mul_sf.o)
collect2: ld returned 1 exit status
scons: *** [.pioenvs/autogen_uno/firmware.elf] Error 1

Apparently, gcc is invoked with the following command:

avr-g++ -o .pioenvs/autogen_uno/firmware.elf -Os -Wl,--gc-sections -mmcu=atmega328p .pioenvs/autogen_uno/src/test.o -L.pioenvs/autogen_uno .pioenvs/autogen_uno/libFrameworkArduino.a -lm
  • You should add more details regarding the exact commands you used to compile the code and the specific error messages you received. "Fails to compile" and "its a gcc error" could mean anything. No one wants to sit around guessing at what your problem could be if you don't have time to explain it properly. – goldilocks Jan 24 '15 at 19:50
  • @goldilocks I wish I could. Unfortunately, PlatformIO doesn't expose what commands and flags it uses to build the files. I'm going through the source to try figuring out the offending commands, and will update the post if I find more information. But for now, this is all I have. Sorry. – duci9y Jan 24 '15 at 19:54
  • @goldilocks I edited the post with more info. – duci9y Jan 26 '15 at 9:45
  • The linker failed, see here. Dunno what you can do about that...maybe try removing -Wl,--gc-sections. – goldilocks Jan 26 '15 at 14:30
1

I'm an author of PlatformIO. Could you look into issue #50? Does it help you?

A temporary solution is to enable "cyclic dependencies" for gcc-linker. Try to add to your environment in platformio.ini this:

[env:...]
...
build_flags = -Wl,--start-group

However, I'm going to release new version next week where this bug will be fixed. Please follow @PlatformIO_Org and you will be informed about all releases.

UPDATED: Please update toolchain-atmelavr package in PlatformIO via command:

> platformio update  

Does it help you?

  • Thanks a lot for your work on PlatformIO! Unfortunately, those build flags didn't solve the problem. I will wait for the next version and tell you what happens. And I'm not really familiar enough with low level compiler and linker functions to be able to understand the issue, sorry. :/ – duci9y Feb 8 '15 at 18:26
  • @duci9y Could you open new issue here with source code example and explanation? Thanks a lot! – ikravets Feb 9 '15 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.