Monday, January 10, 2011

Ubuntu in Windows with VirtualBox

I've used Windows all my computing life, and will for the foreseeable future. However, for certain things, it's very useful, sometimes necessary, to have a computer running Linux available for use. I tried setting up a separate computer for this, but I goof off often enough that it wasn't working out.

Enter VirtualBox. It lets you set up virtual machines running "guest" operating systems within your "host" operating system. Someone's already made an excellent tutorial on setting up VirtualBox on Windows to run Ubuntu: http://www.psychocats.net/ubuntu/virtualbox

I am running Windows 7 as my host OS and Ubuntu 10.10 Desktop as my guest OS, with Virtual Box 4.0.


Virtual machines have been around for a while, and Windows 7 Professional actually includes a downloadable feature called XP Mode to run Windows XP on a virtual machine. VirtualBox makes it very easy though, the setup required to get to the above screenshot is minimal. Networking worked for me without any extra setup, and keyboard/mouse transitions are almost seamless.

One thing that isn't in the guide above is setting up Ubuntu's resolution to match the VirtualBox window size. It's pretty simple.
  1. On your virtual machine windowbar, select Devices -> Install Guest Additions...
  2. This puts the Guest Additions in the virtual machine's CD drive. Mount it within Ubuntu, by selecting Places -> VBOXADDITIONS_4.0.0_69151.
  3. A window will pop up showing the contents of the CD. There should be a button marked "Open Autorun Prompt". Click it, and let Guest Additions install.
  4. When done, "eject" the CD from the Devices menu, and restart the virtual machine. From now on Ubuntu will resize its resolution to the VirtualBox window size. There's also some other cool features available in the Machine menu, like Seamless Mode.
The last modification I did to my setup was to allow SSHing and SCPing to my Ubuntu machine. VirtualBox necessarily passes all network traffic through the host OS, so an attempt to SSH or SCP to the guest will look like an attempt to the Windows host, which won't work. The solution is to add a networking rule to forward that traffic to the guest. Since Windows doesn't have anything using port 22, we can keep it simple.
  1. Shutdown your virtual machine and close all VirtualBox windows.
  2. Open up a command prompt in Windows. Start -> Programs -> Accessories -> Command Prompt
  3. Execute the following command, replacing YOUR_VM_NAME with your virtual machine's name. This creates a rule called "ssh" for your virtual machine, forwarding host port 22 to guest port 22.
     > C:\Program Files\Oracle\Virtualbox\VBoxManage.exe modifyvm "YOUR_VM_NAME" --natpf1 "ssh,tcp,,22,,22"  
    
  4. Open VirtualBox and restart your virtual machine. You will probably get a Windows firewall alert, allow VirtualBox what it is asking. Your virtual machine can now accept SSH connections from your local network if you're behind a router, or from anywhere on the Internet if you're directly connected or in your router's DMZ. 
That's all the VirtualBox setup I've needed. Almost all the benefits of Linux without the drawbacks of actually switching over!

Sunday, January 9, 2011

Insignia Infocast 3.5"

Best Buy had the Insignia Infocast 3.5" on sale for $40 after Christmas, so I bought one online and finally tracked down a unit for pickup in Glendale last week. It's essentially a rebranded Chumby One, which is a device that nobody legitimately needs to have, but that has found a niche market with people who (among other things) want internet access on their alarm clock. It also runs Linux and is easily hackable by design, which is why I got it.

Insignia Infocast 3.5" from Best Buy
Specifications:
  • 454MHz Freescale i.MX233 ARM "applications processor"
  • 64MB RAM
  • 1GB MicroSD storage
  • 320x240x16 touchscreen
  • 802.11b/g wireless
  • 1x external USB 2.0 port
  • 3-axis accelerometer
  • Internal speaker and microphone
There's also a bunch of hidden features on the board, like a 3.3V serial port, composite video out, and digital I/O pins. The hardware developer has a post about this on his blog.

The first thing to do is to void your warranty and get at the SD card to make a backup copy. Almost all the software is on the card, making it very hard to "brick" the Infocast as long as you can restore the card to its original state. There's also a recovery mode activated by powering on while pressing the touchscreen that can save you from minor mishaps.

1. Carefully remove the volume knob.
2. Remove the back shell, held on by 4 recessed Phillips screws.
3. Separate the shell. It is still attached via the whip antenna.
4. Slide the metal cage to the right to remove the MicroSD card.
Once you get the card out, you can pop it into your card reader and make an image (Win32DiskImager on Windows or dd on Linux). Now if you screw up beyond repair, you can start fresh by reimaging a card. I actually didn't do this until after I'd futzed around a bit, so my image is not quite factory-fresh.

Someone else has done a much more detailed teardown of the Infocast 3.5" (here).

There's a lot that the stock Chumby software can do, including streaming internet radio and looking at pictures of cats, but that's not as interesting as using it as an embedded computer. Most of the related easter eggs are detailed on the Chumby Wiki, which is a good place to start. There's a great guide on how to strip down the Chumby One, which I used as a reference to create my own startup scripts.

My barebones boot screen
I assigned a static IP to the Infocast, put it on my router's DMZ, and registered a hostname with a free dynamic DNS service (dyndns.com), pointing to my cable modem's IP that changes every few days. The Infocast is running a dynamic DNS client (inadyn) that updates DynDNS whenever this happens. Note, if you do this, you should set passwords for the root and default users (or disable SSH access).

Next up I think I'll play with the accelerometer and drawing things on the screen. Eventually I'd like to get it interfaced to a UVC webcam.