topamax once a day

Raspberry Pi NES Emulator

This tutorial will demonstrate how to install Nintendo NES/Famicom emulator on the Raspberry Pi running Debian.  Begin by installing the necessary dependencies. In a terminal, enter:

sudo apt-get install scons libsdl1.2-dev libsdl1.2debian-esd subversion libgtk2.0-dev

Checkout the most recent sources using subversion:

svn checkout fceultra

The repo has moved here:

svn checkout svn:// fceultra

Change directory into the root of the source tree

cd fceultra/

Compile and install FCEU using the scons build tool:

sudo scons GTK=1 install

That’s it! To run:


Then select the ROM with from the title bar menu, File->Open ROM, or with Ctrl+O.

You can easily setup a gamepad too, like the USB NES RetroPort. This adapter converts an authentic NES controller to USB.   To configure, run fceux using the inputcfg flag to setup configure.  Press the corresponding buttons in series as they are prompted. Note: There are two dashes ( – – ) together in the command below:

fceux –inputcfg gamepad1


Raspberry Pi + OpenCV

OpenCV is a suite of powerful computer vision tools. Here is a quick overview of how I installed OpenCV on my Raspberry Pi with debian6-19-04-2012.  The guide is based on the official OpenCV Installation Guide on Debian and Ubuntu. Before you begin, make sure you have expanded your SD card to allow for the install of OpenCV. Its a big package with lots of dependencies. You can follow my instructions here.  Once you have expanded the SD card, open up a terminal and install the following packages:

UPDATE: You can execute the following steps with a simple call to the Ansible playbook playbook-opencv. Note that you have to edit the pis.yml file with your pi ip address and update group_vars/pis.yml with your pi password.

git clone
ansible-playbook site.yml -i pis.yml -vvvv

Note: The make command will take HOURS to run. Please be patient.

sudo apt-get -y install build-essential cmake cmake-qt-gui pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools


sudo apt-get -y install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs ffmpeg libavcodec-dev libavcodec53 libavformat53 libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils swig libv4l-0 libv4l-dev python-numpy libpython2.6 python-dev python2.6-dev libgtk2.0-dev pkg-config

There are some dependency issues with the order of the install, mostly with regard to libjpeg issues, so be sure to install in this order. You will see some broken package errors if you attempt to install all the dependencies in one step.

Next, pull down the source files for OpenCV using wget:


Once finished downloading, extract the archive, remove the no longer needed archive (to save space), change directory to the top of the source tree, make a directory for the build, and change into it:

tar -xvjpf OpenCV-2.3.1a.tar.bz2

rm OpenCV-2.3.1a.tar.bz2

cd OpenCV-2.3.1/

mkdir build

cd build

Next, you will need to configure the build using cmake. If you aren’t sure about what options you want/need or are unfamiliar with cmake, this line will create a standard configuration:


Alternatively, you can configure the build using a GUI interface. This can be helpful to build with support for additional OpenCV features. To use the cmake GUI, run:

cmake-gui ..

In the cmake GUI, click ‘configure’ to pre-populate the build options. Select or remove any desired features, then click ‘configure’ again, check the output and ensure that there are not any modules that cmake cannot find. If everything looks good, click ‘generate’ to create the makefiles, then close cmake-gui. Now we are ready to start the build! To compile, run make, then install with make install:


sudo make install

As you can see from the image, this will take a LONG time… over four and a half hours to compile!

Finally, we need to make a few configurations for OpenCV. First, open the opencv.conf file with the following code:

sudo nano /etc/

Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:


Then edit the system-wide bashrc file:

sudo nano /etc/bash.bashrc

Add the following new lines to the end of the file:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH

Now that everything is installed and configured, on to the demos!  The C demos are here:

cd ~/opencv/OpenCV-2.3.1/build/bin

C demos in build/bin demos worth checking out (that don’t require a webcam):




The python demos are located in samples/python:

cd ~/opencv/OpenCV-2.3.1/build/bin

These demos also don’t require a webcam:

python ./

python ./

python ./



Raspberry Pi Root FS on USB Drive

This tutorial will demonstrate how to install the Debian root filestem (ie. ‘/’) on a USB drive instead of the SD card. The SD card still retains the /boot partion and swap space. This requires a modified kernel to support the USB storage. You can download the minimal modified kernel and modules here  or follow my guide on how to compile it for yourself.

In either case, begin by installing the Debian image as you normally would to an SD card. Manually format the USB drive you intend to use as the root filesystem as ext4 using a utility like gparted.

Next, copy the root filesytem from the Debian install on the SD card to the USB drive, preserving attributes with the -a flag, substituting “sdcard-rootfs-partition-uuid” and “usbdrive-rootfs-partition-uuid” with the respective identifiers as the filesystem are mounted in Ubuntu.

sudo cp -a /media/sdcard-rootfs-partition-uuid/* /media/usbdrive-rootfs-partition-uuid/


Now, delete the existing kernel.img and replace it with the new one, substituting “sdcard-boot-partition-uuid” with the identifier of the partion as it is mounted in Ubuntu.

sudo rm /media/sdcard-boot-partition-uuid/kernel.img

sudo mv kernel.img /media/sdcard-boot-partition-uuid/

Next, remove the existing /lib/modules and lib/firmware directories,

sudo rm -rf /media/usbdrive-rootfs-partition-uuid/lib/modules/

sudo rm -rf /media/usbdrive-rootfs-partition-uuid/lib/firmware/

and copy the new modules and firmware in their place:

cd ../../kernel/

sudo cp -a lib/modules/ /media/usbdrive-rootfs-partition-uuid/lib/

sudo cp -a lib/firmware/ /media/usbdrive-rootfs-partition-uuid/lib/


Now we need to modify the location of the root partition in the /boot partion. This is contained within the file, cmdline.txt. In this file, change:




That’s it! Plug in and boot up the root filesystem from the USB stick!


Raspberry Pi Kernel Compile

This tutorial will demonstrate how to cross compile the kernel for the Raspberry Pi on Ubuntu 12.04 LTS. The kernel is functional with both the Debian and Arch Linux Raspberry Pi images.

UPDATE: Alternatively, you can use the following Ansible playbook playbook-raspi_kernel_crosscompile. Note that you have to edit host_vars/localhost.yml file with your local sudo password.

git clone
ansible-playbook -i localhost.yml site.yml -vvvv

First, install the package dependencies, git and the cross-compilation toolchain:

sudo apt-get install git-core gcc-4.6-arm-linux-gnueabi

Create a symlink for the cross compiler:

sudo ln -s /usr/bin/arm-linux-gnueabi-gcc-4.6 /usr/bin/arm-linux-gnueabi-gcc

Make a directory for the sources and tools, then clone them with git:

mkdir raspberrypi
cd raspberrypi
git clone
git clone
cd linux

Generate the .config file from the pre-packaged raspberry pi one:

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- bcmrpi_cutdown_defconfig

If you want to make changes to the configuration, run make menuconfig (optional):

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig

Once you have made the desired changes, save and exit the menuconfig screen. Now we are ready to start the build. You can speed up the compilation process by enabling parallel make with the -j flag. The recommended use is ‘processor cores + 1′, e.g. 5 if you have a quad core processor:

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k -j5

Assuming the compilation was sucessful, create a directory for the modules:

mkdir ../modules

Then compile and ‘install’ the loadable modules to the temp directory:

make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/

Now we need to use from the tools repo to get the kernel ready for the Pi.

cd ../tools/mkimage/
./ ../../linux/arch/arm/boot/Image

This creates a kernel.img in the current directory. Plug in the SD card of the existing Debian image that you wish to install the new kernel on. Delete the existing kernel.img and replace it with the new one, substituting “boot-partition-uuid” with the identifier of the partion as it is mounted in Ubuntu.

sudo rm /media/boot-partition-uuid/kernel.img
sudo mv kernel.img /media/boot-partition-uuid/

Next, remove the existing /lib/modules and lib/firmware directories, substituting “rootfs-partition-uuid” with the identifier of the root filesystem partion mounted in Ubuntu.

sudo rm -rf /media/rootfs-partition-uuid/lib/modules/
sudo rm -rf /media/rootfs-partition-uuid/lib/firmware/

Go to the destination directory of the previous make modules_install, and copy the new modules and firmware in their place:

cd ../../modules/
sudo cp -a lib/modules/ /media/rootfs-partition-uuid/lib/
sudo cp -a lib/firmware/ /media/rootfs-partition-uuid/lib/

That’s it! Exject the SD card, and boot the new kernel on the Raspberry Pi!


WordPress on Raspberry Pi

This tutorial will demonstrate how to install and host WordPress on Raspberry Pi. This process assumes you have Debian for Raspberry Pi installed on an SD card. If not, see RPi Easy SD card setup.

Install Apache

WordPress runs on the Apache2 web server. To setup Apache, follow the instructions in my previous post, Raspberry Pi and Apache.

Install MySQL and PHP

Begin by installing the required dependencies. From a terminal:

sudo apt-get install mysql-server-5.5 php5 php5-mysql php5-gd

Next run the MySQL init script:

sudo mysql_install_db

Download and Extract WordPress

Download the latest wordpress source files


Extract the downloaded archive:

tar -xvzf latest.tar.gz

Create a directory in /var/www for the WordPress install:

sudo mkdir /var/www/wordpress

Copy over the extacted files:

sudo cp -r ~/wordpress/* /var/www/wordpress

Configure Apache

Next, make a backup of the apache config file, then open it in a text editor:

sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
sudo vim.tiny /etc/apache2/apache2.conf

Add this line to the end of the file:

AddType application/x-httpd-php .html

And restart Apache

sudo /etc/init.d/apache2 restart

Configure MySQL

The next step is to configure MySQL for use with WordPress. WordPress needs a database and user, and permissions set correctly for access. Start the mysql config:

mysql -u root -p

Enter the root MySQL password, then arrive at the mysql prompt


Create a database for WordPress, create a user for the database, and set password set the permissions:

CREATE USER wordpressuser;
SET PASSWORD FOR wordpressuser= PASSWORD(“1234”);
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser IDENTIFIED BY ‘1234’;

Then quit the MySQL client:


Now create a new wordpress configuration based on the sample:

sudo cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php

And open it up for edit in an editor:

sudo vim.tiny /var/www/wordpress/wp-config.php

Change this:

/** The name of the database for WordPress */
define(‘DB_NAME’, ‘database_name_here’);

/** MySQL database username */
define(‘DB_USER’, ‘username_here’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password_here’);

to this (substituting password_here with your own from above):

/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wordpress’);

/** MySQL database username */
define(‘DB_USER’, ‘wordpressuser’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password_here’);

Finalizing the install

The hard part is over! Now open up a browser and head to the site and finalize the install. To do this, navigate from a browser on another machine on your local network, only substitute the local address of the Raspberry Pi. To find the address of the Raspberry Pi, open a terminal and run:


Then navigate to that address with a trailing /wordpress from a browser on the same local network: