Monday, November 24, 2008

PCI card based serial and parallel port

Yesterday I went to Sim Lim square for the monthly (or bi-monthly) IT refreshment trip. My intention was mainly to check out network based media player. But interestingly I found out that there are shops selling PCI based serial/parallel port card. You get real serial port and real parallel port from the card. Typically USB to serial port cable can do most of the job. But typical USB to parallel cable is totally useless for interfacing to anything other than your old parallel port based printer. Therefore if you have parallel port based cheap JTAG debugger (say ARM or MSP430), then you are out of luck if you do not have parallel port with your new PC (laptop or desktop).

One of the vendor is ST-LAB ( It is using MOSChip ( as its brain. The single serial or parallel port version is selling at about S$23.

Another company providing chips is Oxford Semiconductor (

Tuesday, November 11, 2008

RTOS Links Collection for Microchip MCUs

There are many interesting discussions in the Microchip Forum
about RTOS. There are also more and more RTOS produced for
Microchip MCUs, especially after the introduction of bigger
PICs like dsPIC30, PIC24, dsPIC33 and PIC32.

Monday, November 3, 2008

Ubuntu 8.10 installed

Ubuntu 8.10 has been released and I installed it last Saturday on my Acer M1641 desktop. It is really very smooth. The only thing I need to do is to use the Nvidia proprietary X driver to get 1280x1024 resolution. I did not encounter problems I met with Ubuntu 8.04 (

Good job, the Ubuntu team!

Sunday, October 5, 2008

Nokia 6280 Problem

Now my wife has the E71. So I took over Nokia 6280 and I'd like to use it to replace my old Samsung SGH-E388 phone and the old MP3 player. I think I would keep my Sony portable FM radio but just in case I could use 6280 as well.

However now I got a problem. My Starhub Green Prepaid SIM card does not work with the phone. The same SIM card works on my old Nokia phones and even the new E71 but just not this 6280. It rejects the SIM card no matter what I tried (cleaning up the SIM card and the phone SIM card holder). A trip to the Starhub service centre does not help either. They would not be able to help me to keep the number if they change the SIM card for me (SG$18 charge is acceptable to me). To me that is not a good idea as I have used the same number for 4 and a half years. So in the end, I may have to use my old Samsung phone. Or maybe I will look at some Windows Mobile Phone -- they are getting cheaper and cheaper. Windows Mobile SE phones like the Treo 500V is selling at SG$299 when I went to Sim Lim Square to buy the toner cartridge for our Samsung SCX-4200.

By the way, it is quite hard to find shops selling the SCX-4200 toner cartridges. Last time I tried Funan and only one shop was selling. And in Sim Lim Square, I only managed to find two. I paid SGD112 finally for the cartridge even though it was about SG$100 last time when we bought the printer.

For the trip, I also bought an SG$9.9 Sandisk 2GB SD card for the Wii and a SG$39 USB IDE harddisk enclosure for the old 250G IDE disk from my failed desktop.

A New E71

My wife would like to combine the functionality of her current three device into one. Her brother would recontract his Singtel mobile contract so this was just nice. He would buy the phone as a gift.

But it turns out that here requirement is actually high even on surface the high end requirements (Wifi, GPS) are not there.

1) Nokia 6280 Phone for voice/sms, MP3, FM radio. This was bought in the Christmas time of year 2006 as a gift. It is a good phone but the built-in dictionary is not good enough for medical study.

2) HP Jornada 545 (my old Pocket PC 2002 PDA bought in 2002) for dictionary function (MDICT and medical dictionary). It is old and heavy.

3) BESTA electronics dictionary with keyboard and voice. It is easy to use but

I was looking at Windows Mobile platform initialy since MDICT works. FM and Keyboard combination seems to be the problem. There are quite some Windows Mobile Professional (Standard is not considered as I think Windows Mobile is designed more with a touch screen in mind) with keyboard but most of them do not have FM radio. The only one selling in Singtel is HTC Touch Pro which costs SGD988 for recontract without trade-in (SGD888 for new line). She would not give up the FM requirement. If she gives up the requirement for the keyboard, there are some more choices like LG KS20 (SGD268 for recontract), some MWG (O2 XDA) device and some HTC devices. However after trying out a lower-end Asus P320 Windows Mobile 6.1 Phone, she did not feel like the keyboard requirement could be dropped.

The I started to look at Symbian OS platform. LG KT610 has keyboard and is cheap, unfortunately it does not have FM. In the end, we bought a Nokia E71 which has a lot of functionality (Wifi seems to be of good use, GPS is no use now). Most of the phones used at home are from Nokia and the quality of Nokia is really top notch based on our experiences.

Initially my wife did not quite like the outlooks. But now she thinks the phone is great.

A new Wii for us

I was thinking of buying a Wii for physical exercises for sometime.
After doing some research, I bought an authorized set this Wednesday
(public holiday in Singapore). I paid SGD710 (after comparing 7 shops
in Funan IT Mall) for the following.
1) Wii Sports Official Singapore version with 3 months warranty
by Maxsoft. Listed price is SGD499 but many shops sell for SGD519.
The so called official Singapore version is just the US version
plus an official 240V AC power supply for Singapore.
2) Extra set of Wii Remote (bundle with Wii Play: SGD79) and Numchuck (SGD39)
3) Active Life Outdoor Advantage (my wife's favorite) (SGD109).

The shop is GameScore (#05-05, Funan Digital Mall). The other
shop (Zavi) seems to have good deals with SG$499 basic sets
and SGD588 basic sets+extra set of controller offer. Many other
shops only sell SGD645 bundle (basic sets with three games and worst
is that you can not choose the game).

I was paying by cash so that the shop gave a bit of discount.
SG$710 is about US$500. I think it is much cheaper in US. Anyway,
Wii is only soft-launched in Singapore.

On Saturday, I also bought 1000 Wii Points (US$10) and spent 500
points on the Internet Channel. I spent the other 500 points on
a casual WiiWare (Defend Your Castle).

We are not serious gamers. If not, Xbox (60G Elite version is selling
at SGD499) and PS3 (basic set is selling at about SGD530) seem to
have better price performance ratio.

So far the experiences with Wii seem to be positive among three of
us in the household.

Friday, September 26, 2008

Microsoft Equation Editor problem with system locale

I was facing similar problems with Office 2000/XP under Windows XP and Vista 32bit. Now I understand the problems. That is because I have set up System Local to use Simplified Chines to be able to display Chinese for some non-Unicode programs. After setting back the System Locale to English (Singapore or USA), equation editor can run again. I believe this applies to other version of Office as well (like 2003 and 2007).

Install XP on HP Compaq Presario V3619AU

There are many articles on installing XP on the HP/Compaq
laptops. The major problem seems to be the chipset,
graphics and sound card driver. Here are some good links
which works for our Presario V3619AU. YMMV.

General overview and dual boot.

I used Vista's built-in Disk Manger to shrink the C: partition
and create another D: partition (the recovery partition will be
E: now. The I installed XP SP1 on the computer (better not
connect to Internet because of some bugs with XP SP1) and then
updated it to XP SP3. After that, we need to fight with various
driver issues.

Working drivers for chipsets and graphics.

I used the same Nvidia chipset driver and graphics driver
(NForce 630a+Gefore GO 6150 graphics) and it works for our
Compaq Presario 3619AU.

Nvidia Chipse driver
Nvidia graphics driver

Sound card was the worst for 3619AU (Connexant HD Audio). I
tried all kind of things to no avail. Finally got an Toshiba driver
and manually edited the INF file to get it working. Still it has
some bugs and occasionally noise comes out. Some people
have lucks with the HP Vista driver, not for us.

[EDIT in October 2008: finally solved the problem by using
the HP XP driver for other models but modifying the
INF files to add the IDs by copying the INF file
section from the Vista driver]

For most of the other things, HP/Compaq's Vista driver/software works
(wireless, card reader, bluetooth, DVD writer, etc). HP puts
the software in C:\SwSetup directory and that is a good thing.

For people who want a real XP based desktop/Notebook, the new
Atom based PCs will be a good option. For instance, I played
with Asus EEEbox and it was not slow at all running XP.

Monday, September 22, 2008

Acer M1641 Ubuntu 8.04 Shutdown Problem Solved

I could not find any BIOS updates to Acer M1641. Therefore I have to use "acpi=off pnpbios=off" option. There was still a problem. Reboot works. Shutdown does not work as it hangs.

Similar bugs were reported for Ubuntu 8.04.

The solution in the Launchpad bug report works.

This is certainly not an old PC and Vista 32bit SP1 works fine. However I tend to believe this is more an Acer Bios bug. Actually FreeBSD 7 hangs during startup. If I disabled ACPI in BIOS, FreeBSD 7 will complain about GPF (General Protection Fault) no matter which option I select for startup. If I enable ACPI in BIOS, it could not find the disk. So I could not run FreeBSD 7 at all with this new PC. So Ubuntu 8.04 is at least better than FreeBSD 7 in this aspect.

FreeBSD problem with Acer M1641 is reported here.

Notes on 10-April-2009:
The latest kernel does not need the options any more for Ubuntu 8.04.

Friday, September 12, 2008

Samsung SCX-4200 Scannding and CUPS Printing Problem Finally Solved

It turns out that the USB cable is to blame. Changing to a better USB cable solved the Scanner I/O Hardware Error problem. Now I do not need to use the USB 1.1 Hub to force the scanner to work in the USB Full Speed mode.

This also solved the CUPS problem when use the Western Digital Mybook World as the printer server. We are using an image from a Chinese website ( It has already done a good job and provide a nice web interface for managing the Mybook World. In CUPS, we need to explicitly enable “raw” printing for application/octet-stream. Please refer to the following two URLs for more information.

Basically what we need to do is to edit /etc/cups/mime.convs and put in this line:
application/octet-stream application/vnd.cups-raw 0 -

Then we also need to install Samsung driver for the Windows Vista, XP and Linux client.

Saturday, September 6, 2008

Acer Aspire M1641 with Ubuntu 8.04

The installation of Ubuntu 8.04 on the Vista based M1641 proved to be a bit harder than I would like.

Problem 1: need to disable acpi (boot the kernel with acpi=off option). Ubuntu 8.04 will hang during bootup after "Starting Bluetooth Services...". Actually I knew this problem when my bother-in-law tried to boot up a Gentoo based live cd for hacking the Mybook World. Still I expected Ubuntu 8.04 to be better. Unfortunately not. And Google shows that this is a common problem. Ubuntu also complain about the PNP bios problem. I will check whether there are new BIOS from Acer.

Problem 2: need to use the Nvidia closed-source driver to get the display working with the native LCD resolution. The default install stuck at 800x600 and 640x480 at 61Hz. Google shows similar problems. Installing the closed-source Nvidia driver (normally I do not want to do this and do not need to do this) solved the problem.

After solving these two problems, I am happy with Ubuntu 8.04 again.

A New Vista PC Acer Aspire M1641

My old desktop suddenly went south. So I have to buy another PC. I was eying the Asus EeeBox (XP Home, Atom CPU, very cute). but later decided to buy a cheap Acer Aspire M1641 (47M32) instead. Its cost is SGD640 (no monitor) with upgraded DDR2 RAM to 2GB since I know Vista will be happy with 2GB RAM. The 47M32 model is the 47MR32 model without the Nvidia 9300 graphics card. Since I do not really play games, the 7050 integrated graphics is good enough to me.

Many people do not like Vista. And Vista really have problems with old hardware and old software. Still most of the desktops and notebooks now come with Vista only and the vendor does not provide XP driver. Anyway, I'd like to try out Vista myself. I have spent a few days to install the software packages I like to use. So far I have not met major problems with it but I did notice a few IE7 stability problems.

Of course, I also installed Ubuntu 8.04 on it. Vista has one good feature. It is so easy to shrink a partition under Vista. Shrinking the empty D drive took only seconds.

Samsung SCX-4200 Printer with Western Digital Mybook World Linux CUPS

We also want to try out to use the Samsung SCX-4200 printer with a hacked Western Digital Mybook World Edition 500GB device. The simple NAS runs Linux and we can use the USB host to connect to the printer and use CUPS to share the printing function. However, it seems that sometimes the printer will stop functioning. My brother-in-law bought this Mybook World in the Comex show recently held in Suntec City. He did quite some research and successfully got the hacked version work nicely as a file/P2P server. But the printer server function is still not so good. Sometime it works. Sometimes it does not.

I tried to downgrade the printer to use USB 1.1 Full Speed by inserting the USB 1.1 hub in-between the host port of Mybook World and SCX-4200 but that does not help too much.

Samsung SCX-4200 Scanner Hardware I/O Error Problem Solved

I bought this Samsung SCX-4200 printer/copier/scanner early this year. The printing and copying function work fine. At its price, it seems to be a good investment. Since we have another old Acer S2W 3300U and it works very well so we have not used the scanning function. But the first time we tried to use it, it gave us "Hardware I/O error". I have tried it under three different PCs, under Windows Vista, XP and Ubuntu Linux. All have the same error even though it works fine as a printer under all three OS. So I was thinking to call Samsung coming Monday since it is still under Warranty.

Today I read this solution here. Finally I understand the problem. The problem seems to be that the scanner does not work fine

Under Linux, one can rmmod the EHCI driver (high speed USB) to force it to use Full Speed USB transfer. Under Windows, my solution is to put a USB 1.1 Hub in between. After that, the scanner works fine.

Friday, August 1, 2008

Two Trivial Patches now in Linux Kernel 2.6.26

I am not a Linux kernel hacker, actually I am not even a programmer.
But I've got two trivial patches about USB PICs in Linux kernel 2.6.26.
So it seems we can help the open source community no matter how minor
the contributions are.
commit 5fc89390f74ac42165db477793fb30f6a200e79c
Author: Xiaofan Chen
Date: Tue May 13 21:52:00 2008 +0800

USB: remove PICDEM FS USB demo (04d8:000c) device from ldusb

Microchip has changed the PICDEM FS USB demo device (0x04d8:000c)
to use bulk transfer and not interrupt transfer. So I've updated the
libusb based program here (Post #31).

So I believe that the in-kernel ldusb driver will no longer work with the
demo firmware. It should be removed.

Signed-off-by: Xiaofan Chen
Cc: Michael Hund
Cc: stable
Signed-off-by: Greg Kroah-Hartman

commit f4971031f4acd98423a2903c6517fb3ef1aea8dc
Author: Xiaofan Chen
Date: Tue May 13 17:11:59 2008 +0200

HID: add Microchip PICKit 1 and PICkit 2 to blacklist

Microchip PICkit 1 and PICKit 2 USB Programmers are USB HID class of device but
they are not real HID device. They are now supported by libusb based programs
like the following programs.

pk2 and pk2cmd Linux port:
usb_pickit original version:

Therefore it is preferred to blacklist them.

Signed-off-by: Xiaofan Chen
Signed-off-by: Jiri Kosina


Wednesday, July 2, 2008

Cross-platform pk2cmd 1.10 released

Microchip has released a cross-platform version of pk2cmd
V1.10. It works under Windows, Mac OS X and Linux. It is
also partially working under FreeBSD. I am proud to
have contributed the development by providing some ideas
and carry out quite some testing under Linux and FreeBSD.



My blog has quite some articles about pk2cmd under
Linux and FreeBSD.

Sunday, June 15, 2008

Fedora 9 Installed

I always want to try out both ubuntu and Fedora since both are among
the most popular Linux distros. I've used Ubuntu since 5.04 (5.10,
6.06, 6.10, 7.04,7.10 and 8.04) and now I am mainly using 8.04
even though I kept 6.06 and 7.10 as well. I've used Fedora since
Core 3 (Core 4, Core 5, Core 6, Fedora 7) but Fedora 8 failed to boot
in my system due to the conflict with FreeBSD last time
So I have not used Fedora for a while except an old Fedora Core 6
installation used for occasional testing purpose.

Today I installed Fedora 9 (after removing the dormant PCLinux 2007
partition). Initially I did not install grub since I always used my trusted
Ubuntu 6.06 to handle grub stuff and it works for all other Linux distros
I am using and it works for FreeBSD 7.0 and NetBSD 4.0 as well.

But this proved to be not a good idea for Fedora 9, which is always
on the cutting edge side. The grub from Ubuntu can not handle
Fedora 9 due to some changes. Google shows that there are many
users having similar problems.


I tried to use the chainloading method in the thread but it did not work.
I was thinking of giving up but I decided to try it again. I chose to "Upgrade"
the new installation and surprisingly it gave me the chance to install the
bootloader and did not mess up the existing installation. The grub
bootloader did not recognize the other operating systems (not even
Windows XP) but I knew this from past experiences.

After this, Fedora 9 can boot properly. I modified the menu.lst file from
the Ubuntu 6.06 menu.lst file so that I could boot the other operating

So this time it is better than last time.

The normal operation of Fedora is quite ok just like my past
experiences with Fedora Core 6 and Fedora 7. There are
some new things like PolicyKit/ConsoleKit to set up permissions
for usb device which I am now learning. Other than that,
it is quite easy to get my usual programs (gputils, sdcc,
libusb, openusb, pk2cmd, etc) to work.

Sunday, June 1, 2008

Simple libusb 1.0 and OpenUSB example

I have created some simple host programs using the latest
libusb-1.0 and OpenUSB to test Jan Axelson's generic
WinUSB firmware under Linux.

As you can see from the examples, it is not that difficult
to port existing libusb-0.1 based program to the new
libusb-1.0 and OpenUSB.

However the main thing may be how to better use the
new features of libusb-1.0 and OpenUSB to have better
performance than the old libusb-0.1.

Sunday, May 18, 2008

Embedded System LCD PC Software Links

Microchip is now offering a free Graphics LCD library for use
with PIC24/dsPIC/PIC32. It also has support from 3rd parties
like Segger and Ramtex.

Segger has emWin which is very powerful but not cheap.

Ramtex has the Font Editor and Graphic libraries for popular LCDs.
They have GLCD simulator as well. They are one of the partner for
Microchip's Graphic Library.

This Chinese guy has a nice software called LCD Font Maker which
only cost US$. It supports many languages including Chinese.

Atmel has the free LCD editor and LCD plug-in for AVRstudio.

Pocket MicroTechnics has the GLCD Font Creator and plugins
for SawFish/Proton Basic compiler and MikroElektronika
mikroBasic/Pascal/C compilers.

This website has a free GLCD font generator which exports
to C compilers like WinAVR and Codevision or similar.

This website has free Simulator for LCDs.

lcdproc is a nice project for Linux/BSDs.

There are also many examples on the internet about using
LCDs, Graphics LCDs, OLED displays with Microcontrollers.

Thursday, May 15, 2008

My first two simple Linux USB patches got accepted

I am basically a non-programmer. However I am interested in learning
USB and I like to support Open Source software and spend my
spare time doing testing or helping with the documentations
for some projects (piklab, pk2, pk2cmdLinux, libusb, openusb,
libusb-win32, pyusb, HPS USB stack for FreeBSD, etc).

I just submitted two trivial patches to the Linux kernel. They both
got accepted.

1) USB HID Quirk Patch: add Microchip PICKit 1 and PICkit 2

2) USB: remove PICDEM FS USB demo (04d8:000c) device from ldusb

Sunday, May 11, 2008

libusb 1.0 and libusb-compact-0.1 now usable

Thanks to Daniel Drake's hard work, now libusb-1.0 and libusb-compact-0.1 seem to work well enough for many applications now.


Git: (use "git clone" to get the initial clone and then use "git pull" to update)

You need to use the latest version of both.

I've tested it with pk2cmdLinux ( and fsusb_demo (

Thursday, May 8, 2008

Windows XP SP3 Installed

I spent some time to find the links from Microsoft website but to no avail (I found one
checked build version but that is not what I want).

Google found this one.

Downloading the 316MB Windows XP SP3 is pretty fast here from my Starhub
8Mbps cable online service.

Its installation is faster (on this slower desktop) compared to Vista SP1 (on
the faster notebook). The installation is pretty smooth as well. I have done
a few tests with Microchip MCU development tools (MPLAB, ICD 2, PICkit 2
and USB Stack V2.1) and all are running fine.

Saturday, May 3, 2008

Ubuntu Launchpad Account Created

I've been a happy Ubuntu user since Ubuntu 5.04. Now I am running Ubuntu 8.04 along with 6.06 and 7.10.

Today I created my Launchpad account to report that an existing bug with 7.10 still exists in 8.04.

I am not a software developer but I think I can be of some help when it comes to testing.

Ubuntu 8.04 First Impression

I installed Ubuntu 8.04 last week. The first impression was not good since it hangs after initial bootup. This reminds me of OpenSuse 10.3 after enabling compiz. So I boot into Gnome Fail Safe Session and disabled Visual Effects (and actually removed compiz) and then reboot. This solved the problem.

Other than this initial glitch, it seems to be quite smooth and solid, not like the initial bump with Ubuntu 7.10 (7.04 was flawless, 6.06 is solid). I was able to set up my usual testing environment and build various PIC or USB related programs from the CVS/SVN source pretty fast and all of them seem to work fine.

On the other hand, there are no nothing too special with Ubuntu 8.04. Maybe this reflects my simple usage pattern with Linux.

Friday, May 2, 2008

Vista Problem Solving Part 2: Vista SP1 installed

I tried to update the Vista installation using Windows updates but it was not there. Therefore I just downloaded the stand-alone x86 installation. It was quite fast to download the 400M+ file from my 8Mbps Starhub Cable Online (I believe Starhub is Microsoft Singapore's ISP). The installation took quite a while (about 50minutes) and finally it was finished without incident.

I will still need to check if it helps on the stability of the computer. One problem my wife has is the stability with Windows Media Player (or the alternative Media Player Classic) when viewing RealPlayer files (rm or rmvb files). I do not want to install RealPlayer since it has caused problems in the past.

Vista Problem Solving Part 1: Excel has stopped working

My wife now has more and more complains about the Vista notebook we bought on Christmas day of 2007 (

The biggest complain is that often Excel will often say that it has stopped working if she double-clicks an Excel file to open it. She has to open Excel and then open the file from within Excel.

Google found the solution.

Quote what johnko99 wrote:
Click "start" - the button down left to your screen Select "run" and type "regedit".
Click OK. The Registry Editor opens in a window.

In the registry editor locate the following: HKEY, LOCALMACHINE, SOFTWARE, MICROSOFT, OFFICE, EXCEL, ADDINS, BtOFFICEAddin.BtOFFICEIntegration.1

Under label "Name" there should be a line: "Lodbehavior". Now in the same line under "Type" there should be REG_DWORD" and under "Data" there should be "0x0000003 (3)" or something similar as far as the last digit is concerned (in this case 3).

Behold, you are close to the solution... Change the last digit AND the one in brackets (in my case 3) to read 0! In my case under "Data" now reads "0x0000000 (0)".

That's it!!!!!!!!!!!!!!! Close the registry editor and restart the computer.

Your Excel now is working perfectly!

This is the perfect solution to this problem. The forum mentioned Excel 2007 and Excel 2003. Actually it works for Excel 2000 as well.

Thursday, May 1, 2008

pk2cmd Linux Port under PCLinuxOS 2007

Here is a mini-howto to get pk2cmd Linux port to work under PCLinuxOS 2007.

1) Download pk2cmdLinux from Jeff Post's website.
Download link:

Edit in 09/2009: new download link

As of this writing, the version is 0.8.

2) Preparation to get pk2cmd working is easy under PCLinuxOS 2007.

You need to have g++ (provided by package gcc-c++) and make (provided by package "make"). You also need to install libusb-devel package. You can use Synaptic (GUI) to install these packages and their dependencies. You can also use apt (apt-get install libusb-devel) as root to install this package.

3) Edit the Makefile and then build it using make.
You need to edit the Makefile to to define the proper CFLAGs.
PCLinuxOS 2007 is usingLinux kernel 2.6.x and support udev rules. So we will use the following option.

# ----- Use the following for Linux kernel 2.6.x: -----

Now we can build pk2cmdLinux. Just type "make".

4) Test it as root and it should just work.

5) In order to run pk2cmdLinux as a normal user, we need to set up udev rules. PCLinuxOS 2007 has done the udev rules for the users. So it is easier than other Linux distros. The only thing you need to do it to add you user name to the group "usb".

Go to PCLinuxOS Control Center and choose "Add, remove or change users of the system", right
click your user name and choose "Edit" and select "Groups". Check "usb" and you are done.

To confirm this, run "group yourusername".

[mcuee@localhost pk2cmdLinux-0.8]$ groups mcuee
mcuee : mcuee tty lp wheel uucp cdrom usb cdwriter audio video users

[mcuee@localhost pk2cmdLinux-0.8]$ lsusb
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 003: ID 04d8:000c Microchip Technology, Inc.
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 002: ID 04d8:0033 Microchip Technology, Inc.
Bus 001 Device 001: ID 0000:0000

[mcuee@localhost pk2cmdLinux-0.8]$ ls -la /dev/bus/usb/001/
total 0
drwxr-xr-x 2 root root 80 May 1 09:09 ./
drwxr-xr-x 5 root root 100 May 1 2008 ../
crw-rw---- 1 mcuee usb 189, 0 May 1 2008 001
crw-rw---- 1 mcuee root 189, 1 May 1 09:12 002

Now you can run pk2cmd as a normal user.

[mcuee@localhost pk2cmdLinux-0.8]$ ./pk2cmd -?V

Executable Version: 1.01.00 (Linux/Mac port 0.8)
Device File Version: 1.42.00
OS Firmware Version: 2.30.01
Operation Succeeded

[mcuee@localhost pk2cmdLinux-0.8]$ ./pk2cmd -PPIC16F690 -I -T
Device ID = 1403
Operation Succeeded

[mcuee@localhost pk2cmdLinux-0.8]$ ./pk2cmd -PPIC16F690 -GFdemo.hex
Read successfully.
Operation Succeeded

[mcuee@localhost pk2cmdLinux-0.8]$ ./pk2cmd -PPIC16F690 -Y -Fdemo.hex
PICkit 2 Verify Report
1-5-2008, 9:42:03
Device Type: PIC16F690

Verify Succeeded.
Operation Succeeded

Sunday, April 27, 2008

pk2cmd Linux Port under Fedora Core 6

Here is a mini-howto to get pk2cmd Linux port to work under Fedora Core 6. It should work for Fedora Core 5 and Fedora 7 as well. Hopefully it also works for Fedora 8. I have never used Fedora 8 since it failed to boot on my machine because of the conflict with FreeBSD.

1) Download pk2cmdLinux from Jeff Post's website.
Download link:

Edit in 09/2009: new download link

As of this writing, the version is 0.8.

2) Preparation to get pk2cmd working is easy under FC6.

You need to have g++ and make. You also need to install libusb-devel package. You can use yum (yum install libusb-devel) as root to install this package.

3) Edit the Makefile and then build it using make.

You need to edit the Makefile to to define the proper CFLAGs.
FC6 is usingLinux kernel 2.6.x and support udev rules. So we will use the following option.

# ----- Use the following for Linux kernel 2.6.x: -----

Now we can build pk2cmdLinux. Just type "make".

4) Test it as root and it should just work.

5) In order to run pk2cmdLinux as a normal user, we need to set up udev rules.

FC6 uses udev with PAM. You can read the file 'usbhotplug.txt'bundled with the pk2cmdLinux source package for more details. A more up-to-date document is presented in the Gphto project website:

Firstly you need to create the file/etc/udev/rules.d/26-microchip.rules with thefollowing content.

#PICKit2SUBSYSTEM=="usb_device", ACTION=="add", SYSFS{idVendor}=="04d8",SYSFS{idProduct}=="0033", SYMLINK+="pickit2-%k"

Secondly, you need to create the file/etc/security/console.perms.d/pickit2.perms
with thefollowing content:

=/dev/pickit2* 0600 0600 root

6) After this unplug and then plug PICkit 2 back in the USB port andit should work.
If not, reboot the machine.

Now we can test pk2cmdLinux under FC6. Here are some examples.

[mcuee@localhost pk2cmdLinux-0.8]$ ./pk2cmd -?V
Executable Version: 1.01.00 (Linux/Mac port 0.8)
Device File Version: 1.42.00OS
Firmware Version: 2.30.01
Operation Succeeded

[mcuee@localhost pk2cmdLinux-0.8]$ ./pk2cmd -PPIC16F690 -I
Device ID = 1403
Operation Succeeded

[mcuee@localhost pk2cmdLinux-0.8]$ ./pk2cmd -PPIC16F690 -GFlowpindemo.hex
Read successfully.
Operation Succeeded

[mcuee@localhost pk2cmdLinux-0.8]$ ./pk2cmd -PPIC16F690 -Y -Flowpindemo.hex
PICkit 2 Verify Report
27-4-2008, 11:49:37
Device Type: PIC16F690
Verify Succeeded.
Operation Succeeded

[mcuee@localhost pk2cmdLinux-0.8]$ ./pk2cmd -PPIC16F690 -T
Operation Succeeded

Thursday, April 24, 2008

pk2cmd Linux port under Ubuntu

Edit in 09/2009: new download link

Download link:

As of this writing, the version is 0.8. I've tested the following under Ubuntu 6.06 and 7.10. It should work for 7.04 as well. For Ubuntu 5.04 and maybe 5.10, you should use hotplug rules instead of udev rules. But I no longer use these older versions.

How to build it from the downloaded source? You need to have gcc, g++, make (sudo apt-get install build-essential) and libusb-dev (sudo apt-get install libusb-dev).

You will also need to edit the Makefile and choose the following option.
# ----- Use the following for Linux kernel 2.6.x: -----

After that, just type "make" and you should have pk2cmd Linux port built.

You will need to set up proper udev rules to run pk2cmd as a normal user and not using sudo.

More detailed steps.
1) Create a group called microchip, add your user name to it.
GUI method: System --> Administration --> Users and Groups -->
Manage Groups --> Add Group
Group name : microchip
Group member: add your user name (mine is "mcuee").

To confirm that this is a success.
mcuee@ubuntu710:~$ groups mcuee
mcuee : mcuee adm dialout cdrom floppy audio dip video plugdev scanner
lpadmin admin netdev powerdev microchip

Take note that the output has "microchip" in it.

The command line way of doing this.
mcuee@ubuntu710:~$ sudo groupadd microchip
mcuee@ubuntu710:~$ sudo gpasswd -a mcuee microchip
(Replace mcuee with your username linuxdev).
mcuee@ubuntu710:~$ groups mcuee
mcuee : mcuee adm dialout cdrom floppy audio dip video plugdev scanner lpadmin admin netdev powerdev microchip

2) Create the udev rule 026_microchip.rules in the directory
/etc/udev/rules.d. You can use gedit.
mcuee@ubuntu710:~$ sudo gedit /etc/udev/rules.d/026_microchip.rules
Here is my udev rules for PICKit 2 and some other Microchip USB tools.

Edit: please follow Peter Restall's comments and use ATTRS{} instead of SYSFS{}. SYSFS{} is deprecated in later version of udev.

mcuee@ubuntu710:/etc/udev/rules.d$ cat 026_microchip.rules
#PICKit 1
SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="0032", MODE="0660",
#PICKit 2
SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="0033", MODE="0660",

SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="8000", MODE="0660",
SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="8001", MODE="0660",

SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="000b", MODE="0660",
SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="000c", MODE="0660",
SYSFS{idVendor}=="04d8", SYSFS{idProduct}=="000a", MODE="0660",

3) Unplug and plug PICkit 2 and check if the udev rules work or not. If not, you may reboot and check again. Actually a better way is to restart udev and then unplug and plug in PICkit 2.

mcuee@ubuntu710:~$ sudo /etc/init.d/udev restart
* Loading additional hardware drivers... [ OK ]

mcuee@ubuntu710:~$ lsusb
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 003: ID 04d8:0033 Microchip Technology, Inc.
Bus 001 Device 004: ID 04d8:000c Microchip Technology, Inc.
Bus 001 Device 001: ID 0000:0000

mcuee@ubuntu710:~$ ls -la /dev/bus/usb/001
total 0
drwxr-xr-x 2 root root 100 2008-04-24 15:26 .
drwxr-xr-x 5 root root 100 2008-04-24 15:26 ..
crw-rw-r-- 1 root root 189, 0 2008-04-24 15:26 001
crw-rw-r-- 1 root microchip 189, 2 2008-04-24 15:26 003
crw-rw-r-- 1 root microchip 189, 3 2008-04-24 15:26 004

Now you can see that PICkit 2 is in Bus 001 and it belongs
to root user but group member of microchip have read
and write access to it.

4) now you should be able to run pk2cmd as normal user.
mcuee@ubuntu710:~/Desktop/build/pk2cmd/pk2cmdLinux-0.8$./pk2cmd -PPIC16F690 -I
Device ID = 1403

Operation Succeeded

USB PIC related open source projects

Updates to be found in Microchip Forum:

1. PUF using sdcc :

"PUF is a USB application framework dedicated to Linux (on the host side) and to the PIC 18F4550 family of microcontrollers (on the device side). PUF includes: a bootloader that can flash the PIC application through the USB, a PIC demo and its corresponding application on the host side, and docker, the host-side flash programming utility.

2. PIC18F4550 USB/MSD sourceforge, Apache License V2.0

3) GPLed USB stack with SDCC

4) PICDEM FS USB bootloader for Linux/Windows using libusb

5) PICDEM FS USB demo appliation under Linux/Windows using libusb

6) PIC18F2455/4455 Assembler USB Firmware (MPASM) From Bminch

7) MPLAB C18 based PIC USB firmware from Bminch (simpler than Microchip's)

8) Microchip USB C18 Firmware framework ported to SDCC

9) USB Midi (using gpasm and sdcc). It is said that the firmware is also based on the Microchip Firmware Framework.

javax usb under Ubuntu 7.10

I have tried to build javaxusb from the CVS source under Ubuntu 7.10. I can
build javax-usb and java-usb-ri without a problem with the Java 6.0 package
included in Ubuntu. But I could not build the package javax-usb-ri-linux.

/javax-usb-ri-linux$ ant jars
Buildfile: build.xml

[echo] Compiling class files.
[echo] Compiling JNI library.
[javah] Error: A required super class could not be found.

compilation failed

Total time: 1 second

Luckily, Google found this and it works for me.

javah -d jni -classpath src:$CLASSPATH
(This will produce the file com_ibm_jusb_os_linux_JavaxUsb.h in the jni directory)
mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux$ cd jni/
export JAVA_HOME=/usr/lib/jvm/java-6-sun
mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux/jni$ make all
(This will create the file
mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux/jni$ cd ..
mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux$ gedit build.xml
Remove the following part.

}" failonerror="yes">

mcuee@ubuntu710:~/Desktop/build/javaxusb/javax-usb-ri-linux$ ant jars
Buildfile: build.xml

[echo] Compiling class files.
[echo] Compiling JNI library.

[echo] Creating JAR files.
[copy] Copying 1 file to

Total time: 0 seconds

After this, I can build the examples and they seem to run fine.

Thursday, March 13, 2008

Microchip Announced PIC32 USB OTG Device

Press Release:

Application Notes:

USB Host and Device Stack Download:

WinUSB example from Jan Axelson
Visual Basic .NET and C# host program and PIC firmware are provided.

I've tested it under Windows XP (with WDK 6000) and a home-made simplified PICDEM FS USB demo board. It works nicely. Take note that Jan is using a new version of WDK (6001?) and I need to change the INF file to reference to the old files. Also take note that Jan is still using an old version of the Microchip USB firmware framework.

Tuesday, February 5, 2008

Happy Chinese New Year!

Chinese New Year is coming closer. The first day of Lunar New Year starts on February 7th this year (the year of Mouse/Rat). Happy Chinese New Year!

To know more about Chinese New Year and the year of Mouse/Rat.

Microchip USB Stack V1.3 Released

Download link:
Release notes:

What's New/Updated in Release v1.3
1) Microchip General Purpose USB Windows® Driver, mchpusb.sys v1.0.0.6, is updated to support Windows Vista™ and 64-bit Windows® Operating Systems. This version is WHQL certified.

2) CDC RS-232 emulation INF file, mchpcdc.inf, updated for supporting Windows Vista™ 32-bit and 64-bit.

3) Some bug fixes in USB library firmware (usb9.c).

Sunday, January 20, 2008

WinUSB Examples

I was looking for WinUSB examples all over the Internet last time but to no avail.

The only one I got is an incomplete example from Microsoft.

Luckily some Microchip Forum posters have come out examples for Visual C++.Net and Visual C#.

Mike Zoran's USB Soundcard and RFModem examples include Visual C++.Net based host software to update the firmware inside PIC18F2550.

J1M has examples for Visual C#.

Tuesday, January 15, 2008

MCU Vendor Ranks and Internet Profile

Often we will judge the popularity of Microcontrollers according to how popular they are on the internet. However this impression may not correlate well with the market ranks.

For example, the top 10 MCU vendors according to iSuppli are listed below (year 2006).
1. Renesas Technology
2. Freescale Semiconductor
3. NEC Electronics
4. Infineon Technologies
5. Toshiba
6. Microchip Technology
7. Matsushita Electric
8. Fujitsu
9. Atmel
10 Texas Instruments.

Of the 10 vendors, Freescale (HC08, HC12, 68k, ColdFire), Microchip (PIC, dsPIC), Ateml (AVR, ARM, AVR32) and TI (MSP430) are very popular from the amount of 3rd Party Internet resources. Interestingly they are all US companies. And I like to use them since they have relatively good documentations and many examples on the Internet. Better sampling policy may also contribute to their popularity. However, in reality, Japanese companies are very strong in MCU market as well. Now it seems that they are beefing up the documentation and start to offer cheaper development tools. Renesas is particularly getting better now.

With the top 10 companies, apparently Microchip is one of the smaller company in terms of turnover. But they are good at concentrating on their core competency (8bit) and branch into 16bit and lower end DSP market. Compared to a few year ago, the growth of Microchip is very remarkable. Maybe Japanese vendors should learn from Microchip by providing cheap development tools and easy sampling.

Friday, January 11, 2008

How to Get Help for Microchip MCU Related Questions

Someone just leaves a comments about asking for PIC related issues through Email. I'd suggest that one tries the following places.

1. Microchip Forum: generic problems with PIC MCUs and associated development tools

2. PIClist

3. For Open Source PIC development tools under Linux or Windows: GNUPIC

4. For PICkit 2 under Linux

Monday, January 7, 2008

2GB RAM Makes Vista Happy

Yesterday I went to Funan Digital Life Mall, one of the leading IT shopping center in Singapore along with Sim Lim Square.

One interesting thing is that many shops are offering free upgrade to 2GB RAM for Vista notebooks. This is a good thing. Vista is not bad but putting Vista to a lowly configured notebook is not going to give the users a good experience. I played with some of them and I think 2GB will make Vista happy. Another good think is that I see that most of the Vista notebooks come with Vista Home Premium or Vista Business. No more Vista Home Basic.

I also played with Asus Eee PC a bit. Its response was ok and the underline Linux OS was not bad. But I do not think I will like the small keyboard and I am not a mobile worker. So it is not for me. Its price is also not low compared to some low end full notebook. But I understand it is targeting a different group of users. Comparable ultra-portable notebooks from Sony and other vendors are quite expensive.

Friday, January 4, 2008

Interesting blog post: Distro hopping all the way back to Windows XP

The following is an interesting blog about Linux distros versus Windows XP.

I think his experiences can be quite typical for many experienced Windows power users. Interestingly I have some similar experiences with him on some of the Linux distros.

Kubuntu is really not good and it is said that Kubuntu 8.04 will not be an LTS version and I think it will remain a second class citizen in Ubuntu family of Linux. KDE is not really the problem as under PCLinuxOS 2007 it works fine for me. It is the KDE part of Ubuntu which sucks. Firefox under Linux is really not so good (interestingly I also have an ATI card). Mandriva 2008 refused to start X from the CD. So it may be really ATI card sucks under Linux. My OpenSuse experience is not as bad as the author but it is really slow (Gnome or KDE) even though it seems smooth. Linux updating can be a daunting tasks without a fast mirror. Luckily I have a 8Mbps cable modem connection. The speed was 6Mbps in 2007 but the ISP Starhub has since upgraded it to 8Mbps. My PCLinuxOS experience is in general positive but I have some reservation about RPM since once it failed to update some package due to conflict but later it was solved.

So far I have best lucks with Ubuntu 6.06/7.04. Ubuntu 7.10 initially did not run well because of my experiment with Compiz/Xgl which caused the system to be unstable. After removing Compiz/Xgl and going back to the open source ATI driver, Ubuntu 7.10 now works fine. I am not so sure why the author does not want to try out Ubuntu. It is quite good for the transition from Windows to Linux due to easy of use. I was trying out different distros before 2005 and had never really used Linux as the main OS at home. However once I installed Ubuntu 5.04 I am kind of hooked. Linux has been the main OS at home for me after Ubuntu 6.06 came out even though I still keep Windows XP and use it from time to time.

Apparently the author is an experienced Windows XP user since he is an IT professional. Windows XP SP2 is really quite good for experienced Windows user who is careful about protecting the system against virus/malware. I am also an experienced Windows user since 1997 (Windows 95 OSR2) and I have positive experience with Windows 95 OSR2, Windows 98SE and Windows XP SP2. Microsoft seems to do well in the third version. ;-) My limited Vista experience shows that Vista is actually not bad. My wife is now happily using the Vista notebook. But it will take Vista SP1 to get Vista more smooth for most users and for more business to adopt Vista (just like Windows XP SP1). It will take Vista SP2 to finally beat Windows XP SP3 (last SP for Windows XP).

For business users, XP is clearly dominant due to the fact many software packages are Windows only and many organizations standardized on Microsoft Office. The supported version of Linux desktop versions (Redhat/Novell) are not cheap at all.

One thing XP is better than Linux for home users is the driver support. It is not a fault for Linux but rather reflect the reality that XP is the main supported platform for peripheral vendors. Modern Linux distros actually support more device right out of the box than Windows XP. But there are some vendors who do not provide information to the Linux community so that driver is not so easy to be developed.

For home users, the other thing XP is better is that it has a better software ecosystem for many small ISVs. Those ISVs can survive under Windows world since they have the expertise and the market for them. Under Linux, they have to compete with free softwares in a small market. It is hard to imagine that small ISVs can develop a Winzip like utility and expect to earn money for Linux. Major Linux players earn money by offering support/subscription (IBM, Redhat, Novell, etc) or offer big and unique applications (Oracle, SAP, etc).

XP is also better for gamers. It is also better for hobbyists and SOHO developers of electronics because of the existence of free or low cost tool chains (IDE, compilers, debuggers, EDA). Linux has a long way to go in this front.

That being said, Linux is actually good for software developers like the author of that blog post. It is also good for home use (browsing Internet with Firefox, word processing with OpenOffice, etc). It is especially good for people who are not so good at protecting XP against virus/spyware and have simple usage pattens which are in general well supported by modern Linux distros.

The world needs more choices, so we need alternative operating systems like Linux and Mac OS X and others. We also need alternative office packages like OpenOffice which is really good enough for most users. Will Linux dominate the world any time soon? I do not think so. Will Linux get more and more stronger? I think so. Will OpenOffice beat MS Office anytime soon? I do not think so. Will OpenOffice gain more popularity? I think so. OpenOffice/Firefox will actually be popular for Windows user as well due to the high price for MS Office and problems with IE6/IE7.

The best is to try out both world and enjoy the good/bad of both world. Windows and Linux both have its strong point and weak point. Both can exist nicely with each other.

Thursday, January 3, 2008

Long way to go: MCU Development without Windows

ICD2 debugging is one of the things which does not work well under Linux yet. Piklab project is the trying to bridge the gap but it will take some time for it to be good enough. So right now people have to run Windows (natively or under VMware or similar virtulization technology).
I am not so sure if petition like this is really useful or not. Main MCU vendors only offer software based on Windows and this will not change anytime soon.

Still Atmel is offering free GNU toolchains (GCC based) and IDEs (Eclipse based, support debugging) for AVR32, under Windows and Linux.

So I am hoping Microchip could learn a bit from Atmel and try to do the same for PIC32. Take note Microchip C30 and C32 compiler are both based on GCC.

There are some third party tools under Linux for PIC development. For example, HiTech offers PICC/PICC18/dsPICC under Linux and it now adding support for ICD2 debugging. HiTech tools are not cheap though compared to Microchip provided tools.

There are quite some good ARM MCU tools under Linux. So that is one direction to go. Still the most popular tools (from Keil and IAR, etc) are still Windows only.

It seems there is still a long way to go for Linux to be the productive environment for many electronics engineer (hardware and firmware).

Nice Industrial Ethernet Blog from Lynn Linse

I just came across this very nice website of Lynn Linse who is an expert in Industrail Automation Protocols.

Main site:

Wednesday, January 2, 2008

Google Page Created

Long time ago (back in 1997), I learned some HTML and created a simple homepage (initially hosted in NTU and later hosted in Geocities. However, after some time, I got not much time to maintain the page and it is gone now. And I almost forgot how to write HTML. Interestingly, somebody used my original website as a template to create the homepage for my Master of Engineering supervisor Dr Luo. One of the page got left over. Those links are mostly dead now.

Now I just created an empty Google Page and hopefully I can pick up HTML again. At the same time, I also created a (again empty) Google code page called picusb:

libusb Project Got a New Leader


libusb project just got a new leader. Daniel Drake will take over the task from Johannes Erdfelt. He will continue the maintenance of libusb 0.1 stable branch. He will put his main efforts to the 1.0 development branch. Hopefully this will speed up the development of libusb 1.0 branch.

Tuesday, January 1, 2008

Debian 4.0 Etch

I am basically a Ubuntu user. Since Ubuntu is based on Debian, I've tried to install Debian Etch from the 4.0r1 single Gnome CD but somehow it refused to boot and this only happens to Debian.

Since I've tried the Ubuntu 6.10/7.04 Installation from Ubuntu 6.06,
(, I managed to install Debian Etch from Ubuntu 6.06 using the same method. One thing I need to mention is that I need to manually set up the timezone by changing the file /etc//default/rcS (UTC=no instead of the original UTC=yes).

Debian Etch (current stable) is said to be very stable and so far it works fine for me except one thing. I am not able to use Swiftfox or Mozilla Firefox to replace the stock Iceweasel (at Stock Firefox under Ubuntu versions are not so stable with my desktop (NForce 3 motherboard with ATI9800SE AGP graphics card, AMD64 3000+ CPU, 1GB DDR RAM). Most likely it is a problem with the Xorg X server and Ubuntu version of Firefox. And this happens to Debian as well: it sometims crashes without warning. Swiftfox in general works better for me. Somehow even after I uninstalled Iceweasel and remove all things Iceweasel related, when I run Swiftfox or Firefox from Mozilla and check the version, it always shows Iceweasel I am not so sure why. Hopefully I can figure it out in the near future.

Edit three hours after posting:
After enable the security updating, now it is at and hopefully this will be better than the old And I can install Swiftfox (the default version of 3.0b3-pre3 is not usable but the older version is ok). I can also run the original Mozilla Firefox

One more problem is that the flash plugin does not work under Opera. I installed Opera before I found the solution to the above-mentioned problem.