Monday
May072012

N900 development using OSX

Tuesday, 8 May

Now using the Qt SDK v1.2.1 on a Mac. I don’t yet know if it will work well as a way of developing on an N900 - but I now know that I have to use Wi-Fi and not the USB in order to connect.

Monday, 7 May

This post is likely to be updated quite a few times …

 

  1. See the earlier post about getting a USB connection
  2. I’m now using Ubuntu 12.04 LTR desktop 32-bit
  3. I’m following http://wiki.maemo.org/Documentation/Maemo_5_Final_SDK_Installation
  4. On my Linux guest, I needed to add a new apt source: this is so far undocumented:
    sudo echo "\ndeb http://scratchbox.org/debian hathor main" >> /etc/apt/sources.list
    and then (and only then) does an apt-get update work.

 

Monday
May072012

Host IP when server brought up in a virtual host

I often need to bring up servers within my dev laptio, and use both VMWare Fusion and VirtualBox. One thing which I nice to have is the guest server’s IP address on screen shortly after startup so that I can ssh into it.

There’s two parts to this:

  1. a script to show the IP information
  2. an entry to call this script when the server (the guest) starts

 

the script

#/bin/sh
# Network interfaces can take a while to come up, esp with DHCP
sleep 5

# What is our current IP address?
CURRENT_IP=$(/sbin/ifconfig | \
  grep "inet addr" | \
  grep -v "addr:127.0.0.1" | \
  awk '{print $2}' | \
  cut -f2 -d':')

# If the current IP address is empty, we need to set up networking
if [ "x$CURRENT_IP" == "x" ]; then
  echo; echo "Networking is NOT configured! " >> /dev/tty1
  echo; echo "run \"system-config-network\" straight-away! " >> /dev/tty1
  echo; echo "then run \"service network restart\" to enable en0 " >> //dev/tty1
else
  OLD_IP=$(cat /root/.ip_info.dat 2>/dev/null)
  if [ "x$CURRENT_IP" != "x$OLD_IP" ]; then
    echo; echo "Update your ~/.ssh/config " >> /dev/tty1
    echo $CURRENT_IP > /root/.ip_info.dat
  fi
  /sbin/ifconfig | grep "inet addr" >> /dev/tty1
fi
I saved this as /root/.ip_info.sh and made it executable. Note that it’s Unixy.

Entry to call the script

If you want this on server start, then add the following line to /etc/rc.local
/root/.ip_info.sh &
Friday
May042012

ssh into a Nokia N900 from a Mac over USB

I wanted to play with neasuring mobile network latency, and the Nokia N900 being a phone based on Debian is a great tool for this. As getting this to work as (a) not as simple as “plug it in” as is often the case on a Linux box and (b) a seemingly strange thing to want to do, I thought I’d write it up here.

First up: I needed to SSH from a Mac OSX Lion. It seems that older version of OSX allowed USB interfaces a lot more easily. In System Preferences, Netowrk I cannot create a USB interface (there isn’t an option) and I don’t want to install yet more new utilities as I have enough already thank you very much.

Second up: I am SSHing into a Nokia N900 as I happen to have one. There are a lot of articles about sshing into an iPhone and other devices, but the OS capabilities of the N900 is what I want to use.

Third up: I am sshing over teh USB cable: not over wifi. I will be playing with the interfaces - 3G and wireless - and I want my full keyboard. SSHing in over wifi is straight-forward and if you’re reading this page I’m going to assume you’ve already done that ;-) If not, check out scratching.psybermonkey.net’s how-to - please read the part about changing the default user password as you will that later.

the bad news

OSX: I couldn’t get the Mac to give me a USB interface over which to SSH. I probably wasted 2 hours trying to get OSX Lion to give me a USB networking interface and I couldn’t manage it.

Virtual Box: I couldn’t get the N900 to connect at all to a CentOS 5.6 instance in Virtual Box (yes, I know it’s an old CentOS, but it wasn’t a CentOS issue) due to this error:

Failed to attach the USB device Nokia N900 (PC-Suite Mode) [0211] to the virtual machine CentOS56.

USB device ‘Nokia N900 (PC-Suite Mode)’ with UUID {856379de-9fd3-4682-a9d8-7ec4665cd26b} is in use by someone else.

Result Code: NS_ERROR_FAILURE (0x80004005)
Component: HostUSBDevice
Interface: IHostUSBDevice {173b4b44-d268-4334-a00d-b6521c9a740a}
Callee: IConsole {1968b7d3-e3bf-4ceb-99e0-cb7c913317bb}

 

However, for other reasons, I also have VMware Fusion and that was able to connect.

the good news

  • Fire-up the N900
  • Fire-up (any) unix - in my case  a CentOS 5.7 within VMWare Fusion (Ubunto 12.04LTS works exactly the same too)
  • Read http://wiki.maemo.org/N900_USB_networking
  • Connect the N900 to the Mac USB port (it doesn’t seem to matter which) and connect as “PC Suite Mode”
  • VMWare Fusion | Virtual Machine | USB | Connect Nokia N900 (PC Suite mode)
  • Over on the guest CentOS you’ll see something like the following -which doesn’t matter as I am not trying to use the N900 as a modem for the laptop :-): 

    drivers/usb/class/cdc-acm.c: This device cannot do calls on its own. It is no modem.

  • On the N900, you need to do the following:
    sudo gainroot
    ifup usb0
  • On the guest unix server, become root
  • ifconfig usb0 192.168.2.14 
  • ssh user@192.168.2.15

And if you’ve followed the instructions and first changed the default user password on the N900 as shown in the scratching.psybermonkey.net article, you’re in :-)

Tuesday
Jan172012

vim and too many spaces

When pasting code into vim you can often get some really annoying spacing.

This first command re-indents the file as vim thinks it should be indented. Of course you gotta teach vim the file type you’re working with but that’s another story.

<esc>gg=G

This one deals with repteated (defined here are two or more) spaces characters within a line by reducing them to one for the whole file

:%s/\(\s\)\{2,\}/\1/g
Monday
Jan022012

Nokia Lumia 800

Be careful! This starts the Diagnostic Field Test and makes the “Diagnostics” app visible too for next time.

##634#