Tuesday, April 20, 2010

Toshiba Portege R100 Upgrade and Reformat

Tales from my first adventure into the ultra-portable computing world.

UPDATED: 4-20-2010 with Ubuntu 10.04 Install Info

This whole thing was sparked by white, dimunutive, sub-laptop I saw on campus called the Asus Eee PC. I immediately knew I wanted one. While doing some research on the Eee PCs I ran into a user review of an 2G Surf Edition. The reviewer was dissatisfied with the speed and screen size, (a minuscule 7" LCD), and gave the suggestion that the Toshiba R100 with a larger 12.1" LCD and more processing power and storage can be had on eBay for about the same price of an Eee PC 4G Surf. I did exactly that.
After reading up on the R100s I picked one up from a seller in Montana for under $400 shipped. Upon receiving it, it sat on my desk taking up only 11.25" by 9" and only 0.65" thick, (take that MacBook Air!) and weighed a tad over 2 pounds. It was the base model with a 1.0GHz processor, 256MB ram, and pokey 4200 RPM 40 GB hard drive. All I received with the laptop was the AC adapter, no optical drives, no second battery or recovery media, which would cause me problems later on. It did however come with enough bloatware to choke a horse, which is a good reason why you should always reformat your computers when you get them, new or used. Fortunately the Windows XP CD key was affixed to the bottom of the unit otherwise I probably wouldn't have received that either.

Upgrade Components Selection
The first step in my refurbishment was replacing the sluggish hard drive because one of the appealing features of the Eee PC was its incredibly low boot times and quick responsiveness of the OS even when Windows XP was installed, mostly due to its flash based mass storage. So the hunt began for a SSD hard drive that could replace the irregular 1.8" 50 pin PATA hard drive. I settled on the Samsung MCBOE32G8APR which ended up costing slightly more than the laptop itself. You might think putting such an expensive hard drive in a cheap laptop is ludicrous, and maybe you're right, but I did this more as a hobby than for profit. Along with the SSD, which was available on newegg.com, I ordered a 1GB SODIMM of Crucial DDR memory, a cheapo USB floppy drive and an IDE / SATA to USB converter, (you'll see why I ordered these in a moment). To complete my assortment of replacement parts: a new LCD from ebay for $200, mine had been badly marred from the keyboard hitting the screen when closed, a screen protector from shaggymac.com to protect the new LCD from the same occurrence, an Intel 2200 802.11b/g wireless Mini PCI card, for a cool twenty bucks, to replace the existing wireless card which was only 802.11b. Finally I also picked up a new battery since the the old one gave me about 10 minutes of power. I did some research and found a BTI 1800mAH battery (old one was 1600mAH), part number TS-P2000L, that was marked as a replacement for the Portege 2000, the predecessor to the R100. With the SSD installed, the wireless on and the screen at 3/4 brightness, the new battery gives me about 2 hours of life.

Hardware Installation
Before pulling the old hard drive I tossed in the the new RAM and booted up windows to verify that it would jive with the laptop. It did and windows reported it as 1.25GB of RAM interestingly enough. Installing the new LCD was just a matter of finding the 10 screws, underneath the stick on pads, around the edge of the screen and removing them with a #0 phillips head screwdriver. Its very easy to strip the screws, and one of mine was already stripped from the previous owner, which I had to drill out, so be careful. Now carefully remove the bezel around the screen. A flat head jewelers screwdriver helps to pop the tabs on the bezel loose from the back cover. Pull the LCD away from the lid, starting from the top revealing two electrical connections at the bottom left and bottom right of the screen. Carefully disconnect these and remove the old LCD, drop in the new LCD, reconnect it and boot up the computer to make sure your connections are good. If it all checks out reverse the instructions above to reinstall the bezel. My new LCD gave a huge increase in brightness, almost too bright, and of course the shadows from where the keyboard rubbed the screen were gone. Install the SSD by simply removing the two screws from the hard drive cover, pull the old hard drive away from the ribbon connector and plug in the SSD.
        Installing the new wireless card involves removing the battery, hard drive cover, and the 14 screws on the back side of the laptop. Then carefully pry off the the power button bezel, remove the two screws for the keyboard and unplug the keyboard ribbon cable, and set aside the keyboard. Remove the 5 screws behind the keyboard. Now the back cover can be removed by unhooking the clip near the battery bay first. We now see the wireless card mounted on a daughter card which we must unplug to remove the wireless card. Release each metal clip on the sides of the wireless card, pull the card out, and finally remove the antenna leads. Reverse these steps with the new wireless card and were set. Now were ready to install our OSs.

Windows Installation
I had in mind to dual boot Windows XP Pro and Ubuntu 9.04 Jaunty Jackalope on this machine. So lets get to it. I prepared a nLited Windows install disk, trying to remove as much as possible to make the most of my comparatively small 32GB of storage while keeping functionality for internet browsing, basic networking, watching videos, etc. Make sure you keep the FAT32 to NTFS converter in the installation, we'll need it later. The few things I added to it were Xable's post SP2 lite update pack, Firefox and IE7, AVG free antivirus, Xpize to purdify windows, WMP11, OpenOffice and 7zip. When I was done I had a windows CD that was under 350MB. Now I know what your thinking, we'll just throw that CD in a USB CD-ROM drive, (the R100 has no internal CD-ROM), switch the BIOS to boot from CD and install windows, right? Wrong, the Toshiba R100 with latest BIOS revision 1.6 can only boot directly from a few sources: USB floppy drives, Network PXE, or Toshiba brand PCMCIA / Cardbus CD-ROM drives. PCMCIA CD-ROM drives are very hard to come by and if you do find one it can cost well over $100, so that was out of the question for me. Network booting is a pain to setup for the first time so I settled on USB floppy boot augmented with a USB CD-ROM.

Booting the Unbootable
After some research I found a site that hosted boot disks specifically for the R100. I tried all three but what ended up working for me was the official Portege R100 Recovery Boot Disk v1.1. Its a little executable that will format and place a Windows 98 based boot disk on a floppy for you, with CD-ROM drivers and a few tools. The standard Windows 98 bootdisk would probably work as well. Once it finished making the floppy I added the following utilities from this site: smartdrv, fdisk, and format.com to the tools directory. Using the IDE to USB converter I had bought previously, I connected the oldest CD-ROM drive I could find, (after all were dealing with Windows 98 here). It ended up being a HP CD-Writer Plus 8100 I pilfered from my roommate. I set the BIOS to boot from floppy first and put the Windows install image in the drive. One little snag with the official Toshiba floppy boot disk is that it boots the computer but then immediately looks for the Toshiba Recovery CDs in the CD-ROM not having received media of any kinda you might think I was snookered, however once it realizes you dont have the recovery CD in the drive, doing a ctrl+c dumps you into a basic DOS environment where A: is your USB floppy drive, C: is your hard drive D: is the RAM drive it just created and X: is the USB CD-ROM drive. Using fdisk I set up my partitions. I decided to allocate 23GB for Windows and the rest, 9.7GB, for Ubuntu. So we create a primary DOS partition of size 23GB, and set it to active, leave the rest as free unpartitioned space (If you are doing just a single boot windows install make the partition span the entire drive). Then format it to FAT32, (we have to leave it as FAT32 otherwise the alternate XP install program wont recognize it as a drive). Once thats done run X:\i386\winnt. Now were getting somewhere, we're at the standard blue screen, not of death but of life, (BSOL), that is the Windows install interface we're all used to. Make sure you answer yes when asked to convert from FAT32 to NTFS. From here its a standard Windows install and man does it fly on the SSD, the GUI part of the installation which it estimates to take 34 minutes took less than half that to complete.

Completing Windows Installation
Now its a simple matter of grabbing the drivers from Toshiba's website. A good tip here is when you extract the drivers don't run the setup executable that comes with them, just do an update driver in Device Manager and navigate to where you extracted the driver package, find the INF file and click Ok. This hopefully avoids installing any extraneous bloatware packaged with the drivers. I suggest you disable the page file to avoid using up the limited read-write cycles of the SSD. Wrap it all up by installing the hotkey drivers so you can adjust the brightness of the backlight and polish it off with tweakUI and DriverHeaven TuneXP and you're left with a fresh copy of Windows done our way, just like the BK lounge. You'll immediately see just how much quicker the OS is with our new upgrades. To satisfy your inner geek, the HDTach before and after analyses of the hard drives in the R100 are shown above, (how does a 100x improvement in random seek time suit you!).

Ubuntu Installation
Now were just left to install Ubuntu, which actually is a simpler process. First download and burn the Ubuntu 9.04 Alternate CD image. Were going to be following the directions on this page, the section titled The CD approach, but I'll give the gist of what were doing here. Copy and paste the entire CD contents to C:\ubuntu and download GRUB for DOS. Extract just grldr to C:\ the rest of the files in the archive are unnecessary. Append c:\grldr="Install Ubuntu" to c:\boot.ini and create a file called c:\menu.lst with the following lines in it:
Menu.lst
title Install Ubuntu
kernel (hd0,0)/ubuntu/install/vmlinuz root=/dev/ram0 devfs=mount,dall ramdisk_size=17000
initrd (hd0,0)/ubuntu/install/initrd.gz

Now simply reboot with the Ubuntu Alternate installer CD in the drive, and select "Install Ubuntu" twice. Now that the CD installer is going we can setup our partitions. I created an 8.7GB ext4 partition and a 1.25GB swap partition. Based on research here I set the noatime mount option as well. When prompted make sure you mark the Ubuntu Desktop Environment for installation. Step through the installation, its pretty self explanatory and eventually you'll be presented with the Ubuntu desktop.

The first problem I had to solve was setting the display to the native resolution of 1024x768. The old /etc/X11/xorg.conf file is deprecated and wont exist on most systems, including the R100. Based on the output from Xorg -configure I settled on the following xorg.conf file:
Xorg.conf
Section "Module"
Load "GLcore"
EndSection
Section "Monitor"

Identifier   "Monitor0"
VendorName   "Generic LCD Display"
ModelName    "LCD Panel 1024x768"
Horizsync    31.5-48.0
Vertrefresh  56.0-65.0
modeline     "1024x768" 65.0 1024 1048 1184 1344 768 771 777 806 -vsync -hsync
EndSection
Section "Device"

Identifier  "Card0"
Driver      "trident"
VendorName  "Trident Microsystems"
BoardName   "CyberBlade XP4m32"
BusID       "PCI:1:0:0"
EndSection
Section "Screen"

Identifier "Screen0"
Device     "Card0"
Monitor    "Monitor0"
DefaultDepth 16
SubSection "Display"
Virtual 1024 768 
Modes  "1024x768"
EndSubSection
EndSection

Next I set out to solve the problem where brightness changes to the LCD backlight, from unplugging AC power for example, would cause the display to zoom into the upper left quarter of the screen. Ctrl+alt+f1 followed by ctrl+alt+f7 would get the screen back to normal but I needed it to work correctly. The solution was to force the VESA BIOS Extension (VBE) Mode to 1024x768 resolution as well. For Ubuntu 9.04 this was accomplished by editing the /boot/grub/menu.lst file by uncommenting the defoptions line and changing it to defoptions=quiet splash vga=791. Ubuntu 9.10 and above are a bit different as they use Grub 2, instead edit /etc/default/grub and change the line to: GRUB_CMDLINE_LINUX="vga=791". For Ubuntu 10.04 instead leave GRUB_CMDLINE_LINUX blank and set GRUB_GFXMODE=1024x768 and GRUB_GFXPAYLOAD_LINUX=1024x768. Then a sudo update-grub updates all active kernels with the options we just specified.

With our display now perfect we can focus on getting the function hotkeys working.

The easiest way I found was to install an app made specifically for Toshiba laptop hotkeys called fnfx. Installing it was a snap with the command sudo apt-get install fnfxd. Then edit /etc/fnfxd/fnfxd.conf and uncomment the lines for backlight brightness. Reboot and now our function hotkeys are working as well.

Ubuntu Upgrade - Clean Install
To perform a clean install of Ubuntu, as I did when v9.04 came out. First remove the Ubuntu and linux swap partitions. I happened to have Partition magic, which I used to delete and secure erase the Ubuntu and swap partitions. With the boot floppy we created above, boot to the DOS environment and run fdisk /mbr, to restore the default Windows bootloader. Now we're back to a Windows only system from which we can follow the directions above to do a fresh install of Ubunutu.

Well I hope you've all enjoyed the tale of my struggle with the R100 and my eventual victory. I hope the information compiled here will be helpful to someone else working with an R100 or any other laptop with a severe lack of bootable devices.

Monday, January 11, 2010

Chrome userscript to hide iGoogle search header


I found it annoying how much screen real-estate the iGoogle search header and footer took up so I created a quick little userscript to solve this. The script which you can install directly by clicking here, hides the search header on page load and puts a small expander [+] icon in the top links bar to show the header to perform searches, looking something like the following:

The source of this script can be expanded below:



iGoogle Tweaks Source
// ==UserScript==
// @name          iGoogle tweaks
// @author        Eric Hoffman
// @description   Toggle showing Search header, hides footer.  Parts based on script by Mikel Gómez - http://ikax.net?contact
// @version       1.0.0
// @namespace     electronicrandomness.blogspot.com
// @include       http*://www.google.com/ig*
// ==/UserScript==

// Initially hide header
var hdr = document.getElementById('nhdrwrapinner');
if(hdr) {
  hdr.style.display = 'none';
}

// Top links bar.
var b = document.getElementsByClassName('gb1');
if(b[0] && b[0].parentNode) {
  var w = b[0] ;

  // Create show search link.
  link = document.createElement('a');
  link.title = 'Show Search';
  link.href= 'javascript:void(0)';
  link.className = 'fmaxbox' ;
  w.parentNode.insertBefore(link, w);
  link.setAttribute("onclick", "if (this.className=='fmaxbox') {document.getElementById('nhdrwrapinner').style.display=''; this.className='fminbox'; this.title='Hide Search'} else {document.getElementById('nhdrwrapinner').style.display='none'; this.className='fmaxbox'; this.title='Show Search'}");
}

// Hide Footer
var elm = document.getElementById('footerwrap');
if(elm) elm.style.display = 'none';
var elm = document.getElementById('modules');
if(elm) elm.style.marginBottom = '1em';
if(elm) elm.style.borderBottom = '1px solid silver';


This script also works with any iGoogle theme, the header background will be hidden till you hit the expand button

Saturday, August 15, 2009

Custom T-Shirt Printing


I had a couple of t-shirt designs I wanted to have printed. They were simple, logo style with three or less colors. After some research online I found a printing company called Spreadshirt which I settled on because of their unique printing process. Instead of jetting ink onto the shirt, which can result in a blurry image and jagged edges, this company had a process where the shapes are cut out of a vinyl sheet with a CNC style plotter and applied to the shirt. According the the marketing material on their website their process will not fade and supposedly will last longer than the shirt itself.


The image to be printed is required to be in vector graphic form. A great program I found to do this for free was Inkscape, a great companion to the Gimp. With these two programs the amateur image editor doesn't need Photoshop. My two designs had to do with the Valve game Portal. Aperture Labs is the company who invented the portal gun and built GLaDOS (Genetic Lifeform and Disk Operating System), the sadistic artificial intelligence from whose clutches you must escape. My final designs were as follows:


With my vector designs in hand the images must be submitted for review for manufacturability. After passing the review process the images appear in your control panel where you select the vinyl color for each section, the shirt or product for it to appear on, and its size and location on the product. They have about 70 different colors and textures of vinyl and a large selection of shirts, including some high quality american apparel shirts which I used. Your designs show up in the control panel, looking something like below, where you can select the color for each region, the size and location of the design on the shirt or product. I ended up changing the order of the colors in my GLaDOS design in the control panel from their original order in my vector graphics file.

After finalizing my designs I submitted them for manufacturing at a cost of ~$24 a peice including shipping. About a week later I received them in a fedex softpack. A few pics and closeups of them are below.


Overall I was very satisfied with the quality of the print and the sharpness of the edges of the designs. No real flaws to speak of. If you are looking to design a logo style T-shirt, I highly recommend spreadshirt.com. If you are interested in buying my designs, you can get them here.

Monday, August 3, 2009

Exporting Contacts from Motorola phones to a Google Account

How to export phone numbers from a Motorola phone to your Google account

I was upgrading from a Motorola Z3 RIZR to a HTC Magic / G2 (aka T-Mobile myTouch 3G with Google ::rolls eyes::) which required me to get the phone numbers off the old phone and into my Google account. So instead of manually typing my numbers into Google contacts, which is for suckers, I automated the process. This is how I did it.

P2KTools Info
First you need an utility to connect your phone to your computer. The first one I tried which worked well out of the box was P2KTools. I'm sure there are other utilities that work equally as well. P2K is the name of Motorola's file system, so a lot of the utilities will refer to this. P2KTools is free, the website is in Russian, however there is an english translation for the program itself which makes it very usable. Get the program and the Motorola USB driver from P2KTools' website. I used version 3.0.9 build 961 and Motorola Handset USB Driver v.3.7.0 for Windows (32-bit) OS. First install the Motorola USB driver and then extract P2KTools.

Before you launch P2KTools, edit the following lines in config.ini to make it a bit more usable (i.e. readable, unless you speak russian):
Config.ini Changes
[General]
Lang=english.lng
Skin=office2007.skn
;...
[P2K_Mode]
OtherFeaturesFile=other_features_en.pof
;...
[AT_Mode]
BaudRate=57600

P2KTools Screen Shot
Now you may launch the utility. Click the big cellphone button at the top left and select AT Mode. Go to the phonebook section if you're not there already. The status at the bottom left should say connected and the model number of your phone. Click the refresh button to download your phonebook. You should see something like the picture to the right:
Now to export the phonebook click the Backup button at the top. Select Save only phone memory: Old MPT format (without extended fields). Save the phonebook as default.csv file (my perl script defaults to that file name). Make sure it is saving as .csv not .pt3, if not you may need to switch to another export format and then switch back, which is a small bug in the program.

Conversion to Google Format
After the export you should have default.csv file with the following format:
P2KTools Phonebook Output Format
CATEGORY;1;General;255;255
PHONE;1;MeganFox;5555551234;3;0;255;0;1;2;255;255;0;VERSION2;;;;;;;;
PHONE;2;KristenBell;5555553421;3;0;255;0;1;1;255;255;0;VERSION2;;;;;;;;
PHONE;3;KariByron;5555554312;1;0;255;0;1;1;255;255;0;VERSION2;;;;;;;;

Which isn't exactly what I would call comma separated values (.csv)

Now we must convert this to a format that your Google account can import. To do this automatically I wrote this perl script whose source can be expanded below:
processContacts.pl Source
#!perl
#
# processContacts.pl - Converts P2KTools phonebook export format to google
#     account import format.
#
# Usage: processContacts.pl [inputfile.csv] [outputfile.csv]
#
# Author Eric Hoffman
#
# Limitations:
#     -Only recognizes Mobile, Home, and Work phone types (the rest need to be added)
#     -First and Last name are split on second capitalized letter (so weird
#          capitilization in first names can cause the second part to be in the
#          last name field)
#     -Ignores contact groups
#     -Input format is fixed to the following format:
#          CATEGORY;1;General;255;255
#          PHONE;1;MeganFox;5555551234;3;0;255;0;1;2;255;255;0;VERSION2;;;;;;;;
#          ...
#     -Output format is fixed to the following format:
#          Name,Given Name,Family Name,Phone 1 - Value,Phone 1 - Type
#          Megan Fox,Megan,Fox,5555551234,Mobile
#          ...
###############################################################################
use warnings;
use strict;
use Text::CSV_XS;

#default file names
my $inputFile = "default.csv";
my $outputFile = "output_default.csv";

#process input args
my $help = 0;
if($#ARGV == 0 || $#ARGV == 1) {
    $inputFile = $ARGV[0];
    if($#ARGV == 0) {
        $outputFile = "output_".$ARGV[0];
    }
    else {
        $outputFile = $ARGV[1];
    }
}
elsif($#ARGV > 1) {
        $help = 1;
}

#check and open input file
print "\nAttempting to open $inputFile for processing, outputting to $outputFile ... ";
my @contactsLines;
if(!open(CONTACTSIN, "<$inputFile")) {
    print "Failed!\n    Can't open $inputFile: $!\n\n";
    $help=1;
}
else {
    print "OK\n\n";
    @contactsLines = <CONTACTSIN>;    
}
close CONTACTSIN;

#print help
if($help) {
    print "Usage: processContacts.pl [inputfile.csv] [outputfile.csv]\n";
    exit 1;
}

#open output file --Will overwrite existing file name!--
open(CONTACTSOUT, ">$outputFile") or die "Can't open $outputFile: $!";
#print column names for google import
print CONTACTSOUT "Name,Given Name,Family Name,Phone 1 - Value,Phone 1 - Type\n";

my $csv = Text::CSV_XS->new ({sep_char => ';'}); #semicolon seperated .scsv?
my $name;
my $givenName;
my $familyName;
my $phone;
my $phoneType; #0 -> work, 1 -> home      , 3 -> mobile   Unknown: fax, pager, other,
my @typeReplace = ("Work", "Home", "Other", "Mobile", "Other", "Other", "Other", "Other", "Other");

#Walk through lines in contacts file, putting into $_
for(@contactsLines) {
    my $curLine = $_;
    if($csv->parse($curLine)) {
        my @field = $csv->fields;
        if($#field >= 14) { # first name     last name            distinguished by captalization only
            if($field[2] =~ /([\w\~\*\-\.]+)([A-Z][\w\~\*\-\.\ ]*)/) {
                $name = "$1 $2";
                $givenName = $1;
                $familyName = $2;
            }
            else { #only first name found in contact
                $name = $field[2];
                $givenName = $field[2];
            }
            $phone = $field[3];
            $phoneType = $typeReplace[$field[4]];
            
            #output to screen and file
            print "    Name \"$name\", first \"$givenName\", last \"$familyName\", phone \"$phone\", phoneType \"$phoneType\"\n";
            print CONTACTSOUT "$name,$givenName,$familyName,$phone,$phoneType\n";
            $familyName = "";
        }
    }
    else { #parsing failure
        $csv->error_diag();
        die "parse() failed on argument: ", $csv->error_input;        
    }
}

close CONTACTSOUT;

Put the perl script in the same directory as the default.csv file. Run the perl script, you'll need Active Perl if you're on Windows. You can just double click the script to run it if you've used the expected input file name. The script has a few limitations, the main ones being: first and Last name are split on the second capitalized letter regardlessly, contact groups are ignored, and the input format is fixed at the above format.

Now we have a true .csv file which your Google account can understand. Which should look like:
Perl Script Output Format for Google Import
Name,Given Name,Family Name,Phone 1 - Value,Phone 1 - Type
Megan Fox,Megan,Fox,5555551234,Mobile
Kristen Bell,Kristen,Bell,5555553421,Mobile
Kari Byron,Kari,Byron,5555554312,Home

Importing to Google
Open up Gmail Contacts and click Import at the top right, select output_default.csv. Its best to add these new contacts to a new group so its easier to manage them at first, so add to a new group called Phone. Now with the contacts imported Gmail makes it very easy to merge any contacts with multiple phone numbers into one contact by highlighting multiple entries and clicking merge these contacts. Also you can merge your phone contacts with the contacts you already had in Google. Finally setup your contact groups as you like. If you complete all of this before setting up your new Android phone, when you turn it on for the first time all your contacts will be downloaded to your phone automatically!

Hope this was helpful and happy Googling.