Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
cross-dev and AVR
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
juansta
n00b
n00b


Joined: 06 Jul 2015
Posts: 11

PostPosted: Sat Mar 05, 2016 12:38 pm    Post subject: cross-dev and AVR Reply with quote

Hi All,
Im trying to get my Gentoo box up to the task of compiling AVR C++ programs. It is not an arduino...

I've had it working previously, with crossdev building all the required tool chain... Im not sure when it stopped working... I haven't touched this stuff in a while...

The target MCU is a atmega32u2

However, this time around, when building my project, it compiles fine... but fails at the link stage with the following;
Code:

/usr/libexec/gcc/avr/ld: cannot find crtatmega32u2.o: No such file or directory
/usr/libexec/gcc/avr/ld: cannot find -latmega32u2
collect2: error: ld returned 1 exit status

There is no library that is named crtatmega32u2.o in my system... Note that this is after manually adding a sym link for the
Code:
ldscripts


There is a crtm32u2.o under /usr/avr/lib/avr35/crtm32u2.o and I've tried updating the device specs to force the use of this file instead... With minor success... Im left with the following (and not knowing if the changed object file reference is valid or not);
Code:

/usr/libexec/gcc/avr/ld: cannot find -latmega32u2
collect2: error: ld returned 1 exit status


Has anyone had this issue? I've also tried build each tool separately by manually downloading and through scripts at AVR-freaks with no success... My project builds fine in a Debian box...
Back to top
View user's profile Send private message
juansta
n00b
n00b


Joined: 06 Jul 2015
Posts: 11

PostPosted: Sat Mar 05, 2016 11:41 pm    Post subject: Reply with quote

I really dont know what's going on...

I've uninstalled all components... And ran
Code:
crossdev -S -t avr

without success... So then I ran
Code:
crossdev -S -t avr

(Yes, the same command) Which now lets me build without errors...
Back to top
View user's profile Send private message
calmar
n00b
n00b


Joined: 22 Dec 2009
Posts: 13

PostPosted: Sun May 22, 2016 3:09 pm    Post subject: Re: cross-dev and AVR Reply with quote

Quote:
Has anyone had this issue? I've also tried build each tool separately by manually downloading and through scripts at AVR-freaks with no success... My project builds fine in a Debian box...


Yep I have the same issues .. exactly.

somehow the same thing compiles just fine on debian (raspberry) - even so there is also no crtatmega32u2.o either.
Back to top
View user's profile Send private message
engineermdr
Apprentice
Apprentice


Joined: 08 Nov 2003
Posts: 297
Location: Altoona, WI, USA

PostPosted: Fri Aug 25, 2017 7:17 pm    Post subject: Reply with quote

I have a very similar problem now trying to upgrade to cross-avr/gcc-5.4.0-r3. I am compiling for atmega328p.
Code:
avr-gcc -mmcu=atmega328p -Os code.c -o code.o

I currently have a working cross-avr/gcc-4.9.4 installed. I switch to gcc-5.4.0 and the above gives:
Code:
/usr/libexec/gcc/avr/ld: cannot find crtatmega328p.o: No such file or directory
/usr/libexec/gcc/avr/ld: cannot find -latmega328p
collect2: error: ld returned 1 exit status

I can switch back to gcc-4.9.4 and all is well. I used crossdev to install gcc-5.4.0. I'm afraid to remove gcc-4.9.4 and start clean for fear I won't get that back working either.

Anyone have any ideas?
Back to top
View user's profile Send private message
R0b0t1
Apprentice
Apprentice


Joined: 05 Jun 2008
Posts: 264

PostPosted: Sat Aug 26, 2017 10:19 pm    Post subject: Reply with quote

juansta wrote:
(Yes, the same command) Which now lets me build without errors...
I encountered this with other targets where crossdev builds a bootstrap compiler (stage 1), may complete the C/C++ runtime libraries (stage 2), and may never make it to stage 3 or stage 4. The bootstrap compiler is dropped into your PATH and can be used, but may or may not compile, assemble, and link code properly for your target architecture.

You should follow the instructions here: https://wiki.gentoo.org/wiki/Arduino#Prepare_the_toolchain. The command should complete, however I may only have an GCC 4 AVR toolchain and not be aware of it. If it fails, please paste complete command output, as well as the files it tells you to attach to bug reports.

As for why this is happening: crossdev does not seem to use the GCC build scripts properly. I am not exactly sure why but the build machinery seems to have been slowly improved and crossdev seems to have been designed for very old (now) versions of GCC. I received conflicting information from the GCC mailing list - they said stages aren't necessary and you can skip to stage 4, but it does appear that stages are necessary as you need to build the C++ compiler separately because it depends on the C/C++ runtime for the target architecture, which must be compiled first.

The other option is that dependencies for the toolchain on your system are incompatible with the new toolchain. This option doesn't seem extremely likely. This usually happens with distributions like Ubuntu and Debian.

In any case, other distributions can generate these toolchains and the common theme on Gentoo is that the builds fail when using crossdev.

I do not think I have the time to improve crossdev by myself but it seems like someone needs to take the compilation steps from this script and put them in crossdev. I do not doubt the bugs currently present can be fixed on their own but I think redoing the crossdev build process may eliminate a lot of future bugs.

Sadly the GCC build process seems to be poorly understood even by GCC developers. All present summaries reference other summaries until, eventually, you end with dead links. The documentation by itself isn't extremely helpful as it's hard to tell what is relevant.


Last edited by R0b0t1 on Sat Aug 26, 2017 11:15 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54508
Location: 56N 3W

PostPosted: Sat Aug 26, 2017 10:32 pm    Post subject: Reply with quote

Team,

I have
Code:
[16] avr-5.4.0
 [17] avr-6.3.0
 [18] avr-6.4.0 *
from helping someone with the build process on IRC.

Code:
$ equery b crtatmega32u2.o
 * Searching for crtatmega32u2.o ...
cross-avr/avr-libc-2.0.0 (/usr/avr/lib/avr35/crtatmega32u2.o)

So the file in question is provided by avr-libc

I have not tried to use the avr cross toolchain.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
R0b0t1
Apprentice
Apprentice


Joined: 05 Jun 2008
Posts: 264

PostPosted: Sat Aug 26, 2017 11:32 pm    Post subject: Reply with quote

NeddySeagoon wrote:
Code:
$ equery b crtatmega32u2.o
 * Searching for crtatmega32u2.o ...
cross-avr/avr-libc-2.0.0 (/usr/avr/lib/avr35/crtatmega32u2.o)

So the file in question is provided by avr-libc

I have not tried to use the avr cross toolchain.
This makes me think crossdev didn't complete the toolchain build process, or only made it to stage 2 or less. It will report success when doing so. It may be necessary to specify "-s3" or "-s4" to make sure all supporting libraries are built in addition to a C compiler, which is mostly useless without those libraries.

The output of your commands makes me think I have GCC 5.4 installed and have used it successfully, but I do not have access to my workstation to verify this.
Back to top
View user's profile Send private message
engineermdr
Apprentice
Apprentice


Joined: 08 Nov 2003
Posts: 297
Location: Altoona, WI, USA

PostPosted: Sun Aug 27, 2017 12:06 am    Post subject: Reply with quote

The directions on the Gentoo Arduino page are what I've been following. To be sure, I tried again, but no difference.

I tried the equery search and mine came up empty, but noticed that I have avr-libc-1.8.0 installed since that's the stable version. So I adjusted my keywords and installed avr-libc-2.0.0 and problem solved! So it would appear the unstable avr-libc is required for gcc-5 and above.

I also tried switching back to avr-gcc-4.9.4, but now that doesn't work:
Code:
/usr/libexec/gcc/avr/ld: cannot find crtm328p.o: No such file or directory
collect2: error: ld returned 1 exit status

Looks like the names have changed from crtm328p.o to crtatmega328p.o
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54508
Location: 56N 3W

PostPosted: Sun Aug 27, 2017 9:43 am    Post subject: Reply with quote

engineermdr,

Post a bug at bugs.gentoo.org please.
I have no idea how quickly it will be addressed but it will be there for others to find.

If you have any C++ code, its not possible to switch backwards and forwards between gcc-4.x and gcc-5-x as all the C++ code will need to be rebuilt for the ABI change.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
engineermdr
Apprentice
Apprentice


Joined: 08 Nov 2003
Posts: 297
Location: Altoona, WI, USA

PostPosted: Sun Aug 27, 2017 2:54 pm    Post subject: Reply with quote

Looks like I was beaten to the punch. I found a similar bug and solution that was assigned just yesterday, so I just added a pointer to this thread.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum