Example of OpenWrt-SDK for Yun

Use https://github.com/arduino/openwrt-yun compile OpenWrt-SDK for Yun.

I enclosed pre-compile OpenWrt-SDK for Yun here.

At Debian 32 bits box:

cd ~

wget -O OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2.tar.bz2 https://www.dropbox.com/s/a0yc8oy4vcvmf7q/OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2.tar.bz2?dl=0
md5sum OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2.tar.bz2
0e5706c72e433c362cf384c462b86f86
tar -vxjf OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2.tar.bz2
nano ~/setup.sh
#!/bin/bash
BACKPATH=$PATH
export BACKPATH
PWD=~/OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2
PWD2=~/OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-mips_r2_uClibc-0.9.33.2
PATH=$PWD/bin:$PATH
export PATH
STAGING_DIR=$PWD
export STAGING_DIR
CFLAGS=$PWD2/usr/include
export CFLAGS
LDFLAGS=$PWD2/usr/lib
export LDFLAGS
source ~/setup.sh

Hello world C example:

mkdir ~/hello
cd ~/hello
nano hello.c
//C hello world example
#include <stdio.h>
int main()
{
  printf("Hello world\n");
  return 0;
}
mips-openwrt-linux-uclibc-gcc -Wall hello.c -o hello
mips-openwrt-linux-uclibc-strip hello
scp hello root@192.168.0.102:/mnt/sda1

Arduino Yun:

root@Arduino:/# /mnt/sda1/hello
Hello world

Hello world C++ example:

mkdir ~/helloplus
cd ~/helloplus
nano helloplus.cpp
// 'Hello World!' program
#include <iostream>
int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}
mips-openwrt-linux-uclibc-g++  helloplus.cpp -o helloplus
mips-openwrt-linux-uclibc-strip helloplus
scp helloplus root@192.168.0.102:/mnt/sda1

Arduino Yun:

opkg update
opkg install libstdcpp
root@Arduino:/# /mnt/sda1/helloplus
Hello world!

Mysql C example:

mkdir ~/mysql
cd ~/mysql
nano version.c
#include <my_global.h>
#include <mysql.h>

int main(int argc, char **argv)
{
  printf("MySQL client version: %s\n", mysql_get_client_info());

  exit(0);
}
mips-openwrt-linux-uclibc-gcc version.c -o version  \
-I${CFLAGS}/mysql -DBIG_JOINS=1  -fno-strict-aliasing   -g \
-L${LDFLAGS}/mysql  \
-L${LDFLAGS} -lmysqlclient -lpthread -lz -lm -lrt -ldl \
-Wl,-rpath-link=${LDFLAGS}
mips-openwrt-linux-uclibc-strip version
scp version root@192.168.0.102:/mnt/sda1

Arduino Yun:

opkg update
opkg install libmysqlclient
root@Arduino:/# /mnt/sda1/version
MySQL client version: 5.1.53

More examples:

http://zetcode.com/db/mysqlc/

SOFTWARE-CONTROLLED PER-PORT POWER SWITCHING FOR USB HUBS

mkdir ~/hub-ctrl
cd ~/hub-ctrl
wget http://www.gniibe.org/oitoite/ac-power-control-by-USB-hub/hub-ctrl.c
mips-openwrt-linux-uclibc-gcc   hub-ctrl.c -o hub-ctrl \
-I${CFLAGS} -L${LDFLAGS} \
-Wl,-rpath-link=${LDFLAGS}  -lusb
mips-openwrt-linux-uclibc-strip hub-ctrl
scp hub-ctrl root@192.168.0.102:/mnt/sda1

Control per port power/per indicator LED of USB Hub

http://forum.arduino.cc/index.php?topic=305968.0

Compile Fortran 90:

source ~/setup.sh
nano helloworld.f90
program HelloWorldF90
    write(*,*) "Hello World!"
end program HelloWorldF90
mips-openwrt-linux-uclibc-gfortran helloworld.f90 -o helloworld-f90-gnu
scp helloworld-f90-gnu root@192.168.0.102:/mnt/sda1

Nice research, although I'm surprised that anyone would use fortran (or cobol for that matter) who is C/C++ proficient as I know you are. How about an exercise in forth? Is there a forth that can be loaded on the yun in a sketch as opposed to firmware?

Forth and Yun

http://forum.arduino.cc/index.php?topic=309294.0

Python bindings for the Linux input subsystem

mkdir -p ~/evdev
cd ~/evdev
git clone https://github.com/gvalkov/python-evdev.git
cd ~/evdev/python-evdev
mkdir -p ~/evdev/python-evdev/build/tmp
mkdir -p ~/evdev/python-evdev/build/lib
source ~/setup.sh
mips-openwrt-linux-uclibc-gcc -pthread -fno-strict-aliasing -DNDEBUG -g \
-fwrapv -O2 -Wall -Wstrict-prototypes -fPIC \
-I/home/sonnyyu/OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/include/python2.7 \
-c evdev/input.c -o build/tmp/input.o -std=c99 -Wno-error=declaration-after-statement

mips-openwrt-linux-uclibc-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/tmp/input.o -o build/lib/_input.so

mips-openwrt-linux-uclibc-gcc -pthread -fno-strict-aliasing -DNDEBUG -g \
-fwrapv -O2 -Wall -Wstrict-prototypes -fPIC \
-I/home/sonnyyu/OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/include/python2.7 \
-c evdev/uinput.c -o build/tmp/uinput.o -std=c99 -Wno-error=declaration-after-statement

mips-openwrt-linux-uclibc-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/tmp/uinput.o -o build/lib/_uinput.so

mips-openwrt-linux-uclibc-gcc -pthread -fno-strict-aliasing -DNDEBUG -g \
-fwrapv -O2 -Wall -Wstrict-prototypes -fPIC \
-I/home/sonnyyu/OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/target-mips_r2_uClibc-0.9.33.2/usr/include/python2.7 \
-c evdev/ecodes.c -o build/tmp/ecodes.o -std=c99 -Wno-error=declaration-after-statement

mips-openwrt-linux-uclibc-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/tmp/ecodes.o -o build/lib/_ecodes.so

copy all the .so and .py file together for Yun use.