Monthly Archive for March, 2008

PDa on openembedded gumstix

Thanks to some expert tips from Guenter Geiger, I have made a bitbake recipe for installing PDa on gumstix computers running openembedded linux.

This version includes GUI support, I have been using this remotely using X windows. It should also work directly on a screen but I don’t have one to test this.

The bitbake recipe can be downloaded here.

This can be used to build PDa on your own openembedded development system.

Alternatively, the prebuilt package is here. You can copy this onto your gumstix and install it with the command:

ipkg install PDa_0.6-r0.1_armv5te.ipk

This requires X11, the gumstix will need to have access to the internet to install it. Alternatively there are pre-built images available which incorporate X11.

You can now run PDa from any directory on the gumstix as it is installed in /usr/bin.

As before, you can use PDa in command line mode:

pd -nogui -open mypatch.pd

Alternatively, to run the gui you will need tcl and tk installed. Unfortuneately Fortuneately there is some there is now no problem with these packages in the gumstix ipkg repository so but I have made installable binaries of them in case your gumstix doesn’t have a ‘net connection.here and here. You will need to copy them to the gumstix and install them:

ipkg install tcl_8.4.11-r5_armv5te.ipk
ipkg install tk_8.4.11-r5_armv5te.ipk

Otherwise just install them automatically on the gumstix with:

ipkg install tk

To run PDa with the gui remotely on ubuntu I followed the instructions here.

You have to enable X11 forwarding with ssh by editing (on ubuntu) the file /etc/ssh/ssh_config

ForwardX11Trusted yes

And then ssh into the gumstix with these commands:

xhost +IP.of.gumstix
ssh -2 -X -C user@IP.of.gumstix

And on the gumstix I had to set this environment variable before launching PDa:

DISPLAY=IP.of.desktop:0
pd

And PDa launched a menu on my computer!

update: this hasn’t worked for me using Ubuntu Hardy Heron, the workaround was to install xauth on the gumstix which allows the DISPLAY environment variable to be forwarded.

Connecting a gumstix to the internet via USBnet

I have managed to connect my gumstix connex 400bt to the internet via my laptop (running ubuntu 7.10) and USBnet.. not that involved but I couldn’t find any guidelines anywhere so here goes.

I had to set up IP forwarding and NAT (network address translation) on the laptop.. after googling at iptables info I used a simple script Ubuntu-firewall.

The configuration is pretty obvious, you just set it up to do NAT rather than act as a firewall, select your interfaces (eth1 and usb0 in my case), set the enable flag (disabled by default), and then to launch it type:

sudo ubuntu-firewall start

I got this friendly and reassuring message:

* Starting Ubuntu-firewall…
Detecting external interface IP address…
External interface IP configuration looks good! Loading ruleset…
NAT-only configuration selected!
NAT Routing Functions are enabled for 11.0.0.0/24 on usb0!
Port Forwarding Established!

Logging into the gumstix, I was now able to ping and traceroute IP addresses on the internet. However, ping www.google.ie still gave the error ‘Name lookup failed’.

Further poking around revealed the fact that a configuration file, ‘/etc/resolv.conf’, that doesnt exist on the gumstix by default, is needed to determine how to lookup host names.

The answer: create the file

vi /etc/resolv.conf

and add a line:

nameserver 11.0.0.1 (or whatever address your usb0 connection has on your host computer)

voila! the gumstix is now able to resolve names, and also (importantly) run:

ipkg update

————————-nb
trying to do the same thing for bnep networking

setting /proc/sys/net/ipv4/ip_forward to 1 by:
sudo gedit /etc/sysctl.conf

sudo iptables –table nat –append POSTROUTING –out-interface eth0 -j MASQUERADE
sudo iptables –append FORWARD –in-interface bnep0 -j ACCEPT

doesnt seem to work.

Setting up USBnet on openembedded gumstix

I have just installed openembedded linux for my gumstix connex-400bt.

Its pretty impressive, but unfortuneately I couldn’t get USBnet working straight away- and this is the way I usually connect to my gumstix.

After trying quite a few things, this is the solution I came up with:

To enable static IP address and to autolaunch the usb0 interface, I changed the entry in /etc/network/interfaces to:

auto usb0
iface usb0 inet static
address 11.0.0.2
netmask 255.255.255.0
network 11.0.0.1
gateway 11.0.0.1

I also had to add the following lines to get the interface to initialise:

pre-up /sbin/modprobe g_ether;/sbin/modprobe gumstix_gadget
post-down /sbin/modprobe -r g_ether

However I found that, although the gumstix thought it then had a usb0 interface, this only made the interface work the second time it was invoked: ie. I had to type

ifdown usb0
ifup usb0

After the auto-initialiser had tried to start it.

Hmm, not good, after trying lots more stuff, I came up with this ultra-inelegant solution: editing /etc/init.d/networking, and adding

ifdown usb0
ifup usb0

just after ‘ifup -a’ in the stanza ’start’.

Ugly but it works.

Running!




Montjuic is certainly a nice place to run although I didnt go all that
far or fast..

(Save the file and open it in google earth if it doesnt launch automatically, it also works in google maps).

Hopefully will do better tomorrow…

Mirrors

These ingenious mirrors allow you to see how a new hairstyle will look on your own face.

What will they think of next!

Funny, mirrors seem to crop up in my life increasingly these days.

Here are a few more photos of mirrors…

Hello world in pure data

First full day of my residency at UPF Barcelona, and I am just getting my head around writing ‘pd externals’ i.e. writing plugins for pure data, the ubiquitous opensource music patching software.

The syntax to define an object is fairly tortuous- relying as it does on function calls in c, rather than inbuilt concepts of a ‘real’ object oriented language. I think this implies that the object system can work at runtime though, hmm, must think about this.

Anyway, making a trivial ‘hello world’ for pd (thanks to this excellent tutorial) looks like this:

#include “m_pd.h”

static t_class *helloworld_class;

typedef struct _helloworld {
t_object x_obj;
} t_helloworld;

void helloworld_bang(t_helloworld *x)
{
post(”Hello world !!”);
}

void *helloworld_new(void)
{
t_helloworld *x = (t_helloworld *)pd_new(helloworld_class);

return (void *)x;
}

void helloworld_setup(void) {
helloworld_class = class_new(gensym(”helloworld”),
(t_newmethod)helloworld_new,
0, sizeof(t_helloworld),
CLASS_DEFAULT, 0);
class_addbang(helloworld_class, helloworld_bang);
}

What’s not so clear however is how to compile it! I guess this is because pd is cross platform (originally running on IRIX and windows NT).

As I’m using linux and the gcc compiler, I know I need to write a ‘makefile’.. for those who haven’t had the pleasure, its a textfile which defines possibly recursive rules for the ‘gnu make’ programme to compile a tree of source code.

So after the time-honoured method of digging through existing examples, heres a good basic makefile for linux pd (which I would have been very happy to stumble upon today!) based on the vbap external from the pd extras repository.

PD=../pd-0.37-4

NAME=helloworld

Phony: $(NAME).pd_linux

.SUFFIXES: .pd_linux

LINUXCFLAGS = -DPD -DUNIX -O2 -funroll-loops -fomit-frame-pointer \
-Wall -W -Wshadow -Wstrict-prototypes -Werror \
-Wno-unused -Wno-parentheses -Wno-switch

LINUXINCLUDE = -I/$(PD)src

.c.pd_linux:
cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
ld -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm -L/usr/local/lib
strip –strip-unneeded $*.pd_linux
rm -f $*.o ../$*.pd_linux
ln -s $*/$*.pd_linux ..

install:
cp help-*.pd $(PD)/doc/5.reference

clean:
rm -f *.o *.pd_* so_locations

Barcelona!

I am off today to begin my residency at the Music Technology Group at Universitat Pompeu Fabra.


Here I will be working on PDa, developing some new objects for my projects and hopefully incorporating it in the gumstix source tree.

Watch this space!