Compiling a custom uwsgi for the Rascal

This post is just a note to myself about how to modify the uwsgi source code, recompile uwsgi and install it on a Rascal. Here are the steps:

1. Create a uwsgi source code tarball on goelzer.com

I have the uwsgi source code in a directory (/home/mikegoelzer/goelzer.com/uwsgi). After modifying the C code, I can use these commands to build a new tarball that bitbake will fetch in the next step:


cd /home/mikegoelzer/goelzer.com/uwsgi
tar cvzf uwsgi-1.2.3.tar.gz uwsgi-1.2.3/
md5sum uwsgi-1.2.3.tar.gz && shasum -a 256 uwsgi-1.2.3.tar.gz

The tarball is now accessible at http://goelzer.com/uwsgi/uwsgi-1.2.3.tar.gz. The above command also prints two hashes of the tar file that will be used below.

2. Update the OE uwsgi recipe

On the OE build system, I modify the bitbake recipe for uwsgi in recipes/uwsgi/uwsgi_1.2.3.bb:


DESCRIPTION = "uWSGI is a WSGI web server for Python web applications"
HOMEPAGE = "http://projects.unbit.it/uwsgi/wiki"
SECTION = "net"
PRIORITY = "optional"
LICENSE = "GPLv2"
SRCNAME = "uwsgi"
PR = "r0"

SRC_URI = "http://goelzer.com/uwsgi/uwsgi-1.2.3.tar.gz \
file://editor.ini \
file://public.ini \
file://arm-timer-syscall.patch"

[...]

Here’s the full recipe as a backup. And a shell script used to rebuild uwsgi.

Also, the last two lines of the file should be updated with the hash values computed in step 1.

3. Rebuild uwsgi using bitbake:


source env.sh
rm oe_sources/uwsgi-1.2.3.tar.gz*
bitbake -c clean uwsgi
bitbake -b uwsgi_1.2.3.bb

4. SCP and install the newly built opkg

From the Rascal:


rm uwsgi_1.2.3-r0.6_armv5te.ipk
opkg remove uwsgi
scp ubuntu@ec2-204-236-242-68.compute-1.amazonaws.com:/home/ubuntu/openembedded-rascal/tmp/deploy/glibc/ipk/armv5te/uwsgi_1.2.3-r0.6_armv5te.ipk .
opkg install uwsgi_1.2.3-r0.6_armv5te.ipk
/etc/init.d/rascal-webserver.sh reload

To see the uwsgi logs:


cat /var/log/uwsgi/public.log

Leave a Comment

Rascal/Arduino Dual Relay Shield v2

Yesterday, I assembled a few copies of my Dual Relay Shield (rev 2). Here’s a picture of its handsome exterior:

Dual Relay Shield v2

Dual Relay Shield v2 (green thing on top) connected to a Rascal 0.6 (red and yellow thing on bottom). The DRS lets you switch 2 relays on and off to control devices up to 5 amps at 220 volts.

The shield has two relays that can switch up to 5 amps — this could be a pair of lights, motors, speakers, etc. It also has an integrated I2C temperature sensor. You could use this to build, for instance, a web-based thermostat. I expect Brandon will set up a Rascal demo or tutorial using the shield in the near future, to which I’ll link from here once it exists.

All of the design files are open source. You can find them on my Rascal Shield github.

Leave a Comment

Building uWSGI on Ubuntu 11.xx

uWSGI is the HTTP server included with the Rascal. I want to fiddle with its source code and extend it, so I started by building the stock distribution on an x86 Ubuntu 11.04 box. This is how I did it.

0. I had to first install some packages for the build to succeed:

sudo apt-get install libxml2 libxml2-dev python-dev

1. Download the current tarball listed under http://projects.unbit.it/uwsgi/wiki/WikiStart#Getit

2. Untar and then follow the instructions from projects.unbit.it/uwsgi/wiki/Install

tar xzvf uwsgi-1.0.2.1.tar.gz
cd uwsgi-1.0.2.1
make

3. The compile should complete successfully with the last line reading like this:

*** uWSGI is ready, launch it with ./uwsgi ***

4. Start it like this:

./uwsgi --http :80

In future posts, I’ll look at modifying the uWSGI source code to support Python-programmed user mode interrupt handlers.

Leave a Comment

Compiling and loading kernel modules on the Rascal

Here’s a tut showing how to cross-compile your own device driver (as a kernel module) on the Rascal and then load/unload it into Linux on the device.  Before you attempt this tutorial, you need to set up a Rascal kernel build environment. The instructions are here: rascalmicro.com/docs/build-guide.html. Even if you’ve previously done this, remember that before compiling anything you need to re-run these commands (every time you open a new terminal window):

export CROSS_COMPILE=arm-linux-
PATH=$PATH:/opt/eldk/usr/bin:/opt/eldk/bin:/opt/cs/bin

Now for the driver building tutorial. Let’s download Dave Hylands’s gpio-event driver and usermode application for the Gumstix Overo.  We can compile this driver for the Rascal unmodified once we get some paths set correctly in the Makefile.  Check out the Rascal kernel git branch to ~/rascal/linux-2.6 and download Hylands’s code to ~/rascal/gpio-event.  Modify ~/rascal/gpio-event/module/Makefile to use these alternate variable definitions:

CROSS_COMPILE ?= /opt/eldk/usr/arm-linux-gnueabi
KERNEL_PATH   ?= /home/mike/rascal/linux-2.6/arch/arm/kernel
ARCH          ?= arm

(Of course, the /home/mike prefix is specific to my machine.  What matters is that $(KERNAL_PATH) is a directory containing a bunch of C source files, like module.c.)

Now we’re ready to build the driver. Do this:

cd ~/rascal/gpio-event/module
make -C ~/rascal/linux-2.6/ M=`pwd` ARCH=arm modules

You should get a file called gpio-event-drv.ko in ~/rascal/gpio-event/module.

SCP this file to the Rascal and ssh in to it.  From the directory where you put the gpio-event-drv.ko file, you can use these commands:

insmod gpio-event-drv.ko
rmmod gpio-event-drv.ko

to load and unload the module respectively.

Leave a Comment

How to beat the Wikipedia SOPA blackout

I was able to download a local copy of Wikipedia and a reader and set them up in less than 5 minutes.  Used this tut:  http://lifehacker.com/5876833

Leave a Comment