Tuesday, April 22, 2008

Gumstix - Missing Bluetooth Serial Port

I've been rebooting my Gumstix quite a lot and sometimes removing the Bluetooth pairing from my Mac.  When I try to pair the Mac and Gumstix again, quite often the serial port does not show up.  The only way I have found to get around this is to reboot and try pairing as soon as it is booted, if I leave it for a while I don't see the serial port.  Simply restarting the bluetooth software using:

/etc/init.d/bluetooth restart

does not work.  I am investigating ...

Monday, April 21, 2008

Gumstix - Forgotten the root password?

If you need to reset the root password on your Gumstix and don't want to reflash it you have to run Linux in single user mode. You do this by replacing the normal initialisation program with the shell.

Change the standard bootargs (your line may differ from mine) from:
bootargs=console=ttyS0,115200n8 root=1f01 rootfstype=jffs2 reboot=cold,hard
bootargs=console=ttyS0,115200n8 root=1f01 rootfstype=jffs2 reboot=cold,hard init=/bin/sh
NB: The above bootargs lines are single lines, they have been wrapped by the browser.

You can change the line and reboot with the commands:

GUM> setenv bootargs $bootargs init=/bin/sh
GUM> boot

When the kernel boots you will be presented with a shell prompt, you can change the password using the passwd command.  Here is the output when changing the password to gumstix.  The word gumstix will not actually be echoed back to you but I have shown it here to show where it is entered.

$ passwd
Changing password for root
Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.
Enter new password: gumstix
Bad password: too simple.

Warning: weak password (continuing).
Re-enter new password: gumstix
Password changed.
$ reboot

Gumstix - The Bluetooth passkey

I installed a new OS into my Gumstix and then tried to pair the Bluetooth device with my Mac.  It failed because it would not accept the passkey.  I had to log into the Gumstix using the serial port from a PC and hunt around the system.

In /etc/bluetooth/hcid.conf you will find the passkey that you have to tell the Mac about.  Here is the relevant part of my file:

# HCId options
options {
        # Automatically initialize new devices
        autoinit yes;

        # Security Manager mode
        #   none - Security manager disabled
        #   auto - Use local PIN for incoming connections
        #   user - Always ask user for a PIN
        security auto;

        # Pairing mode
        #   none  - Pairing disabled
        #   multi - Allow pairing with already paired devices
        #   once  - Pair once and deny successive attempts
        pairing multi;

        # Default PIN code for incoming connections
        passkey "BlueZ";    

There's the default password, this image is using BlueZ. You can either use this value as it is or edit it and use your new value.  After editing the file (if you choose to do this), you must restart the Bluetooth subsystem either by rebooting the Gumstix or by using the command:

/etc/init.d/bluetooth restart
Now you can use your new passkey for pairing from your host computer.

Gumstix - Getting started with Bluetooth

I've just been given a Gumstix so that I can put some of my software onto it and use it for demos.  It has taken a little time to feel comfortable with it so I thought I'd share some of my experiences and give a few pointers into the bewildering pages of documentation out there.

These notes are just my experiences with my particular Gumstix and my MacBook Pro.  I have a connex 400mt-bt.  It is a 400MHz ARM processor with 64 Mbytes of memory, 16 Mbytes flash and Bluetooth on board. I received it with a Compact Flash card adaptor, a wifi board and a USB adaptor which will supply power to the motherboard.  It also came with a serial card and a cable to plug into a PC DB9 serial port.  The Gumstix runs Linux which takes up around 9 Mbytes for the whole system!  Since my Gumstix had been used by someone else, it had an operating system on it already, more in a later post about replacing it.

I first tried the Gumstix with my MacBook Pro.   I put the BT antenna onto the motherboard and added the USB board. I then plugged it into my Mac's USB port.  A little light came on. Great.

I tried to connect to it using Bluetooth. The BT models have a BT serial port for talking to the Linux system on board.  This is covered in an excellent page, with pictures entitled Bluetooth on OSX.  Here are my distilled instructions for doing this (note the passkey may be 1234 or it may be BlueZ)
  1. Run the B setup assistant
  2. Select Any device
  3. Select the device called Gumstix (0)
  4. Click on Passkey options and select Use a specific passkey. This is because unlike a keyboard you have no way of entering the random number that you are normally given for pairing.  The Gumstix has a passkey built in so you have to tell your Mac what it is so it knows what to expect.
  5. On the next screen you are asked to give the passkey that the Gumstix will send.  When I first got the Gumstix the passkey was 1234, when I put another system into it the passkey became BlueZ, so if one fails try the other.
  6. The Mac will then add the Gumstix to its list of devices.
If all went well that is all you have to do because the Mac sets up a special serial port for you to communicate with the Gumstix.  

To talk to the Gumstix, you simply have to start a terminal and then run one of my favourite programs - screen (before we had windowing systems I used to use screen to give myself multiple logins to the same machine and it also allowed me to login at work, start jobs, go home, dial in and pick up my session. Those were the days!)

Ok, back to business, at the terminal prompt enter:
  • screen /dev/tty.Gumstix-1 921600
Press return a couple of times and you will get a login prompt and will be able to log in. To leave screen enter: ^Aky  - that is three characters: control-A, k and y.

I have done this procedure several times now and a couple of times no serial port was set up.  In this case you have to add it yourself, here is the relevant window under Leopard:

If no ports are shown, click on the + and add a port.