Tuesday, December 23, 2008

quick removable drive with omap3

One neat little trick of having an OTG port is the capability to have the board act as any type of device you'd want it to be.. in my case, I wanted to emulate a disk drive for the heck of it..
I found this link particularly useful. g_file_storage.ko which is generated once you enable file storage gadget as a module in the kernel build.
Step 1: create the "disk" - essentially a file
dd bs=1M count=64 if=/dev/zero of=fs
fdisk fs (follow the steps in the link)
fdisk -lu fs
sudo losetup -o 4096 /dev/loop0 fs
sudo mkdosfs /dev/loop0
mkdir r
sudo mount -t vfat /dev/loop0 r
vim r/hellow.txt (put what ever files we want here)
sudo umount r
sudo losetup -d /dev/loop0

ensure that fs file exists in the filesystem of the target
Step 2: load it up..
insmod g_file_storage.ko file=./fs stall=n

where fs is the file which we created in the first place.. and that'z it.. once you connect the musb to a windows PC, it appears as a disk ;)...

Thursday, December 04, 2008

Towards creating a beagleboard NAND recovery script

NOTE: This is a work in progress yet..

Get Code base:
x-loader:
git clone git://www.sakoman.net/git/x-load-omap3.git

u-boot-v1 - omap3:
git clone git://www.sakoman.net/git/u-boot-omap3.git
cd u-boot-omap3
git checkout --track -b omap3-dev origin/omap3-dev
Updated: see here if this did not work..

u-boot-v2:
git clone git://git.denx.de/u-boot-v2.git

omap-uboot-utils:
git clone git://github.com/nmenon/omap-u-boot-utils.git

signGP tool:
wget http://beagleboard.googlecode.com/files/signGP.c

Compilers:
Cross compiler: arm-none-eabi-gcc: 2007q3-53 (4.2.1)
Host compiler: x64bit: (Ubuntu 4.3.2-1ubuntu11)

Build commands:
Before starting the build process, lets set up a simple alias command:
alias mymake='make ARCH=arm CROSS_COMPILE=arm-none-eabi- V=1'

U-boot-arm:
mymake omap3_beagle_config
mymake

U-Boot-v2:
mymake omap3530_beagle_per_uart_defconfig
mymake

X-Loader:
mymake omap3530beagle_config
mymake

[Update: 2008-12-13 - I completely forgot that we need to sign an image for it to boot from nand flash.. :(
once you have the x-load.bin, you need the signGP.c. Build this by the command:
gcc -o signgp signGP.c
Then run signgp from the same directory that x-load.bin is present. this generates a x-load.bin. Let me know if you feel signGP.c should be moved into omap-u-boot-utils..
]

Omap-Uboot-utils:

make

Copy Images:
Assuming a directory structure as in:
omap-u-boot-utils u-boot-arm u-boot-v2 x-load-omap3
Run the following commands:
cp u-boot-arm/u-boot.bin omap-u-boot-utils/images/u-boot-v1.bin
cp x-load-omap3/x-load.bin omap-u-boot-utils/images/
cp u-boot-v2/uboot.bin omap-u-boot-utils/images/u-boot-v2-serial.bin

Execution script file:


#!/bin/bash
if [ ! -w "$1" ]; then
echo "Usage: $0 path/to/ttyDevice"
exit 1
fi
set -x
export PATH=$PATH:.
pserial -p $1 -f images/u-boot-v2-serial.bin
ucmd -p $1 -c "loadb -f /dev/ram0" -e "bps..."
ukermit -p $1 -f images/u-boot-v1.bin
ucmd -p $1 -c "go 0x80000000" -e "autoboot"
ucmd -p $1 -c "help" -e "#"
ucmd -p $1 -c "loadb 0x80000000" -e "bps..."
ukermit -p $1 -f images/x-load.bin.ift
ucmd -p $1 -c "nand unlock" -e "#"
ucmd -p $1 -c "nandecc hw" -e "#"
ucmd -p $1 -c "nand erase 0 80000" -e "#"
ucmd -p $1 -c "nand write 80000000 0 80000" -e "#"

[Note: 2008-12-04 22:50hrs:
1. I just started up my laptop and connected my usb2serial
connector -> just found that pserial did not work out of the box.. ran minicom once and it started working.. will debug this later..
2. The nand erase and nand write seems to tell me my entire nand is filled with badblocks.. need to debug this a little more :(
Update 2008-12-11: Khasim has a patch for u-boot-v1 here which is supposedly working now.

Update: 2008-12-13: it seems to work automatically for zoom MDK

Interesting note: on zoom MDK, nand unlock is required before doing a saveenv!! :( need to fix this sometime..
]

Things to do:
a) introduce hw ecc for x-loader.. it should simplify things a lot..
b) Dirk,Steve and others are planning on sending the u-boot patches for mainline tree this weekend.

Send a git patch with gmail

The following is thanks to Dirk Behme (based on ubuntu 8.10):
Install packages:
On Ubuntu, I have done: sudo apt-get install git git-email

Stage1: development:
set up your GIT variables(probably in ~/.bashrc)
export GIT_COMMITTER_EMAIL=yourEmail@somewhere.com
export GIT_COMMITTER_NAME='YourName'
export GIT_AUTHOR_EMAIL=yourEmail@somewhere.com
export GIT_AUTHOR_NAME='YourName'

git clone ... or git pull.. etc to get to the latest code.
git branch branch_name
git checkout branch_name

Do changes
git commit with commit message in incremental stages..

Stage 2: Generate email-able patch files.
git-format-patch -s -n -o origin..
-s will generate the signed of-by
-n will generate numbered patches (if you have just a single patch, you can ignore it) - but if you have multiple ones, this is a good idea to use to generate subject auto numbered 1/2, 2/2 etc..
-o is where the output patch files will be stored -> each commit is a separate file.

Stage3: Email the patches:(for gmail)
Simple one (no mail threads):
git-send-email --from "My Name " --to "Some One " --cc "If I wantACC " --smtp-server smtp.gmail.com --smtp-user MyMailID@gmail.com --smtp-pass WONTTellPassword --smtp-ssl --subject "usually the result of grep Subject PatchFile" PatchFile

See --thread in man git-send-email for further info.. this is a pretty versatile tool.. just need to get used to it I guess

omap-uboot-utils supports usb2serial device

It has been a long time desire to use usb2serial convertors for pserial application. :(.. Anyways, yesterday night, I looped back my usb2serial back to my PCI serial port and tried to write a bit of loopback code.. to figure out the issue with pserial, I wrote a simple little app to print the ttySx flags:


#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>

/************* VARS ***************/
static int fd;
static struct termios oldtio;

int main(int argc,char * argv[])
{
int ret;
int i;
if (argc!=2){
printf ("error no args..%d\n",argc);
return 1;
}
printf ("port: %s\n",argv[1]);
fd = open(argv[1], O_RDWR | O_NOCTTY);
if (!fd) {
printf("terminal is not open!\n");
return 1;
}
/* save current port settings */
ret = tcgetattr(fd, &oldtio);
if (ret < 0) {
printf("failed to get old attribs\n");
ret= 1;
goto quit;
}
ret = 0;
printf ("c_iflag = 0x%04X\n",oldtio.c_iflag);
printf ("c_oflag = 0x%04X\n",oldtio.c_oflag);
printf ("c_cflag = 0x%04X\n",oldtio.c_cflag);
printf ("c_lflag = 0x%04X\n",oldtio.c_lflag);
printf ("c_line = 0x%02X\n",oldtio.c_line);
printf ("c_ispeed = 0x%04X\n",oldtio.c_ispeed);
printf ("c_ospeed = 0x%04X\n",oldtio.c_ospeed);
for (i=0;i<NCCS;i++){
printf(" c_cc[%d]=0x%02X\n",i,oldtio.c_cc[i]);
}
quit:
close(fd);
return ret;

}




Comparing the vals with /usr/include/bits/termios.h, it was educational to first use minicom to communicate with even parity bit, then try the same with my pserial mods.. Initially found few flag setting issues, later found a fundamental error in my assumption in s_close function -> i assumed that it will happen at the end of transmission, in the case of a pci serial port, this would be true, but in the case of a usb2serial convertor, it looks like the data is send to the device but not actually transmitted on the lines :(.. a delay solved the issue..

bah!!! something silly!!! anyways, the patches are pushed to mainline omap-uboot-utils now.. you can get the source here . Will tag and make a binary zip for upload here a week from now if folks could let me know if things are working fine.... Meanwhile, I will try and create an beagle nand recovery tool updater later tonight.. just a bunch of wgets and ucmds I assume..

Sunday, September 28, 2008

Linux audio flows

The following link is thanks to mru in beagleboard irc channel. the link to the discussion is here.

The interesting thing is unless you work at oss/alsa layer, there are too many higher sound server options...

IMHO, flexibility vs scaring folks off... ;)

Saturday, September 20, 2008

Overo: yet another low cost OMAP3 development board

Gumstix guys have been a fun bunch known to create tiny little boards at low costs.. Overo seems to be their solution for OMAP3! check it out here. lots of the linux guys hacking are in the beagle community too.. you can find many(such as Steve Sakoman) in the beagle irc also if you are interested..

IRC games: Customizing Festival voice

Setting basics up:
I use x-chat2 with uberscripts and festival plugin. Tired of the default festival voice, Today's effort was to change the voices ;). I found this to be the best available resource.
Here are the instructions in command format. You can just copy paste the following.
sudo apt-get install festival festlex-cmu festlex-poslex festlex-oald libestools1.2 unzip
sudo apt-get install festvox-don festvox-rablpc16k festvox-kallpc16k festvox-kdlpc16
cd ~/tmp
mkdir hts_tmp
cd hts_tmp/
wget -c http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_awb_arctic_hts-2.0.1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_bdl_arctic_hts-2.0.1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_clb_arctic_hts-2.0.1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_rms_arctic_hts-2.0.1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_slt_arctic_hts-2.0.1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/2.0.1/festvox_nitech_us_jmk_arctic_hts-2.0.1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/1.1.1/cmu_us_kal_com_hts.tar.gz
wget -c http://hts.sp.nitech.ac.jp/archives/1.1.1/cstr_us_ked_timit_hts.tar.gz
for t in `ls` ; do tar xvf $t ; done
sudo mkdir -p /usr/share/festival/voices/us
sudo mv lib/voices/us/* /usr/share/festival/voices/us/
sudo mv lib/hts.scm /usr/share/festival/hts.scm
cd ../
rm -rf hts_tmp/

NOTE: I have chosen just the smallest of the voices. In the link I provided previously, MonkeeSage explains other voices.

Testing, Selecting and Configuring the default voice
Start up festival. Note that festival is a "lispy". () form each sentence. (quit) is to quit, (SayText "Hello World") causes festival to speak "Hello World".
Procedure for testing and selecting voice
  1. (voice.list) - list all voices available.
  2. (voice_) - select as the current voice
  3. (SayText "Hello World") - Say the text Hello World
  4. Repeat steps 2 and 3 till you find the voice which you are ok with.
  5. (quit) - to exit from festival
Example:
(voice.list)
(voice_rab_diphone)
(SayText "magnetic interferance from money/credit cards")
(voice_ked_diphone)
(SayText "waste water tank overflowed onto computer")
(voice_kal_diphone)
(SayText "nesting roaches shorted out the ether cable")
(voice_nitech_us_jmk_arctic_hts)
(SayText "need to wrap system in aluminum foil to fix problem")
(voice_nitech_us_bdl_arctic_hts)
(SayText "Groundskeepers stole the root password")
(voice_nitech_us_rms_arctic_hts)
(SayText "your keyboard's space bar is generating spurious keycodes")
(voice_nitech_us_slt_arctic_hts)
(SayText "Communications satellite used by the military for star wars")
(voice_nitech_us_clb_arctic_hts)
(SayText "We didn't pay the Internet bill and it's been cut off")
(voice_nitech_us_awb_arctic_hts)
(SayText "Your cat tried to eat the mouse.")
(Disclaimer: all of the above wordings were "borrowed" from bofh.txt from uberscript)

Next step will be to create/edit your own ~/.festivalrc file using your fav editor(gedit, vim etc..). Mine is as follows:
(set! default_after_synth_hooks
(list (lambda (utt) (utt.wave.rescale utt 1.6 t))))
(set! voice_default 'voice_nitech_us_slt_arctic_hts)
Note: you can change the voice_nitech_us_slt_artic_hts to which ever voice you choose. IRC: xchat configuration:
#!/usr/bin/perl
#
# An X-Chat interface to the Festival speech synthesis system 
#
# Based on ircspeal.pl v0.2 by Gareth Watts 1998 
#
# For more information 
# Festival http://www.cstr.ed.ac.uk/projects/festival/
#  ircspeak.pl http://www.omnipotent.net/ircspeak/
#
###################################
## CONFIGURE THIS BIT!

# I react only when any of the case insensitive regex is found in list below.
@MyKeyWordsRegeXs=("NishanthMenon");

# I react only for the following events:
#@HANDLERS=("PRIVMSG", "NOTICE", "TOPIC", "NICK", "JOIN", "PART", "QUIT", "INVITE");
@HANDLERS=("PRIVMSG", "INVITE");
#
# Adjust this so it reflects the location of your festival executable
$festival='/usr/bin/festival --pipe';

# Adjust this to your preferred Voice 
#$VOICE = "voice_don_diphone"; # A British voice.
#$VOICE = "voice_rab_diphone"; # A muted British-esque voice
#$VOICE = "voice_kal_diphone"; # An American male voice
$VOICE = "voice_ked_diphone"; # A less mechanical American male voice

# Smaller numbers = faster speech
$SPEED = ".75";

## YOU CAN STOP CONFIGURING!
###################################
# 
# Commands 
#  Enable speech using /speechon
#  Disable speech using /speechoff
#
# Uncomment for Debugging printing in IRC
#$DEBUG = 1;
#
# Released WITHOUT WARRANTY under version 2 of the GNU Public License
# See the end of this file for the full text
#
 
$MY_NAME = "xchat_speak.pl by SCK based on ircspeak.pl by Gareth Watts";
$VERSION = "0.3.2";

# Changelog:
# 25/Oct/2002
#  v0.03 released
#  + First code release by SCK
# 08/Nov/2002
#  v0.03.1 released
#  + Removed un-needed strippuunct sub routine that failed under Perl 5.8
# 09/Nov/2002
#  v0.03.2 released
#  + Fixed return code issue with xchat.

# IRC translator data below.  Feel free to add to the list
# Be sure it is is all lowercase, and escape any contractions
%regex_convert = (
  'privmsg' => 'says',
  'topic'  => 'changes topic to',
  'join'  => 'has joined',
  'part'  => 'has left',
  'quit'  => 'has quit',
  'invite' => 'has invited you to',
);

%wordsub = (
        '..'=> '\,',
        '...'=> '\,',
        '2nd'=> 'second',
        '31337'=> 'eleet',
        '56k'=> '56 k',
        ':)'=> 'smiles',
        ':-)'=> 'smiles',
        ':-p'=> 'sticks tongue out',
        ':>'=> 'smiles',
        ':p'=> 'sticks tongue out',
        ';)'=> 'winks',
        ';-)'=> 'winks',
        'aamof'=> 'as a matter of fact',
        'ad'=> 'add',
        'adn'=> 'any day now',
        'afaik'=> 'as far as i know',
        'afair'=> 'as far as i remember',
        'afj'=> 'april fool\'s joke',
        'afk'=> 'away from the keyboard',
        'asap'=> 'as soon as possible',
        'at0mic_'=> 'atomic',
        'atm'=> 'at the moment',
        'awc'=> 'after while, crocodile',
        'awgthtgtwta?'=> 'are we going to have to go through with this again?',
        'ayt'=> 'are you there?',
        'b4'=> 'before',
        'b4n'=> 'bye for now',
        'bak'=> 'back at keyboard',
        'bakerw0rk'=> 'baker-work',
        'bbfn'=> 'bye bye for now',
 'bbiab'=> 'be back in a bit',
        'bbiaf'=> 'be back in a few',
        'bbialb'=> 'be back in a little bit',
        'bbl'=> 'be back later',
        'bcnu'=> 'be seeing you',
        'bf'=> 'boy friend',
        'brb'=> 'be right back',
        'bta'=> 'but then again',
        'btw'=> 'by the way',
        'bye?'=> 'are you ready to say goodbye',
        'bykt'=> 'but you knew that',
        'byob'=> 'bring your own bottle',
        'byom'=> 'bring your own mac',
        'cmiiw'=> 'correct me if i\'m wrong',
        'cu'=> 'see you',
        'cul'=> 'see you later',
        'cul8r'=> 'see you later',
        'cula'=> 'see you later, alligator',
        'cya'=> 'see ya',
        'd/l'=> 'download',
        'd00d'=> 'dood',
        'diku?'=> 'do i know you?',
        'dtrt'=> 'do the right thing',
 'dvd'=> 'd v d',
        'esad'=> 'eat shit and die',
        'f2f'=> 'face to face',
        'fcfs'=> 'first come, first served',
        'fitb'=> 'fill in the blank',
        'flyaway'=> 'fly away',
        'foad'=> 'feck off and die',
        'foaf'=> 'friend of a friend',
        'freebsd'=> 'free bsd',
        'fs'=> 'for sale',
        'fubar'=> 'fecked up beyond all repair',
        'fud'=> 'fear, uncertainty and doubt',
        'fwiw'=> 'for what it\'s worth',
        'fya'=> 'for your amusement',
        'fyi'=> 'for your information',
        'ga'=> 'go ahead',
        'gal'=> 'get a life',
        'gb'=> 'gigabytes',
        'gd\&r'=> 'grinning, ducking and running',
        'gd\&wvvf'=> 'grinning, ducking, and walking very, very fast',
        'gf'=> 'girl friend',
        'giwist'=> 'gee, i wish i\'d said that',
        'gmta'=> 'great minds think alike',
        'hhoj'=> 'ha ha only joking',
        'hhok'=> 'ha ha only kidding',
        'hhos'=> 'ha ha only serious',
 'hmm'=> 'hurrmmm',
        'hoyew'=> 'hanging on your every word',
        'hp/ux'=> 'hp ux',
        'hrm'=> 'herm',
        'hth'=> 'hope that helps!',
        'i8urdog'=> 'I ate your dog',
        'iac'=> 'in any case',
        'ianal'=> 'i am not a lawyer',
        'iaw'=> 'in accordance with',
        'ic'=> 'i see',
        'identd'=> 'ident d',
        'iirc'=> 'if i remember correctly',
        'ijwtk'=> 'i just want to know',
        'ijwts'=> 'i just want to say',
        'ikwum'=> 'i know what you mean',
        'ima'=> 'i might add',
        'imao'=> 'in my arrogant opinion',
        'imco'=> 'in my considered opinion',
        'ime'=> 'in my experience',
        'imho'=> 'in my humble opinion',
        'imnsho'=> 'in my not so humble opinion',
        'imo'=> 'in my opinion',
        'inpo'=> 'in no particular order',
 'irq'=> 'i r q',
        'iow'=> 'in other words',
        'ip'=> 'i p',
        'ipx'=> 'i p x',
        'irl'=> 'in real life',
 'isdn'=> 'i s d n',
        'iss'=> 'i\'m so sure',
        'issygti'=> 'i\'m so sure you get the idea!',
        'iswim'=> 'if you see what i mean',
        'iwbni'=> 'it would be nice if',
        'iyfeg'=> 'insert your favorite ethnic group',
        'iyswim'=> 'if you see what i mean',
        'jam'=> 'just a minute',
        'jic'=> 'just in case',
        'k3nny'=> 'kenny',
        'kb'=> 'kilobytes',
        'kibo'=> 'knowledge in, bullshit out',
        'kwim'=> 'know what i mean?',
        'kyfc'=> 'keep your fingers crossed',
        'l8r'=> 'later',
        'lin0x'=> 'linux',
        'ljbf'=> 'let\'s just be friends',
        'lol'=> 'laughing out loud',
        'lshmba'=> 'laughing so hard my belly aches',
        'lthtt'=> 'laughing too hard to type',
        'ltns'=> 'long time no see',
        'mb'=> 'megabytes',
        'motas'=> 'member of the appropriate sex',
        'motd'=> 'message of the day',
        'motos'=> 'member of the opposite sex',
        'motss'=> 'member of the same sex',
        'msg'=> 'message',
        'myob'=> 'mind your own business',
        'n-tropy'=> 'entropy',
        'nah'=> 'no',
        'ne1'=> 'anyone',
        'netbsd'=> 'net bsd',
        'nhoh'=> 'never heard of him slash her',
        'np'=> 'no problem',
        'obo'=> 'or best offer',
        'obtw'=> 'oh, by the way',
        'oic'=> 'oh, i see',
        'ok'=> 'o k',
        'openbsd'=> 'open bsd',
        'otf'=> 'on the floor',
        'otfl'=> 'on the floor laughing',
        'otoh'=> 'on the other hand',
        'ott'=> 'over the top',
        'pci'=> 'p c i',
        'pmf'=> 'pardon my french',
        'pmfbi'=> 'pardon me for butting in',
        'pmfji'=> 'pardon me for jumping in',
        'pmji'=> 'pardon my jumping in',
        'pncah'=> 'please, no cursing allowed here',
        'pnpisa'=> 'p n p i s a',
        'po0p'=> 'poop',
        'ppl'=> 'people',
 'pstn'=> 'p s t n',
        'ptmm'=> 'please tell me more',
        'quazwork'=> 'quaz-work',
        'r u there?'=> 'are you there?',
        're'=> 'regreet',
        'redhat'=> 'red hat',
        'rehi'=> 'hi again',
        'rl'=> 'real life',
        'rotf'=> 'rolling on the floor',
        'rotfl'=> 'rolling on the floor laughing',
        'rotflol'=> 'rolling on the floor laughing out loud',
        'rsn'=> 'real soon now',
        'rsvp'=> 'please reply',
        'rtbm'=> 'read the bloody manual',
        'rtfaq'=> 'read the frequently asked questions',
        'rtfm'=> 'read the fecking manual',
        'rtm'=> 'read the manual',
        'ryfm'=> 'read your friendly manual',
        'scsi'=> 'scuzy',
        'sec'=> 'wait a second',
        'secs'=> 'seconds',
        'snafu'=> 'situation normal, all fouled up',
        'sol'=> 'shit out of luck',
        'sos'=> 'help!',
        'swim'=> 'see what i mean?',
        'tafn'=> 'that\'s all for now',
        'tanj'=> 'there ain\'t no justice',
        'tanstaafl'=> 'there ain\'t no such thing as a free lunch',
        'tcp'=> 't c p',
        'thankx'=> 'thanks',
        'thx'=> 'thanks',
        'tia'=> 'thanks in advance',
        'tic'=> 'tongue in cheek',
        'tntl'=> 'trying not to laugh',
        'tnx'=> 'thanks',
        'tnxe6'=> 'thanks a million',
        'tptb'=> 'the powers that be',
        'ttbomk'=> 'to the best of my knowledge',
        'ttfn'=> 'ta ta for now',
        'ttksf'=> 'trying to keep a straight face',
        'ttyl'=> 'talk to you later',
        'tyvm'=> 'thank you very much',
        'uok'=> 'are you ok?',
        'w/o'=> 'without',
        'wb'=> 'welcome back',
        'wdyt'=> 'what do you think?',
        'wibni'=> 'wouldn\t it be nice if',
        'willg'=> 'will g',
        'wrt'=> 'with regard to,  or with respect to',
        'wtb'=> 'want to buy',
        'wtf'=> 'what the feck',
        'wtg'=> 'way to go!',
        'wtgp'=> 'want to go private?',
        'wth'=> 'what the hell?',
        'wygiswypf'=> 'what you get is what you pay for',
        'xoxoxo'=> 'kisses and hugs',
        'yaba'=> 'yet another bloody acronym',
        'yaun'=> 'yet another unix nerd',
        'ygti'=> 'you get the idea?',
        'ygwypf'=> 'you get what you pay for',
        'yiu'=> 'yes, i understand',
        'yiwgp'=> 'yes, i will go private',
        'ymmv'=> 'your mileage may vary',
);


%spellcorrect = (
        'Ameria'=> 'America',
        'I\"m'=> 'I\'m',
        'I\;d'=> 'I\'d',
        'I\;ll'=> 'I\'ll',
        'UnitedStates'=> 'United States',
        'abbout'=> 'about',
        'abotu'=> 'about',
        'abouta'=> 'about a',
        'aboutit'=> 'about it',
        'aboutthe'=> 'about the',
        'abscence'=> 'absence',
        'accesories'=> 'accessories',
        'accidant'=> 'accident',
        'accomodate'=> 'accommodate',
        'accordingto'=> 'according to',
        'accross'=> 'across',
        'acheive'=> 'achieve',
        'acheived'=> 'achieved',
        'acheiving'=> 'achieving',
        'acn'=> 'can',
        'acommodate'=> 'accommodate',
        'acomodate'=> 'accommodate',
        'actualyl'=> 'actually',
        'additinal'=> 'additional',
        'addtional'=> 'additional',
        'adequit'=> 'adequate',
        'adequite'=> 'adequate',
        'adn'=> 'and',
        'advanage'=> 'advantage',
        'affraid'=> 'afraid',
        'afterthe'=> 'after the',
        'againstt he'=> 'against the',
        'aganist'=> 'against',
        'aggresive'=> 'aggressive',
        'agian'=> 'again',
        'agreemeent'=> 'agreement',
        'agreemeents'=> 'agreements',
        'agreemnet'=> 'agreement',
        'agreemnets'=> 'agreements',
        'agressive'=> 'aggressive',
        'ahppen'=> 'happen',
        'ahve'=> 'have',
        'allwasy'=> 'always',
        'allwyas'=> 'always',
        'almots'=> 'almost',
        'almsot'=> 'almost',
        'alomst'=> 'almost',
        'alot'=> 'a lot',
        'alraedy'=> 'already',
        'alreayd'=> 'already',
        'alreday'=> 'already',
        'alwasy'=> 'always',
        'alwats'=> 'always',
        'alway'=> 'always',
        'alwyas'=> 'always',
        'amde'=> 'made',
        'amke'=> 'make',
        'amkes'=> 'makes',
        'anbd'=> 'and',
        'andone'=> 'and one',
        'andt he'=> 'and the',
        'andteh'=> 'and the',
        'andthe'=> 'and the',
        'anothe'=> 'another',
        'anual'=> 'annual',
        'apparant'=> 'apparent',
        'apparrent'=> 'apparent',
        'appearence'=> 'appearance',
        'appeares'=> 'appears',
        'applicaiton'=> 'application',
        'applicaitons'=> 'applications',
        'applyed'=> 'applied',
        'appointiment'=> 'appointment',
        'approrpiate'=> 'appropriate',
        'approrpriate'=> 'appropriate',
        'aquisition'=> 'acquisition',
        'aquisitions'=> 'acquisitions',
        'aren\;t'=> 'aren\'t',
        'arguement'=> 'argument',
        'arguements'=> 'arguments',
        'arn\'t'=> 'aren\'t',
        'arond'=> 'around',
        'artical'=> 'article',
        'articel'=> 'article',
        'asdvertising'=> 'advertising',
        'askt he'=> 'ask the',
        'assistent'=> 'assistant',
        'asthe'=> 'as the',
        'atention'=> 'attention',
        'atmospher'=> 'atmosphere',
        'attentioin'=> 'attention',
        'atthe'=> 'at the',
        'audeince'=> 'audience',
        'audiance'=> 'audience',
        'availalbe'=> 'available',
        'awya'=> 'away',
        'aywa'=> 'away',
        'bakc'=> 'back',
        'balence'=> 'balance',
        'ballance'=> 'balance',
        'baout'=> 'about',
        'bcak'=> 'back',
        'beacuse'=> 'because',
        'becasue'=> 'because',
        'becaus'=> 'because',
        'becausea'=> 'because a',
        'becauseof'=> 'because of',
        'becausethe'=> 'because the',
        'becauseyou'=> 'because you',
        'becomeing'=> 'becoming',
        'becomming'=> 'becoming',
        'becuase'=> 'because',
        'becuse'=> 'because',
        'befoer'=> 'before',
        'beggining'=> 'beginning',
        'begining'=> 'beginning',
        'beginining'=> 'beginning',
        'beleiev'=> 'believe',
        'beleieve'=> 'believe',
        'beleif'=> 'belief',
        'beleive'=> 'believe',
        'beleived'=> 'believed',
        'beleives'=> 'believes',
        'benifit'=> 'benefit',
        'benifits'=> 'benefits',
        'betwen'=> 'between',
        'beutiful'=> 'beautiful',
        'blase'=> 'blas\E9',
        'boxs'=> 'boxes',
        'brodcast'=> 'broadcast',
        'butthe'=> 'but the',
        'bve'=> 'be',
        'byt he'=> 'by the',
        'cafe'=> 'caf\E9',
        'caharcter'=> 'character',
        'calcullated'=> 'calculated',
        'calulated'=> 'calculated',
        'can\'t of been'=> 'can\'t have been',
        'can\;t'=> 'can\'t',
        'candidtae'=> 'candidate',
        'candidtaes'=> 'candidates',
        'catagory'=> 'category',
        'categiory'=> 'category',
        'certian'=> 'certain',
        'challange'=> 'challenge',
        'challanges'=> 'challenges',
        'chaneg'=> 'change',
        'chanegs'=> 'changes',
        'changable'=> 'changeable',
        'changeing'=> 'changing',
        'changng'=> 'changing',
        'charachter'=> 'character',
        'charachters'=> 'characters',
        'charactor'=> 'character',
        'charecter'=> 'character',
        'charector'=> 'character',
        'cheif'=> 'chief',
        'chekc'=> 'check',
        'chnage'=> 'change',
        'cieling'=> 'ceiling',
        'circut'=> 'circuit',
        'claer'=> 'clear',
        'claered'=> 'cleared',
        'claerly'=> 'clearly',
        'cliant'=> 'client',
        'cliche'=> 'clich\E9',
        'cna'=> 'can',
        'colection'=> 'collection',
        'comanies'=> 'companies',
        'comany'=> 'company',
        'comapnies'=> 'companies',
        'comapny'=> 'company',
        'combintation'=> 'combination',
        'comited'=> 'committed',
        'comittee'=> 'committee',
        'commadn'=> 'command',
        'comming'=> 'coming',
        'commitee'=> 'committee',
        'committe'=> 'committee',
        'committment'=> 'commitment',
        'committments'=> 'commitments',
        'committy'=> 'committee',
        'comntain'=> 'contain',
        'comntains'=> 'contains',
        'compair'=> 'compare',
        'company\;s'=> 'company\'s',
        'compleated'=> 'completed',
        'compleatly'=> 'completely',
        'compleatness'=> 'completeness',
        'completly'=> 'completely',
        'completness'=> 'completeness',
        'composate'=> 'composite',
        'comtain'=> 'contain',
        'comtains'=> 'contains',
        'comunicate'=> 'communicate',
        'comunity'=> 'community',
        'condolances'=> 'condolences',
        'conected'=> 'connected',
        'conferance'=> 'conference',
        'confirmmation'=> 'confirmation',
        'considerit'=> 'considerate',
        'considerite'=> 'considerate',
        'consonent'=> 'consonant',
        'conspiricy'=> 'conspiracy',
        'consultent'=> 'consultant',
        'convertable'=> 'convertible',
        'cooparate'=> 'cooperate',
        'cooporate'=> 'cooperate',
        'corproation'=> 'corporation',
        'corproations'=> 'corporations',
        'corruptable'=> 'corruptible',
        'cotten'=> 'cotton',
        'coudl'=> 'could',
        'coudln\'t'=> 'couldn\'t',
        'coudn\'t'=> 'couldn\'t',
        'could of been'=> 'could have been',
        'could of had'=> 'could have had',
        'couldn\;t'=> 'couldn\'t',
        'couldnt'=> 'couldn\'t',
        'couldthe'=> 'could the',
        'cpoy'=> 'copy',
        'creme'=> 'cr\E8me',
        'ctaegory'=> 'category',
        'cusotmer'=> 'customer',
        'cusotmers'=> 'customers',
        'cutsomer'=> 'customer',
        'cutsomers'=> 'customers',
        'cxan'=> 'can',
        'danceing'=> 'dancing',
        'dcument'=> 'document',
        'deatils'=> 'details',
        'decison'=> 'decision',
        'decisons'=> 'decisions',
        'decor'=> 'd\E9cor',
        'defendent'=> 'defendant',
        'definately'=> 'definitely',
        'deja vu'=> 'd\E9j\E0 vu',
        'deptartment'=> 'department',
        'desicion'=> 'decision',
        'desicions'=> 'decisions',
        'desision'=> 'decision',
        'desisions'=> 'decisions',
        'detente'=> 'd\E9tente',
        'develeoprs'=> 'developers',
        'devellop'=> 'develop',
        'develloped'=> 'developed',
        'develloper'=> 'developer',
        'devellopers'=> 'developers',
        'develloping'=> 'developing',
        'devellopment'=> 'development',
        'devellopments'=> 'developments',
        'devellops'=> 'develop',
        'develope'=> 'develop',
        'developement'=> 'development',
        'developements'=> 'developments',
        'developor'=> 'developer',
        'developors'=> 'developers',
        'develpment'=> 'development',
        'diaplay'=> 'display',
        'didint'=> 'didn\'t',
        'didn\;t'=> 'didn\'t',
        'didnot'=> 'did not',
        'didnt'=> 'didn\'t',
        'difefrent'=> 'different',
        'diferences'=> 'differences',
        'differance'=> 'difference',
        'differances'=> 'differences',
        'differant'=> 'different',
        'differemt'=> 'different',
        'differnt'=> 'different',
        'diffrent'=> 'different',
        'directer'=> 'director',
        'directers'=> 'directors',
        'directiosn'=> 'direction',
        'disatisfied'=> 'dissatisfied',
        'discoverd'=> 'discovered',
        'disign'=> 'design',
        'dispaly'=> 'display',
        'dissonent'=> 'dissonant',
        'distribusion'=> 'distribution',
        'divsion'=> 'division',
        'do\'nt'=> 'don\'t',
        'docuement'=> 'documents',
        'docuemnt'=> 'document',
        'documetn'=> 'document',
        'documnet'=> 'document',
        'documnets'=> 'documents',
        'doe snot'=> 'does not',
        'doens\'t'=> 'doesn\'t',
        'doese'=> 'does',
        'doesn\;t'=> 'doesn\'t',
        'doesnt'=> 'doesn\'t',
        'doign'=> 'doing',
        'doimg'=> 'doing',
        'doind'=> 'doing',
        'dollers'=> 'dollars',
        'don\'t no'=> 'don\'t know',
        'don\;t'=> 'don\'t',
        'donig'=> 'doing',
        'dont'=> 'don\'t',
        'dosn\'t'=> 'doesn\'t',
        'driveing'=> 'driving',
        'drnik'=> 'drink',
        'eclair'=> '\E9clair',
        'efel'=> 'feel',
        'effecient'=> 'efficient',
        'efort'=> 'effort',
        'eforts'=> 'efforts',
        'ehr'=> 'her',
        'eligable'=> 'eligible',
        'embarass'=> 'embarrass',
        'emigre'=> '\E9migr\E9',
        'enought'=> 'enough',
        'entree'=> 'entr\E9e',
        'equippment'=> 'equipment',
        'equivalant'=> 'equivalent',
        'esle'=> 'else',
        'especally'=> 'especially',
        'especialyl'=> 'especially',
        'espesially'=> 'especially',
        'excellant'=> 'excellent',
        'excercise'=> 'exercise',
        'exchagne'=> 'exchange',
        'exchagnes'=> 'exchanges',
        'excitment'=> 'excitement',
        'exhcange'=> 'exchange',
        'exhcanges'=> 'exchanges',
        'experiance'=> 'experience',
        'experienc'=> 'experience',
        'exprience'=> 'experience',
        'exprienced'=> 'experienced',
        'eyt'=> 'yet',
        'facade'=> 'fa\E7ade',
        'faeture'=> 'feature',
        'faetures'=> 'features',
        'familair'=> 'familiar',
        'familar'=> 'familiar',
        'familliar'=> 'familiar',
        'fammiliar'=> 'familiar',
        'feild'=> 'field',
        'feilds'=> 'fields',
        'fianlly'=> 'finally',
        'fidn'=> 'find',
        'finalyl'=> 'finally',
        'firends'=> 'friends',
        'firts'=> 'first',
        'follwo'=> 'follow',
        'follwoing'=> 'following',
        'fora'=> 'for a',
        'foriegn'=> 'foreign',
        'forthe'=> 'for the',
        'forwrd'=> 'forward',
        'forwrds'=> 'forwards',
        'foudn'=> 'found',
        'foward'=> 'forward',
        'fowards'=> 'forwards',
        'freind'=> 'friend',
        'freindly'=> 'friendly',
        'freinds'=> 'friends',
        'frmo'=> 'from',
        'fromt he'=> 'from the',
        'fromthe'=> 'from the',
        'furneral'=> 'funeral',
        'fwe'=> 'few',
        'garantee'=> 'guarantee',
        'gaurd'=> 'guard',
        'gemeral'=> 'general',
        'gerat'=> 'great',
        'geting'=> 'getting',
        'gettin'=> 'getting',
        'gievn'=> 'given',
        'giveing'=> 'giving',
        'gloabl'=> 'global',
        'goign'=> 'going',
        'gonig'=> 'going',
        'govenment'=> 'government',
        'goverment'=> 'government',
        'gruop'=> 'group',
        'gruops'=> 'groups',
        'grwo'=> 'grow',
        'guidlines'=> 'guidelines',
        'hadbeen'=> 'had been',
        'hadn\;t'=> 'hadn\'t',
        'haev'=> 'have',
        'hapen'=> 'happen',
        'hapened'=> 'happened',
        'hapening'=> 'happening',
        'hapens'=> 'happens',
        'happend'=> 'happened',
        'hasbeen'=> 'has been',
        'hasn\;t'=> 'hasn\'t',
        'hasnt'=> 'hasn\'t',
        'havebeen'=> 'have been',
        'haveing'=> 'having',
        'haven\;t'=> 'haven\'t',
        'hda'=> 'had',
        'he\;ll'=> 'he\'ll',
        'hearign'=> 'hearing',
        'helpfull'=> 'helpful',
        'herat'=> 'heart',
        'here\;s'=> 'here\'s',
        'hesaid'=> 'he said',
        'hewas'=> 'he was',
        'hge'=> 'he',
        'hismelf'=> 'himself',
        'hlep'=> 'help',
        'hsa'=> 'has',
        'hsi'=> 'his',
        'hte'=> 'the',
        'htere'=> 'there',
        'htese'=> 'these',
        'htey'=> 'they',
        'hting'=> 'thing',
        'htink'=> 'think',
        'htis'=> 'this',
        'hvae'=> 'have',
        'hvaing'=> 'having',
        'hwich'=> 'which',
        'i snot'=> 'is not',
        'idae'=> 'idea',
        'idaes'=> 'ideas',
        'identofy'=> 'identify',
        'ihs'=> 'his',
        'iits the'=> 'it\'s the',
        'imediate'=> 'immediate',
        'imediatly'=> 'immediately',
        'immediatly'=> 'immediately',
        'importent'=> 'important',
        'importnat'=> 'important',
        'impossable'=> 'impossible',
        'improvemnt'=> 'improvement',
        'improvment'=> 'improvement',
        'includ'=> 'include',
        'indecate'=> 'indicate',
        'indenpendence'=> 'independence',
        'indenpendent'=> 'independent',
        'indepedent'=> 'independent',
        'independance'=> 'independence',
        'independant'=> 'independent',
        'influance'=> 'influence',
        'infomation'=> 'information',
        'informatoin'=> 'information',
        'inital'=> 'initial',
        'instaleld'=> 'installed',
        'insted'=> 'instead',
        'insurence'=> 'insurance',
        'int he'=> 'in the',
        'inteh'=> 'in the',
        'interum'=> 'interim',
        'inthe'=> 'in the',
        'inwhich'=> 'in which',
        'isn\;t'=> 'isn\'t',
        'isthe'=> 'is the',
        'it snot'=> 'it\'s not',
        'it\' snot'=> 'it\'s not',
        'it\;ll'=> 'it\'ll',
        'it\;s'=> 'it\'s',
        'itis'=> 'it is',
        'ititial'=> 'initial',
        'itnerest'=> 'interest',
        'itnerested'=> 'interested',
        'itneresting'=> 'interesting',
        'itnerests'=> 'interests',
        'its a'=> 'it\'s a',
        'its the'=> 'it\'s the',
        'itwas'=> 'it was',
        'iwll'=> 'will',
        'iwth'=> 'with',
        'jsut'=> 'just',
        'jugment'=> 'judgment',
        'knowldge'=> 'knowledge',
        'knowlege'=> 'knowledge',
        'knwo'=> 'know',
        'knwon'=> 'known',
        'knwos'=> 'knows',
        'konw'=> 'know',
        'konwn'=> 'known',
        'konws'=> 'knows',
        'labratory'=> 'laboratory',
        'lastyear'=> 'last year',
        'learnign'=> 'learning',
        'lenght'=> 'length',
        'let\'s him'=> 'lets him',
        'let\'s it'=> 'lets it',
        'let\;s'=> 'let\'s',
        'levle'=> 'level',
        'libary'=> 'library',
        'librarry'=> 'library',
        'librery'=> 'library',
        'liek'=> 'like',
        'liekd'=> 'liked',
        'lieutenent'=> 'lieutenant',
        'liev'=> 'live',
        'likly'=> 'likely',
        'lisense'=> 'license',
        'littel'=> 'little',
        'litttle'=> 'little',
        'liuke'=> 'like',
        'liveing'=> 'living',
        'loev'=> 'love',
        'lonly'=> 'lonely',
        'lookign'=> 'looking',
        'maintenence'=> 'maintenance',
        'makeing'=> 'making',
        'managment'=> 'management',
        'mantain'=> 'maintain',
        'marraige'=> 'marriage',
        'may of been'=> 'may have been',
        'may of had'=> 'may have had',
        'memeber'=> 'member',
        'merchent'=> 'merchant',
        'mesage'=> 'message',
        'mesages'=> 'messages',
        'might of been'=> 'might have been',
        'might of had'=> 'might have had',
        'mispell'=> 'misspell',
        'mispelling'=> 'misspelling',
        'mispellings'=> 'misspellings',
        'mkae'=> 'make',
        'mkaes'=> 'makes',
        'mkaing'=> 'making',
        'moeny'=> 'money',
        'morgage'=> 'mortgage',
        'mroe'=> 'more',
        'msot'=> 'most',
        'must of been'=> 'must have been',
        'must of had'=> 'must have had',
        'mysefl'=> 'myself',
        'myu'=> 'my',
        'naive'=> 'na\EFve',
        'necassarily'=> 'necessarily',
        'necassary'=> 'necessary',
        'neccessarily'=> 'necessarily',
        'neccessary'=> 'necessary',
        'necesarily'=> 'necessarily',
        'necesary'=> 'necessary',
        'negotiaing'=> 'negotiating',
        'nkow'=> 'know',
        'nothign'=> 'nothing',
        'nver'=> 'never',
        'nwe'=> 'new',
        'nwo'=> 'now',
        'obediant'=> 'obedient',
        'ocasion'=> 'occasion',
        'occassion'=> 'occasion',
        'occured'=> 'occurred',
        'occurence'=> 'occurrence',
        'occurrance'=> 'occurrence',
        'ocur'=> 'occur',
        'oeprator'=> 'operator',
        'ofits'=> 'of its',
        'oft he'=> 'of the',
        'ofthe'=> 'of the',
        'oging'=> 'going',
        'ohter'=> 'other',
        'omre'=> 'more',
        'oneof'=> 'one of',
        'onepoint'=> 'one point',
        'ont he'=> 'on the',
        'onthe'=> 'on the',
        'onyl'=> 'only',
        'oppasite'=> 'opposite',
        'opperation'=> 'operation',
        'oppertunity'=> 'opportunity',
        'opposate'=> 'opposite',
        'opposible'=> 'opposable',
        'opposit'=> 'opposite',
        'oppotunities'=> 'opportunities',
        'oppotunity'=> 'opportunity',
        'orginization'=> 'organization',
        'orginized'=> 'organized',
        'otehr'=> 'other',
        'otu'=> 'out',
        'outof'=> 'out of',
        'overthe'=> 'over the',
        'owrk'=> 'work',
        'owuld'=> 'would',
        'oxident'=> 'oxidant',
        'papaer'=> 'paper',
        'parliment'=> 'parliament',
        'partof'=> 'part of',
        'paymetn'=> 'payment',
        'paymetns'=> 'payments',
        'pciture'=> 'picture',
        'peice'=> 'piece',
        'peices'=> 'pieces',
        'peolpe'=> 'people',
        'peopel'=> 'people',
        'percentof'=> 'percent of',
        'percentto'=> 'percent to',
        'performence'=> 'performance',
        'perhasp'=> 'perhaps',
        'perhpas'=> 'perhaps',
        'permanant'=> 'permanent',
        'perminent'=> 'permanent',
        'personalyl'=> 'personally',
        'pleasent'=> 'pleasant',
        'poeple'=> 'people',
        'porblem'=> 'problem',
        'porblems'=> 'problems',
        'porvide'=> 'provide',
        'possable'=> 'possible',
        'postition'=> 'position',
        'potentialy'=> 'potentially',
        'pregnent'=> 'pregnant',
        'presance'=> 'presence',
        'probelm'=> 'problem',
        'probelms'=> 'problems',
        'prominant'=> 'prominent',
        'protege'=> 'prot\E9g\E9',
        'protoge'=> 'prot\E9g\E9',
        'psoition'=> 'position',
        'ptogress'=> 'progress',
        'puting'=> 'putting',
        'pwoer'=> 'power',
        'quater'=> 'quarter',
        'quaters'=> 'quarters',
        'quesion'=> 'question',
        'quesions'=> 'questions',
        'questioms'=> 'questions',
        'questiosn'=> 'questions',
        'questoin'=> 'question',
        'quetion'=> 'question',
        'quetions'=> 'questions',
        'realyl'=> 'really',
        'reccomend'=> 'recommend',
        'reccommend'=> 'recommend',
        'receieve'=> 'receive',
        'recieve'=> 'receive',
        'recieved'=> 'received',
        'recieving'=> 'receiving',
        'recomend'=> 'recommend',
        'recomendation'=> 'recommendation',
        'recomendations'=> 'recommendations',
        'recomended'=> 'recommended',
        'reconize'=> 'recognize',
        'recrod'=> 'record',
        'religous'=> 'religious',
        'reluctent'=> 'reluctant',
        'remeber'=> 'remember',
        'reommend'=> 'recommend',
        'representativs'=> 'representatives',
        'representives'=> 'representatives',
        'represetned'=> 'represented',
        'represnt'=> 'represent',
        'reserach'=> 'research',
        'resollution'=> 'resolution',
        'resorces'=> 'resources',
        'respomd'=> 'respond',
        'respomse'=> 'response',
        'responce'=> 'response',
        'responsability'=> 'responsibility',
        'responsable'=> 'responsible',
        'responsibile'=> 'responsible',
        'responsiblity'=> 'responsibility',
        'restaraunt'=> 'restaurant',
        'restuarant'=> 'restaurant',
        'reult'=> 'result',
        'reveiw'=> 'review',
        'reveiwing'=> 'reviewing',
        'rumers'=> 'rumors',
        'rwite'=> 'write',
        'rythm'=> 'rhythm',
        'saidhe'=> 'said he',
        'saidit'=> 'said it',
        'saidt he'=> 'said the',
        'saidthat'=> 'said that',
        'saidthe'=> 'said the',
        'scedule'=> 'schedule',
        'sceduled'=> 'scheduled',
        'seance'=> 's\E9ance',
        'secratary'=> 'secretary',
        'sectino'=> 'section',
        'seh'=> 'she',
        'selectoin'=> 'selection',
        'sentance'=> 'sentence',
        'separeate'=> 'separate',
        'seperate'=> 'separate',
        'sercumstances'=> 'circumstances',
        'shcool'=> 'school',
        'she\;ll'=> 'she\'ll',
        'shesaid'=> 'she said',
        'shineing'=> 'shining',
        'shiped'=> 'shipped',
        'shoudl'=> 'should',
        'shoudln\'t'=> 'shouldn\'t',
        'should of been'=> 'should have been',
        'should of had'=> 'should have had',
        'shouldent'=> 'shouldn\'t',
        'shouldn\;t'=> 'shouldn\'t',
        'shouldnt'=> 'shouldn\'t',
        'showinf'=> 'showing',
        'signifacnt'=> 'significant',
        'simalar'=> 'similar',
        'similiar'=> 'similar',
        'simpyl'=> 'simply',
        'sincerly'=> 'sincerely',
        'sitll'=> 'still',
        'smae'=> 'same',
        'smoe'=> 'some',
        'soem'=> 'some',
        'sohw'=> 'show',
        'soical'=> 'social',
        'somethign'=> 'something',
        'someting'=> 'something',
        'somewaht'=> 'somewhat',
        'somthing'=> 'something',
        'somtimes'=> 'sometimes',
        'sot hat'=> 'so that',
        'soudn'=> 'sound',
        'soudns'=> 'sounds',
        'speach'=> 'speech',
        'specificaly'=> 'specifically',
        'specificalyl'=> 'specifically',
        'statment'=> 'statement',
        'statments'=> 'statements',
        'stnad'=> 'stand',
        'stopry'=> 'story',
        'stoyr'=> 'story',
        'stpo'=> 'stop',
        'strentgh'=> 'strength',
        'stroy'=> 'story',
        'struggel'=> 'struggle',
        'strugle'=> 'struggle',
        'studnet'=> 'student',
        'successfull'=> 'successful',
        'successfuly'=> 'successfully',
        'successfulyl'=> 'successfully',
        'sucess'=> 'success',
        'sucessfull'=> 'successful',
        'sufficiant'=> 'sufficient',
        'suposed'=> 'supposed',
        'suppossed'=> 'supposed',
        'suprise'=> 'surprise',
        'suprised'=> 'surprised',
        'swiming'=> 'swimming',
        'tahn'=> 'than',
        'taht'=> 'that',
        'talekd'=> 'talked',
        'talkign'=> 'talking',
        'tath'=> 'that',
        'tecnical'=> 'technical',
        'teh'=> 'the',
        'tehy'=> 'they',
        'tellt he'=> 'tell the',
        'termoil'=> 'turmoil',
        'tghe'=> 'the',
        'tghis'=> 'this',
        'thansk'=> 'thanks',
        'thats'=> 'that\'s',
        'thatt he'=> 'that the',
        'thatthe'=> 'that the',
        'thecompany'=> 'the company',
        'thefirst'=> 'the first',
        'thegovernment'=> 'the government',
        'their are'=> 'there are',
        'their is'=> 'there is',
        'themself'=> 'themselves',
        'themselfs'=> 'themselves',
        'thenew'=> 'the new',
        'there\'s is'=> 'theirs is',
        'theri'=> 'their',
        'thesame'=> 'the same',
        'thetwo'=> 'the two',
        'they\'re are'=> 'there are',
        'they\'re is'=> 'there is',
        'they\;l'=> 'they\'ll',
        'they\;ll'=> 'they\'ll',
        'they\;r'=> 'they\'re',
        'they\;re'=> 'they\'re',
        'they\;v'=> 'they\'ve',
        'they\;ve'=> 'they\'ve',
        'theyll'=> 'they\'ll',
        'theyve'=> 'they\'ve',
        'thgat'=> 'that',
        'thge'=> 'the',
        'thier'=> 'their',
        'thigsn'=> 'things',
        'thisyear'=> 'this year',
        'thna'=> 'than',
        'thne'=> 'then',
        'thnig'=> 'thing',
        'thnigs'=> 'things',
        'threatend'=> 'threatened',
        'thsi'=> 'this',
        'thsoe'=> 'those',
        'thta'=> 'that',
        'tihs'=> 'this',
        'timne'=> 'time',
        'tiogether'=> 'together',
        'tje'=> 'the',
        'tjhe'=> 'the',
        'tkae'=> 'take',
        'tkaes'=> 'takes',
        'tkaing'=> 'taking',
        'tlaking'=> 'talking',
        'todya'=> 'today',
        'togehter'=> 'together',
        'toldt he'=> 'told the',
        'tomorow'=> 'tomorrow',
        'tongiht'=> 'tonight',
        'tonihgt'=> 'tonight',
        'totaly'=> 'totally',
        'totalyl'=> 'totally',
        'tothe'=> 'to the',
        'towrad'=> 'toward',
        'traditionalyl'=> 'traditionally',
        'transfered'=> 'transferred',
        'truely'=> 'truly',
        'truley'=> 'truly',
        'tryed'=> 'tried',
        'tthe'=> 'the',
        'tyhat'=> 'that',
        'tyhe'=> 'the',
        'udnerstand'=> 'understand',
        'understnad'=> 'understand',
        'undert he'=> 'under the',
        'unliek'=> 'unlike',
        'unpleasently'=> 'unpleasantly',
        'untilll'=> 'until',
        'useing'=> 'using',
        'usualyl'=> 'usually',
        'veyr'=> 'very',
        'virtualyl'=> 'virtually',
        'vis-a-vis'=> 'vis-\E0-vis',
        'vrey'=> 'very',
        'vulnerible'=> 'vulnerable',
        'wa snot'=> 'was not',
        'waht'=> 'what',
        'warrent'=> 'warrant',
        'wasnt'=> 'wasn\'t',
        'watn'=> 'want',
        'we\;d'=> 'we\'d',
        'we\;ll'=> 'we\'ll',
        'we\;re'=> 'we\'re',
        'we\;ve'=> 'we\'ve',
        'wehn'=> 'when',
        'wern\'t'=> 'weren\'t',
        'werre'=> 'were',
        'what\;s'=> 'what\'s',
        'whcih'=> 'which',
        'whent he'=> 'when the',
        'where\;s'=> 'where\'s',
        'wherre'=> 'where',
        'whic'=> 'which',
        'whicht he'=> 'which the',
        'whihc'=> 'which',
        'who\;s'=> 'who\'s',
        'who\;ve'=> 'who\'ve',
        'whta'=> 'what',
        'wief'=> 'wife',
        'wierd'=> 'weird',
        'wihch'=> 'which',
        'wiht'=> 'with',
        'will of been'=> 'will have been',
        'will of had'=> 'will have had',
        'willbe'=> 'will be',
        'windoes'=> 'windows',
        'witha'=> 'with a',
        'withe'=> 'with',
        'witht he'=> 'with the',
        'withthe'=> 'with the',
        'wiull'=> 'will',
        'wnat'=> 'want',
        'wnated'=> 'wanted',
        'wnats'=> 'wants',
        'wo\'nt'=> 'won\'t',
        'woh'=> 'who',
        'wohle'=> 'whole',
        'wokr'=> 'work',
        'won\;t'=> 'won\'t',
        'woudl'=> 'would',
        'woudln\'t'=> 'wouldn\'t',
        'would of been'=> 'would have been',
        'would of had'=> 'would have had',
        'wouldbe'=> 'would be',
        'wouldn\;t'=> 'wouldn\'t',
        'wouldnt'=> 'wouldn\'t',
        'wriet'=> 'write',
        'writting'=> 'writing',
        'wrod'=> 'word',
        'wroet'=> 'wrote',
        'wroking'=> 'working',
        'wtih'=> 'with',
        'wuould'=> 'would',
        'wya'=> 'way',
        'yera'=> 'year',
        'yeras'=> 'years',
        'yersa'=> 'years',
        'yoiu'=> 'you',
        'you\'re own'=> 'your own',
        'you\;d'=> 'you\'d',
        'you\;re'=> 'you\'re',
        'youare'=> 'you are',
        'your a'=> 'you\'re a',
        'your an'=> 'you\'re an',
        'your her'=> 'you\'re her',
        'your here'=> 'you\'re here',
        'your his'=> 'you\'re his',
        'your my'=> 'you\'re my',
        'your the'=> 'you\'re the',
        'your their'=> 'you\'re their',
        'your your'=> 'you\'re your',
        'youve'=> 'you\'ve',
        'ytou'=> 'you',
        'yuo'=> 'you',
        'yuor'=> 'your',
);

IRC::register ($MY_NAME, $VERSION, "cmd_speechoff", "");
IRC::print("*** \0038,2$MY_NAME text->speech module $VERSION loaded \003");
IRC::add_command_handler("speechon", cmd_speechon); 
IRC::add_command_handler("speechoff", cmd_speechoff); 

$lastthingsaid = "";

sub spch_substitute {
 my $linein=$_[0];
 my ($sub,$lineout);
 foreach my $word (split(' ',$linein)) {
 # $sub=$wordsub{$word};
  $sub=$wordsub{$word} unless $sub;
  if ($sub) {
   $lineout.=" $sub ";
  } else {
   $lineout.=" $word ";
  }
  undef($sub);
 }
 return($lineout);
}

sub spch_spellcorrect {
 my $linein=$_[0];
 my ($sub,$lineout);
 foreach my $word (split(' ',$linein)) {
  $sub=$spellcorrect{$word};
  $sub=$spellcorrect{$word} unless $sub;
  if ($sub) {
   $lineout.=" $sub ";
  } else {
   $lineout.=" $word ";
  }
 }
 return($lineout);
}

sub cmd_speechon {

 if (!defined($speech_pipe)) {
  open(SPEECH,"|$festival 2>&1 >/dev/null") || do { &print("*E* Error opening pipe to $festival"); return; };
  $fhcp=select(SPEECH);
  $|=1;
  select($fhcp);
  $speech_pipe=1;
  IRC::print("*** Speech activated!");
  $DEBUG && IRC::add_message_handler("NOTICE","speak");

  for my $handle ( @HANDLERS ) {
   IRC::add_message_handler($handle, "speak");
  }

  print SPEECH "($VOICE)\n";
  print SPEECH "(Parameter.set 'Duration_Stretch $SPEED)\n";
  &speak("Speech activated");
  return(1);
 }
}

sub cmd_speechoff {
 defined($speech_pipe) || return;
 IRC::print("*** Speech disabled");
 &speak("Speech disabled");
 undef($speech_pipe);
 close(SPEECH);
 return(1);
}

sub speak {
 defined($speech_pipe) || return;
 my $speakline;
 my $talk = 0;

 $speakline=$_[0];
 $speakline = lc($speakline);
 # parse the privmsg
 if ($DEBUG) { IRC::print("incoming: $speakline\n"); }

 if ($speakline eq $lastthingsaid) {
  if ($DEBUG) {IRC::print("Repeating last line\n");}
  return 0;
 }

 $lastthingsaid = $speakline;

 # Cleanup text
 foreach my $convert (keys %regex_convert) {
  if ($speakline=~/^:(.*)!.*$convert[^:]*:(.*)/) {
   $speakline = "$1 $regex_convert{$convert} $2";
   if ($DEBUG) {IRC::print("event_match $convert\n,");}
   break;
  }
 }

 if ($DEBUG) {if ($speakline=~/.*notice[^:]*:(.*)/) { $speakline="Server says $1"; $talk = 1; }}

 # Find match
 for my $regex ( @MyKeyWordsRegeXs ) {
  if ( $speakline=~ /$regex/i) {
   $talk = 1;
   if ($DEBUG) {IRC::print("Match found for $regex\n");}
   break;
  }
 }

 if ($talk == 0) {
  if ($DEBUG) {IRC::print("No Match found for '$speakline' - no words\n");}
  return 0;
 }

 $speakline=&spch_substitute($speakline);
 $speakline=&spch_spellcorrect($speakline);
 $speakline =~ tr/a-z0-9,.<>?'@+=&%$\A3!\/: ]//cd;
 $speakline =~ s/ +/ /g; # Collapse spaces
 $speakline =~ s/\.{2,}/ /g; # Collapse multiple dots
 $DEBUG && IRC::print("Will say '$speakline'\n\$1 = $speaker \$2 = $message talk=$talk\n");
 print SPEECH "(SayText \"$speakline\")\n";
 return 0;
}

IRC::command("/speechon");

#END OF PROGRAM
######################################################################################
## LICENSE INFORMATION
#
#       GNU GENERAL PUBLIC LICENSE
#          Version 2, June 1991
# 
#  Copyright (C) 1989, 1991 Free Software Foundation, Inc.
#                           675 Mass Ave, Cambridge, MA 02139, USA
#  Everyone is permitted to copy and distribute verbatim copies
#  of this license document, but changing it is not allowed.
# 
#        Preamble
# 
#   The licenses for most software are designed to take away your
# freedom to share and change it.  By contrast, the GNU General Public
# License is intended to guarantee your freedom to share and change free
# software--to make sure the software is free for all its users.  This
# General Public License applies to most of the Free Software
# Foundation's software and to any other program whose authors commit to
# using it.  (Some other Free Software Foundation software is covered by
# the GNU Library General Public License instead.)  You can apply it to
# your programs, too.
# 
#   When we speak of free software, we are referring to freedom, not
# price.  Our General Public Licenses are designed to make sure that you
# have the freedom to distribute copies of free software (and charge for
# this service if you wish), that you receive source code or can get it
# if you want it, that you can change the software or use pieces of it
# in new free programs; and that you know you can do these things.
# 
#   To protect your rights, we need to make restrictions that forbid
# anyone to deny you these rights or to ask you to surrender the rights.
# These restrictions translate to certain responsibilities for you if you
# distribute copies of the software, or if you modify it.
# 
#   For example, if you distribute copies of such a program, whether
# gratis or for a fee, you must give the recipients all the rights that
# you have.  You must make sure that they, too, receive or can get the
# source code.  And you must show them these terms so they know their
# rights.
# 
#   We protect your rights with two steps: (1) copyright the software, and
# (2) offer you this license which gives you legal permission to copy,
# distribute and/or modify the software.
# 
#   Also, for each author's protection and ours, we want to make certain
# that everyone understands that there is no warranty for this free
# software.  If the software is modified by someone else and passed on, we
# want its recipients to know that what they have is not the original, so
# that any problems introduced by others will not reflect on the original
# authors' reputations.
# 
#   Finally, any free program is threatened constantly by software
# patents.  We wish to avoid the danger that redistributors of a free
# program will individually obtain patent licenses, in effect making the
# program proprietary.  To prevent this, we have made it clear that any
# patent must be licensed for everyone's free use or not licensed at all.
# 
#   The precise terms and conditions for copying, distribution and
# modification follow.
#  
#       GNU GENERAL PUBLIC LICENSE
#    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
# 
#   0. This License applies to any program or other work which contains
# a notice placed by the copyright holder saying it may be distributed
# under the terms of this General Public License.  The "Program", below,
# refers to any such program or work, and a "work based on the Program"
# means either the Program or any derivative work under copyright law:
# that is to say, a work containing the Program or a portion of it,
# either verbatim or with modifications and/or translated into another
# language.  (Hereinafter, translation is included without limitation in
# the term "modification".)  Each licensee is addressed as "you".
# 
# Activities other than copying, distribution and modification are not
# covered by this License; they are outside its scope.  The act of
# running the Program is not restricted, and the output from the Program
# is covered only if its contents constitute a work based on the
# Program (independent of having been made by running the Program).
# Whether that is true depends on what the Program does.
# 
#   1. You may copy and distribute verbatim copies of the Program's
# source code as you receive it, in any medium, provided that you
# conspicuously and appropriately publish on each copy an appropriate
# copyright notice and disclaimer of warranty; keep intact all the
# notices that refer to this License and to the absence of any warranty;
# and give any other recipients of the Program a copy of this License
# along with the Program.
# 
# You may charge a fee for the physical act of transferring a copy, and
# you may at your option offer warranty protection in exchange for a fee.
# 
#   2. You may modify your copy or copies of the Program or any portion
# of it, thus forming a work based on the Program, and copy and
# distribute such modifications or work under the terms of Section 1
# above, provided that you also meet all of these conditions:
# 
#     a) You must cause the modified files to carry prominent notices
#     stating that you changed the files and the date of any change.
# 
#     b) You must cause any work that you distribute or publish, that in
#     whole or in part contains or is derived from the Program or any
#     part thereof, to be licensed as a whole at no charge to all third
#     parties under the terms of this License.
# 
#     c) If the modified program normally reads commands interactively
#     when run, you must cause it, when started running for such
#     interactive use in the most ordinary way, to print or display an
#     announcement including an appropriate copyright notice and a
#     notice that there is no warranty (or else, saying that you provide
#     a warranty) and that users may redistribute the program under
#     these conditions, and telling the user how to view a copy of this
#     License.  (Exception: if the Program itself is interactive but
#     does not normally print such an announcement, your work based on
#     the Program is not required to print an announcement.)
# 
# These requirements apply to the modified work as a whole.  If
# identifiable sections of that work are not derived from the Program,
# and can be reasonably considered independent and separate works in
# themselves, then this License, and its terms, do not apply to those
# sections when you distribute them as separate works.  But when you
# distribute the same sections as part of a whole which is a work based
# on the Program, the distribution of the whole must be on the terms of
# this License, whose permissions for other licensees extend to the
# entire whole, and thus to each and every part regardless of who wrote it.
# 
# Thus, it is not the intent of this section to claim rights or contest
# your rights to work written entirely by you; rather, the intent is to
# exercise the right to control the distribution of derivative or
# collective works based on the Program.
# 
# In addition, mere aggregation of another work not based on the Program
# with the Program (or with a work based on the Program) on a volume of
# a storage or distribution medium does not bring the other work under
# the scope of this License.
# 
#   3. You may copy and distribute the Program (or a work based on it,
# under Section 2) in object code or executable form under the terms of
# Sections 1 and 2 above provided that you also do one of the following:
# 
#     a) Accompany it with the complete corresponding machine-readable
#     source code, which must be distributed under the terms of Sections
#     1 and 2 above on a medium customarily used for software interchange; or,
# 
#     b) Accompany it with a written offer, valid for at least three
#     years, to give any third party, for a charge no more than your
#     cost of physically performing source distribution, a complete
#     machine-readable copy of the corresponding source code, to be
#     distributed under the terms of Sections 1 and 2 above on a medium
#     customarily used for software interchange; or,
# 
#     c) Accompany it with the information you received as to the offer
#     to distribute corresponding source code.  (This alternative is
#     allowed only for noncommercial distribution and only if you
#     received the program in object code or executable form with such
#     an offer, in accord with Subsection b above.)
# 
# The source code for a work means the preferred form of the work for
# making modifications to it.  For an executable work, complete source
# code means all the source code for all modules it contains, plus any
# associated interface definition files, plus the scripts used to
# control compilation and installation of the executable.  However, as a
# special exception, the source code distributed need not include
# anything that is normally distributed (in either source or binary
# form) with the major components (compiler, kernel, and so on) of the
# operating system on which the executable runs, unless that component
# itself accompanies the executable.
# 
# If distribution of executable or object code is made by offering
# access to copy from a designated place, then offering equivalent
# access to copy the source code from the same place counts as
# distribution of the source code, even though third parties are not
# compelled to copy the source along with the object code.
# 
#   4. You may not copy, modify, sublicense, or distribute the Program
# except as expressly provided under this License.  Any attempt
# otherwise to copy, modify, sublicense or distribute the Program is
# void, and will automatically terminate your rights under this License.
# However, parties who have received copies, or rights, from you under
# this License will not have their licenses terminated so long as such
# parties remain in full compliance.
# 
#   5. You are not required to accept this License, since you have not
# signed it.  However, nothing else grants you permission to modify or
# distribute the Program or its derivative works.  These actions are
# prohibited by law if you do not accept this License.  Therefore, by
# modifying or distributing the Program (or any work based on the
# Program), you indicate your acceptance of this License to do so, and
# all its terms and conditions for copying, distributing or modifying
# the Program or works based on it.
# 
#   6. Each time you redistribute the Program (or any work based on the
# Program), the recipient automatically receives a license from the
# original licensor to copy, distribute or modify the Program subject to
# these terms and conditions.  You may not impose any further
# restrictions on the recipients' exercise of the rights granted herein.
# You are not responsible for enforcing compliance by third parties to
# this License.
# 
#   7. If, as a consequence of a court judgment or allegation of patent
# infringement or for any other reason (not limited to patent issues),
# conditions are imposed on you (whether by court order, agreement or
# otherwise) that contradict the conditions of this License, they do not
# excuse you from the conditions of this License.  If you cannot
# distribute so as to satisfy simultaneously your obligations under this
# License and any other pertinent obligations, then as a consequence you
# may not distribute the Program at all.  For example, if a patent
# license would not permit royalty-free redistribution of the Program by
# all those who receive copies directly or indirectly through you, then
# the only way you could satisfy both it and this License would be to
# refrain entirely from distribution of the Program.
# 
# If any portion of this section is held invalid or unenforceable under
# any particular circumstance, the balance of the section is intended to
# apply and the section as a whole is intended to apply in other
# circumstances.
# 
# It is not the purpose of this section to induce you to infringe any
# patents or other property right claims or to contest validity of any
# such claims; this section has the sole purpose of protecting the
# integrity of the free software distribution system, which is
# implemented by public license practices.  Many people have made
# generous contributions to the wide range of software distributed
# through that system in reliance on consistent application of that
# system; it is up to the author/donor to decide if he or she is willing
# to distribute software through any other system and a licensee cannot
# impose that choice.
# 
# This section is intended to make thoroughly clear what is believed to
# be a consequence of the rest of this License.
# 
#   8. If the distribution and/or use of the Program is restricted in
# certain countries either by patents or by copyrighted interfaces, the
# original copyright holder who places the Program under this License
# may add an explicit geographical distribution limitation excluding
# those countries, so that distribution is permitted only in or among
# countries not thus excluded.  In such case, this License incorporates
# the limitation as if written in the body of this License.
# 
#   9. The Free Software Foundation may publish revised and/or new versions
# of the General Public License from time to time.  Such new versions will
# be similar in spirit to the present version, but may differ in detail to
# address new problems or concerns.
# 
# Each version is given a distinguishing version number.  If the Program
# specifies a version number of this License which applies to it and "any
# later version", you have the option of following the terms and conditions
# either of that version or of any later version published by the Free
# Software Foundation.  If the Program does not specify a version number of
# this License, you may choose any version ever published by the Free Software
# Foundation.
# 
#   10. If you wish to incorporate parts of the Program into other free
# programs whose distribution conditions are different, write to the author
# to ask for permission.  For software which is copyrighted by the Free
# Software Foundation, write to the Free Software Foundation; we sometimes
# make exceptions for this.  Our decision will be guided by the two goals
# of preserving the free status of all derivatives of our free software and
# of promoting the sharing and reuse of software generally.
# 
#        NO WARRANTY
# 
#   11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
# FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
# OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
# PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
# OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
# TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
# PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
# REPAIR OR CORRECTION.
# 
#   12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
# WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
# REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
# INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
# OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
# TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
# YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
# PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.
# 
#        END OF TERMS AND CONDITIONS

Friday, September 12, 2008

50 years of integrated Circuits!!


Jack Kilby invented IC this very day 50 years back :).. And guess what? in his memory, Texas Instruments has started Kilby Labs. We have come some way in the last 50 years.. and beagleboard is one of the shining lights of what our technology really is :)

Tuesday, September 02, 2008

arm and cortex documentation

thanks to beagle board irc (#beagle on freenode), found this link useful:
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0344e/index.html
It is literally a goldmine for those working on ARM processors!

Sunday, August 31, 2008

Low cost Jtag for beagle

In the quest for a proper debug tool.. printfs have been my friend so far.. but printfs cannot help in many cases optimally.. JTAG is the right solution for such cases. keesj and I have been independently working on getting openocd working with flyswatter.
http://elinux.org/BeagleBoardJTAG is the starting point in this quest! join us, provide your thoughts etc..

[Update: Sept 3, 2008:
1. keesj has mailed an excellent report to the beagleboard list on his progress on the JTAG saga. Read about it here (excellent job Kees :) ).
2. As pointed by keesj, tincan tools have the adapter on the product page]

Today, the thought has been in creating a jtag debugger convertor - given that "ARM standard" and "TI standard" are not 1-1!

Note: Tincan tools is planning on making a more professional connector than "mine" and most probably will work.. one thing I can say for sure.. OMAP still works after plugging this in.. and I can probe the chip ID from openocd we are still way off from getting openocd working..

keesj had an adapter which does the translation. here is how it ought to look:
==>

Now, I dont have the above connector, so I set about creating my own:
step 1: connectors and my setup as per this:

step 2: created a connectivity of the same as per this:


NOTE: I screwed up the EMU0,1 wiring to pull up instead of down in the above picture.. my"rev0.2" fixes it ;)..

Thanks to keesj: (sample openocd.cfg):
#Basic configuration
#default port 4444
telnet_port 4444

#interface

interface ft2232
ft2232_device_desc "Flyswatter"
ft2232_layout "flyswatter"
ft2232_vid_pid 0x0403 0x6010
jtag_speed 1

#jtag scan chain
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
jtag_device 6 0x1 0x0 0x0

target arm926ejs little 0 arm926ejs

#
# trst == test rest is part of the jtag optional specs and allows the jtag state machine
# to be reset to an initial state
#
# srst ==system reset?
#
reset_config trst_and_srst
Building openOCD: http://openfacts.berlios.de/index-en.phtml?title=Building_OpenOCD
I did it with libftdi using ubuntu, as the binaries of the closed source ftdi driver is x32 bit :(
nmenon@coyote:~/Src/opensource/openocd/trunk$ sudo ./src/openocd -f ../keesj/jtag-3530.cfg
Open On-Chip Debugger 1.0 (2008-09-01-16:50) svn:977
$URL: svn://svn.berlios.de/openocd/trunk/src/openocd.c $
jtag_speed: 1
Info: JTAG device found: 0x0b7ae02f (Manufacturer: 0x017, Part: 0xb7ae, Version: 0x0)
Error: unknown EmbeddedICE version (comms ctrl: 0x00000000)
Warning:no gdb port specified, using default port 3333
Warning:no tcl port specified, using default port 6666
telnet localhost 4444
> halt
timed out while waiting for target halted
Runtime error, file "command.c", line 436:
> scan_chain
0: idcode: 0x0b7ae02f ir length 6, ir capture 0x1, ir mask 0x0, current instruction 0xc
Not too good, as keesj points here, we probably need to give tapid commands before things start working..

[Update: Sept 3, 2008:
as keesj mentions:

SCANINIT t1:w1000:t0:w1000: ;toggle TRST,
SCANINIT ch10:w1000: ;clock TCK with TMS high and wait
SCANINIT i6=07:d8=89:i6=02: ;connect and select router
SCANINIT d32=81000080: ;IP control: KeepPowered
SCANINIT d32=a3002048: ;TAP3: DebugConnect, ForcePower, ForceActive
SCANINIT d32=81000081: ;IP control: KeepPowered, SysReset
SCANINIT d32=a3002148: ;enable TAP3
SCANINIT cl10:i10=ffff ;clock 10 times in RTI, scan bypass

In openocd this would translate to the following sequence.

irscan 0 7
drscan 0 8 0X89
irscan 0 2
drscan 0 32 0xA3002108
......
irscan 0 0x3F
sleep 10
jtag_device 4 0x1 0x0 0xe

A final frontier remains: EMU0,1 -> unlocking it's mysteries..]

Thursday, August 28, 2008

omap u-boot-utilities released!!

Finally, it is out.. nothing great as of each of the tools.. but these are handy little blokes to have around.. see the announce here
Links to the project sites:
* Source Code hosting: Git Hub
http://github.com/nmenon/omap-u-boot-utils/
* Binaries, Defect tracking and Documentation: code.google.com -
http://code.google.com/p/omap-u-boot-utils/

pserial history:
They started off coz, I wanted something to work on windows and Linux equally well and I had nothing on hand.. the first app I ever wrote in this thread of thought was the perl script here. Now, perl is good but it can turn ugly too- esp for a new guy poking around.. hence wanted a pserial with a c version. While, doing that with windows, I set myself some weird targets:
a) I will not use cygwin or vmware -> I wanted folks to use the exes without worrying about where the lib files should be got from!
b) It will provide the user apis to be as similar as possible.
I ended up with MingW compiler for windows, and the usual gcc for linux.

pusb history:
Incidently around the same time Dirk and I had a interesting few days getting usb apps working -> which we both did in our own ways. Dirk's code is accessible here. I must say, we had been thinking about this w.r.t doing a custom driver + app.. but libusb seems to have done it all before.. The only hickup was getting Win32 version of it functional.

ucmd history:
Many days later while trying to download I hated having to switch windows between hyperterm and pserial command window, and decided to be lazy and write a ucmd -> something to send commands to uboot!

ukermit history:
This has an interesting story of me getting tired of using ckermit and hyperterminal and finally deciding to write my own kermit application custom to u-boot which I could run from command line in windows and linux. Note: This does not mean u-boot wont work with standard apps.. Mine is just one which you can tweak around (like the -d option) for u-boot!

That is long short story of how all of these started... anyways.. So have fun and send your patches if you like things and could fix things up -> esp the irritating usb2serial convertor and pserial issue!!

Monday, August 11, 2008

some thoughts on writing boot code for omap

This following post is based on a reply I send to Vishal Bhoj, thought I'd share with all..
In general before starting, I suggest one does read the TRM and Data Manual pretty well.
If you are starting from scratch, it may not be quick to get things running on OMAP,but the basics are same no matter which OMAP you do take.. Unfortunately, I don't think I could start explaining the entire OMAP architecture even if I wanted to.. :( I am not saying it is an herculean task doing a boot code, but it is challenging and is a good way to start really know OMAP's potential. The question was related to UART and character LCD on SDP2430/3430, and the following is a very very brief overview of what to think of as a starter..

Some basic Fundamentals:

OMAP is a SOC (System On Chip) -containing ARM, DSP and other peripherals.
ARM has a memory mapped interface to it's peripherals it can talk to.
UART is one such peripheral,
character LCD on SDP2430 on the other hand is emulated over FPGA on the board. So, you need to look at how to talk to FPGA from ARM.

Now, every peripheral has a few basic stuff:
a) Basic clocks: Interface clock -> clock to enable register access, functional clock -> clock for it's functionality.
b) Another generic stuff is called pin muxing -> OMAP has hundreds of peripherals with tons of possible pins flowing out.. so the logic is simplified by muxing multiple pins to a single pin out and OMAP allows configuration of which pin you want in what mode.

Note: the above is the bare minimum stuff you need to take care, there
may be more per peripheral.

So when you boot up you need to get your clocks right(to make the module functional) and also the pin muxing right if you intend to talk to the world outside OMAP. Now every peripheral has it's own internal methodology of programming and operation.. + you may have specific needs
of power and timing -> esp when you speak with the peripherals outside of OMAP. Remember OMAP is designed to talk to as many things as possible, so you'd need to configure things as per the device you want to.. usually one-size-fits all is not optimal esp in the embedded
world.. so you'd need to tweak timings..

You also need to remember what you need to do when your code gets control - esp while you boot up. what things are active and can cause a reset(e.g. watchdogs), where are you booting from -> sram, NOR, NAND, sdram etc.. things are bit different and constraints different for a
boot code..

If you intend to write boot code, you need to understand the hardware pretty well.. it usually a mite tougher to write a boot code from scratch compared to writing a simple driver once everything is setup and you just need to call apis to get things done..

So, U-Boot, X-Loader might be good places to look at, but dont stop there.. you could write your own boot loader.. or even port something like grub, lilo or anything out there.. doing it is fun.. but getting it to work and be stable gives an even high level of exhilaration..

happy hunting.. Remember in boot code, most things are logical.. so knowing the hardware as well as your code is of equal importance :)...

Saturday, August 02, 2008

How to make a bootable MMC card on Linux for BeagleBoard (using gparted)

H/w I have:
a) Beagle board rev A5
b) a 512Meg Micro SD card with adapter
c) USB2Serial convertor (my laptop docking station has a PCI UART, but I hardly ever use docking stations)
d) card reader
Objective use the UI tools in Linux as much as possible to boot mmc card on beagleboard.

Step 1:
getting to know the usb sd/mmc card reader device:
plugin the reader and run dmesg
E.g.:
[50306.414076] sd 6:0:0:0: [sdb] 254208 512-byte hardware sectors (130 MB)
[50306.419071] sd 6:0:0:0: [sdb] Write Protect is off
[50306.419080] sd 6:0:0:0: [sdb] Mode Sense: 03 00 00 00
[50306.419084] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[50306.431052] sd 6:0:0:0: [sdb] 254208 512-byte hardware sectors (130 MB)
[50306.436051] sd 6:0:0:0: [sdb] Write Protect is off
[50306.436059] sd 6:0:0:0: [sdb] Mode Sense: 03 00 00 00
[50306.436063] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[50306.436071] sdb:
[50306.442153] sd 6:0:0:0: [sdb] Attached SCSI removable disk
[50306.442235] sd 6:0:0:0: Attached scsi generic sg1 type 0
See here for more instructions on using fdisk
-> here are my own instructions (Ubuntu 8.04)
Step 2: Formating the mmc card
a) Stop HAL from autodetecting drives..
sudo /etc/init.d/hal stop
b) Run gparted
sudo gparted /dev/sdb
c) Delete all partitions present

































d) create the minimum FAT32 partition (primary partition)











e) create the rest of the disk for ext3fs (primary partition)











f) apply the changes
g) Set the FAT32 partition as bootable:
select manage flags for the FAT32 partition

select bootable option:


apply and quit from gparted.
h) restart the hal
sudo /etc/init.d/hal start
sudo /etc/init.d/hal restart


(At this point, you can replug your mmc card without it being auto detected ;)...
Step 3:Copy the images
a) run mount command to see the partitions:
mount

/dev/sdb2 on /media/disk-1 type ext3 (rw,nosuid,nodev,uhelper=hal)
/dev/sdb1 on /media/disk-2 type vfat (rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush)

b) mount the partitions and copy the following to FAT32 partition:
MLO, uImage, u-boot.bin (See here and here for more versions)
c) unmount the filesystem on the PC. put the card in the board
d) boot up and you should see x-loader followed by u-boot coming up.

Boot args: for Linux to boot out of mmc card and continue using the filesystem in mmc partition 2,
setenv bootargs "console=ttyS2,115200n8 noinitrd root=/dev/mmcblk0p1 rootfstype=ext2 rw rootdelay=1 nohz=off"
setenv bootcmd 'mmcinit; fatload mmc 0 0x80300000 uImage;bootm 0x80300000'
saveenv


NOTE: I dont trust the bootargs completely.. any one with proper values.. please comment in.. there are two variants here:
a) partition number mmcblk0p1 or the equal based on udev etc..
b) partition type - ext2/ext3 etc..