Go Down

Topic: Native GCC for Yun (Read 12140 times) previous topic - next topic

arbor

Cross-compiling for the Yun I use the OpenWRT toolchain.  It works rather well.  Just set up your environment variables, configure for the mips target and your working.

Native GCC on the Yun is really only for playing around or if you an amazing amount of patience.  I got it working just because I thought I could.

I was able to compile a native mips avr-gcc toolchain for the Yun.  I'm testing that out with Arduino Makefile.  It's working well.  It's not as slow as I was expecting and is very usable.  I have my whole avr-tools setup as a nfs mount to the Yun and am satisfied with it.  I was going to make it a package, but having it separate from the main root filesystem is much easier and to me cleaner.

As far as qemu virtual mips there are some decent choices.  You can use the malta snapshot from OpenWRT trunk (http://downloads.openwrt.org/snapshots/trunk/malta/).  It's specifically for running in qemu . 
There's also the yocto project (https://www.yoctoproject.org/)that is rather easy to setup by reading the documentation.

sonnyyu


...
Native GCC on the Yun is really only for playing around or if you an amazing amount of patience.  I got it working just because I thought I could.

I was able to compile a native mips avr-gcc toolchain for the Yun.  I'm testing that out with Arduino Makefile.  It's working well.  It's not as slow as I was expecting and is very usable.  I have my whole avr-tools setup as a nfs mount to the Yun and am satisfied with it.  I was going to make it a package, but having it separate from the main root filesystem is much easier and to me cleaner.
...


:P

sonnyyu


sonnyyu


...
As far as qemu virtual mips there are some decent choices.  You can use the malta snapshot from OpenWRT trunk (http://downloads.openwrt.org/snapshots/trunk/malta/).  It's specifically for running in qemu . 
...


I found few catch about malta;-

http://downloads.openwrt.org/snapshots/trunk/malta/ is for little-endian image, AR9331 is big-endian, I manage to compile big-endian image as well as GCC for it, but Yun's OS is attitude_adjustment and so no go here.

http://downloads.openwrt.org/attitude_adjustment/12.09/malta/generic/ is empty, means upstream OS fail to compile it.
I manage to compile big-endian image for attitude_adjustment and have not chance to compile GCC yet.

an other problem is qemu's mips support is limit at Max 256MiB  RAM. I would like to have 4GiB RAM.


noblepepper

I have finally gotten a Makefile that produces an install-able, working gcc package.  You can get the package here https://www.dropbox.com/s/gdgjpmz845o5xl2/gcc_4.6.2-1_ar71xx.ipk  It is big, over 60mB and there are probably some issues that still need to be taken care of so please try it and let me know if it works for you.

@federico - one of the last things I found was that if you let openwrt strip the files compiling on the Yun chokes at the linking stage because it can't find symbols it needs.

To try it follow these steps:
1. Put an sd card in the Yun and run the diskSpaceExpander sketch http://arduino.cc/en/Tutorial/ExpandingYunDiskSpace , I am using a 16 gig sdcard with 10000 Mb data partion leaving 6 gig for the system.

2. Install binutils
Code: [Select]
root@Arduino:~# opkg update
Downloading http://downloads.arduino.cc/openwrtyun/1/packages/Packages.gz.
Updated list of available packages in /var/opkg-lists/attitude_adjustment.
Downloading http://downloads.arduino.cc/openwrtyun/1/packages/Packages.sig.
opkg install Signature check passed.
root@Arduino:~# opkg install binutils
Installing binutils (2.22-5) to root...
Downloading http://downloads.arduino.cc/openwrtyun/1/packages/binutils_2.22-5_ar71xx.ipk.
Installing objdump (2.22-5) to root...
Downloading http://downloads.arduino.cc/openwrtyun/1/packages/objdump_2.22-5_ar71xx.ipk.
Configuring objdump.
Configuring binutils.
root@Arduino:~#


3. Copy the ipk to your data partition. On linux I use:
Code: [Select]
scp gcc_4.6.2-1_ar71xx.ipk arduino.local:/mnt/sda1


4. Install gcc, this takes a LONG time so be patient.
Code: [Select]
root@Arduino:~# opkg install /mnt/sda1/gcc_4.6.2-1_ar71xx.ipk
Installing gcc (4.6.2-1) to root...
Configuring gcc.
root@Arduino:~#


5. Give it a source file named hello.c to compile, this works:
Code: [Select]
#include <stdio.h>

void main(void)
{
   printf("%s","hello world\n");
}


6. Compile it
Code: [Select]
root@Arduino:~# gcc -fno-use-linker-plugin -msoft-float hello.c -o hello
hello.c: In function 'main':
hello.c:5:5: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
root@Arduino:~#


7. run the executable:
Code: [Select]
root@Arduino:~# ./hello
hello world
root@Arduino:~#


8. Yes it is slow:
Code: [Select]
time  gcc -fno-use-linker-plugin -msoft-float hello.c -o hello
hello.c: In function 'main':
hello.c:5:5: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
real 0m 0.53s
user 0m 0.34s
sys 0m 0.10s


I need to clean up the makefile and then I'll put in a pull request to the yun repository so it can be built by anyone who wants to.

federicofissore

Can't wait to see it, amazing work :)

federicofissore

Reviving this old topic to make everyone aware that, thanks to the work done here, a package name "yun-gcc" is now available. Thanks noblepepper and everyone for their past and future contributions

dctsystems

Thanks to noblepepper for turning my hacked code into something that's now part of the main tree!

nice one guys!

Go Up