NB! this is work in progress! - but it seems to do all I need at present.

Towards a "load it, run it" distro for Debian on Bifferboard
for web connected hardware control projects.

(For people like me who are not Linux developers but want to web-connect
a PIC based hardware control system or similar at minimum cost and only use 1 Watt).


NB! These are my personal notes for back-up.
- please email me with comments and corrections if you attempt to repeat this.
Other notes on this site for Sweex router and NSLU2 (Slug) may you help you to follow this page - do a keyword search of this site here

Objective
Run the Bifferboard with an operating system that allows it to web connect a network of i2c devices.
Some of these may be PIC micros running as i2c slave devices connected to servos, relays etc.
I had hoped to run OpenWrt on Bifferboard since it needs no swap partition.
However it was not possible to read and write to i2c devices using OpenWrt.

Method
Run Debian on an external USB memory stick or hard disk.
Once a core system is up and running it is then very easy to load new programs with "apt-get install xxxx"

Working so far -
Secure ftp connection for file transfer.
ssh terminal
rs232 terminal
web server (lighttpd) with cgi scripting

i2c both read and write (!!!!) - a PIC can be used for servo control, A/D, D/A, port expansion etc
Logitech 9000 HD webcam
USB sound dongle like this

WIFI dongle as on this page - D-Link DWL-G122
Compile C programs directly (gcc -o program program.c)
Blassic basic - great for hardware control and you can understand it simply by reading it!

Python
Perl
EDIT
GPIO *is* working
! - see http://sites.google.com/site/bifferboard/Home/gpio - here is a backup of that page -

GPIO SYSFS
SYSFS interface
The GPIO SYSFS interface allows one to control IO pins using files under the /sys directory.
When the system boots, all GPIO pins are owned by the kernel.
They won't show up in the sysfs system until they are 'exported'.
In order to export them, echo the pin number (for example 16 for the RED LED) to the file /sys/class/gpio/export:
$ echo 16 > /sys/class/gpio/export
This will result in the pseudo-files for pin 16 showing up under /sys/class/gpio/gpio16 as:
/sys/class/gpio/gpio16/direction
/sys/class/gpio/gpio16/value
etc...
You can set the direction to either 'in' or 'out':
$ echo out > /sys/class/gpio/gpio16/direction
And then set the pin value with:
$ echo 1 > /sys/class/gpio/gpio16/value
$ echo 0 > /sys/class/gpio/gpio16/value

The first echo should turn the LED off, the second on.
You can stop using a pin as GPIO by 'unexporting' it:
$ echo 16 > /sys/class/gpio/unexport
This will make /sys/class/gpio/gpio16 disappear.

Not yet working (expert help welcome please)
rs232 read from a webpage (write works OK but not read - the read code worked on OpenWrt BB - odd....)

Acknowledgements and links

Debian on Bifferboard has been developed by, in particular,
famzah
and by d1savowed. See this debate
Many thanks for their hard work and helpful answers to my very basic questions.



My back-up notes for when I have to repeat this build process
- skip down the page if you just want to try it
I ran the scripts created by d1savowed to create the firmware for the board and the files to load onto the external USB memory stick .
secure ftp and the easy to use nano text editor were pre installed.


i2c network drivers
These are included in my custom start-up script /etc/graham_startup.sh
- If this is modified do the following at a command line-
update-rc.d -f graham_startup.sh remove
update-rc.d -f graham_startup.sh defaults 99


modprobe rdc321x_gpio
modprobe i2c-algo-bit
modprobe i2c-gpio
modprobe i2c-gpio-custom bus0=0,12,9 - NB these are not the same pins as in the Bifferos Wiki
modprobe i2c-dev

i2c works! -

BiffDeb09:~# i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- 08 -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 -- -- -- -- -- -- 27 -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 49 4a 4b 4c -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
BiffDeb09:~#



Web server
apt-get update
apt-get install lighttpd
- web server


USB sound dongle
see this

apt-get install alsa-utils - wav file player - works very well
apt-get install madplay - mp3 player - only works for very short, single word mp3 files
apt-get install flite - text to speech - make it speak temperatures etc!

For flite to work you need snd-pcm-oss but if you add it to /etc/graham_startup.sh as modprobe snd-pcm-oss
then the USB webcam only works if plugged in after boot time
To have it work if plugged in before boot time you have to add snd-pcm-oss to the file etc/modules


WIFI dongle
(D-Link DWL-G122 IEEE 802.11b/g USB 2.0 High Speed 2.4GHz Wireless Adapter) - also see this
apt-get install wireless-tools was not needed - they are present. But rt73.bin was absent
I found a copy and put it into /lib/firmware then did depmod

In /etc/network/interfaces you have to add

allow-hotplug wlan0
iface wlan0 inet static
pre-up ifconfig wlan0 up
pre-up iwconfig wlan0 mode Managed
pre-up iwconfig wlan0 essid "225"

and comment out the lines

allow-hotplug eth0
iface eth0 inet static

(My WIFI is at 192.168.0.225)
To make WIFI live do
ifconfig wlan0 up
iwlist wlan0 scan


UVC Webcam
(I use a Logitech Quickcam Pro 9000 HD webcam)

get mjpg-streamer-r63.tar.gz from Source Forge
cd /home/mjpg-streamer-r63

apt-get install libjpeg-progs
tar xzvf mjpg-streamer.tar.gz
make clean all
export LD_LIBRARY_PATH=.
test it with -
./mjpg_streamer -o "output_http.so -w ./www"

The web page cgi script that starts the webcam calls /var/www/cgi-bin/mjpg_streamer_on.sh
which starts mjpg-streamer as a daemon (background process)
/home/mjpg-streamer-r63/mjpg_streamer -i "/home/mjpg-streamer-r63/input_uvc.so -r 960x720" -b -o "/home/mjpg-streamer-r63/output_http.so -p 8080 -w /home/mjpg-streamer-r63/www


Also

PHP scripting - confusion here!! - needs more work
apt-get install php5-cgi was used for lighttpd (- I think?)
apt-get install php5 allowed PHP scripts to run but I got web pages at 80 and 8009
- it seemed to load Apache? - removed at present
note - filename.php did work in var/www folder but not var/www/cgi-bin

I did -
apt-get install libcgi-fast-perl libio-all-perl
but I now forget why
....

fsck would run some 3 or 4 times at boot time because there is no hardware clock see this
It says "Edit /etc/init.d/checkroot and locate part of the script responsible
for executing fsck" but I did not know how - so I hit the file with an axe and the problem died - improve this later!!

espeak runs but is "jumpy" - so I use flite

GPIO control is now working - see above

/etc/graham_startup.sh loads a 2MByte ramdisk at /var/www/ramdisk
mount -o size=2M -t tmpfs tmpfs /var/www/ramdisk
I use this to interface Blassic with bash scripts



The "distro"
No need to repeat my battle with Linux!
- just load it, run it, and web-connect that PIC

This "distro" (my current back-up files) allows a remote web browser to run cgi scripts to test the board and associated i2c and USB hardware.
It is similar to my OpenWrt experiment.
The associated PIC runs servos as described here


the rs232 terminal uses speed 115200 N81
login to rs232 terminal or ssh session with
User root
password root

From a network terminal type
ssh root@192.168.0.9
password root

The web home page is at http://192.168.0.9 to change this make the same changes as here
Samba is not yet present - it used lots of memory on the NSLU2 (Slug) and was not so reliable as "secure ftp"

when I run
http://192.168.0.9/cgi-bin/rs232/drive_ttyS0.cgi
and type hello world in the form box the string that the script sees is hello+world
This did not happen with the same pages in my OpenWrt slug - to be fixed with sed

This works
http://192.168.0.9/cgi-bin/hello.py


The "distro" is here

For the Bifferboard
download vmlinuz-2.6.32.2 and burn it to the Bifferboard as explained here

For the external memory stick or hard drive
I compressed a folder called disk containing all the files and folders that go onto the external USB memory stick or hard disk by doing
tar -cf disk.tar disk/
The Skydrive host limits files to 50MBytes so I split the compressed file disk.tar into 49MByte files using
split -b 49m disk.tar

download the files xab xac ........xaj and put in a folder in a Linux PC (I use Ubuntu in a VMWare image on a Mac)
Use the terminal to cd to the folder then type
cat xa* > disk.tar

To "untar" the file do -
tar -xvvf disk.tar

Then modify the network files like here if you do not want to use 192.168.0.9

Then in Ubuntu using the GUI do "System/Administration/Partition Editor"
Create a disk with an ext3 partition first (on the left of the bar) then add a Linux Swap partition of perhaps 100MByte (on the right of the bar).
Copy the files to the stick using the command line (the Ubuntu GUI fails)

Use http://192.168.0.9 to see a web page that runs scripts that test the system
The html files go into /var/www and cgi and bash scripts go into /var/www/cgi-bin
rs232 input fails


I use Cyberduck to connect by secure ftp
user root
password root

Use apt-get update
and apt-get install filename
to add more functions


If you are a Mac user like me you will hate the Ubuntu GUI. Not so bad for PC users since they expect life to be difficult ;-).
If you try to compress the dev folder, for example, it fails but the command line works.
Linux developers do not fully test the GUI.
Since I use a VMWare image on my Mac I can keep backups of my Ubunto image very easily
- so I always work as root (the world did *not* end) and this makes Ubuntu a bit more Mac like.

Please email me if it works for you or if you can fix the problems noted above.


Sunspot Home