Go Down

Topic: gcc on linino? (Read 16180 times) previous topic - next topic

SPlatten

Kind Regards,
Sy

sonnyyu


Trying this:
http://wiki.openwrt.org/doc/howto/build



That will work, make sure build 12.09 branch (Attitude Adjustment). and you could get official support  at
https://forum.openwrt.org/.

SPlatten

#32
May 04, 2014, 09:59 am Last Edit: May 04, 2014, 10:08 am by SPlatten Reason: 1
I've been following the guide on:
http://wiki.openwrt.org/doc/devel/crosscompile

I've now been through it several times, not sure what I've missed out, but I keep getting to the same stage.  When I try to create a new project in eclipse, I choose the project type, but then I just get a blank wizard page with no further options.

I've seen another reference showing entry for the target toolchain, but I'm not sure how to get there from the original guide.  Also in the guide build it shows a trunk folder, I don't have that.

My tree looks as follows:
Code: [Select]

simon@ubuntu:~/openwrt$ ls -l
total 108
drwxr-xr-x  3 simon simon  4096 May  3 20:51 bin
-rw-rw-r--  1 simon simon   179 May  3 19:11 BSDmakefile
drwxr-xr-x  5 simon simon  4096 May  3 20:00 build_dir
drwxrwxr-x  2 simon simon  4096 May  3 19:11 config
-rw-rw-r--  1 simon simon   560 May  3 19:11 Config.in
drwxr-xr-x  2 simon simon  4096 May  3 21:15 dl
drwxrwxr-x  2 simon simon  4096 May  3 19:11 docs
drwxrwxr-x 10 simon simon  4096 May  3 19:37 feeds
-rw-rw-r--  1 simon simon   714 May  3 19:17 feeds.conf.default
drwxrwxr-x  3 simon simon  4096 May  3 19:11 include
-rw-rw-r--  1 simon simon 17992 May  3 19:11 LICENSE
-rw-rw-r--  1 simon simon  3102 May  3 19:11 Makefile
drwxrwxr-x 12 simon simon  4096 May  3 19:12 package
-rw-rw-r--  1 simon simon  1259 May  3 19:11 README
-rw-rw-r--  1 simon simon 10151 May  3 19:11 rules.mk
drwxrwxr-x  4 simon simon  4096 May  3 19:11 scripts
drwxrwxr-x  5 simon simon  4096 May  3 19:41 staging_dir
drwxrwxr-x  6 simon simon  4096 May  3 19:11 target
drwxrwxr-x  4 simon simon  4096 May  3 21:30 tmp
drwxrwxr-x 12 simon simon  4096 May  3 19:11 toolchain
drwxrwxr-x 54 simon simon  4096 May  3 19:11 tools


Contents of staging_dir:
Code: [Select]

simon@ubuntu:~/openwrt/staging_dir$ ls -l
total 12
drwxr-xr-x 13 simon simon 4096 May  3 20:51 host
drwxrwxr-x 11 simon simon 4096 May  3 21:30 target-mips_34kc_uClibc-0.9.33.2
drwxr-xr-x 12 simon simon 4096 May  3 21:29 toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2


I feel I'm close its so frustrating, the guide isn't the easiest thing to follow as it jumps around, rather than step by step instructions.

Thank you,
Kind Regards,
Sy

federicofissore

Give a look at @fibasile guide for cross compiling a single package http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html

In order to use that guide, you need either the SDK for your OS or a compiled yun image: for the latter, see the guide at https://github.com/arduino/openwrt-yun

noblepepper

#34
May 04, 2014, 01:01 pm Last Edit: May 04, 2014, 02:28 pm by noblepepper Reason: 1
You are very close, it looks like you have your build root complete. Check the bin/ar71xx directory, there should be a md5sums file, a package directory and several files that start with openwrt-ar71xx. Even if this isn't there you most likey have the toolchain at this point.

Here is a way to see if you can compile assuming your OpenWrt-yun directory is in your home directory:
Code: [Select]

cd ~/OpenWrt-yun/
mkdir test
cd test

Create a file "src/HelloOpenWrt.c" with these contents using whatever editor you like:
Code: [Select]
#include <stdio.h>

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


Add the tools location to your path:
Code: [Select]
PATH=$PATH:~/OpenWrt-yun/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin
Now you can compile and link:
Code: [Select]
mips-openwrt-linux-gcc -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/HelloOpenWrt.d" -MT"src/HelloOpenWrt.d" -o "src/HelloOpenWrt.o" "src/HelloOpenWrt.c"
mips-openwrt-linux-gcc -o "HelloOpenWrt"  ./src/HelloOpenWrt.o

Copy the program to the Yun:
Code: [Select]
scp HelloOpenWrt root@arduino.local:/tmp

ssh into the Yun and run the program:
Code: [Select]
ssh root@arduino.local
/tmp/HelloOpenWrt


Don't worry about the missing trunk directory. I don't understand what it is but in some build roots you have it, in others the contents are just in the base directory. If you are working in the current OpenWrt-yun build root just leave the /trunk/ out of the paths when you see it.

noblepepper

#35
May 04, 2014, 02:03 pm Last Edit: May 04, 2014, 02:18 pm by noblepepper Reason: 1
If you can compile like I showed in the last post here is how I got Eclipse working, I really think it is worth the trouble if you write programs, if you just want to compile already working programs it may not be worth the trouble.

Start at step 4 in http://downloads.openwrt.org/docs/eclipse.pdf, you have already completed the steps before this point.
Install openssh-sftp-server and gdbserver on the Yun
Code: [Select]
root@Arduino:~# opkg install openssh-sftp-server
Installing openssh-sftp-server (6.1p1-1) to root...
Downloading http://downloads.arduino.cc/openwrtyun/1/packages/openssh-sftp-server_6.1p1-1_ar71xx.ipk.
Configuring openssh-sftp-server.
root@Arduino:~# opkg install gdbserver
Installing gdbserver (6.8a-4) to root...
Downloading http://downloads.arduino.cc/openwrtyun/1/packages/gdbserver_6.8a-4_ar71xx.ipk.
Configuring gdbserver.


In step 5 I used Eclipse IDE for C/C++ Juno from here https://www.eclipse.org/downloads/packages/release/juno/sr2 and unpacked it in my OpenWrt-yun directory and I put my workspace in OpenWrt-yun/eclipse/workspace.

In step 6 I use this

to create a new project and I get this


is this where you have a problem?

If so make sure you did this in step 5:
We have to install additional eclipse packages: enter Menu ? Help ? Install new Software ..
and select in section "Mobile and Device Development" packages "C/C++ GCC Cross Compiler
Support" and "Remote System Explorer End-User Runtime".

SPlatten

#36
May 04, 2014, 07:09 pm Last Edit: May 04, 2014, 07:20 pm by SPlatten Reason: 1
Thank you so much for the help, I will try to get follow it tonight, just did the following:
Code: [Select]

simon@ubuntu:~/openwrt$ find . -name mips-openwrt-linux-gcc
./build_dir/target-mips_34kc_uClibc-0.9.33.2/OpenWrt-Toolchain-ar71xx-for-mips_34kc-gcc-4.8-linaro_uClibc-0.9.33.2/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-gcc
./build_dir/target-mips_34kc_uClibc-0.9.33.2/OpenWrt-SDK-ar71xx-for-linux-x86_64-gcc-4.8-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-gcc
./staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-gcc


I modified the path:
Code: [Select]

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/simon/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/


When I tried to compile:
Code: [Select]

mips-openwrt-linux-gcc -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/HelloOpenWrt.d" -MT"src/HelloOpenWrt.d" -o "src/HelloOpenWrt.o" "src/helloworld.c"
mips-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined


The contents of src after compilation is:
Code: [Select]

ls -l
total 12
-rw-rw-r-- 1 simon simon   37 May  4 18:18 HelloOpenWrt.d
-rw-rw-r-- 1 simon simon 1316 May  4 18:18 HelloOpenWrt.o
-rw-rw-r-- 1 simon simon   77 May  4 18:01 helloworld.c


The toolchain path is different to yours, not sure why?
Kind Regards,
Sy

SPlatten

Any idea what the password is likely to be when using scp to transfer file to yun?

I've tried the password I set to login using putty, but no joy.
Kind Regards,
Sy

noblepepper

#38
May 04, 2014, 07:49 pm Last Edit: May 04, 2014, 07:52 pm by noblepepper Reason: 1
The password should be the same as you use to login with putty, the web interface or anything else.

You can also set up to not need the password by using a ssh key like this: http://forum.arduino.cc/index.php?topic=196604.0

Since you are trying to scp something to the yun I assume you know that the STAGING_DIR warning doesn't stop the linking.

It looks like you are building from a build root from openwrt not the Yun specific build root which gives the difference in paths. It should work for most things but you will probably want to do the Yun build eventually https://github.com/arduino/openwrt-yun

SPlatten

I don't unstand why I can't connect via scp...I've opened an ssh session using putty and logged in as root with my set password, but I can't get in with the same password on scp.
Kind Regards,
Sy

noblepepper

Are you on linux or windows, I didn't know there was a putty for linux.

SPlatten

Its complicated...I'm running Windows 7 x64 with VMplayer hosting Ubuntu, I'm using Ubuntu to compile and use for Cross Platform development.

Output from uname:
Code: [Select]

Linux ubuntu 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux


Putty is on the Windows desktop.
Kind Regards,
Sy

noblepepper

Are you using root@arduino.local not just arduino.local? I make myself say DOH!! with that frequently.

Code: [Select]
$ ssh arduino.local
pep@arduino.local's password:
Permission denied, please try again.
pep@arduino.local's password:
Permission denied, please try again.
pep@arduino.local's password:
Permission denied (publickey,password).

$ ssh root@arduino.local


BusyBox v1.19.4 (2014-04-10 11:08:41 CEST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
|       |.-----.-----.-----.|  |  |  |.----.|  |_
|   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
|_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
-----------------------------------------------------


root@Arduino:~#
I have the public key stuff set up so it doesn't ask for the password when I use the correct user (root)

I am aware of people using your setup but I am not extremely familiar with how to set it up. Try using ssh like above from within your virtual linux. There may be some extra things needed to get network connectivity from there.

If nothing else can you save the executable somewhere that you can reach from with in Windows and then transfer using putty?

SPlatten

Ok, now I get:
Code: [Select]

scp HelloOpenWrt root@192.168.1.171:/tmp
root@192.168.1.171's password:
HelloOpenWrt: No such file or directory


The files in src are:
Code: [Select]

-rw-rw-r-- 1 simon simon   37 May  4 18:57 HelloOpenWrt.d
-rw-rw-r-- 1 simon simon 1316 May  4 18:57 HelloOpenWrt.o
-rw-rw-r-- 1 simon simon   77 May  4 18:01 helloworld.c


Kind Regards,
Sy

noblepepper

Is there anything in test?
Code: [Select]
test$ ls -l
total 12
-rwxr-xr-x 1 pep pep 5014 May  4 05:58 HelloOpenWrt
drwxr-xr-x 2 pep pep 4096 May  4 05:58 src

Did you link after compiling?
Code: [Select]
mips-openwrt-linux-gcc -o "HelloOpenWrt"  ./src/HelloOpenWrt.o

You do need to be in the test dir, if not you need to give the path.

Go Up