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

2 comments:

  1. the falconwing package doesn't seem to contain libQtGui.so. Is that available elsewhere compiled for the arm9?

    ReplyDelete
    Replies
    1. WARNING: the unzip binary included on the infocast can't unzip the falconwing archive file. It bails out with a CRC error causing some of the files(such as the above libQtGui) to not be decompressed. Unzip it on another machine, then copy over to the Chumby.

      Delete