Saturday, January 15, 2011

Installing a serial port connector on the Chumby/Infocast

Overview
Both the Infocast 8" NS-DP8CH and the Infocast 3.5" NS-DP3CH have 3.3v TTL level serial ports available on connector ports on the motherboards. The serial ports come with transmit (TX), receive (rx) and ground connections and are enabled by default by the Chumby operating system as the boot log on startup and as a serial based terminal after boot.  Traditional computer serial ports operate at different voltages and modern computers often have no serial ports at all.  Developers and users can connect to the Chumby through the use of a USB to 3.3v serial device adapter cables.  Pre-made ftdi brand cables are available on the internet but a lot of folks hack up cheap or surplus USB-cell phone cables like the Nokia. The Chumby is a 3.3v system so don't use a 5v cable. Search on the internet for appropriate cables. USB to serial cables appear to operating systems as (virtual) COM ports.  Mine shows up as COM4 on my Windows 7 machine.  Many terminal emulators communicate with the device over the virtual serial port as if it was a true serial port simplifying configuration when communicating with the device. I use Putty on my Windows 7 machine.

I like to bring the serial port out of the case with a stereo socket connector.  This lets us communicate with the device through the jack without opening up the Chumby. Stereo jacks have 3 wires which matches up with our TX, RX and Ground needs.  FTDI sells a USB to stereo jack cable but I make my own following their pinout. TX is on the tip, followed by RX on the 2nd ring and ground closest to  the plug.   The wires are TX<-->RX RX<-->TX and ground<-->ground.  So the stereo socket mounted on the side of the box will connect the Chumby's RX to the tip, TX to the middle ring and ground to the ground ring.  The basic steps are.

Infocast 8"
  1. Prepare or modify your USB-to-ttl cable. It should be a bus powered cable where the power comes fro the PCGo to radio shack and buy a stereo socket.  I shredded an old ISA card for its audio out jacks.
  2. Open up the Infocast.  On the 8", there are 4 screws on the bottom under the rubber feet.  There are also two locks in the center of the base on the long sides. I just pried until they popped off but there may be some special way to take off the bottom.  The 3.5" exposes 4 screws when looking at the device from the back. Unscrew the 4 motherboard screws and cautiously remove all the connectors.  Note that you will have to remove the LCD cable from its' connector on the motherboard. Pry the grey bar up to release the cable. This picture shows the motherboard with a detached LCD cable


  3. Find the serial connector on the motherboard at the bottom left as pictured below. Note that the heat shield leaves all the interesting ports exposed. The following pictures shows an open Infocast 8" from the bottom.  The unit is face down on the table.

  4. Solder wires to the TX, RX, GND connectors on the serial port connection points.  I like colored cables because it makes easier to figure out what I'm doing I put a little dab of hot clue on my to holder it to the board as a strain relief.
  5. Solder the TX, RX and GND wires stereo jack making sure that you put the Infocast on the TX on the middle ring and the RX to the tip. The picture below shows the 3 wire connection to the serial port connector (right under the flash glare)  This board also has two additional cables attached.  The grey cable is connected to the ground and the 4 GPIO pins and has a 5 pin female header socket at the end.  The colored wires are connected to the two i2c lines, ground and the 3.3v power pin and have a 4 pin female header socket at the end.  This cable's ground line is tied to an unused USB grounding point so that I didn't have to try and solder two wires to the single ground point on the 8 pin port.
     
  6. Mount the stereo jack in the side of the Infocast (shown facing down). The empty space next to the motherboard provides ample room for one or more stereo connectors.  Youi might be able to barely pick out the grey GPIO cable mentioned above. It and the i2c cables are just left with the connectors on when the unit is sealed up. That lets me use those lines later without having to take the whole unit apart and start soldering

Here's the finished product.


Infocast 3.5"
The 3.5" infocast comes with two unpopulated connectors. The serial. port is in the corner right next to the power button. The following picture shows a right angle connector. The idea here was that a small slit could be cut in the back of the unit next to the power button and that an external connector could be pushed into the unit and on to the pins. 

An alternative is to use a straight through header and then create a short stereo jack to header adapter cable. The jack can be mounted anywhere there is room.






The following picture shows the 4 pin serial port connector in the bottom left corner.  The 3.3v power pin has been cut because it was not needed and it simplifies figuring out the orientation of  the header style connector from a USB/TTL serial cable.


Here you can see that the connector has been replaced with a straight connector.  I made up a 3 pin cable with a 4 pin header connector.  Just the TX, RX and Ground pins have been connected. The gray plastic under the RYB cable is the rotary encoder used for volume control.  We will use the empty space behind that for the stereo jack that will be mounted to the case.


The three wires are connected to the serial headphone jack purchased at Radio Shack. We connect the RX pin on the tip, the TX pin on the middle and the ground on the ring closest to the base.  This will connect the USB serial cable's TX (on the tip) to the Chumby RX and the USB cable's RX (2nd ring) to the Chumby TX.  You could mount the connector on the back of the unit but liked putting it on the side of the box far enough back that it will not interfere with the rotary encoder on that side.

 

Here's the 3.5" unit all buttoned up with the console port installed and labeled.


Wrap Up
Exposing the internal serial port provides a way of communicating with the Infocast machines without enabling SSH.  You just plug in your USB/TTL serial cable and fire up your terminal emulator.  The TX and RX pins can be converted to PWM lines with a few regutil commands. You can then use the installed stereo connector as a way of bring out those pwm signals. 

The Chumby will also bring up a terminal on the device if you plug in a USB keyboard. The downside of this approach is that it ties up the chumby screen while you are exploring.

Thursday, January 6, 2011

Hints on installing a qt webkit browser on the Chumby/Infocast

This Chumby Forum posting describes how to install a webkit browser on a Silvermoon/Infocast 8" device and on the Falconwing/ChumbyOne device. 


Silvermoom Infocast 8" Setup 
Download the pre-built browser usb image that is designed to run on a usb thumb drive (/mnt/usb).  Unpack the image to the root directory of the thumb drive.  Stick the thumb drive into the device and restart the device.  It should come up with the web browser on the www.chumby.com page.  This relies on the fact that the Chumby system will run  the debugchumby in the root of any thumb drive that is inserted into a usb port.  The debugchumby script can be customized with an editor to drive the web browser to any url that you wish. The system also supports a USB keyboard for URL entry if you are running the browser version with the URL bar.

Webkit browser components can be built to operate in various ways.  The one from the package above runs as a window. The actual browser executable is in the demos/browser folder. You can download alternative full screen browser or a kiosk style browser components that are used with the image mentioned above.  Download the appropriate executable and put into the demos/browser folder.  You can overwrite the existing demos/browser/browser executable on the thumb drive or you can add it to the folder with a different name and edit the debugchumby script to use that browser.  

The best part of a thumb drive installation is that you can restore he Chumby to it's original configuration just by unplugging the thumb drive.  Some folks will want to "modify" their devices to run the browser without the need for a USB drive.  This is still reversible but requires a little more software skills.  Most Chumby devices enough space to install this browser directly to the microsd card in the /mnt/storage directory.  I took the following steps.

  1. SSH into the device using instructions available on the chumby wiki or my other blog postings.
  2. Make a directory on /mnt/storage.  I used /mnt/storage/browser.
  3. cd into the directory
  4. Download the zip package to /mnt/storage/browser using wget <http_path_tofilename>
  5. Unzip the package in the browser directory using unzip <filename.zip>
  6. The file permissions may be wrong for execution.  Turn on the execute bits of the appropriate files with chmod +x <filename>.  While sitting in /mnt/storage/browser I did chmod +x debugchumby bin/* demos/browser/browser
  7. Rename debugchumby to <some_name>.sh The .sh suffix isn't required but  makes it easier to see that it's a script. Some web server cgi-bin configurations require the .sh suffix to recognize the file as a shell script. Of course that only matters if you start switch to "browser mode" via cgi-bin
  8. Change the script to point at the browser in the new (non thumb drive) location.  Here is my script. You can see that I'm playing around with different browser styles and default web sites.
#!/bin/sh

CHUMBY_BROWSER_ROOT=/mnt/storage/browser
export LD_LIBRARY_PATH=$CHUMBY_BROWSER_ROOT/lib:$LD_LIBRARY_PATH
export QT_QWS_FONTDIR=$CHUMBY_BROWSER_ROOT/lib/fonts

stop_control_panel
rmmod silvermoon_tsb
insmod $CHUMBY_BROWSER_ROOT/silvermoon-tsb.ko scaled_touchscreen=1
switch_fb.sh 0

if [ ! -e $CHUMBY_BROWSER_ROOT/browser_etc ]; then
cp -rP /etc $CHUMBY_BROWSER_ROOT/browser_etc
fi
mount -t loop -o bind $CHUMBY_BROWSER_ROOT/browser_etc /etc

mkdir -p $CHUMBY_BROWSER_ROOT/root
mount -t loop -o bind $CHUMBY_BROWSER_ROOT/root /root

export TSLIB_CONFFILE=$CHUMBY_BROWSER_ROOT/etc/ts.conf
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_TSDEVICE=/dev/input/by-id/soc-noserial-event-ts
export TSLIB_PLUGINDIR=$CHUMBY_BROWSER_ROOT/lib/ts
export QWS_MOUSE_PROTO=Tslib

if [ ! -e /etc/pointercal ]; then
$CHUMBY_BROWSER_ROOT/bin/ts_calibrate
sync
fi

while [ 1 ] ; do
# regular browser
# $CHUMBY_BROWSER_ROOT/demos/browser/browser -qws 'www.chumby.com'
# fulscreen browser
# $CHUMBY_BROWSER_ROOT/demos/browser/browser_qt-4.6.3-fullscreen -qws 'http://www.yahoo.com'
# no URL browser
$CHUMBY_BROWSER_ROOT/demos/browser/wv -qws 'http://www.yahoo.com'
done

Silvermoom Infocast 8" Execution 

The simplest way to test the browser installation is to just run your start script that you created above.  with sh <name of script>.  The control panel should disappear and the touch screen calibration screen should show up.  Run through the calibration and the browser will startup automatically.  Touchscreen calibration only happens the first time you run the browser.

It is also possible to start the browser programmaticly or remotely.  Possibilities include:
  1. ssh into the box and run the start script.  This is great for debugging but can be cumbersome in any type of real world situation.
  2. Fall back to the default startup method.  Copy the start script to debugchumby on a thumb drive and insert the thumb drive.
  3. Use one of the standard startup hooks.  Create the directory /mnt/storage/psp/rfs1/ and copy the start script into the file userhook1 . I already have a userhook1 there to start my web server so now my file starts both a web server and a web browser.
  4. You could put the start script in the cgi-bin directory of the built in web server. Then you could flip the Chumby into browser mode remotely by requesting that URL with a remote browser.  This lets the device run in "standard" mode until some network tool decides they need to be in browser mode.  This might be useful when maintaining a network of devices.
  5. Do a "no coding" hack on the standard Chumby control panel.   The control panel screen availble from the Pi menu.  It contains a menu of functions where each button actually runs an .sh script located in /usr/chumby/scripts. You can replace one of those scripts with the browser start script. Possible candidates include fb_cgi.sh

You can only return to normal chumby mode by cycle power. There is a good chance that a browser will become standard on the larger screen devices. This blog entry will become obsolete at that time.


Chumby One / Falconwing
Setting up a browser on a small screen Chumby/Infocast is similar to the 8 inch. The main Falconwing browser download contains the entire package. There is an additional web view download that is available for those folks that want to run a browser full screen with no URL entry area.You should download it after installing the full package and put the wv file in the <root_dir>/demos/browser.  I put the whole package in /mnt/storage/browser.  The general steps are:
  1. ssh into the device
  2. mkdir /mnt/storage/browser
  3. cd  browser
  4. wget <falconwing browser package>
  5. unzip <falconwing browser package>
  6. cd demos/browser
  7. wget <the web view single file>
  8. move back to /mnt/storage/browser with cd /mnt/storage/browser
  9. Turn on the execute bits to make shell script execution easier easier  with
    chmod +x debugchumby bin/* demos/browser/browser demos/browser/wv_falconwing
  10. Patch debugchumby. First make a bakcup copy.
  11. Copy debugchumby to the root of a USB thumb drive or mkdir /psp/rfs1 and copy the script to /psp/rfs1/debugchumby
Here is a sample startup script that does the appropriate setup for the browser sitting in /mnt/storage/browser:

#!/bin/sh

CHUMBY_BROWSER_ROOT=/mnt/storage/browser
export LD_LIBRARY_PATH=$CHUMBY_BROWSER_ROOT/lib:$LD_LIBRARY_PATH
export QT_QWS_FONTDIR=$CHUMBY_BROWSER_ROOT/lib/fonts

stop_control_panel
switch_fb.sh 0
/usr/bin/switch_output -l

if [ ! -e $CHUMBY_BROWSER_ROOT/browser_etc ]; then
    cp -rP /etc $CHUMBY_BROWSER_ROOT/browser_etc
fi
mount -t loop -o bind $CHUMBY_BROWSER_ROOT/browser_etc /etc

mkdir -p $CHUMBY_BROWSER_ROOT/root
mount -t loop -o bind $CHUMBY_BROWSER_ROOT/root /root

export TSLIB_CONFFILE=$CHUMBY_BROWSER_ROOT/etc/ts.conf
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_TSDEVICE=/dev/input/by-id/soc-noserial-event-ts
export TSLIB_PLUGINDIR=$CHUMBY_BROWSER_ROOT/lib/ts
export QWS_MOUSE_PROTO=Tslib

if [ ! -e /etc/pointercal ]; then
    $CHUMBY_BROWSER_ROOT/bin/ts_calibrate
    sync
fi

while [ 1 ] ; do
#    $CHUMBY_BROWSER_ROOT/demos/browser/browser -qws 'www.chumby.com'
#   Note that webkit views need the fully qualified URL including protocol
    $CHUMBY_BROWSER_ROOT/demos/browser/wv_falconwing -qws 'http://www.chumby.com'
done



Usability Issues 


If you are hosting pages on your web site for this then you might use something like this floating javascript keyboard in your pages
http://www.greywyvern.com/code/javascript/keyboard

Sunday, January 2, 2011

Using Phidgets on a Chumby/Infocast 8


I had been kicking around the idea of a system that retrieves the status of various devices and displays that state on on a set of lamps.  I wanted some type of embedded system that already had network support and a standard tool chain. I also needed some simple way to interface with my indicator lights.
Chumby and it's Infocast derivatives are really slick customizable internet aware devices with built in touch screens, a linux kernel, USB ports and available GPIO pins.  Chumby also provides a development toolchain, documentation and a nice user forum. Best Buy had these on sale during the 2010 Christmas rush for less than almost any DIY system could be built.
Phidgets are USB connected peripherals that let you interface to sensors, I/O, servos and other real world devices without having to write micro-controller code.  This is a picture of my 8" Infocast and Phidget 0/16/16 board.



The Chumby comes with Linux Phidget kernel divers. The Phidget folks recommend using their user space drivers available on their web site instead of the kernel drivers. Binary versions are not a vailable which means we have to build the phidget user space drivers
We have to compile the phidgets library libphidget21 which requires libhid and libusb. They have to be built in the order libusb, libhid and then libphidget21. The chumby comes with some libhid and libusb code but not all of the header files required to buld libphidget21. The best thing to do is to build and install libusb , libhid and then libphidget21.

Device Preparation
  1. Enable sshd through the control panel
  2. SSH into the box using a terminal window under linux or putty under Windows
  3. You can enable sshd across reboots by creating /psp/startsshd  with the command touch /psp/start_sshd
  4. Optional: This isn't required and has nothing to do with this project but I'm kind of detail oriented. Set the hardware clock from the software clock. Enter hwclock -s
  5. Run make to install the tool chain if it isn't already installed. The system will ask you if you want it to try and install make. Enter “Y” and hit return at the prompt. This installs all the compiler tools
Directory Preparation
The kernel and include search paths on the Chumby include /mnt/storage directories that correspond to the usual /usr. So there is a /mnt/storage/local/bin in the same way that a linux server /has /usr/local/bin. /mnt/storage directories are writeable on the Chumby while /usr directories are read/only.
  1. Make the root director for locally compiled software and libraries mkdir /mnt/storage/local
  2. I normally make a temp directory /mnt/storage/software on the chumby for all of my downloading and compilation.  I then cd into that directory for all my downloads and unpacking.
Compiling and Installing libusb
 The system comes with the libusb runtime but none of the compile time headers. We have to download, compile and install the libusb libraries and headers.
  1. download libusb 0.1.12  from http://files.chumby.com/source/ . The direct link for this file is http://files.chumby.com/source/falconwing/build2370/libusb-0.1.12.tar.gz You can download the files directly to the Chumby/Infocast using the wget command in the terminal/ssh window.
  2. Uncompress the .tar.gz file with gunzip.  Un-tar the .tar file with tar -xvf
  3. cd into libusb-0.1.12 created by the unpacking operation.
  4. Run the configure script telling it where we intend to install the library and header files. Run the command ./configure -prefix=/mnt/storage/local
  5. Compiling libusb at this point will fail because the chumby comes wih a misconfigured libstdc++.la file. We need to rename (or move) /usr/lib/libstdc++.la to some other name like /usr/lib/libstdc++.la.badpaths. Just use the mv command mv /usr/lib/libstdc++.la /usr/lib/libstdc++.la.badpaths
  6. Run make to build the library
  7. Run make install to install the library and headers.

Compiling and installing libhid
libphidget21 is dependent on libhid 0.2.16 libraries and header files. There isn't any libhid source jar on the chumby download site so you'll have to grab it from the main libhid download site.

  1. Download the source tar ball from a libhid site. I used links available off of http://libhid.alioth.debian.org/ The direct download link (at that time) was http://alioth.debian.org/frs/download.php/1958/libhid-0.2.16.tar.gz. You can use the wget command to directly download to the chumby. From the command prompt run wget <url_for_package>
  2. Unzip the .gz file with gunzip. Untar the resulting .tar file with tar (tar xvf <filename_.tar>).
  3. Change directory into libhid-0.2.16
  4. Run the configure command and tell it about the Chumby “special places”  ./configure -prefix=/mnt/storage/local
  5. run the make command to build the project
  6. run make install to install the library and headers in /mnt/storage/local
Compiling and Installing libphidget21
Now we can finally build and install the phidget library.
  1. Download the linux phidgets drivers from the downloads page at http://www.phidgets.com/drivers.php to some place on /mnt/storage. I usually create a /mnt/storage/software directory for this type of work. The actual download file is http://www.phidgets.com/downloads/libraries/libphidget_2.1.7.20101222.tar.gz . You can use the wget command on the chumby/infocast to download them directly to the device.
  2. Unpack the archive with gunzp.
  3. Unpack the tar archive with tar -xvf <name_of_tar_file>
  4. cd into the unpacked libphidget21 directory
  5. The phidget compile process doesn't know about those special Chumby include or library directories so we'll tell it about them when we run the configure command. Run ./configure --prefix=/mnt/storage/local  CFLAGS=-pthread CPPFLAGS=-I/mnt/storage/local/include
  6. Build the library.  Run make. You may have to run it a couple times if it dies with random out of memory errors. A restart on my machine eliminated the problem. You could also try turning off the control panel and other processes before running make. I just ignored it and kept running make on one of my machines.
  7. Install the library and headers by running make install  libphidget21 will install the tools into /mnt/storage/local
Enabling the User Mode Device Access
You now have to enable user mode access to phidget devices. You should look on the Internet for a more thorough explanation of this. The udev rules file in the Read/Only filesystem is sym-linked to a copy in /mnt/storage/psp. This means changes made to /mnt/storage/psp/udev/chumby.rules actually show up in /etc/udev/rules/50-udev.rules.
  1. Add the following line to /mnt/storage/psp/udev/chumby.rules on silvermoon devices or /psp/udev/chumby.rules on falconwing devices
    SUBSYSTEM=="usb_device", SYSFS{idVendor}=="06c2", MODE="0666"
    Verify
    Verify that all this works using the example programs built in the libphidget21/examples directory
    1. Plug in the phidget device (in my case a 0/16/16) and run lsusb. Verify there is a line containing “ID 06c2:xxxx”. The 06c2 is the Phidgets vendor id.
    2. cd into the examples directory located in the phidgets source tree where you build the libraries.
    3. Build the examples by running make
    4. Run ./manager. It should log out the connected phidget device. You should be able to unplug and plug in phidget boards and see it log each insertion and removal. Press ctrl-c to kill the program.
    5. The example ifkit.c has a bug in it so I made some minor changes. Folks with one of the interface boards can: make the following changes to ifkit.c, rebuild and run the program.  The Phidget indicator lights should flash as the program cycles through the channels.
    Change
    while(1)
    {
    CPhidgetInterfaceKit_setOutputState(IFK, 7, 1);
    CPhidgetInterfaceKit_setOutputState(IFK, 7, 0);
    }
    to
    int increment = 1;
    int i = 0;
    while(i>=0)
    {
       
    CPhidgetInterfaceKit_setOutputState(IFK, i, 1);
       
    sleep(1);
       
    CPhidgetInterfaceKit_setOutputState(IFK, i, 0);
       
    sleep(1);
        i+=increment;
       
    if (i == 7) increment = -1;
    }

    Additional Work
    The Phidgets folks also have custom web service lets you communicate with devices on remote machines using the same libphidgets21 libraries.  A source package is available on the Phidgets web site.  The following configure command worked for me.

    ./configure --prefix=/mnt/storage/local LIBS=/mnt/storage/local/lib/libphidget21.so CFLAGS=-pthread CPPFLAGS=-I/mnt/storage/local/include
    I verified it worked from a Windows machine but didn't go any farther than that. I instead decided to talk add cgi scripts to my Chumby web server that call Phidget command line programs.  That makes it easy for anyone to talk to or read data from my Phidget devices.

    Controlling with Java Programs on the Chumby
    Oracle has a version of the standard J2SE runtime available for ARM v5 processors.  It it is a full function JRE that does not come with development tools.  You can actually run the Phidgets Java example programs on the Chumby using this VM. 
    1. Download the VM from Oracle (ejre1.6.0_21 at the time of this writing).  Copy to the Chumby and unpack the .tar.gz file.  I put mine into /mnt/storage so that I ended up with java on the path /mnt/storage/ejre1.6.0_21.
    2. Download a version of Phidget21.jar to your chumby and copy to somewhere on the LD_LIBRARY_PATH. I put it in /mnt/storage/local/lib, the same place I put the phidgets shared library.
    3. Compile a sample phidget program on your PC to test it with your interface board.  I have an Interface kit so I played with OpenIFKitExample.
    4. Copy the .class file to the chumby.
    5. Set your JAVA_HOME and PATH in the shell.  You could set it in a .bashrc or something but for testing it is simpler to just enter

      export JAVA_HOME=/mnt/storage/ejre1.6.0_21
      export PATH=$JAVA_HOME/bin:$PATH

    6. Run the program adding the current directory (where the .class file is) and the Phidget21.jar to the classpath.  Here is an example that runs OpenIFKitExample which is a Java program that talks JNI to the libphidget21 which talks to the device.

      java -classpath .:Phidget21.jar OpenIFKitExample


    Final Notes
    Phidgets and Chumby are a great combination for folks wanting a package that lets them integrate a network, physical devices and user interfaces.

    Saturday, January 1, 2011

    Simple cgi on the Chumby/Infocast with lighthttpd

    There is a great blog posting, featured on Hack a Day, that describes how to run lighthttpd on the Chumby.  The blog also provides a pre-built version of the web server that is configured to run in /mnt/storage instead of /mnt/usb.  This is nice because it lets you run the httpd server from the writable partition of the internal microsd card instead of having to use a thumb drive.  A lot of the Chumby derived  devices have enough space in /mnt/storage to do all kinds of interesting things.

    I recently purchased an BestBuy Insignia Infocast 8" device. It is essentially an 800Mhz big screen Chumby running linux 2.6 with some BestBuy customizations.  The Insignia team did not include a web server and the simplest way to fix that is to use the lighthttp server from the blog mentioned above.

    Installing and Configuring

    The basic steps for installation are:
    1. Turn on SSH in the Info cast. Touch the Insignia logo in the upper right corner.  This should make the About Device panel appear. Then touch the Pi symbol in the upper right corner. Enable sshd by touching the SSHD button. The daemon starts immediately. The machine's IP address appears in the panel.  You will need that to ssh into the box.
    2. SSH into the device from your PC.  Windows users can use putty which is freely available on the internet.  Linux users probably already have it installed.   The root user id has no ssh password so linux users will login with ssh root@<chumby_ip_address>
    3. You can enable sshd across reboots by creating /psp/start_sshd with the command touch /psp/start_sshd but remember that you the default sshd has no password.
    4. cd into /mnt/storage.  
    5. Download the pre-built version of light httpd.  Find the URL in the blog mentioned above and enter wget <the_.tar.gz file path> in the ssh window. I normally create a software or downloads directory to keep stuff organized.
    6. Unzip the package with gunzip <the_.tar.gz file name> and then untar the .tar file while in the /mnt/storage directory.
    7. You can delete the .tar file because it is no longer needed.
    The next step is to configure and start the web server.  The blog author kindly created a startup script that works on the Chumby/Infocast.  The chumby folks kindly created a set of startup hooks that let you run additional scripts at startup without having to modify the Read/Only partition on the microsd card.  They search specific directories for scripts with specific names.  The most commonly used on is a debugchumby script in root directory of any inserted USB flash drive.  In this case we use one of the other two user hooks, /mnt/storage/psp/rfs1/userhook1.   
    1. The directory /mnt/storage/psp/rfs1 does not exist in the default Infocast installation so create that directory using mkdir.
    2. Copy /mnt/storage/lighty/startup.sh to /mnt/storage/psp/rfs1/userhook1.  Note that the userhook1 filename does not have any file extension.  
    Web servers like lighthttp create error and access logs that grow over time filling up the micro sd card.  The other blog posting added log rotation and trim scripts to their installation but I didn't want to have to worry about it.  I turned off the access logs and put the error logs on the /tmp partition.
    1. Edit /mnt/storage/lighty/lighthttpd.conf
    2. Change the server.errorlog and accesslog.filename to fit your needs.  I changed mine to
    # server.errorlog = "/mnt/storage/logs/lighthttpd.error.log"
    # accesslog.filename = "/mnt/storage/logs/lighttpd.access.log"
    server.errorlog = "/tmp/lighthttpd.error.log"
    accesslog.filename = "/dev/null"
    Start the web server and verify it's running
    1. Type /mnt/storage/psp/rfs1/userhook1 to start the server.  
    2. You should be able to verify  the process is running with the ps -ef command.
    3. You can then hit the web server with your browser http://<chumby_ip_address>  and see the welcome screen.
    Some Simple cgi Programs

    One of the nifty things about running a web server is that you can cause it to run programs on the device just by requesting the URL of a program tied to the web server.  Everything written to standard-out is returned to the web browser.

    The lighty/lighttpd.conf file contains mappings to support Bourne Shell and Perl scripts. It assumes that any file ending in .sh is a shell script and any file ending in .pl is a Perl script.
    cgi.assign = ( ".sh" => "/bin/sh", ".pl" => "/mnt/storage/usr/bin/perl", ".cgi" => "/psp/usr/bin/perl" )                        
    alias.url = ( "/cgi-bin/" => "/mnt/storage/lighty/cgi-bin/", "/images/" => "/mnt/storage/images/" )
     The Infocast 8" comes with a couple shell scripts that were intended for the standard Chumby web server that are easily adapted to lighthttpd (with a simple rename). They have .sh on the end so we'll fix that when we copy them into the lighty cgi-bin directory.
    1. cp /www/cgi-bin/memstats /mnt/storage/lighty/cgi-bin/memstats.sh
    2. cp /www/cgi-bin/wifi /mnt/storage/lighty/cgi-bin/wifi.sh
    The url for these files will be
    1. http://<ip_address>/cgi-bin/memstats.sh
    2. http://<ib_address>/cgi-bin/wifi.sh
    Here is a simple shell script top.sh that displays cpu usage of currently running programs via the top command and returns the results to the web browser.

    #!/bin/sh
    echo "Content-type: text/html"
    echo ""
    echo "<html><head>"
    echo "<title>Chumby Top Processes</title>"
    echo "<meta http-equiv=\"Refresh\" content=\"5\";>"
    echo "</head></html>"
    echo "<body>"
    echo "<h4>Top Processes (refreshes every 5 seconds) </h4>"
    echo "<pre>"
    top -n1
    echo "</pre>"
    echo "</body></html>"
    I installed it in /mnt/storage/lighty/cgi-bin/top.sh and run it with http://<ip_address>/cgi-bin/top.sh

    Final Thoughts

    The referenced blog article describes how to build lighthttpd from scratch.  You might want to do a custom build if you need additional modules.