Authors
Mark Trantor
Those of you who have been following Liam's tutorials might be interested in seeing the Game Mark Trantor developed after watching the Pi Shooter tutorials.
Get the source code here:
http://www.frambozenbier.org/index.php/tutorials/authors/mark-trantor
Liam got his RasPi
Frambozenbier site admin Liam Fraser just got his RasPi this weekend.
He's been busy compiling Quake for the last few hours but found the time to send me some photos to put up on the site.
These photos are quite big so we wouldnt recommend opening them on a mobile data tarrif...
Liams Tutorial Section
Liam will be adding new tutorials into this section over the next few days. Keep checking back here for more info:
Web link to this section:
http://www.frambozenbier.org/index.php/tutorials/authors/liam-fraser
RSS feed for this section:
http://www.frambozenbier.org/index.php/tutorials/authors/liam-fraser?format=feed&type=rss
In 26 days, the weekend of April 26th the OSHWA, Open Source Hardware Association, is holding a Document Jam at ITP-NYU in NYC to help standardize and improve the how Open Source Hardware projects are documented so that others can replicate them and so that future generations of hackers, tinkerers and makers won't lose the knowledge previous generations have discovered. Unfortunately i'll probably not be able to make it and I really don't have the skills that will be needed as although I am often asked to help friends by proof reading and idiot proofing, I am darn good at it too even if I do say so myself, My super power is that i'm a tiny bit of an OCD pedant when it comes to typos & grammer in other peoples documents. I really don't have any hardware skills other than following instructions and even then it'll probably take me a few goes to get it right & even though I could probably help with some of the documentation and design stuff I really don't do well in crowds so Hack-a-thons & Jams are things I try to avoid. I can cope with crowds in large open spaces but i'd be a gibbering wreak anywhere else.
However if you think you can contribute, the problem statement is here and the how to contribute is here and if you have an account on Trello you can help with some of the pre-event stuff here. I'm not seeing many people using the Trello board so if you think you can help check it out and start using it.
The Guidelines for Participation to the First OSHW Doc Jam can be found here
The stepper motor I want to use to move the TSL2561 sensor along a track arrived on Thursday and i've wired it up and tested it and it works very well for what I want however, i'm going to be busy for a few days so i'll not be able to build the track, case and transfer the circuits to veroboard until next weekend at the earliest. So rather than leave anyone hanging if they are interested in this I thought i'd write up what I have so far so they can replicate it if they want.
As far as the hardware is concerned what I did was combine two circuits available from Adafruit. The "using an L293D" circuit from lesson 10 by Simon Monk and a RaspberryPi'd version of the circuit wiring the TSL2561 by LadyAda and just for kicks bunged an LED on the Raspberry Pi's GPIO pin 21. As you can see from the photo below (and above) it is a bit of a rat's nest but it worked first time so I have to be doing something right especially as so far touch wood no computers have yet been harmed.
Once I move this to veroboard the TSL2561 board & the LED will be put on a small piece of veroboard with some longish wires mounted on a track to be moved along it by the stepper motor and the stepper motor circuit will be mounted on to of the Raspberry Pi somehow.
For the software I used a slightly modified & wiringPi'd & C'd version of Adafruit's Arduino TSL2561 C++ code, the header & the functions, along with Gordon Drogon's wiringPi library and knocked up a very quick & dirty program that sort of works well enough for testing.
pi@raspberrypi ~/raspberryhunt $ cat raspberryhunt.c
/**************************************************************
* RaspberryHunt version 0.4a *
* By Russell "ukscone" Davis *
* 2013-03-22 *
* Portions Copyright Adafruit, wiringPi is GPL3 Gordon Drogon *
***************************************************************/
#include
#include
#include
#include
#include "Adafruit_TSL2561.h"
#include "wiringPi.h"
#include "wiringPiI2C.h"
/* Global Variables */
typedef int bool;
#define true 1
#define false 0
int _fd;
int _addr;
int _gain;
int _integrationtime;
bool _autogain;
#define VER "0.4a"
#define LED_PIN 21
#define ON 1
#define OFF 0
#define setupLed pinMode
#define led digitalWrite
#define ENABLE_PIN 18
#define COIL_A_1_PIN 4
#define COIL_A_2_PIN 17
#define COIL_B_1_PIN 23
#define COIL_B_2_PIN 24
#define gpioDirection pinMode
#define powerCoil digitalWrite
/* Stepper Motor Handling */
void setupStepperMotor(void) {
gpioDirection(ENABLE_PIN, OUTPUT);
gpioDirection(COIL_A_1_PIN, OUTPUT);
gpioDirection(COIL_A_2_PIN, OUTPUT);
gpioDirection(COIL_B_1_PIN, OUTPUT);
gpioDirection(COIL_B_2_PIN, OUTPUT);
}
void doStep(int s1, int s2, int s3, int s4) {
powerCoil(COIL_A_1_PIN, s1);
powerCoil(COIL_A_2_PIN, s2);
powerCoil(COIL_B_1_PIN, s3);
powerCoil(COIL_B_2_PIN, s4);
}
void stepForward(int delay_ms, int steps) {
int i;
for(i=0; i<=steps; i++) {<br />
doStep(ON, OFF, ON, OFF);
delay(delay_ms);
doStep(OFF, ON, ON, OFF);
delay(delay_ms);
doStep(OFF, ON, OFF, ON);
delay(delay_ms);
doStep(ON, OFF, OFF, ON);
delay(delay_ms);
}
}
void stepBackward(int delay_ms, int steps) {
int i;
for(i=0; i<=steps; i++) {<br />
doStep(ON, OFF, OFF, ON);
delay(delay_ms);
doStep(OFF, ON, OFF, ON);
delay(delay_ms);
doStep(OFF, ON, ON, OFF);
delay(delay_ms);
doStep(ON, OFF, ON, OFF);
delay(delay_ms);
}
}
/* TSL2561 Functions (Copied from Adafruit_TSL2561.cpp at https://github.com/adafruit/Adafruit_TSL2561) */
/* enable TSL2561 by setting the control bit to 0x03 */
int enable() {
return wiringPiI2CWriteReg8(_fd, TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL,\
TSL2561_CONTROL_POWERON);
}
/* turn off the TSL2561 to save power */
int disable() {
return wiringPiI2CWriteReg8(_fd, TSL2561_COMMAND_BIT | TSL2561_REGISTER_CONTROL, \
TSL2561_CONTROL_POWEROFF);
}
void getData (uint16_t *broadband, uint16_t *ir)
{
enable();
/* Wait x ms for ADC to complete */
switch (_integrationtime)
{
case TSL2561_INTEGRATIONTIME_13MS:
delay(14);
break;
case TSL2561_INTEGRATIONTIME_101MS:
delay(102);
break;
default:
delay(403);
break;
}
/* Reads a two byte value from channel 0 (visible + infrared) */
*broadband = wiringPiI2CReadReg16(_fd, TSL2561_COMMAND_BIT | TSL2561_WORD_BIT | TSL2561_REGISTER_CHAN0_LOW);
/* Reads a two byte value from channel 1 (infrared) */
*ir = wiringPiI2CReadReg16(_fd, TSL2561_COMMAND_BIT | TSL2561_WORD_BIT | TSL2561_REGISTER_CHAN1_LOW);
/* Turn the device off to save power */
disable();
}
void setIntegrationTime(int time)
{
enable();
/* Update the timing register */
wiringPiI2CWriteReg8(_fd, TSL2561_COMMAND_BIT | TSL2561_REGISTER_TIMING, time | _gain);
/* Update value placeholders */
_integrationtime = time;
disable();
}
void setGain(int gain) {
enable();
wiringPiI2CWriteReg8(_fd, TSL2561_COMMAND_BIT | TSL2561_REGISTER_TIMING, _integrationtime | gain);
_gain = gain;
disable();
}
void enableAutoGain(bool enable)
{
_autogain = enable ? true : false;
}
uint32_t getFullLuminosity()
{
enable();
switch (_integrationtime)
{
case TSL2561_INTEGRATIONTIME_13MS:
delay(14);
break;
case TSL2561_INTEGRATIONTIME_101MS:
delay(102);
break;
default:
delay(403);
break;
}
uint32_t x;
x = wiringPiI2CReadReg16(_fd,TSL2561_COMMAND_BIT | TSL2561_WORD_BIT | TSL2561_REGISTER_CHAN1_LOW);
x <<= 16;<br />
x |= wiringPiI2CReadReg16(_fd,TSL2561_COMMAND_BIT | TSL2561_WORD_BIT | TSL2561_REGISTER_CHAN0_LOW);
disable();
return x;
}
void getLuminosity (uint16_t *broadband, uint16_t *ir)
{
bool valid = false;
/* If Auto gain disabled get a single reading and continue */
if(!_autogain)
{
getData (broadband, ir);
return;
}
/* Read data until we find a valid range */
bool _agcCheck = false;
do
{
uint16_t _b, _ir;
uint16_t _hi, _lo;
int _it = _integrationtime;
/* Get the hi/low threshold for the current integration time */
switch(_it)
{
case TSL2561_INTEGRATIONTIME_13MS:
_hi = TSL2561_AGC_THI_13MS;
_lo = TSL2561_AGC_TLO_13MS;
break;
case TSL2561_INTEGRATIONTIME_101MS:
_hi = TSL2561_AGC_THI_101MS;
_lo = TSL2561_AGC_TLO_101MS;
break;
default:
_hi = TSL2561_AGC_THI_402MS;
_lo = TSL2561_AGC_TLO_402MS;
break;
}
getData(&_b, &_ir);
/* Run an auto-gain check if we haven't already done so ... */
if (!_agcCheck)
{
if ((_b < _lo) && (_gain == TSL2561_GAIN_1X))
{
/* Increase the gain and try again */
setGain(TSL2561_GAIN_16X);
/* Drop the previous conversion results */
getData(&_b, &_ir);
/* Set a flag to indicate we've adjusted the gain */
_agcCheck = true;
}
else if ((_b > _hi) && (_gain == TSL2561_GAIN_16X))
{
/* Drop gain to 1x and try again */
setGain(TSL2561_GAIN_1X);
/* Drop the previous conversion results */
getData(&_b, &_ir);
/* Set a flag to indicate we've adjusted the gain */
_agcCheck = true;
}
else
{
/* Nothing to look at here, keep moving ....
Reading is either valid, or we're already at the chips limits */
*broadband = _b;
*ir = _ir;
valid = true;
}
}
else
{
/* If we've already adjusted the gain once, just return the new results.
This avoids endless loops where a value is at one extreme pre-gain,
and the the other extreme post-gain */
*broadband = _b;
*ir = _ir;
valid = true;
}
} while (!valid);
}
uint32_t calculateLux(uint16_t broadband, uint16_t ir)
{
unsigned long chScale;
unsigned long channel1;
unsigned long channel0;
/* Make sure the sensor isn't saturated! */
uint16_t clipThreshold;
switch (_integrationtime)
{
case TSL2561_INTEGRATIONTIME_13MS:
clipThreshold = TSL2561_CLIPPING_13MS;
break;
case TSL2561_INTEGRATIONTIME_101MS:
clipThreshold = TSL2561_CLIPPING_101MS;
break;
default:
clipThreshold = TSL2561_CLIPPING_402MS;
break;
}
/* Return 0 lux if the sensor is saturated */
if ((broadband > clipThreshold) || (ir > clipThreshold))
{
return 0;
}
/* Get the correct scale depending on the intergration time */
switch (_integrationtime)
{
case TSL2561_INTEGRATIONTIME_13MS:
chScale = TSL2561_LUX_CHSCALE_TINT0;
break;
case TSL2561_INTEGRATIONTIME_101MS:
chScale = TSL2561_LUX_CHSCALE_TINT1;
break;
default: /* No scaling ... integration time = 402ms */
chScale = (1 << TSL2561_LUX_CHSCALE);<br />
break;
}
/* Scale for gain (1x or 16x) */
if (!_gain) chScale = chScale << 4;</p>
/* Scale the channel values */
channel0 = (broadband * chScale) >> TSL2561_LUX_CHSCALE;
channel1 = (ir * chScale) >> TSL2561_LUX_CHSCALE;
/* Find the ratio of the channel values (Channel1/Channel0) */
unsigned long ratio1 = 0;
if (channel0 != 0) ratio1 = (channel1 << (TSL2561_LUX_RATIOSCALE+1)) / channel0;</p>
/* round the ratio value */
unsigned long ratio = (ratio1 + 1) >> 1;
unsigned int b, m;
#ifdef TSL2561_PACKAGE_CS
if ((ratio >= 0) && (ratio <= TSL2561_LUX_K1C))<br />
{b=TSL2561_LUX_B1C; m=TSL2561_LUX_M1C;}
else if (ratio <= TSL2561_LUX_K2C)<br />
{b=TSL2561_LUX_B2C; m=TSL2561_LUX_M2C;}
else if (ratio <= TSL2561_LUX_K3C)<br />
{b=TSL2561_LUX_B3C; m=TSL2561_LUX_M3C;}
else if (ratio <= TSL2561_LUX_K4C)<br />
{b=TSL2561_LUX_B4C; m=TSL2561_LUX_M4C;}
else if (ratio <= TSL2561_LUX_K5C)<br />
{b=TSL2561_LUX_B5C; m=TSL2561_LUX_M5C;}
else if (ratio <= TSL2561_LUX_K6C)<br />
{b=TSL2561_LUX_B6C; m=TSL2561_LUX_M6C;}
else if (ratio <= TSL2561_LUX_K7C)<br />
{b=TSL2561_LUX_B7C; m=TSL2561_LUX_M7C;}
else if (ratio > TSL2561_LUX_K8C)
{b=TSL2561_LUX_B8C; m=TSL2561_LUX_M8C;}
#else
if ((ratio >= 0) && (ratio <= TSL2561_LUX_K1T))<br />
{b=TSL2561_LUX_B1T; m=TSL2561_LUX_M1T;}
else if (ratio <= TSL2561_LUX_K2T)<br />
{b=TSL2561_LUX_B2T; m=TSL2561_LUX_M2T;}
else if (ratio <= TSL2561_LUX_K3T)<br />
{b=TSL2561_LUX_B3T; m=TSL2561_LUX_M3T;}
else if (ratio <= TSL2561_LUX_K4T)<br />
{b=TSL2561_LUX_B4T; m=TSL2561_LUX_M4T;}
else if (ratio <= TSL2561_LUX_K5T)<br />
{b=TSL2561_LUX_B5T; m=TSL2561_LUX_M5T;}
else if (ratio <= TSL2561_LUX_K6T)<br />
{b=TSL2561_LUX_B6T; m=TSL2561_LUX_M6T;}
else if (ratio <= TSL2561_LUX_K7T)<br />
{b=TSL2561_LUX_B7T; m=TSL2561_LUX_M7T;}
else if (ratio > TSL2561_LUX_K8T)
{b=TSL2561_LUX_B8T; m=TSL2561_LUX_M8T;}
#endif
unsigned long temp;
temp = ((channel0 * b) - (channel1 * m));
/* Do not allow negative lux value */
if (temp < 0) temp = 0;
/* Round lsb (2^(LUX_SCALE-1)) */
temp += (1 << (TSL2561_LUX_LUXSCALE-1));</p>
/* Strip off fractional portion */
uint32_t lux = temp >> TSL2561_LUX_LUXSCALE;
/* Signal I2C had no errors */
return lux;
}
/* main() */
void main(void) {
_addr = TSL2561_ADDR_FLOAT;
_fd = wiringPiI2CSetup(_addr);
_integrationtime = TSL2561_INTEGRATIONTIME_402MS;
uint32_t shot;
uint16_t broadband, ir;
int hits;
int forever = true;
int sensitivity = 100; /* this is a percentage */
wiringPiSetupGpio ();
setupLed(LED_PIN, OUTPUT);
setupStepperMotor();
setGain(TSL2561_GAIN_16X);
printf("Welcome to RaspberryHunt version %s\n",VER);
printf("By Russell \"ukscone\" Davis 2013-03-22\n");
uint32_t baseline_lux;
getLuminosity(&broadband, &ir);
baseline_lux = calculateLux(broadband, ir);
hits = 0;
while(forever) {
stepForward(10, 10);
getLuminosity(&broadband, &ir);
shot = calculateLux(broadband, ir);
led(LED_PIN, OFF);
if (shot > (baseline_lux+((baseline_lux/100)*sensitivity))) {
hits++;
led(LED_PIN, ON);
printf("*** Hit *** Current number of hits=%d\n",hits);
}
}
}
As you can see from the video below the stepper motor, sensor & led all work together and once it's all mounted nicely in a pretty case and solid, stable track with some proper software it should be quite good & the same hardware should work for a variety of light based experiments such as my original goal.
Click here to view the embedded video.
As I said at the top of this post i'm going to be busy with some other projects that have a greater priority for a week to ten days but if anyone has any questions or wants to do something like this drop me a line & i'll try to help.
[note: please don't laugh at the code, i knw it's rubbish but it does what I need for the time being and i'll eventually write a nice pretty SDL version with lots of sound effects and pretty graphics and use events rather than a big loop with individual checks of the sensor & small movements of the motor.]
About three decades ago I was on work experience in the Physics department at Leicester Poly and in-between watching the IETS (Inelastic Electron Tunneling Spectroscopy) experiments (lots of fun liquid gases to play with) & playing on the Commodore PET & BBC Micros I was assigned the task of automating the Double-slit experiment. In the time I was on work experience I got most of the hardware & software completed, however, due to a slight miscalculation and misreading of the schematic the first two test runs were also the last two test runs as I sent 240v from the mains straight into the BBC Micro and all the magic smoke escaped with a lot of sparks and loud noises. Over the years I have often thought i'd like to revisit the project and do it correctly this time without harming any innocent computers so when I was looking for a project to do to give my brain a break from moderating the Raspberry Pi forums & some things I am doing for friends I remembered the double-slit experiment and decided that the Raspberry Pi would be perfect as even if I made a mistake at most it's only a $35 computer that would have to die.
30 years ago I used a pretty hefty stepper motor, some photodarlingtons & a bucketful of resistors, ic's and odds and sods. When I looked on Adafruit for the parts i'd need I found that it looked like the bucket of parts could be reduced down to a TSL2561 Digital luminosity/lux/light sensor , a L293D Dual H-Bridge driver , a stepper motor , and a few wires. Rather than about £150 worth of parts this time I could get everything for under $30. Unfortunately when I went to place my order everything but the TSL2561 was out of stock so I ordered that & asked for an email when the rest was back in stock (and I was able to order them last Saturday). The TSL2561 arrived on last friday & while I wait for the stepper motor to arrive I was looking for something to do with the TSL2561 to test it and while I was testing it I came up with the idea that rather than automate the double-slit experiment I could make a target shooting game instead and it'd probably be more fun than some dry educational physics experiment ![]()
So far I have wired up the TSL2561 to the Raspberry Pi's I2C, connected an LED to a GPIO pin on breadboard
and written a basic skeleton of the software using Gordon Drogon's wiringPi & Adafruit's Arduino C++ header for the TSL2561 and it seems to work very well
Click here to view the embedded video.
. Once the stepper motor arrives i'll wire that up and make the target (the TSL2561) move, make proper PCB for it and add some graphics and sounds.Rather than using a stepper motor to move the light sensor along a horizontal track you could mount the sensor to Alex Eames Flag waving kit to make a more compact device.
I do seem to have hit one stumbling block that might need a bit of finagling to get around. I was going to use cheap 99cent store "laser" pointers as "guns" but it looks like they might be banned in NYC as a couple of years ago you could get them everywhere in NYC but I went in over 25 99cent stores in the last couple of days & none had them for sale and one store owner said "no! cost much money for ticket" which I take to mean they are now illegal in NYC.
[I also did work experience at Leicester Uni & did even more damage to poor innocent computers although this time I was able to fix them so it only cost me one round for the students & head of dept rather than the seven at the Poly]
A couple of days ago I realized that I hadn't written a blog post in a while and had been working on one about using a "hacked" Vonage vPhone usb dongle on the Raspberry Pi but as today is the 1 year anniversary, I won't say birthday as it was released on the 29th of February of a leap year, of the Raspberry Pi's release into the wild I have decided to just say "a hacked Vonage vPhone works really well on the Raspberry Pi, use the right tools to delete the CD partition and repartition & format & you have a nice orange usb dongle with a headphone jack & Mic input with 256MB of flash storage on it to put your windows, mac & linux IAX/SIP softphones on" and instead write a quick blog post about the Raspberry Pi.
The Raspberry Pi in case you've been living in a cave for the last 18months or so is an approximately credit card sized (i think they are off by a couple of micro-millimeters on one of the dimensions, but don't hold me to that) 700Mhz ARMv6 based SBC with USB, HDMI Out, Composite Out, Audio Out, SD card for storage and OS, in the case of the Model B Ethernet and depending on model & revision 256MB or 512MB of RAM that sells for $25/$35 plus local Tax, Shipping & Handling.
Originally designed by Eben Upton et al for the purposes of halting the decline in the level of programming & engineering skills of students entering the UK's university system, in particular those entering Cambridge as by tradition Cambridge University's courses of study have an extremely compressed time span and if you aren't already at a reasonable level of knowledge & skill you'll never get through it in one piece, and as a side effect increasing the size of the pool of skilled programmers and engineers available to industry. Basically Eben & his colleagues wanted to reproduce the effects of the reasonably easily available tinkerable with Home Micros in the 1980s had for British industry. I think they are not only succeeding with that aim but have also had some unintended consequences. They've created a whole new niche of computing device, the small and tiny usable general purpose computer, spawned several new businesses (and helped others expand), including case manufacturers, add-on board manufacturers and at least a couple of authors. They've also put the Maker community in the spotlight and made the general public aware of it's existence and they've sparked the interest of young and old alike in learning, building and doing things especially together. There is nothing that warms the heart more than seeing a video of a youngster with their father, mother or grandparent building or programming something together and getting it to work.
This time last year I wrote a quick blog post about how the Raspberry Pi launch broke the internet
http://russelldavis.org/2012/02/29/how-to-break-the-internet-in-10-easy-steps/ This year the blog post should really be titled "How the Raspberry Pi saved the world", over dramatic i know but in some ways it does feel like it.
So Bravo Eben, David, Pete, Jack, Alan, Robert and not forgetting Liz, Mooncake, James, James, Dom, Alex, Clive, Gordon & Rob
See you this time next year.
Many years ago, around 2001/2 to be precise ralphm made something called the Jabber World Map, and the Jabber fish bowl and the Jabber Christmas Tree and the ..., [see http://ralphm.net/world & http://ralphm.net/ ]
, and at least two Jabber IM clients, BuddySpace & Tkabber had functions where your contact list could be displayed as a map or graphic.

Unfortunately BuddySpace & ralphm's web maps haven't been updated in several years & Tkabber hasn't had a stable release in about 3 years although the svn version does run very well on the Raspberry Pi. We do have something very similar to ralphm's Jabber World Map with @Ryanteck's RasTrack, which is very good.
But it isn't quite what I want as I want to have something can be private to me, or my group and can be used at a variety of levels, house, building, club, village, town,... or with non-traditional maps and is easy to setup, deploy & take down (if it's only to be used for a short time).
The Prosody XMPP server that I talked about it an earlier post is perfect to do something like this as not only does it run very well on the raspberry Pi, is easy to setup, it comes with a 3rd party webpresence module that only requires installing into your modules directory, editing a config file and restarting the Prosody server and it's ready to use.
The mod_webpresence module is not part of the Prosody core so you'll need to download it from http://code.google.com/p/prosody-modules/wiki/mod_webpresence (If you are using the stable Prosody, version 8.2, from the raspbian repos due to API changes between the stable and unstable branch you'll need to use the 8.x compatible version from http://0-8.prosody-modules.googlecode.com/hg/ . which unfortunately isn't quite as good as the version for use with unstable prosody but it'll do the job although some of the nicer things such as user supplied icons don't work). If you are using the 0.9 branch of prosody copy the icons/ directory & the mod_webpresence.lua file to your prosody modules directory, if you are using the 8.x branch then just copy the mod_webpresence.lua file. The modules directory will be in one of several locations depending on on you installed Prosody. If you installed it from the raspbian repos then it'll be in /usr/lib/prosody/modules, if you installed from source then it'll probably be in /usr/local/lib/prosody/modules or if you changed the prefix when building and installing then it'll be in [prefix]/lib/prosody/modules e.g. /home/ukscone/prosody-0.9/lib/prosody/modules
Once you have copied the module you'll need to edit the config file for the prosody VirtualHost, in my case I added the line
"webpresence"; to the modules_enabled section in birstall.leicestershire.lan.cfg.lua
modules_enabled = {"roster"; -- Allow users to have a roster. Recommended
Once you've added the line to *.cfg.lua for your server, restart Prosody and test it using the webpresence url.
Now you know that it is working for one user you can now create a webpage to display the presence status for several users. In theory Prosody has a module to act as a webserver for static html files however i've never been able to get it to work correctly so I installed apache2 on my my raspberry pi but any method of serving webpages will do as long as it can "see" the url that the webpresence module produces. My html skills are very bad, non-existant, consist of being able to cut & paste and add text so I knocked up a simple webpage that uses a graphic of the floorplan of my apartment and uses absolute positioning to position the icons. [note: i know it's rubbish html & probably the wrong way to do it so you don't need to tell me
]
<html>
<head>
<style>
html {
background: url(floorplan.png) no-repeat center center fixed;
-webkit-background-size: 400px 600px;
-moz-background-size: 400px 600px
-o-background-size: 400px 600px;
background-size: 400px 600px;
background-color: #0c47ef;
}.tooltip {
border-bottom: 1px dotted #000000; color: #000000; outline: none;
cursor: help; text-decoration: none;
position: relative;
}
.tooltip span {
margin-left: -999em;
position: absolute;
}
.tooltip:hover span {
border-radius: 5px 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 5px 5px rgba(0, 0, 0, 0.1); -moz-box-shadow: 5px 5px rgba(0, 0, 0, 0.1);
font-family: Calibri, Tahoma, Geneva, sans-serif;
position: absolute; left: 1em; top: 2em; z-index: 99;
margin-left: 0; width: 250px;
}
.tooltip:hover em {
font-family: Candara, Tahoma, Geneva, sans-serif; font-size: 1.2em; font-weight: bold;
display: block; padding: 0.2em 0 0.6em 0;
}
.classic { padding: 0.8em 1em; }
* html a:hover { background: transparent; }
.classic {background: #FFFFAA; border: 1px solid #FFAD33; }</style> </head>
<body> <center><h1>Who is home & online?</h1></center>
<div style="position:absolute; top:540; left:500;"> <a class="tooltip" href="#"> <img src="http://birstall.leicestershire.lan:5280/status/linda/" /> Linda <span class="classic">Linda</span> </a> </div> <div style="position:absolute; top:100; left:500;"> <a class="tooltip" href="#"> <img src="http://birstall.leicestershire.lan:5280/status/john/" /> John <span class="classic">John</span> </a> </div> <div style="position:absolute; top:400; left:500;"> <a class="tooltip" href="#"> <img src="http://birstall.leicestershire.lan:5280/status/admin/" /> Russell <span class="classic">Russell</span> </a> </div> </body>
</html>
which gives me a webpage that looks vaguely like this.
If you have better css/html skills then you can do all sorts of fun & fancy things and you can use any background graphic you like, say the map of your school, town, a Christmas tree, ... Of course for anyone on your map/graphic to appear as online they'll need to be signed in to your prosody server using an IM client that supports XMPP or have an XMPP bot running on their Raspberry Pi. Most modern multiprotocol IM clients support XMPP, including, but not limited to pidgin, adium, centerim, IM+ and there are serveral XMPP clients that run very well on the Raspberry Pi including Tkabber. You could also write an XMPPBot for people to run on their Raspberry Pi, there are several XMPP libraries available for languages like Python, lua, php,... that make it very easy to write your own bot or client. A quick google will lead you to them. This doesn't scale that well, probably no more than a couple of hundred users max but it is very flexible and will do for smaller (semi-)private groups and there is lots of room for improvement and hacking and doing fun things with.
[note: if you are using the 0.9+ branch of prosody & the mod_webpresence module you can change the icons in the icons directory that the webpresence module uses, if you are using 8.x branch then the icons are "hardcoded" into the lua source of the module so changing them isn't just a case of dropping them into the icons directory and you can read more about the Prosody, the webpresence module, and the other modules available at http://prosody.im/ & http://code.google.com/p/prosody-modules/wiki/mod_webpresence & http://code.google.com/p/prosody-modules/]
Although I only live with 4 others, wife, son & 2 cats, in a small 5 room apartment most evenings we are in different rooms, or in the summer 3 different floors, wearing headphones chilling to our own choices in music & tv. As I think it's uncouth to yell out of the window or across the apartment to get someone's attention I setup a Raspberry Pi Model B as an XMPP server running MUC. As it's only for 3 people, unless we have visitors, I chose to run Prosody, it's pretty lightweight, easy to setup, the stable version is in the raspbian repos & i've used it before. I've also used and run ejabberd, openfire, tigase, jabberd,... but IMHO they are heavier on resources and a bit harder to setup, and are overkill for my needs and anyway I like lua.
As stable Prosody, currently 8.2, is in the raspbian repos you install it via apt.
sudo apt-get install prosody
which will install (if they are not already installed)
liblua5.1-0 lua-event lua-expat lua-filesystem lua-sec lua-socket prosody ssl-cert
Once Prosody is installed you'll need to create a config file & add some users.
First create an admin user for the server. As Prosody is running on birstall.leicestershire.lan, i'll use This email address is being protected from spambots. You need JavaScript enabled to view it. as my admin account & create it using the prosodyctl utility.
sudo prosodyctl adduser%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6721%%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6722%This email address is being protected from spambots. You need JavaScript enabled to view it.%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6723%
which will ask you to enter a password for that user (twice)
Enter new password: Retype new password:
[As i'm going to disallow in-band registration i also created accounts for my wife & son & a non-admin account for myself after creating the admin account also using prosodyctl. But if you are going to allow users to create their own accounts you can just skip to creating the config file.]
sudo prosodyctl adduser%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6724%%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6725%This email address is being protected from spambots. You need JavaScript enabled to view it.%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6726%
sudo prosodyctl adduser%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6727%%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6728%This email address is being protected from spambots. You need JavaScript enabled to view it.%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6729%
sudo prosodyctl adduser%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6730%%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6731%This email address is being protected from spambots. You need JavaScript enabled to view it.%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6732%
Now you need to create a config file. It's written in lua, but you don't need to know lua to create it as it's pretty human readable.
Create a file in /etc/prosody/conf.avail with the filename of FQDN of the host Prosody is running on and a suffix of .cfg.lua using whatever editor you are comfortable with, in my case I happen to like vi/vim so i'll use that.
sudo vi /etc/prosody/conf.avail/birstall.leicestershire.lan.cfg.lua
My configuration file looks like this.
VirtualHost "birstall.leicestershire.lan" -- FQDN of host server is running on
admins = {"%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6733%%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6734%This email address is being protected from spambots. You need JavaScript enabled to view it.%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6735%"} -- admin account
modules_enabled = {
"roster"; -- Allow users to have a roster. Recommended [If you want to allow in-band registration, users can register an account from their XMPP client, uncomment the
"register"; -- Enable mod_register
&
allow_registration = true -- Allow users to register new accounts
lines.]
After you have created & saved the configuration file you need to create a symlink to it in the /etc/prosody/conf.d directory.
sudo ln -s /etc/prosody/birstall.leicestershire.lan.cfg.lua /etc/prosody/birstall.leicestershire.lan.cfg.lua
[Change birstall.leicestershire.lan to your hosts name]
And then start Prosody
sudo /etc/init.d/prosody start
Actually you are restarting it as it's already running as you installed it using apt and it'll start automatically when you reboot as well. You can now login to the server, if you are the admin user create muc/chatrooms, im logged in users and do all the other things you can do using xmpp by using any xmpp compliant client such as adium, pidgin, Tkabber, psi, ...
This is just a very simple setup that works for my needs as I don't need to worry about setting up SRV records, portforwarding, federation or even much security. If you want to do a more complicated setup or just read a bit more about XMPP look at these sites.
http://prosody.im
http://xmpp.org
Hexxeh's rpi-update is a great utility to keep your Raspberry Pi firmware either up to date or on the bleeding edge but over the last couple of weeks it has on occasion been failing and stalling without giving any clue as to what was wrong. After a few days it really started to annoy me so I did a quick search and replace on --quiet to see what the problem was and after turning off the self update function of the script (I forgot to do that and spent 20minutes wondering why my changes weren't being preserved
) I discovered that it would sometimes fail on "compressed objects", I'm not sure why other than it's probably just one of those things as on the new run of the script it would normally work. While I was looking through Hexxeh's script I found what I considered a bug, if you choose install a specific commit the .firmware_revision file in /boot isn't updated with that commit value, an annoyance, the script defaults to self updating, and a lack of functionality, the to show error messages. So i've put together a small patch, currently version 3.
The changes i've made to Hexxeh's script that is available at https://github.com/Hexxeh/rpi-update are
1. Make it default to not updating itself (you can revert to it's old behaviour by using the envvar UPDATE_SELF=1)
2. It now writes the firmware revision of a user selected commit to /boot/.firmware_revision which stops it saying your firmware is up to date when you move from a old commit to the current head.
3. 3 levels, ok 4 if you count silent of verboseness. You select the verboseness using the envvar VERBOSE.
if the envvar doesn't exist or is 0 then the script is as per normal. if VERBOSE=1 then all git & wget commands display their actions, if VERBOSE=2 then you get output from git, wget, tar & cp, and if VERBOSE=3 then you get output from git, wget, tar, cp & rm
e.g. if you run rpi-update after applying the patch then
sudo UPDATE_SELF=0 VERBOSE=1 rpi-update
the the script will not update itself if there are changes and it will display the output of git,wget but not cp, tar & rm
the patch against Hexxeh's rpi-update commit de54b22c4eff6e06fd0e090a84fcdedcbdc1dd28 is here
Yesterday someone (not named to protect the wazzock) said their codecs had stopped working and for about an hour we couldn't work out why. Then all of a sudden we worked out why. Case matters to vcgencmd commands doh! mpg2 is wrong MPG2 is right
so this morning I decided to knock up a couple of oneliners/alias's so that we won't make that mistake again.
WVC1 codec
alias hasVC1='/opt/vc/bin/vcgencmd codec_enabled WVC1 | grep enabled > /dev/null ; RETVAL=$? [ $RETVAL -eq 0 ] && echo True [ $RETVAL -ne 0 ] && echo False '
MPG2 codec
alias hasMPG2='/opt/vc/bin/vcgencmd codec_enabled MPG2 | grep enabled > /dev/null ; RETVAL=$? [ $RETVAL -eq 0 ] && echo True [ $RETVAL -ne 0 ] && echo False '
H.264 codec
alias hasH264='/opt/vc/bin/vcgencmd codec_enabled H264 | grep enabled > /dev/null ; RETVAL=$? [ $RETVAL -eq 0 ] && echo True [ $RETVAL -ne 0 ] && echo False '
[these are just quick & dirty alias's but they work so don't knock it
]
This is just a quick & dirty post as an aide-mémoire for me on how to setup sshfs and in particular on the Raspberry Pi.
On the Raspberry Pi (sshfs client)
sudo apt-get install sshfs fuse fuse-utils libfuse2
sudo usermod -a -G fuse <username>
On the Host computer (sshfs server)
mkdir <directory to mount via sshfs>
On the Raspberry Pi
mkdir <mount point>
sshfs <server username>@<server ip/name>:<directory to mount via sshfs> <mount point>
The above will ask you for a password each time you run sshfs. if you want to use it passwordless then
on the Raspberry Pi
ssh-keygen -t rsa
and press enter to all the questions and copy the ~/.ssh/id_rsa.pub file to the host computer as ~/.ssh/authorized_keys
On the Host Computer
ssh-keygen -t rsa
and press enter to all the questions and copy the ~/.ssh/id_rsa.pub file to the Raspberry Pi as ~/.ssh/authorized_keys
once you have setup sshfs do all your compiling on the Raspberry Pi in the <mount point> directory and you'll not be slowly wearing out your SD Card
. Also a nice side effect of using sshfs is that if you are cross compiling on your host computer you can just copy the programs you build to the directory that is mounted via sshfs and it'll be automagically available on your Raspberry Pi.
A couple of weeks a fellow #raspberrypi irc channel user called ReggieUK suggested to those awfully nice chaps at Industrial ARMWorks Inc. that I might be a good person to get sent a FriendlyARM Mini210S (a Samsung S5PV210, based ARM Cortex ™-A8, running at 1GHz with 512MB RAM & 4GB onboard NAND Flash) to play with and break er I mean test, fix & port stuff to and being the awfully nice chaps that they are they agreed and it arrived today. Actually it arrived yesterday but the postman (never) rings once let alone twice so I didn't know until I checked the mailbox in the evening and saw the "we tried to deliver but you ignored us" note. I wandered up to the post office as soon as they were open this morning and picked it up
and after removing a pair of furry critters from my desk I started to unpack it.
As well as the actual friendlyarm mini210s they included a few extras like hdmi cable, ethernet cable, sdio wifi card, a camera module, a small prototyping board,... (see i told you they are really nice chaps)
If you buy a mini210s from Industrial ARMWorks they include the touch screen display, power supply & the HDMI cable but I think the sdio wifi card, prototype board & the camera module are additional purchases.
The Mini210s can run Android, Linux (yeah i know Android IS Linux but ...
) & WinCE 6.0 and comes with Android installed by default.
After i've had a bit of a play with Android for a few days i'll be replacing the Android install on the onboard NAND to Linux but for now i'm having fun messing with Android as you'll be surprised to know this is my only Android based device other than my nookcolor which is still running the stock firmwware so is limited to the B&N store for apps.
So far after a few hours playing and messing around i'm really liking the Mini210S and i can think of quite a few projects I can use it for although we all know what one of the first things i'll do after installing Linux on it is build OpenCOBOL for it and run a few benchmarks
yeah I know i'm completely nuts ![]()
I have a bit of a soft spot for COBOL. I was taught & used the Ryan-McFarland version on Tandy Model III & IVs at college & one of the first programs I ever got paid to write although originally written in compiled BASIC was quickly rewritten in COBOL, for those that are interested it was a complete accounting & payroll suite including interfacing to a Hugan-Alpha till (cash register) for stock control for a Camping, Caravaning & Outdoor Leisure activities store. I was actually quite proud of it and from what I heard it was still in use until fairly recently nearly 30years after I originally wrote it although I haven't been involved with maintaining it for nearly 15 years. Anyway because I do have this soft spot for COBOL (and I still program in it on occasion, which is why I am always grumpy
) when I got my Raspberry Pi I built OpenCOBOL for it, actually i built it before I got my Raspberry Pi as I originally built it last September using my Raspberry Pi development VM but all i did with it was run the tests to check that it built, ran correctly & produced working binaries & modules. However, a few weeks ago Heirloom Computing Inc released a version of their Elastic COBOL compiler for the Raspberry Pi for free, the press release is available to read here, so I decided to rebuild OpenCOBOL actually on my Raspberry Pi & compare the two as they have different methods of producing runnable code, OpenCOBOL produces C code that can then be compiled to a standalone binary or a callable module, Elastic COBOL produces Java code that is then run on JVM, Elastic COBOL has builtin GUI functions, OpenCOBOL has no GUI out of the box other than normal COBOL screen handling but it does have the ability to produce GUI applications using 3rd party libraries such as GTK or TUI or Qt or ... and OpenCOBOL is opensource & Elastic COBOL is free to use although the compiler has a "phone home" function that requires you to have your Raspberry Pi attached to the internet via the Ethernet connection at least once a week , it must be Ethernet, Wifi won't work.
To build & install OpenCOBOL on the Raspberry Pi
1. Downlaod the source tarball from http://sourceforge.net/projects/open-cobol/
2. Install (if not already installed) the headers & shared lib for ncurses & berkeleydb, berkeleydb is sort of optional if you haveanother ISAM library installed but the 3 current ISAM choices don't necessarily work on ARM devices or if they do are a bit flakey so it's best to just go with berkeleydb > 4.1. on raspbian
sudo apt-get install libncurses5 libncurses5-dev libdbx.x libdbx.x
where x.x is the version of berkeleydb that is available that is > 4.1 (raspbian has several versions all are ok to use)
3. untar the source tarball, cd to the directory that it untared to (open-cobol1.1 probably) and
./configure ; make ; make check
and if all the tests passed (it'll take about 25minutes with gcc 4.6 & for some weird reason that I can't fathom about 30minutes with gcc 4.7)
sudo make install
to install Elastic COBOL on the Raspberry Pi
1. Register on the Elastic COBOL portal at https://www.elasticcobol.com/index.php/raspberry-pi/ and then once you you have registered and logged in follow the setup instructions that Heirloom Computing have supplied.
2. I did have one slight problem when I was sent the elasticcobol.properties file that is needed to get Elastic COBOL to. Thunderbird "hid" the attached file and I had to manually cut & paste it out of the message source (Ctrl+U) and run it through uudecode manually.
Now you should have both Elastic COBOL & OpenCOBOL installed and usable, check that they both work. I used the ElasticCOBOL supplied hello world sample program.
ukscone@welham ~/cobapps $ cat hello.cbl * * HELLO-WORLD * * (C) Copyright Heirloom Computing 2011. All Rights Reserved. * * This file and associated files are copyrighted information * of Heirloom Computing. Permission is granted for usage in * conjunction with the Elastic COBOL product. * * This is an application meant to run using SYSOUT, * that is, a DOS Box under Windows or the console under Unix. * * This file also shows that the PROGRAM-ID is the important * factor in determing the name of the Java file. (As each * Java class needs its own file, and a single COBOL file * can have multiple COBOL programs and thus multiple Java * classes, you can see why the source filename was not used.) * Java names cannot have hyphens such as our PROGRAM-ID here * does, so underscores replace it, becoming "hello_world". * * This program's only purpose is to print upon sysout, and * as browsers do not normally have a sysout, do not run this in * a browser. * * To get this program to display in a browser, change * the SYSOUT to CONSOLE, or remove the UPON SYSOUT entirely, * and it will print upon a graphical console.
IDENTIFICATION DIVISION. PROGRAM-ID. HELLO.
ENVIRONMENT DIVISION.
DATA DIVISION. WORKING-STORAGE SECTION.
PROCEDURE DIVISION. MAIN-PARAGRAPH. DISPLAY "Hello World from Raspberry Pi!" UPON SYSOUT.
As you can see below ElasticCOBOL is a bit slower because of the overhead of having to start the JVM but that really isn't that much of a concern as it's a small "fixed" amount of time that doesn't actually affect the speed of execution.
ukscone@welham ~/cobapps $ cobc -m hello.cbl ukscone@welham ~/cobapps $ time cobcrun hello Hello World from Raspberry Pi!
real 0m0.029s user 0m0.010s sys 0m0.010s ukscone@welham ~/cobapps $ ecc hello.cbl Elastic COBOL V12.7.20 Copyright (C) 2010-2012 Heirloom Computing
LOC: 40 (0 variables in 0 records) Warnings: 0 Errors: 0 Result: Compilation SUCCESSFUL Building: Class files ukscone@welham ~/cobapps $ time ecr hello Hello World from Raspberry Pi!
real 0m4.144s user 0m3.370s sys 0m0.260s ukscone@welham ~/cobapps $
A slightly more complicated program is hanoi.cob
000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. hanoi. 000300 AUTHOR. Amit Singh <http://hanoi.kernelthread.com>. 000400 000500 ENVIRONMENT DIVISION. 000600 000700 CONFIGURATION SECTION. 000800 SOURCE-COMPUTER. ALMOST-PORTABLE. 000900 OBJECT-COMPUTER. ALMOST-PORTABLE. 001000 001100 DATA DIVISION. 001200 001300 WORKING-STORAGE SECTION. 001400 001500 01 STACK-SPACE. 001600 02 ESP PIC S9(3) COMP. 001700 02 STACK-FRAME OCCURS 1024. 001800 03 S-N PIC 9(1). 001900 03 S-FROM PIC X(1). 002000 03 S-USING PIC X(1). 002100 03 S-TO PIC X(1). 002200 03 S-PROC PIC 9(1). 002300 002400 01 CURRENT-FRAME. 002500 02 CN PIC 9(1) VALUE 3. 002600 02 CFROM PIC X(1) VALUE "1". 002700 02 CUSING PIC X(1) VALUE "2". 002800 02 CTO PIC X(1) VALUE "3". 002900 02 CPROC PIC 9(1) VALUE 0. 003000 003100 01 TMP-FRAME. 003200 02 TN PIC 9(1) VALUE 3. 003300 02 TFROM PIC X(1) VALUE "1". 003400 02 TUSING PIC X(1) VALUE "2". 003500 02 TTO PIC X(1) VALUE "3". 003600 02 TPROC PIC 9(1) VALUE 0. 003700 003800 PROCEDURE DIVISION. 003900 BEGIN-PROGRAM. 003910 PERFORM GET-DISKS 004000 MOVE 1 TO ESP 004100 MOVE CURRENT-FRAME TO STACK-FRAME (ESP) 004150 PERFORM DO-HANOI 004200 UNTIL ESP = ZERO 004300 . 004500 STOP RUN 004600 . 004700 004800 DO-HANOI. 004900 MOVE STACK-FRAME (ESP) TO CURRENT-FRAME 005000 SUBTRACT 1 FROM ESP 005100 IF CPROC = 0 005200 IF CN = 1 005300 PERFORM MOVE-DISK 005400 ELSE 005500 MOVE CN TO TN 005600 MOVE CFROM TO TFROM 005700 MOVE CUSING TO TUSING 005800 MOVE CTO TO TTO 005900 MOVE 1 TO TPROC 006000 ADD 1 TO ESP 006100 MOVE TMP-FRAME TO STACK-FRAME (ESP) 006200 MOVE CN TO TN 006300 SUBTRACT 1 FROM TN 006400 MOVE CFROM TO TFROM 006500 MOVE CTO TO TUSING 006600 MOVE CUSING TO TTO 006700 MOVE 0 TO TPROC 006800 ADD 1 TO ESP 006900 MOVE TMP-FRAME TO STACK-FRAME (ESP) 006950 END-IF 007000 ELSE 007100 PERFORM MOVE-DISK 007200 MOVE 0 TO TPROC 007300 MOVE CTO TO TTO 007400 MOVE CFROM TO TUSING 007500 MOVE CUSING TO TFROM 007600 MOVE CN TO TN 007700 SUBTRACT 1 FROM TN 007800 ADD 1 TO ESP 007900 MOVE TMP-FRAME TO STACK-FRAME (ESP) 008000 END-IF 008100 . 008200 008300 MOVE-DISK. 008400 DISPLAY CFROM 008500 "--> " 008600 CTO 008700 . 008800 008900 GET-DISKS. 009000 DISPLAY "How many disks to solve for? " NO ADVANCING 009100 ACCEPT CN. 009200 IF CN < 1 OR CN > 9 009300 DISPLAY "Invalid number of disks (1 <= N <= 9)." 009400 EXIT PROGRAM 009500 END-IF 009600 . 009700 .
ukscone@welham ~/cobapps $ cobc hanoi.cob ukscone@welham ~/cobapps $ cobcrun hanoi How many disks to solve for? 5 1--> 3 1--> 2 3--> 2 1--> 3 2--> 1 2--> 3 1--> 3 1--> 2 3--> 2 3--> 1 2--> 1 3--> 2 1--> 3 1--> 2 3--> 2 1--> 3 2--> 1 2--> 3 1--> 3 2--> 1 3--> 2 3--> 1 2--> 1 2--> 3 1--> 3 1--> 2 3--> 2 1--> 3 2--> 1 2--> 3 1--> 3
[i couldn't be bothered to edit the source so that Elastic COBOL used the stdout so below is a jpeg of it's output. it pretty much took the same amount of time to run (after subtracting the java overhead)
Now that I know that both OpenCOBOL & ElasticCOBOL work pretty well on the Raspberry Pi I decided that before messing around with ElasticCOBOL any more e.g. looking into which dialect of COBOL it uses (it's cobol85 with a few additions for the gui and some inline java) i'd run a completely biased benchmark. I knew before I even ran it that ElasticCOBOL would be slooooow as java on the Raspberry Pi is slow & as far as I know doesn't use the floating point hardware. I am just interested to see if it will run out of the box or with minimal changes & it required only changing the name of a variable from Time-Out to Tyme-Out as ElasticCOBOL has TIME-OUT as a reserved word and the in/out filenames.
You can find the benchmark code & datafiles at http://speleotrove.com/decimal/telco.html.
I used the COBOL version with http://speleotrove.com/decimal/expon180-1e6.zip datafile.
With an non-overclocked Raspberry Pi using OpenCOBOL1.1 compiled with gcc 4.6 the benchmark took from
Start-Time:23:39:39.08 to End-Time:23:41:26.26 =1m47ish
and ElasticCOBOL took from Start-Time:22:20:49.58 to End-Time:23:16:04.66 = 56minutesish ![]()
As I said this was a completely biased benchmark as I am an OpenCOBOL fanboy and knew it would win hands down but I am still quite impressed with ElasticCOBOL even if it is using java and hits my "irrational loathing of java" prejudice but it's gui stuff is great and very responsive and i'll probably spend more time playing around with it but I definitely won't be processing a million entry data file with it ![]()
I'm not a big fan of Apple and although I do have a Blueberry iMAC and an SE20 stored in the cat's room & I have had an Apple II & Apple IIe or IIc, which is the one that was about the size of a box of chocolates and had a handle? all of which were found on my garbage days perambulations. I normally wouldn't have any interest in anything Apple as I think they are overpriced artsy-fartsy hardware that just doesn't appeal to me. However, the HP laptop that I got in 2008 has spent the last 3 & a bit years slowly dying, (DVD burner not working, track pad not working, half the usb ports not working, several keys require a mallet to press, overheating, webcam busted, speakers very quiet, bios is the typical crippled HP bios...) and in the last few months has been hanging on only because I am a master at the art of bodgery & jury rigging through the judicious application of duct tape, little bits of metal, and cardboard. So when a friend asked me if I wanted his old Macbook Pro2,2 that although very beat up and scuffed still worked and was surplus to requirements I immediately said that "yes please" as you can never have too many computers
and I thought if nothing else SWMBO (who lusts after Apple hardware) would like it or I could install Linux on it and use it for listening to BBC Radio 4, watching videos and an SSH/VNC terminal for logging into my other computers (mostly my Raspberry Pi) & servers.
It arrived last week and after opening the box he sent it in my plans changed. Yes it was a bit scuffed and beaten up and it had a nasty ugly sticker over the Apple logo (now replaced by several raspberry Pi stickers) but it still looked quite nice with a bit of weight to it, It feels like I could crack a nut or two with no real damage to it and when comparing it to other 6 year old computers I have it's much nicer with better specs. My friend purchased & installed Lion* on it for me, and as he'd paid for the OS I felt I couldn't really just wipe it & install Linux on it without at least giving OS X a chance. After the first day of trying to use OS X and get used to the fact that there is only one "mouse button" I was ready to defenestrate the Macbook or give up and put Linux on it but the fact that OS X had cost my friend money stopped me and I forced myself to keep OS X on there and try to get used to it. The second day was a bit better, I still kept trying to right click, which is a tiny bit difficult when there is only one "mouse button" and I couldn't find stuff but after installing macports, which took a couple of hours as the document i found on how to install macports seemed to be wrong or at least for a different version of OS X than it claimed to be for things started to get better. It's now been 7 days since I received the Macbook Pro & i'm beginning to understand why people like Apple hardware. I still wouldn't buy one new, mostly because I would never be able to afford it or even justify paying that much upfront for a computer but when I see how well it performs even being 6 year old hardware I must say i'm pretty impressed and it does work really well for my needs. I am sharing the wifi on the Macbook with my Raspberry Pi and that is working really well and although I am still very low on the OS X learning curve i am slowly getting used to it and learning how to do things the OS X way. There are things I don't like about it, the forced usage of the App store..., but i'd say that Apple have a partial convert and if another macbook ever comes my way i'll not turn my nose up at it.
*I believe that Lion is going to be the last version of OS X that will be installable on this Macbook Pro as I recall reading that Mountain Lion is going to drop support for Macbooks build prior to 2007 so I may end up install Linux on it eventually anyway but we'll see.
This morning (February 29th 2012) at some ungodly hour (1am EST/6am UTC) the Raspberry Pi was finally released. Originally the Raspberry Pi Foundation was going to manufacturing the Raspberry Pi themselves and sell it in their own online store but instead they have setup a licensing deal with 2 companies (Premier Farnell/RS Components) who will make the Raspberry Pi themselves, using their manufacturing facilities and sell them in their online stores. There have been some initial teething problems with this but on the whole this is a good thing as it will mean more people will be able to get their hands on the Raspberry Pi much sooner than if the Foundation was handling the manufacture of the Raspberry Pi themselves. The foundation now gets to concentrate on other things such as writing documentation and actually teaching programming to children rather than spending enormous amounts of time on behind the scene things not directly related to their ultimate aims.
Within seconds of the announcement that the Raspberry Pi was now available for purchase and even though this initial batch is limited to one per person the stores for both of the licensed manufacturers had crashed, raspberry pi was trending in the top 3 on twitter and the IRC channel (#raspberrypi) had over 500 users. For the next couple of hours every time the Farnell or RS stores came back online they were crashed again by the throngs of geeks all trying to order their Raspberry Pi. It seems that not only have the Foundation designed a great tiny computer and a cheap price they have also designed an effective method to harness the collective power of the geek community to DDoS an online store. There are some teething problems with the foundation's licensed manufacturing partners such as the RS online store seems to be willing to only sell to companies in the UK (you need a UK address and company name to even register), their affiliates stores in other countries don't have the Raspberry Pi listed as even an out of stock item and they seemed to have forgotten that the 29th was release day as it has been said by some on twitter and in the IRC channel that RS said it's not available until later in the week. Farnell also have some problems too unrelated to the fact that their store crashed. There seems to be some confusion with regard to fees, shipping costs, taxes etc. and some of their affiliates in other countries don't have the Raspberry Pi available for purchase or even backorder. I believe that this first batch is actually a special case in that people who have managed to order a Raspberry Pi will be getting one from the Foundation manufactured batch so things were a little confused and there was some miscommunication within RS & Farnell between the various departments involved in making the deal with the foundation, the sales department and the website department etc. Eventually once things have died down and RS & Farnell are selling Raspberry Pi's they have built themselves that all the these initial problems will sort themselves out and that people will be able to get hold of Raspberry Pi's much quicker than if the foundation was building and selling the Raspberry Pi themselves.
One thing that might have sneaked passed a few people in the announcement was that the Model A is now much better value for money as they have been able to double it's RAM to be the same as the Model B's 256MB. This means that the only difference between the Model A & B is the extra USB slot and the Ethernet connector.
So how do we break the Internet in 10 easy steps?
- Go to the pub with friends and complain about how poor the standard of programming skills of applicants to University are in the UK and that things were much better in my day. Now get of my lawn you darn kids.
- Design a cheap, simple, tiny SBC that uses a TV or HDMI enabled monitor as it's display
- Wait 5 years
- Setup a website and forum and post articles about how the computer was designed, what you are doing at the moment and that you'll be releasing soon.
- Get lots of articles about your tiny computer in both the old and new media, bonus points if you can get slashdot to post a story at least twice a month.
- Post lots of stories on your website that release day will be quite soon.
- Post more stories on your website that release day is almost here
- Post a story that release day is in a couple of days
- Warn your sales partners that lots and lots of people will want to try to buy your SBC as you have a mailing list with over 100,000 subscribers, a forum with thousands of members, lots of twitter followers... and you have only made 10,000 of them
- ANNOUNCE that sales are now possible and post links to the stores of your sales partners then sit back with a Glass of wine in your hand and laugh manically while watching the Internet being brought to it's knees Bwahahahahahahahahaha
The Raspberry Pi will probably be available to buy in the store sometime within the next ten days and one of the operating system sd card images is already available (debian) with another to follow in a day or so (fedora) so it's time to start thinking about making an sd card for use with the raspberry pi.
If your main machine is a linux system then you should have no problem, a standard dd will be fine but under windows not only do we not have a dd program (we do but it's not a pleasant experience and windows users are not command line junkies on the whole so use something like Win32DiskImager or equivalent) but there are a couple of gotchas that might catch the unaware out.
The main gotcha is that although your computer has a builtin sd card reader/writer and it works with your cellphone or camera sd card perfectly well it might not work for creating a bootable sd. The biggest problem builtin sd card reader/writer is the ricoh one in HP laptops although other makes of sd card hardware and laptops also have this problem. When you use a builtin reader/writer and it is goingto fail it doesn't always tell you that it's failed so the first thing you now something is wrong is that your raspberry pi (or other target device) won't boot So although you have a builtin sd card reader/writer it is a good idea to get hold of a USB SD card reader/writer and use that for making your bootable SD card. [I have no real idea why builtin reader/writers have problems making bootable sd cards but my thinking is that the controller in the builtin ones was cut down for windows machines to save a few pennies as noone thought that they'd want to write to the 0 to xxxx areas of the SD card]
The other gotcha you should be aware of is that SD cards are formatted and written to in a slightly "weird" way. An unformatted/blank SD card is actually full of 1's and when you write to it it just flips the appropriate bits to 0. Under normal use there is no way to unflip a bit from 0 back to 1 so you'll end up with areas that can't be used and that deleting files won't actually free up that space. So if you are going to use an SD card that you have used before you'll want to format it before using it with the raspberry pi. Don't use the windows formatter with your SD card as although it'll sort of work it won't have set all the bits to 1 instead user the panasonic sd card formatter which you can find at http://panasonic.jp/support/global/cs/sd/download/index.html [I can never remember which way around it is for when an sd card is in an unused state, whether it's all 0's or all 1's but i'm leaning towards all 1's as that is what has seemed to have stuck in my head].
To quickly summarize if making a bootable sd card on windows.
- Use a USB SD Card reader/writer
- Use the panasonic sd card formatter
- There is a windows version of dd but use Win32DiskImager or equivalent instead
I'm got disgusted with Virtualbox when trying to get a USB webcam working with it so rather than building a new linux system to use for developing some object indentification from a webcam software i decided to see if there were any nice open source compilers or interpreters for things like Algol, Snobol4 etc.
I found an Algol68 interpreter on sourceforge that seems to be still maintained (last update in 2011 and a related piece of software updated this year) http://algol68.sourceforge.net/ so i thought i'd give it a go using an ARM fedora rootfs. I ran the configure script and saw that it would like gsl & ncurses so I added the runtimes and headers using yum inside scratchbox2 and then reran the configure script and then make and after adding the usual "-fsigned-char" it built with non of the usual X86 C to ARM C warnings.
I ran a couple of test programs from http://rosettacode.org and they all worked and although it did fail on one test when I ran the test suite for the interpreter I think that was just because it was so slow when running inside nested emulators and there was an error right where the test suite finishes but I don't think that is too serious when just running to see if there are any showstopping problems, which there don't seem to be. I make no guarantees that the binary will actually work for you on real Raspberry Pi hardware or using an other distro other than ARM Fedora14 but it seems to be ok using qemu, a fedora arm rootfs and a bit of finger crossing.
[raspberry@localhost algol68g-2.3.5]$ sb2 make check make check-TESTS make[1]: Entering directory `/home/raspberry/build/algol68g-2.3.5' [1] Peano curve using Van Wijngaarden's algorithm. ........ ........ ......... ......... ......... . . . . . . . . . . . ..... .... ..... ..... ..... ..... .... ..... . . . . . ..... .... ..... ..... . .... . .... ..... . . . . . . . . . . . . . . ........ ........ . ..... ..... . ......... . . . ..... ............ ..... ..... ..... . ......... . . . . . . . . . . . ..... .... ..... ..... . .... . .... ..... . . . . . . . . ..... . . .... . ..... ..... .... ..... . . . . . . . . . . . . . ..... .... ..... ..... ..... ......... ......... . . ..... .... ..... ..... ..... ......... ......... . . . . . . . . . . . . . . ..... . . .... . ..... ..... .... ..... . . . . . . . ..... .... ..... ..... . .... . .... ..... . . . . . . . . . . . ..... ............ ..... ..... ..... . ......... . . . . ........ ........ . ..... ..... . ......... . . . . . . . . . . . . . ..... .... ..... ..... . .... . .... ..... . . . . . ..... .... ..... ..... ..... ..... .... ..... . . . . . . . . . . . . ........ ........ ......... ......... .........
PASS: check-01.a68 [2] Mersenne primes by the Lucas-Lehmer test
M_3 has 1 digits M_5 has 2 digits M_7 has 3 digits M_13 has 4 digits M_17 has 6 digits M_19 has 6 digits M_31 has 10 digits M_61 has 19 digits M_89 has 27 digits M_107 has 33 digits M_127 has 39 digits 28 DO s := (s * s - 2) MOD cand 1 a68g: runtime error: 1: time limit exceeded (detected in VOID loop-clause starting at "FROM" in line 27). FAIL: check-02.a68 [3] Miniature LISP interpreter >(1 2 3 4) (1 2 3 4) >(append (1 2) (3 4)) (1 2 3 4) >(+ 1 (* 2 3)) 7 >(quit) PASS: check-03.a68 [4] Recursive back-tracking algorithm There are 98411 ways to split 1000 cents in 5 10 20 50 100 200 cent coins PASS: check-04.a68 [5] Building a decision-tree Please name an object 'rectangle' I will guess the object you are thinking of rectangle? 'no' What was the object? 'square' Give a question to distinguish 'square' 'does it have four sides of equal length' Does 'does it have four sides of equal length' apply to 'square'? 'yes' Another round? 'yes' I will guess the object you are thinking of does it have four sides of equal length? 'no' rectangle? 'no' What was the object? 'cube' Give a question to distinguish 'cube' 'does it have three dimensions' Does 'does it have three dimensions' apply to 'cube'? 'yes' Another round? 'no' PASS: check-05.a68 (6) Exact determinant of Hilbert matrices using fractions Rank 1, determinant 1 / 1, ok Rank 2, determinant 1 / 12, ok Rank 3, determinant 1 / 2160, ok Rank 4, determinant 1 / 6048000, ok Rank 5, determinant 1 / 266716800000, ok Rank 6, determinant 1 / 186313420339200000, ok Rank 7, determinant 1 / 2067909047925770649600000, ok Rank 8, determinant 1 / 365356847125734485878112256000000, ok Rank 9, determinant 1 / 1028781784378569697887052962909388800000000, ok Rank 10, determinant 1 / 46206893947914691316295628839036278726983680000000000, ok PASS: check-06.a68 [7] Hamming numbers 1 2 3 4 5 6 8 9 10 12 15 16 18 20 24 25 27 30 32 36 2125764000 PASS: check-07.a68 [8] Ackermann function A(1, 1) = 3 A(2, 1) = 5 A(2, 2) = 7 A(3, 1) = 13 A(3, 2) = 29 A(3, 3) = 61 PASS: check-08.a68 [9] Synthetic benchmark after Curnow & Wichmann 1.0 MWhets PASS: check-09.a68 ========================================================= 1 of 9 tests failed Please report to Marcel van der Veer <%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6736%%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6737%This email address is being protected from spambots. You need JavaScript enabled to view it.%MINIFYHTML4b40971746b4fc6f45f4655682cdbc6738%> ========================================================= make[1]: *** [check-TESTS] Error 1 make[1]: Leaving directory `/home/raspberry/build/algol68g-2.3.5' make: *** [check-am] Error 2 [raspberry@localhost algol68g-2.3.5]$
You can find the ARM binary here and the command used to build it was
sb2 CFLAGS="-fsigned-char" ./configure && make
I think you'll agree this has to be worth at least a Bronze medal in the Olympic procrastination event.
I was informed yesterday that there seems to be a problem following my VM setup instructions when using Ubuntu 11.10. I spent about 5 hours and 3 Ubuntu 11.10 installs checking this and it certainly seems to be the case that without an awful lot of fiddiling and complications that this is definitely the case. So for the time being the recommended guest os's for building your own VM are Ubuntu 10.04LTS, Fedora16 or Debian (I haven't built the VM on Debian for a long time so i'm not sure exactly which version to recommend but I can't imagine that Debian will be much of a problem with any recent versions. If anyone has a problem with Debian please let me know.)
Once again if you are using my instructions to build the Raspberry Pi development VM (or a VM for any development using Scratchbox2 and/or qemu) i'd recommend (in no particular order) currently using
- Ubuntu 10.04LTS
- Fedora
- Debian
Now a tip when porting x86 code to ARM using gcc. If you get a lot of warnings when trying to build software originally written in C for x86 for ARM especially things like "comparison is always true/false due to limited range of data type" the chances are that you aree being bitten by the fact that x86 compilers usually default to signed chars if not specified by the variable declaration while ARM compilers usually default to unsigned chars. If you are using gcc (which you are if you are using my VM or your own installation of Scratchbox2 then the fix is to use the
-fsigned-char
gcc option. e.g.
gcc hello.c -o hello -fsigned-char
Another thing that might prove useful when you have access to the real Raspberry Pi hardware and the standardized distro is that by default the codesourcery toolchain included in the VM by default builds for generic ARMv5. On the whole this really shouldn't matter as ARMv6 can run ARMv5 instructions but there maybe times when you are doing something that needs to use an ARMv6 specific instruction or you are including assembler in the C code or something else where a generic ARM version binary just won't cut it. In that case using the gcc option
-mcpu=arm1176jzf-s
which specifies that gcc emits the correct instructions for the specific ARM core that the Raspberry Pi uses might be helpful.
e.g.
gcc -mcpu=arm1176jzf-s hello.c -o hello
I don't claim that the following is the best way to install scratchbox2, qemu and a seed rootfs and configure them to produce binaries that will run on the real Raspberry Pi hardware. I don't even claim it is the correct way but it works for me and I can almost do it in my sleep by now. The way I do things will probably seem a bit inefficient and in some cases just plain wrong but it's how I work and hopefully they are easy to follow and adapt to your style of working. I also make no guarantees that it will actually work for you at all. Hopefully it will but if it doesn't sorry but oh well. I made the decision when I first started building the development vm that I would place all the required software under the users home directory rather than installing it globally as
- Installing in subdirectories in the user's home directory makes it easy to keep things organised.
- It makes things almost idiotproof when you want to upgrade the ARM toolchain, scratchbox2, qemu or change the seed rootfs etc. as it's pretty much just rename the old directory, create a new directory and if neccessary rerun sb2-init.
- Open a terminal
- If you haven't already got git & wget installed. Install them now. On Ubuntu or Debian the command to install them is
- Create a directory for temporary use. I personally call it hold and change to it.
- Download scratchbox2 and qemu from their respective git repositories
- Download the codesourcery ARM toolchain. I have been using the 2011.03 version successfully and I believe it was the last released version before codesourcery was bought by Mentor Graphics who seem to have closed sourced the more recent releases of the toolchain.
- Then download an ARM rootfs. Eventually we will be able to use the official Raspberry Pi standard rootfs but until that time any ARM based one will do. As I believe that the official Raspberry Pi distribution is going to be Fedora we'll download a Fedora one. In this case we use one I found on the fedora-arm mailing list. http://lists.fedoraproject.org/pipermail/arm/2011-December/002386.html
- If you now do a directory listing you will have a terminal window that looks this
- Now create some more directories.
- Untar the rootfs
The reason we extract the seed rootfs using sudo is that there are some special files that a normal user cannot create when untarring a tarred rootfs. Lots of filenames will scroll before your eyes as the seed rootfs is untarred into the rootfs subdirectory. This will take quite a while so it might be a good time to go and get a drink or take a bathroom break. - Extract the codesourcery ARM toolchain into the raspberry_pi_development directory.
- Do a directory listing of the raspberry_pi_development directory and it will look like the image below.
- If you haven't already got the SDL and ncurses libaries and headers installed. Install them now. In Ubuntu and Debian
- You should also install autoconf, fakeroot and realpath. Fedora users will need to find their own copy of the realpath source as it is not included in the distribution. I found a copy that works on stackoverflow. In Ubuntu and Debian
change to scratchbox2 directory and run the autogen.sh script.
- then run make
You can ignore all the warnings that will scroll passed and when it finishes the screen will look something like the one below. The interesting lines are the final 4 or 5 which should basically say the same thing that the screenshot does.
- Scratchbox2 is now installed and we now need to build qemu so cd to the qemu directory
- To use scratchbox2 you only need to build qemu usermode for ARM, however, I find it useful to also build the ARM system emulation as well (I use the qemu full system emulation for some little hacks and tricks that are beyond the scope of this howto but I will write them up at a later date along with how to use scratchbox2 with real hardware once I have the process down pat & actually have a real Raspberry Pi to test on).
- Now that scratchbox2, the toolchain, qemu and the seed rootfs are installed we just have a few more steps before we can actually use the VM for compiling software. First of all we need add the scratchbox2 and qemu bin directories to our PATH environment variable. You can do this as a single export statement but so it's clear i'll do it as two.
You will also want to add the previous two lines to your .bashrc file. Start your favourite editor and open the .bashrc file and add them to the bottom and in the case of nano save the file using ^x y <enter>. If you are using vi the it would be <esc> :wq
- Now that you have added scratchbox2 and qemu to your PATH (and in .bashrc as well) check that it works.
The version numbers returned might be different but that doesn't matter it's the fact that you actually got the version numbers that confirms that the PATH environment variable is set correctly. - change to the rootfs directory
- before we can use the seed rootfs inside scratchbox2 we need to change the owner, group and permissions so that it is read/writable by our non-root account. When I installed Ubuntu into the VM I was asked to make a default user. In my case I called it raspberry and gave it a password of password. You might have called your default user something different replace raspberry in the following lines with your user name.
- There is just one more thing to do before we can start using scratchbox2. We need to initialize it. While inside the the seed rootfs directory. In this case rootfs_f14
sb2-init actually has a lot of options you can use but in most cases they just complicate matters and for our needs the above command line is good enough. What it actually means is configure scratchbox2 to create a target called raspberry and use the toolchain binaries that we have installed in$HOME/raspberry_pi_development/arm-2011.03/bin
As you get more familar with scratchbox2 you might want to experiment with things such as having multiple targets with a single scratchbox2 installation etc.After a short wait your screen will look something like this
- You are now ready to start using scratchbox2 to compile software. However, I do a few more things just to make life easier that you might also want to do. I create a directory called $HOME/build, install an ssh server and apache2 and put a symlink of the build directory in the apache2 directory tree. This allows me to keep all my ARM binaries an source seperate from anything else and lets me get them out of the VM easily although I could also use shared folders but I prefer using a webserver as then any machine on my network can access them. I got a bit bored doing the screenshots and cutting out the relevant parts so here is a video of me doing this final bit of setup
If you have got this far you are now ready to start building software for the Raspberry Pi. As a test I create a C hello world program and check that it compiles and runs both in the host os and also inside scratchbox2 and if that works then I check that the seed rootfs's package manager works. If both do then i'll start using the vm. Again because I am bored with doing screenshots here is a short video of that process.
Click here to view the embedded video.
When and if I get time I might do some more blog posts about some advanced scratchbox2 and qemu usage, tips and tricks but for this post i say
THE END
If you decided to use a Debian or Ubuntu based distro then when you booted the Raspberry Pi Development VM that you just created you will have probably noticed an error message flash on the screen saying
piix4_smbus 0000.00.07.0: SMBus base address uninitialized - upgrade bios or use force_addr=0xaddr
and you'll want to fix that before doing anything else. The Fedora16 VM doesn't produce this error so Fedora users can skip straight to the guest addition installation instructions. I wrote a short post about this error last year but to save you having to go there to read that post the fix [Credit for that fix goes to http://finster.co.uk & Karl Foley] is:
- Start a terminal
- sudo vi /etc/modprobe.d/blacklist.conf
- Add the line blacklist i2c_piix4 to the end of the file and save
- sudo update-initramfs -u -k all
- sudo reboot
There are just a couple of things you need to do before installing guest additions. No matter which distro you have chosen as your guest os for your Virtual Machine.
- Use your distributions update manager to install any updates released since the installation iso was created.
- install (if they haven't already been installed) gcc, kernel headers and other essential tools and utilities that compiling C programs require for your distribution. In Debian or Ubuntu you would open a terminal and type
sudo apt-get install build-essential
Fedora uses a program called yum instead of apt so for Fedora the command would be
sudo yum install gcc kernel-headers
[sudo allows you to run a command as root without actually knowing the root password if you have been authorized to do so. In Debian and Ubuntu the user you created at installation has already been authorized. in Fedora and other distributions this might not be the case so you'll have to lookup how to do this in the distributions documentation or on google or bing or your favourite search engine.]
When that has completed you should have a screen looking vaguely similar to the one below.
Click in the menu item labeled Devices
Select the Install Guest Additions menu entry
After a few seconds a CD icon will appear on your desktop and a dialog asking if you want to autorun the CD will popup
Click the OK button and a new dialog will open
A final dialog will popup asking you to enter your password
Enter your password and click the Authenticate button and after a few minutes you have a screen that looks similar (exact on Ubuntu, vaguely the same on Debian and Fedora and other distributions) to the following screenshot
Press enter to close the terminal. Right click the CD icon on the desktop and click eject
then reboot your Virtual Machine.
If everything went to plan then you'll now have a working VM with the ability to cut & paste between it and your host operating system, USB support, better graphics support (larger screen resolutions and 3d/2d acceleration...), shared folders between the VM and the host os and a few other bits and bobs. It is also now I do things like disabling the screen saver in the VM and changing the desktop and gdm wallpaper/splash screens but as they don't affect the purpose of the VM I won't document how to do that but will leave that for the user to discover how to do it.
This post was going to continue to the completion of the VM with Scratchbox2, qemu and a seed rootfs installed and configured but this post has gotten rather long so actually stop this post here and complete everything in a following post.
Last week I released version 0.2 of the Raspberry Pi development VM and I thought that I could safely call it a day because in a few weeks the Raspberry Pi hardware will be available and therefore we will no longer need the VM for software development. So yesterday I announced on this blog and the Raspberry Pi forums that I had decided to EOL the VM and would no longer be updating it as I didn't see the need and i'm not going to have the time to maintain it for the next few months as it takes about 12 to 14 hours to create, configure and upload, 8 to 10 hours of that is uploading using all my upstream bandwidth which is no longer feasible for me to do again until after June.
However, almost immediately after posting that I started to receive tweets and PM's asking me not to stop working on the VM or to at least write detailed instructions on how to create your own VM for Raspberry Pi (or other ARM based devices) from scratch. Yesterday I also finally managed to get SDL programs working correctly, not that I had actually tried that hard previously as the majority of software I was personally interested in building and porting to the Raspberry Pi are text based and at most use ncurses. So although I really won't have time to work on upgrading, tweaking and maintaining the VM personally I have decided that it should continue to live in the form of detailed instructions on how to create your own Raspberry Pi development VM, which is almost mostly transferable to other ARM based devices as well, it's actually pretty much transferable to any device that qemu will emulate but that is beyond the scope of this how-to.
- If you don't already have Virtualbox and the Extension pack installed then you'll need to download it from https://www.virtualbox.org/wiki/Downloads, choosing the correct one for your platform and also download the Extension Pack from the same page if you haven't already installed it. Once you have downloaded and installed Virtualbox+Extension pack for your platform move on to step 2.
- Now you'll need to decide which Linux distro you want to use for your VM. I suggest Debian, Ubuntu or Fedora. You can use any that you want but those are the only 3 that I have any personal experience with for installing and using Scratchbox2. When you have decided download the installation iso for that distro. I'm going to use ubuntu in this guide as although Fedora and Debian work and works well they do require a bit more setup for Scratchbox2 than Ubuntu. You can download the Ubuntu iso from http://www.ubuntu.com/download/ubuntu/download
- Once you have the Ubuntu iso downloaded, start Virtualbox and create a new Virtual machine by clicking the New button.
- Virtualbox will then start the Virtual Machine Wizard.
- Give your VM a name. I suggest something like RaspberryPi Development. Choose Linux & Ubuntu from the dropdowns (or if you are not going to use Ubuntu as the guest os then select whichever distro you are going to use). It should look something like this
-
- Choose the amount of memory to allocate to the VM. I normally just accept the default. Ubuntu normally asks for 512MB, Fedora 738MB and Debian is normally 384MB
-
- Create a virtual harddisk.
choose VDI
Dynamically allocated
Make it at least 16GB big
Click the Create button
After clicking the Create button another dialog may popup and give a summary of the settings you asked for. if it does click the Create button on that dialog. You will then be returned to the main Virtualbox screen
- With the VM you have just created highlighted click the Settings button.
- You can leave most of the settings as their default settings.
-
- The only setting you MUST change is storage.
- The storage settings screen may look slightly different to the above as your Virtual harddisk may be on the emulated IDE controller. Personally I prefer it to be on the emulated SATA controller as it seems to be faster and less resource hungry but it's entirely up to you and YMMV but for the basis of this guide it doesn't matter which it is on.
- Click the little CD icon and add the iso you downloaded earlier
- Click OK
- then click Start
- You may now install your choosen Linux distribution as you normally would.
This ends part one. When my copy of Ubuntu has installed i'll post part two which will cover installing guest additions and installing and configuring scratchbox2, qemu and a seed rootfs.
[update: looks like i EOL'ed the VM a day or so too soon seeing as I now have SDL working correctly (mostly) in it now. I'll either do one more release or roll a script and detailed instructions on how to install and configure scratchbox2, qemu and a rootfs (and sbrsh/sbrshd for using the real raspberry pi hardware with scratchbox2) before I do actually EOL it. It might take me a day or so to get to it though.]
In a few weeks we'll have our sticky paws on the real Raspberry Pi hardware which on the whole will obsolete the current VM. I could build sbrsh/sbrshd (mount nfs on the real hardware and use that for cpu transparancy, currently using qemu) which might be useful and there are a couple of tiny buglets and uglyness that I could fix but as it takes about 4 hours to create and clone the vm and configure everything and about 8 to 10 hours to upload somewhere using ALL my upstream bandwidth is it worth it?
I don't mind continuing with the VM if anyone else really wants/needs it but if it's only me that is using it then i'll probably not bother as the VM is good enough for a few more weeks until i/we have the real hardware and i'm kind of running short of tuits for anything that isn't related to a couple of projects i'm currently working on at the moment that will enable me to afford the odd raspi, one, three, fifteen...., but I don't want to leave anyone in the lurch if they really use the VM and would prefer not to have to set it up themselves or don't know how to do it.
So can i have a show of hands in the comments of who would like me to do another release of the VM and/or add sbrsh/sbrshd.
[Disclaimer: All opinions in this post are mine and mine alone. Although I am a moderator on the forums on http://raspberrypi.org I don't speak for the foundation and any factual errors, upset I may cause or spelling mistakes are completely my responsibility]
I took a bit of a break from writing this series of posts while I did some work on the development vm which I could do lying down using my eCafe Slim ARM based netbook (ta muchly Obarthelemy) as i'm still in a bit of pain from various aches and pains that being an old fogie seem to bring so sitting down typing for long periods is a right PITB. Now get off my lawn you darn kids. I also wanted to spend some time doing some research for a non-Raspberry Pi related project (although I might try to bring the Raspberry Pi into it if I can at some stage if I can).
So where were we upto at the end of part two? Ah yes The logo competition and MakerFaire NY 2011. i did mention MakerFaire and post a video of Eben's presentation a MakerFaire but I'll expand on that a bit for this post.
MakerFaire NY 2011 was on the 17th & 18th of September and thanks to DigiKey's twitter account I was able to wangle two free tickets, I actually ended up with three free tickets because there was one in the Open Hardware Summit goodie bag but I gave the that one to one of my wife's work collegue's who is a bit of a caffine addict and geek.
Eben, Liz and the Raspberry Pi Alpha board (not neccessarily listed in order of importance) were only going to attend on the Saturday because they were on their way to the west coast and were just killing two birds with one stone and splitting a 12 hour flight into two six hour ones and using the layover as an excuse/opportunity to attend MakerFaire and show off the Alpha board.
So as travelling from Brooklyn to Queens and back again on the subway especially on the weekend is a real PITA and I didn't fancy doing it two days in a row I decided to go on the Saturday. I didn't want to waste the extra ticket so I bullied and nagged my son into coming with me and after a lot of muttering under his breath about how getting up at 8am on a Saturday was cruel and unusual punishment and was banned by the constitution and that he'd sue me for civil rights offenses, whose bright idea was it to let him do the constitution law class at university????, he agreed, after I told him there would fire and explosions and stuff, that it might be fun after all and that he'd come. He's a bit of a luddite, I really don't know where I went wrong bringing him up but he has no real interest in computers other than a tool to do his college work; go facebook & youtube and to watch his anime and read his manga.
[edit for boring bits and skip forward to September 17th at 10am at the main entry gate to a lawn outside the NY Hall of Science.]
Some how or other I, and my son, were first in line to get in
although they were about 15 minutes late in letting us in as they had to find the waiver forms that you had to sign if you actually wanted to do some soldering, climbing on stuff or anything that might lead to be you cooked, squashed or blown up etc. Once they let us in we did a quick run through all the stands and tents to see what & who were there and made notes on where we'd like to spend a bit more time looking and talking to people and went off to the help desk to find out where Eben, Liz and the Alpha board were to be found as on our first pass through I hadn't spotted them. The help desk said they should be in a big tent towards the rear of the area so I dragged my son away from the lock picking demonstration and went back to where the Raspberry Pi was suppose to be. Still no Liz, Eben or Alpha board
So I went to one of the other help desks and they confirmed that the Raspberry Pi table was supposed to be where I had been told previously so I told my son to go have a wander and i'd either be at the tent where we were told that Raspberry Pi would be, at the coffee truck or in another tent where there was something I wanted to look at, The CortCyberex AV, as I was due to receive one for my Kickstarter pledge for the CyberCortex AV. It was now approximately 11am and no sign at the Raspberry Pi table, although there was now a table in the space they were supposed to be
which was an improvement on the previous walk around. Some of you might be wondering why I was so antsy about the Raspberry Pi as there were lots of other interesting things to look at and do. The main reason was of course to see the Raspberry pi Alpha board in action and to finally meet Eben & Liz but there was also another reason as well. Liz had promised to bring me a 6 pack bag of Twiglets :) I also had a small present for them too.
It was now about 11:15am and as there was no sign of the Raspberry Pi i wandered over to talk to Bryan Pape about the CyberCortex AV and look at some of his demo's for a while and keep an eye open for Liz & Eben as I could just see the table where they were supposed to be from Bryan's table. After talking to Bryan for about 25minutes I looked over and there was someone sitting at the Raspberry Pi table. Female check, looked a bit like Liz's forum avatar check, sitting at the raspberry Pi table with a ruddy great handbag that looked like it could hold a large bag of twiglets check. it could only be Liz! So I finished my currrent conversation with Bryan and ambled over and asked "Liz?" and the currently unidentified female said yes. YAY! a fifth of who and what I had come to see had actually arrived. I was doing well, I had completed three fifths of my goals for the day, actually a little under as I hadn't yet gone to pick up the freebies that I had coupons for from the Open hardware summit goodie bag.
Liz said Eben had gone off to look for the HDMI monitor or TV they had requested and for electricity as there currently (pun sort of intended) wasn't any available and that he'd be back soon. We swapped presents
Liz gave me twiglets and I gave Eben & Liz a Zipit Z2 (a tiny clam shell ARM, pxa270, based IM device that has been hacked to run debian, openwrt...) that I thought they might like to have to mess around with in there spare time (right they have spare time) and let me have a look at the Alpha board by which time Eben had returned.
One of the reasons other than the obvious to see the Alpha board and obtain twiglets, that I wanted to meet Eben & Liz is that it turns out he went to school with someone I knew in the late 80s so after he'd said electricity was coming and the organisers were looking for a monitor or TV that had an HDMI input we had a discussion about how he knew our mutual acquaintance and how I did.
It was now about noon and still no monitor but there was electricity and the Raspberry Pi table was surrounded with people asking Eben & Liz questions about the foundation, the raspberry pi, the alpha board, expected selling date etc.
I might be off recalling the exact time the monitor with HDMI arrived, i'd asked Bryan if any of his monitors had an HDMI input and if he'd got one spare that I could borrow until the one the organisers of MakerFaire were trying to obtain arrived but unfortunately all his monitors were VGA input and if i'd got to the stage where I was going on a scrounging mission it had to be at least 12:30pm probably nearer 1pm when a suitable monitor arrived at the Raspberry Pi table.
Eben quickly plugged everything in and booted the Alpha board they had brought with them and started a movie trailer playing, I think it was the star trek trailer, i was blown away by how good the trailer played. The table now started to get swamped with geeks three deep all asking questions and admiring the alpha board. this went on almost until it was time for Eben to give his 5 minute presentation at 5pm. The area where he was to give his presentation had been used throughout the day for other projects to give short presentations and while it hadn't been empty for those presentations it became almost standing room only when Eben was due to speak. As Liz was going to be filming Eben's presentation she left acfaizer and myself in charge of her handbag and the Alpha boards. acfraizer and I did discuss maybe accidently walking off with the alpha boards but decided it'd be too obvious that we had half-inched them.
[i've already posted the video of Eben's presentation but i'll do it again]
Click here to view the embedded video.
As it was now around 5:30pm I once again dragged my son away from the lock picking demonstration and tutorial area, said good bye to Eben, Liz and the Alpha board and we made our way home, with a quick stop when we got out of the subway station near home to pick up chinese for dinner.
I think this is enough writing for now. I promise we'll get to the beta boards eventually I am just too knackered to write anymore today and it's time for my mid morning nap ![]()
[Disclaimer: All opinions in this post are mine and mine alone. Although I am a moderator on the forums on http://raspberrypi.org I don't speak for the foundation and any factual errors, upset I may cause or spelling mistakes are completely my responsibility]
I just put together another quick screencast of the development vm in action. A tiny bit more complicated than tiny basic for curses this time as i had to install a library and edit the makefile a tad and i also ran the test suite inside sb2 as well.
Click here to view the embedded video.
ok enough messing around with the vm for the time being. it's time to start writing the raspberry pi (part three) blog post.
I just did a quick screen capture video of the Raspberry Pi development VM in action and have uploaded it to youtube. I'm not very good with making screencasts so please forgive how rubbish it looks.
[update: There is a tiny little buglet in the vm that slipped passed me as it didn't crop up when I was testing that yum worked as I didn't install a library that needed to go in the top level of the rootfs. If you get a lot of errors about unpacking or mkdir... when trying to install something using yum then you'll need to do the following
cd $HOME/raspberry_pi_development/f13arm_rootfs
sudo chmod -R 777 *
and that should fix it. sorry about that.
the torrent is now available.]
I have put together a new VM for developing software for the Raspberry Pi. I've made a few tweaks and cleaned up a lot of stuff and it's a much more pleasant setup and easier to use and update without making a whole new VM. I also used fedora13 for ARM as the seed rootfs so it should be possible to just swap files from/to a real Raspberry Pi and it should just run and you can update the seed rootfs as well (hopefully I guessed Raspberry Pi standardized educational disto correctly). I was planning to use fedora16 as the guest OS in the VM but after struggling with some of it's foibles for several hours and having to rebuild it a few times i gave up and reverted back to a ubuntu based release. it's currently compressing and uploading and with my upstream speed being so rubbish it'll take about 8 to 18 hours to finish but once it is finished i'll post a link to it and hopefully someone will make a torrent of it.
http://russelldavis.org/RaspberryPi/raspberrypi_dev_vm_02.torrent
Below is the README that is included with the exported appliance.
-------
RaspberryPi Development Virtual Machine 0.2
This is an exported virtualbox virtual machine for developing software for
the RaspberryPi. It is setup using the git versions of scratcbox2 & qemu (19/01/12), the fedora 13 for ARM as rootfs seed & arm-2011.03 codesourcery toolchain.
The root password is toor and the username and password for the normal user
is raspberry/password
To compile software for the raspberrypi as you would normally on an x86 machine
prefixing sb2 to any command. e.g. instead of gcc hello.c -o hello you would type sb2 gcc hello.c -o hello
To update, install or remove libraries and software in the seed rootfs use the command sb2 -eR yum ... where update, install, remove etc.
If you want to build and install libraries to use when building other software
that are not availble via fedora yum then rather than prefixing with sb2 prefix the command with sb2 -eR e.g. sb2 -eR make && make install
You can upgrade scratchbox2, qemu, the rootfs or toolchain quite easily as they are all in seperate dirs inside the raspberry_pi_development directory. it shoudl be possible to just swap them out when/if you need/want.
I have installed apache2 adn linked the $HOME/build directory so you can download anything you build to another system. You will probably want to change the network settings for the VM from NAT to Bridged though.
An ssh server is also installed so you can ssh in to the vm if you want as well (same proviso as above though. You'll need to change from NAT to Bridged to get it working).
If you have any other questions about the VM then you can send them via my blog (http://russelldavis.org) or post on the raspberry pi forum. (http://raspberrypi.org)
I have added one of my favourite bash aliases to the .bashrc doch is very handy in case you forget to use the sudo prefix to a command. just type doch and it'll redo the command but with sudo added.
Russell Davis (ukscone) 20/01/12
Tutorial - Python - Space Invaders
Mark Trantor
Here it is, Mark Trantor's Space Invader game tutorial, based on Liam Fraser's Pi Shooter tutorials.