Sunday, December 30, 2007

PICDEM FS USB Demo Board under Linux

PICDEM FS-USB demo board is the demonstration and evaluation board for the PIC18F4550 family of Flash microcontrollers with full speed USB 2.0 interface
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en021940

Back in 2005, people have developed application based on libusb to get it work under Linux. I have since patched them to work under Windows as well using libusb-win32.

Bootloader under Linux:
http://www.internetking.org/fsusb/
My latest patches:
http://forum.microchip.com/tm.aspx?m=106426

Demo mode which includes my patches for libusb-win32:
http://www.varxec.net/picdem_fs_usb/
My latest patches to detach kernel ldusb driver for later Linux kernels.
http://forum.microchip.com/tm.aspx?m=106426

Interesting discussion about the ldusb driver issue.
Thread: [PATCH 70/78] USB: add picdem device to ldusb:
http://marc.info/?t=117770076400003&r=1&w=2

To me I think it is better to do this in user space using libusb. But the original submitter wants to keep it as he did not know the existence of the libusb based application and has already an in-house application based on the kernel driver.

CDC-ACM demo works fine under Linux. The HID mouse demo also works fine under Linux.

Interestingly, again someone wants to add the bootloader to the kernel. Hopefully this time it will not be included. The libusb based application should still work but why adding so many things to the kernel space when the user space libusb based application works fine.
http://www.mail-archive.com/linux-usb@vger.kernel.org/msg00296.html

One FAQ is how to run the libusb based application as a normal user (without root credential). This is a moving target under Linux. Hotplug, udev, udev with PAM and HAL rules are the methods to achieve the goal. You need to choose the right one for the Linux distro you are using.

The following is a good summary.
http://www.gphoto.org/doc/manual/permissions-usb.html

An older document which does not cover HAL:
http://piklab.sf.net/files/libusb_udev_hotplug.txt

Some examples (not really for PICDEM FS-USB but for PICkit 1/2 and ICD2) you can use as the starting point:
http://piklab.sourceforge.net/wiki/index.php/USB_port_problems

Saturday, December 29, 2007

Windows Vista First Impression

Windows Vista has been out for 1 year and many reviews on the Internet is still negative. XP is quite decent now that it has been in the market for quite some time. XP SP2 is pretty stable to use and many companies has not deployed Vista. Still most of the consumers are buying new PCs and most of them come with Vista bundled.

I just started playing with the Vista notebook bought 4 days ago. It is not bad, I will say. As the first step, I removed the two trial version software (Office 2007 and Norton). For antivirus, I installed AVG Free. For spyware detection, Vista comes with Windows Defender installed. With some education done, my wife is now a careful enough Windows user. I've used IE7 in my desktop so I have no problems with IE7 under Vista. Still I installed Firefox as an alternative. IE7 seems to be faster with Windows Live Hotmail.

I think 4GB of RAM helps so that I do not feel Vista is slow. My desktop is a 3 year old AMD64 single core with 1GB RAM running Linux/FreeBSD/Windows XP. So this notebook should not be slower anyway.

I do not like those eye candies so the sidebar feature is not so useful. My wife may like it. As for specially effect of Aero, I do not think it is any useful so that I have not tried it. Anyway, I do not like Compiz under Linux and always switched it off.

UAC is kind of annoying but I decided to leave it on as this will be used by my wife. I am just preparing the notebooks for her and getting familiar with Vista so that I can be he IT support helpdesk. Unfortunately the fine control of UAC options is not available for the Home Premium version of Vista.
http://technet2.microsoft.com/WindowsVista/en/library/0d75f774-8514-4c9e-ac08-4c21f5c6c2d91033.mspx?mfr=true

Hardware compatibility is still a problem. My wife's Nokia 6280 Mobile Phone works (on the other hand, it did not work under my Linux Desktop. It originally did not work under XP with the same Desktop either but with the updated software it now works under XP). Her beloved Samsung SPP-2020 Photo Printer does not work even though Samsung claims Vista support in their website. I am still investigating this issue. Hopefully I can solve this issue with new software from Samsung or Vista SP1 (now under testing).

Edit: 10 minutes after I posted the blog, I found the solution. It work after deleting C:\windows\inf\INFCACHE.1 and reinstall the printer driver, it works now. It seems to be a common problem.

My newly bought cheap S$75 Orient MP4 player 2GB (looks like IPod Nano, MP3 sound quality is okay, but FM is pretty bad, anyway, I have my trusted Sony Radio.) failed to work (it works under XP and Linux by appearing as a USB storage device). Anyway, I think that is mainly a firmware fault. There are so may buggy USB device out there.

Edit: This again works now after getting SPP-2020 to work.

As this notebook is not intended for my use, I will not install development tools like MPLAB on the computer. Anyway, MPLAB and many other Microchip development tools are now supported under Vista 32bit.

Overall the first impression of Vista is that it seems to be okay. There is nothing too exciting but nothing too disappointed. Anyway, it is not that bad as reported.

New Vista Notebook

On Christmas day, we bought a notebook with Vista Home Premium. It is Compaq Presario V3619AU (GX855PA) with RAM upgraded to 4GB from 1GB as the promotion. It costs S$1299 for the base 1 year warantee option. Since I did not trust the quality of any notebook vendors due to my bad experience with Dell Inspiron 600M I bought back in 2003 (1st year HDD and motherboard gone but luckily under warantee. Now keyboard controller is bad so I have to put an external USB keyboard), I opted to upgrade to have 3 year warantee which cost another S$199. So alltogether it is S$1498.

Specification:

Product Name: Compaq Presario V3619AU
Product Number: GX855PA
Microprocessor: 1.90 AMD Turion 64 X2 Dual-Core Mobile Technology TL-58
Microprocessor Cache: 512 KB + 512 KB L2 Cache
Memory: 1024 MB (2 x 512 MB) (now upgraded to 4GB)
Memory Max: Up to 4 GB
Video Graphics: NVIDIA GeForce Go 7150M
Video Memory: Up to 287 MB (not seem to correct now that it has 4GB RAM)
Hard Drive: 160 GB (5400 rpm)
Multimedia Drive: LightScribe SuperMulti 8X DVD±RW with Double Layer Support
Display: 14.1” WXGA High Definition BrightView Widescreen Display (1280 x 800)
Fax/Modem: High speed 56K modem
Network Card: Integrated 10/100BASE-T Ethernet LAN
Wireless Connectivity: 802.11 a/b/g WLANBluetooth wireless networking
Sound: Altec Lansing speakers
Keyboard: 101 key compatible keyboard with 1 Quick Launch Button
Pointing Device: Touch Pad with On/Off button and dedicated vertical and horizontal Scroll Up/Down pad

PC Card Slots: One ExpressCard/54 slot (also supports ExpressCard/34)

External Ports:
5-in-1 integrated Digital Media Reader for Secure Digital cards, MultiMedia cards, Memory Stick, Memory Stick Pro, or xD Picture cards
VGA
3 USB
RJ-11
RJ-45
Headphone out
Microphone in
IEEE 1394 firewire
Consumer IR
S-Video TV out
Expansion port 3

Dimensions : 33.4 cm (L) x 23.7 cm (W) x 2.6 cm (min H) / 3.9 cm (max H)
Weight: 2.45 kg
Power
65 W AC Power Adapter
6-cell Lithium-Ion (Li-Ion) battery

OS: Windows Vista Home Premium, Microsoft Works, etc

Bundled Junk:
Microsoft Office 2007 Home/Student (60 day Trial)
Norton Internet Security (60 days trial)

Tuesday, December 25, 2007

Serial Port Based Intelligent PIC Programmers

I have wrote about USB based PIC programmers and simple PIC programmers. It seems that with PICkit 2 coming out, it makes less sense to use other serial based intelligent PIC programmers. Still some of the users may already have those simple programmers and want to build their own intelligent PIC programmers. In that case, here are some recommendations.

1. Wisp628A: http://www.voti.nl/wisp628/
You can build this relatively easily. Actually back in 2005, I've built two of this on a breadboard.
The alternative firmware and software from Rob Hamerling's xwisp2 (http://www.robh.nl/picsoft.php) is my preferred choice. It is cross-platform and supports OS/2, Windows, Linux, Mac OS X and FreeBSD.

You can either buy the kit and build your own or create your own based on the information on the site.

2. Easyprog: http://www.embedinc.com/easyprog/
The author (Olin Lathrop) provides the hardware design, firmware and software sources.
You can buy the kit and assemble by yourself. I do not think you would like to buy the ready-made kit since PICkit 2 may be cheaper and better. Embed Inc also has the ProProg
(http://www.embedinc.com/proprog/index.htm) which is aimed at production and USBProg (http://www.embedinc.com/products/eusb2/index.htm) which is aimed at profoessional lab and benchtop use. ProProg and USBprog seem to be both well designed.

3. Kitrus also has some kits. http://www.kitsrus.com/pic.html
The price may not be justified now that PICkit 2 is out and at only US$35 (not including tax and shipment).

4. Microchip PICstart+:
Some of the sites have the clones but I think this is not easy to be built by hobbyists and its feature is not as good as PICkit 2 even though it is more expensive than PICkit 2.

A survey of simple PIC programmers under Windows and Linux

Merry Christmas and Happy New Year!

I myself do not use any simple PIC programmers without a PIC as the brain of the programmer. Still some people think PICkit 2 is too expensive at US$35. So there is still a market for the simple programmers. Coupled with bootloader, it can still be useful for some hobbyists. Of course I will still recommend PICkit 2 to those who can afford the US$35, it is well worth the money and save you a lot of troubles with the simple programmers.

Windows simple PIC programmer software sites often links to the supported hardware. Some of them are based on Parallel port (eg: Tait), some of them are based on Serial port (eg: JDM), very few of them are based on USB. Parallel port and serial port start to disappear from many laptop computers. And many of the serial port based programmers will not work properly with common USB-to-Serial converters. Almost all Parallel port based programmers will not work with common USB-to-Parallel converter (often made for old printer). Some of the very simple programs only support LVP (low voltage programming) which only applies to very few PICs (but some of the PICs are popular). So far I can see that most simple programmers do not support 3V only PICs like PIC18J/18K and PIC24/dsPIC33 which PICkit 2 support well.

WinPIC:
http://freenet-homepage.de/dl4yhf/winpicpr.html
http://www.qsl.net/dl4yhf/winpic/index.htm
WinPIC supports many 5V PICs and its manual seems to be quite good. Another advantage is that the author also provides the source packages.

WinPIC800: http://www.winpic800.com/index.php?lang=en
It claims the support of most Flash PICs and can rival some of the features of PICkit 2. But take note that its main supported programmer GTP-USB+ is actually an intelligent PIC programmer and at 60 Euro it is much more expensive than PICkit 2 which costs US$35 . If you are using the simple programmer, I am not so sure if it still supports the same number of device.

PICPGM: http://www.members.aon.at/electronics/pic/picpgm/
PICPGM also supports quite some PICs. One interesting thing is that it has an FT245BL based USB programmer which unfortunately only supports LVP.

IC-Prog: http://www.ic-prog.com/index1.htm
IC-Prog is perhaps one of the most popular programing software in the web. However, its support of PICs is actually one of the weakest from the website.

Linux:
pikdev: http://pikdev.free.fr/
pikdev supports many simple programmers and PICs under Linux.

piklab: http://piklab.sourceforge.net/
piklab supports many simple programmers and PICs under Linux. Of course, it also supports many other programmers, including Microchip MPLAB ICD2.

picprog: http://hyvatti.iki.fi/~jaakko/pic/picprog.html
This is different from the maybe-better-known picprg (http://www.brianlane.com/software/picprg) but it is actually much better than that one.

Odyssey: http://vasco.gforge.enseeiht.fr/index.php?article=Odyssey.html
It only supports Parallel port based programmer. But anyway, parallel-port based simple programmers is said to be more reliable than serial port based simple programmers.

Saturday, December 22, 2007

NetBSD 4.0 upgrade -- smooth process

I installed NetBSD 3.1 sometime ago. I also used the pkgsrc binary CD to install GNOME so that I had a basic working installation.

One of the annoying 'feature' of NetBSD 3.1 is that it is not compliant to multi-boot so that grub will not be able to pass the kernel parameters to it. Therefore I need to answer several questions before I can boot into NetBSD. Somehow pkg_add did not work well with ftp.netbsd.org.

So now NetBSD 4.0 is just out. So I update the existing installation to it today. It is a very smooth process. More importantly, it is compatible with multiboot and grub has no problem to boot NetBSD 4.0 now. The existing 3.1 binary packages are still working. pkg_add is now working as well with ftp.netbsd.org even though it still prints out some error messages.

Since I have got PICkit 2 to work under FreeBSD (with HPS USB stack), I will try to get it to work under NetBSD. But I have never used NetBSD before, this might take some time.

Friday, December 21, 2007

fpusb -- Another libusb-0.1 replacement under Linux

http://reactivated.net/fprint/wiki/Fpusb

The author is trying to solve the problems of libusb-0.1 but not going to use OpenUSB which is more ambitious.
  • Isochronous endpoint I/O
  • Asynchronous I/O with per-URB style callbacks
  • Zero threads (lightweight, uses main thread of calling application)
  • Exposure of poll fds to applications for good main loop integration
Right now it only works under Linux but it looks promising. Anyway, there is not much development of libusb-0.1 and libusb-1.0 now. OpenUSB is only partially working under Linux and Solaris right now.

What I am really hoping to have is a real cross platform HID API. libhid is supposed to be the one, unfortunately it is not really cross-platform.

libhid: http://libhid.alioth.debian.org/
libusb: http://libusb.sourceforge.net/
libusb-win32: http://libusb-win32.wiki.sourceforge.net/
OpenUSB: http://openusb.sourceforge.net/wiki/

GPLed dsPIC33 MP3 Decoder Based on MAD

Finally this is done by Alex B in Microchip Forum. I am not into dsPIC much yet but I think this is really outstanding.

http://forum.microchip.com/tm.aspx?m=166133&mpage=4

Download (GPL licensed):
http://www.pic24.ru/upload/dspic_mp3.zip

It is based on MAD.
http://www.underbit.com/products/mad/

Installing Ubuntu from a Unix/Linux System

https://help.ubuntu.com/6.10/ubuntu/installation-guide/i386/linux-upgrade.html

This is nice guide and today I tried to install a Ubuntu 6.10 to a existing partition (which was used to test Vmware Player but I found Vmware Player is not my cup of tea since I prefer multi-boot) from a chroot environment under Ubuntu 6.06 LTS.

A fast mirror is nice to have in this case. For me I use either the default Singapore mirror (http://sg.archive.ubuntu.com) or the Australia mirror (ftp://mirror.pacific.net.au).

I manually installed the following file, there may be new versions when you read this.
http://sg.archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.7_all.deb

After that, I followed the guide and I have a working base installation in less than 20 minutes.

I found /etc/resolve.conf and etc/hostname was already set up properly for me.

After editing the grub.conf inside Ubuntu 6.06 LTS (I mainly use it along with 7.10) and rebooting, I ran the following two commands and then I had a almost fully working system. Strangely sound did not work under Gnome until power-down and then cold-boot the computer.
sudo apt-get install ubuntu-standard
sudo apt-get install ubuntu-desktop


Sunday, December 9, 2007

Nice Article: Forget the Linux Desktop, it's the Linux Laptop that matters!

http://sourcesmouth.co.uk/blog/Forget-the-Linux-Desktop-it-s-the-Linux-Laptop-that-matters.html

OLPC, EEE and similar efforts are really bring Linux closer to the mainstream. Anyway, most of the people do not need the functionality of Office 2007 and do not need the Aero interface of Vista.

XP+Office XP (or Windows 2k+Office 2k) will be good for most home and business users. And now main stream Linux+OpenOffice is actually good enough for most home users. For business user, depending on the field, it may or may not be possible to ditch Windows XP which is really a very good OS with SP2 installed. But I believe OpenOffice is actually good enough for majority of the business users.

What is a Vista Home Basic Machine with 512MB RAM Good for?

http://www.microsoft.com/windows/products/windowsvista/editions/systemrequirements.mspx
Microsoft typically published their system requirement a bit too low for real world. But I've seen some Vista Home Basic machine with only 512M of RAM. What is that machine good for?

The best answer so far comes from Dell Singapore website.
http://www.dell.com.sg/vista

It is great for " Booting the Operating System, without running applications or games".

Nice demo machine to show off Vista, huh? ;-) ;-)

Saturday, December 8, 2007

Impressions of Some Linux/BSD Distributions

Before Fall 2002, I was mainly playing with Linux (Slackware, Redhat, Mandrake, Corel, Caldera, etc) but still use Windows mostly at home. I was not using Linux between Fall 2002 and Spring 2005.

I started to try out Linux again with Ubuntu 5.04 and I liked it quite a lot. Then I was trying to 5.10 and it was not as good so I started to look at Fedora as well (Core 4). Soon I fixed the problem with 5.10 and then I found 6.06 LTS a great distribution that I am still running it as the main distribution now. I also tried Ubuntu 6.10/7.04 and they were good as well. Now I have Ubuntu 7.10 installed. Initially it is not good (problem with USplash screen) but I solved it. Firefox 1.5 under Ubuntu 6.06 is not that good but switching to swiftfox seems to solve the problem. Firefox 2.0 under Ubuntu 7.10 initially is very bad but once I remove xgl/compiz stuff it becomes better now.

On the other hand, FC5/FC6 and Fedora 7 were also not bad so I was using Fedora as the 2nd option to Ubuntu. Fedora 8 is a disaster (despite the flawless installation process) that it did not boot after installation due to the bug associated with FreeBSD partitions. So now I do not have a Fedora installation.

I tried to use OpenSuse as well, it is rather sophiscated but I feel it is relative slow. OpenSuse 10.2 installation is not good that it writes the Grub bootloader without asking and messed up my Grub. I have to boot to Ubuntu 6.06 and recover the bootloader. BTW, for Grub recover, it seems that Knoppix is good. OpenSuse 10.3 installation is flawless but trying compiz caused the system not to boot so I gave up.

I tried to use Arch Linux and it is quite good in terms of upgrading (versionless) but I do not find it offer anything more than Ubuntu.

I tried to use Gentoo for two days and it was a pain due to dead mirrors and long compiling process. And since I have FreeBSD installed, I do not need another source based distribution. FreeBSD does offer something Linux does not offer -- a BSD licensed kernel and userland. FreeBSD is not as easy to use as Linux but it is quite usable as well. I am also trying out NetBSD but I feel it is not good for desktop usage.

PClinuxOS looks nice and in the end it does not offer anything better than Ubuntu (maybe KDE is better under PClinuxOS).

So now I have Ubuntu 6.06/7.10 and FreeBSD 7.0 Beta. I will try out other things from time to time.

I still use Windows XP SP2 at home occassionaly but mostly I am using Ubuntu.

USB Programmers for PICs

http://forum.microchip.com/tm.aspx?m=283491

As someone who has used PICKit 1, PICkit 2, ICD2, Promate II and Promate III and a follower of PICkit 2, I find it interesting that people still want to create yet another simple USB programmer.

Anyway, here are my classification of USB PIC programmers. I might miss many programmers in the lists but it pretty much show you the pictures. After class 3, then there are many high end programmers from Data I/O, BP or similar for mass production.

Class 1: Simple USB programmers (not as good as PICkit 2 and USBprog):
1. picsquirt http://www.p10link.net/plugwash/picsquirt/
2. GTP USB lite (somewhat like a USB version of Wouter's WISP628A) http://www.hobbypic.com/index.php?option=com_content&task=view&id=12&Itemid=35

Class 2: Good for personal and lab use
1. PICKit 2, good and cheap, supports many PICs and double as a debugger.
http://www.microchip.com/pickit2

2. Another good USB programmer is the Amadeus.
The author is aparently very knowledgeable about PIC programming specifications. Not many people understand it as thoughly as him. Olin may be one of them. http://home.arcor.de/bernhard.michelis/

3. The author of WinPIC800 software has the GTP USB+ Programmer which seems to be a decent programmer as well.
http://www.winpic800.com/index.php?lang=en

4. USBprog is a kind of higher-end PICkit 2 in terms of hardware functionality. USBprog hits a good spot between PICkit 2 and Promate III but I find its chip support a bit limitted compared to PICKit 2.
http://www.embedinc.com/products/eusb2/index.htm

Class 3: low quantity production quality programmer After class 2 then you have higher-end USB programmers like Promate III and SoftLog ICP2. SoftLog ICP2 seems to be a serious contender to PM3 at much lower cost.

Between USBProg and Promate III, there are still quite some good gaps. SoftLog ICP2 is a good attempt.
https://www.microchipdirect.com/ProductDetails.aspx?Catalog=BuyMicrochip&Category=Programmers&mid=13

Some PICkit 2 Links

PICKit 2 website:
http://www.microchip.com/pickit2

PICkit 2 Faq:
http://forum.microchip.com/tm.aspx?m=270347

PICKit 2 Wishlist:
http://forum.microchip.com/tm.aspx?m=260540

PICkit 2 under Linux, pk2 and pk2cmd Linux port:
http://home.pacbell.net/theposts/picmicro/

PICkit 2 versus ICD2:
http://forum.microchip.com/tm.aspx?m=287314
http://forum.microchip.com/tm.aspx?m=282776

Tuesday, November 20, 2007

Debian Template to Build GCC for dsPIC/PIC24

Microchip uses GCC as the base for its C30 compiler for PIC24/dsPIC30/dsPIC33. They have also published the source according to GPL requirement.

John Steele Scott has done some good jobs to patch the Microchip sources and provided the Debian templates to build debian packages.

Instruction for V3.01b (patches and Debian Templates)
http://www.nabble.com/Debian-templates-for-dsPIC-build-toolchain-3.01-t4308624.html

Old version V2.05
http://www.nabble.com/Debian-templates-for-dsPIC-build-toolchain-2.05-t2825194.html

Old version V2.00 and related information
http://forum.microchip.com/tm.aspx?m=139360

Free PDF Touchup Utility for Linux

Often we need to do a bit of touch up for the PDF document. Normally Adobe Acrobat is the preferred tools to do it. However free tools are now catching up as well.

flpsed: touch up and edit
http://www.ecademix.com/JohannesHofmann/flpsed.html

pdfedit: touch up and edit
http://pdfedit.petricek.net/

pdftk: combine/split PDF files
http://www.accesspdf.com/pdftk/index.html

New FC8 install hangs at the message "Creating root device"

http://www.fedoraforum.org/forum/showthread.php?t=171223&page=2&pp=15

I had the exact same problem as post #15. I have two HDDs in the system. Windows/Ubuntu (6.06 and 7.10) are in the SATA HDD. I installed Fedore 8 on the IDE HDD which has also Windows DATA partitions and Linux DATA partitions along with FreeBSD 7-Beta.

I ended up going back to Fedora 7 which is working fine. It is really a pity. The installation process from the live CD was quite smooth. It just did not boot after the "flawless" installation.

Sunday, November 11, 2007

Setting up permissions for USB ports to use libusb for FreeBSD

During the testing of pk2cmd port for FreeBSD, I found a great resource on setting up permissions for USB ports to use libusb or other programs under Linux/BSD.
http://www.gphoto.org/doc/manual/permissions-usb.html

There is no udev under FreeBSD. It is called devfs rule. To set up proper usb device persimmion so that I can run pk2cmd without being root, I need to do the following.

Steps:
1. Create group "usb" and add the user name to it.
[Added on 22-Dec-2007]
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/users-groups.html
[mcuee@localhost /usr/home/mcuee]$ su -
Password:
localhost# pw groupadd usb (this may not be necessary for FreeBSD 7.0 Beta)
localhost# pw groupmod usb -M mcuee (your_user_name here, mine is "mcuee")
localhost# pw groupshow usb
usb:*:1003:mcuee

2. Edit /etc/devfs.rules to add the following lines.
[usb_devices=10]
add path 'ugen*' mode 0660 group usb
add path 'da*s*' mode 0660 group usb
3. Edit /etc/devfs.conf and add following lines: [Confirmed that this
is necessary]
perm usb0 0660
own usb0 root:usb
perm usb1 0660
own usb1 root:usb
4. Edit /etc/rc.conf and add the following lines:
# Set the default devfs ruleset.
devfs_system_ruleset="usb
_devices"
5. Activate the changes by running the following command (no reboot required):
localhost# /etc/rc.d/devfs start

6. Testing:
localhost# exit
logout

===[mcuee] ~/Desktop/build/pk2cmd4bsd # ls -la /dev/ugen0*
crw-rw---- 1 root usb 0, 138 Nov 1 22:31 /dev/ugen0
crw-rw---- 1 root usb 0, 120 Nov 1 22:56 /dev/ugen0

[Added on 22-Dec-2007]
===[mcuee] ~/Desktop/build/pk2cmd4bsd # lsusb
Bus /dev/usb1 Device /dev/ugen0: ID 04d8:0033 Microchip Technology, Inc.

===[mcuee] ~/Desktop/build/pk2cmd4bsd # ./pk2cmd -PPIC12F675 -I

Locating USB Microchip PICkit2 (vendor 0x04d8/product 0x0033)
Found USB PICkit as device '/dev/ugen0' on USB bus /dev/usb1
Communication established. PICkit2 firmware version is 2.10.0

Device ID = 0FC3

Operation Succeeded

Saturday, November 10, 2007

Good article about GPLv3

http://www.fsf.org/licensing/licenses/quick-guide-gplv3.html

I like the four free spirits mentioned in the article.

"Nobody should be restricted by the software they use. There are four freedoms that every user should have:

  • the freedom to use the software for any purpose,
  • the freedom to share the software with your friends and neighbors,
  • the freedom to change the software to suit your needs, and
  • the freedom to share the changes you make.

When a program offers users all of these freedoms, we call it free software."

From the article, it seems GPLv3 is actually better than GPLv2. Initially I hear quite some negative review about GPLv3, but this article seems to clarify some doubts I had before.

I think both the permissive licenses (I like BSD style licenses) and GPL both have its places in the open source movement.

Still I have some doubts about using GPL in embedded software development. Maybe it needs some further clarifications.

Top 100 jobs in Singapore (2007)

http://www.salary.sg/2007/top-100-jobs-in-singapore-2007/

It seems electronics engineers are not too bad.

Building Microchip PIC32 GCC Compiler from Source

Over the past few days, I learned how to build PIC32 (MIPS32 M4K Core based) Cross Compiler from provided GCC source under Ubuntu Linux.

This is documented in this forum thread.
http://forum.microchip.com/tm.aspx?m=292995

libusb-win32 and OpenUSB wiki opened

Often open source projects suffer from poor documentation which scares the new users away. Now SourceForge starts to offer wiki service. Based on my suggestion, libusb-win32 and OpenUSB have opened the wiki site.

As a start, I created some initial pages.
http://libusb-win32.wiki.sourceforge.net/Porting+libusb+based+program+to+libusb-win32
http://openusb.wiki.sourceforge.net/libusb+related+projects

Thursday, November 1, 2007

Bootloaders for Microchip PIC MCUs

The following is a list of bootloaders for Microchip PIC MCUs.

Comments on 14-Mar-2010: The updated list is here:
http://www.microchip.com/forums/tm.aspx?m=424874

Commercial/Non-Free.
1. http://www.microchipc.com/PIC18bootload/ Non-free
2. http://www.microchipc.com/PIC16bootload/ free for no-commercial
3. http://kulesh-software.com/Software/USBPicBooloader/index.html
4. Ethernet bootloader
http://www.brushelectronics.com/index.php?page=software#EBL
5. http://www.auelectronics.selfip.com/Software.htm

Free from Microchip:
1. Microchip AN851: PIC16F/18F bootloader via serial
2. Microchip AN247: PIC18F CAN MCU bootloader via CAN bus
3. Microchip AN1094: PIC24/dsPIC30/dsPIC33 bootloader
4. Microchip TCP/IP Stack 4.1x: Internet bootloader for PIC18J Ethernet MCU
5. Microchip PICkit 2: USB HID Bootloader
6. Microchip USB Firmware framerwork: USB bootloader using generic USB driver

Free from third party:
1. ingenia free dsPIC bootloader:

http://www.ingenia-cat.com/

2. Tiny Bootloader. It also lists many other bootloaders.
http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm
Some of the listed bootloaders in the Tiny Bootloader page.
3) Wouter's Wloader: http://www.voti.nl/wloader/index_1.html
4) Wouter's ZPL: http://www.circuitcellar.com/flash2002/honorable.htm
5) Jolt: http://mdubuc.freeshell.org/Jolt
6) Hitech PIC16F/18F bootloader
http://www.htsoft.com/forum/all/showflat.php/Cat/0/Number/26726/an/0/page/0#Post26726
7. Colt bootloader: http://mdubuc.freeshell.org/Colt/
8. Bloader and Screamer: http://www.sparkfun.com/commerce/hdr.php?p=tutorials
9. Free USB bootloader (with encription support)
http://www.diolan.com/pic/bootloader.html
10. Serial Wombat's boot-loader for 18F4620 (with encription) is available for free here:

http://forum.microchip.com/tm.aspx?m=126770

11. Philip Pemberton's PIC18F bootloader
http://www.philpem.me.uk/elec/pic/
12. dsPIC30 open source bootloader
http://mrmackey.no-ip.org/elektronik/ds30loader/

There are so many bootloaders. It seems to me AN851 and Tiny Bootloader are the most popular ones for 16F/18F.

PK2CMD Ported to Linux and FreeBSD

PK2CMD is a 32-bit command line interface for the PICkit 2 Programmer. It is available for download from the PICkit 2 webpage: http://www.microchip.com/pickit2 .

Microchip has released the source code here:
http://ww1.microchip.com/downloads/en/DeviceDoc/PICkit2_PK2CMD_SourceV1_00.zip

Jeff Post has since released the Linux port of PK2CMD here:
http://home.pacbell.net/theposts/picmicro/pk2cmdLinux-0.1.tar.gz

Take note that CFLAGS -fpermissive may need to be added to avoid compiling error with later version of g++ (for example: under Ubuntu 7.04/7.10).

It might needs some modification to work under Mac OS X.

I've also tried it under FreeBSD 7.0 Beta. I need to get the alternative USB Stack from Hans Petter Selasky (HPS) to get it work. It should work under other version of FreeBSD which HPS stack supports.

To get the HPS USB stack for FreeBSD, follow the following instruction.

svn --username anonsvn --password anonsvn checkout svn://svn.turbocat.net/i4b
cd i4b/trunk/i4b/FreeBSD.usb
make S=../src package
make install
Follow the "make help" instructions.

One patch required is the file "ugen.c". In the function
"ugen_open_pipe_read()",
find the line "case UE_INTERRUPT:" and then some lines further down you will find:
/* first transfer clears stall */
sce->read_stall = 1; //---> Chaneg this to "0".
Then recompile and install the "ugen" module and/or kernel.

PICkit 2 with FreeBSD (old):
http://lists.freebsd.org/pipermail/freebsd-usb/2007-April/003177.html

PICkit 2 with FreeBSD (new):
http://lists.freebsd.org/pipermail/freebsd-usb/2007-October/004057.html

Sample running session:
===[mcuee] ~/Desktop/build/pk2cmd4bsd # uname -a
FreeBSD FreeBsd.Mshome 7.0-BETA1 FreeBSD 7.0-BETA1 #2: Thu Nov 1
19:56:07 SGT 2007
root@FreeBsd.Mshome:/home/obj/home/src/sys
/USBDEBUG i386
===[mcuee] ~/Desktop/build/pk2cmd4bsd # sudo ./pk2cmd -PPIC12F675 -I

Locating USB Microchip PICkit2 (vendor 0x04d8/product 0x0033)
Found USB PICkit as device '/dev/ugen0' on USB bus /dev/usb1
Communication established. PICkit2 firmware version is 2.10.0

Device ID = 0FC3

Operation Succeeded
===[mcuee] ~/Desktop/build/pk2cmd4bsd # sudo ./pk2cmd -PPIC12F675 -GF12F675.hex

Locating USB Microchip PICkit2 (vendor 0x04d8/product 0x0033)
Found USB PICkit as device '/dev/ugen0' on USB bus /dev/usb1
Communication established. PICkit2 firmware version is 2.10.0

Read successfully.

Operation Succeeded
===[mcuee] ~/Desktop/build/pk2cmd4bsd # sudo ./pk2cmd -PPIC12F675 -Y
-F12F675.hex

Locating USB Microchip PICkit2 (vendor 0x04d8/product 0x0033)
Found USB PICkit as device '/dev/ugen0' on USB bus /dev/usb1
Communication established. PICkit2 firmware version is 2.10.0

PICkit 2 Verify Report
1-11-2007, 20:04:10
Device Type: PIC12F675

Verify Succeeded.

Operation Succeeded

Wednesday, October 17, 2007

PICkit 2 and PICDEM FS USB Demo Board Under FreeBSD

With the help of Hans, I am able to get the PICDEM FS USB Demo Board demo mode (interrupt transfer) work under FreeBSD using his USB stack under FreeBSD 6.2 Stable. This is a byproduct of getting the PICkit 2 work again under FreeBSD.

One patch required is the file "ugen.c". In the function "ugen_open_pipe_read()",
find the line "case UE_INTERRUPT:" and then some lines further down you will find:
/* first transfer clears stall */
sce->read_stall = 1;

Chaneg this to "0".
Then recompile and install the "ugen" module and/or kernel.

Links to the FreeBSD USB Mailing List thread:
http://lists.freebsd.org/pipermail/freebsd-usb/2007-October/004057.html

http://lists.freebsd.org/pipermail/freebsd-usb/2007-October/004063.html

The bootloader (bulk transfer) is not working yet.
http://lists.freebsd.org/pipermail/freebsd-usb/2007-October/004058.html

Monday, September 17, 2007

Olimex LPC-P2148 USB Under Linux/Windows

My LPC-P2148 was collecting dust after the first failure under Linux and change of job mid-2006. My NForce3 AMD64 motherboard is quite picky. The thread is here and I was not able to solve the problem.
http://www.spinics.net/lists/usb/msg05773.html

Later I found out lpcusb and jcwren's example which works fine for me. So I will start again with LPC-P2148 after some learning on the PIC USB side. Maybe I will start with modifying the lpcusb stack for bare-minimum device ( interrupt transfer, bulk transfer, generic HID like the example from LakeView Ressearch). I want to try out isochronous transfer as well as it is the base for USB audio device.

Some links:

Olimex LPC-P2148
http://www.olimex.com/dev/lpc-p2148.html

lpcusb
http://wiki.sikken.nl/index.php?title=LPCUSB

jcwren's good example
http://jcwren.com/arm/

gnuarm
http://www.gnuarm.com/

WinArm
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/

H-Jtag
http://www.hjtag.com/

Startup Guide with Open Source Arm Development Tools
http://www.akamina.ca/Reports/GnuArm_Setup_Guide_1.11.pdf

AN10583: USB Audio with libmad port and EFSL
http://www.standardics.nxp.com/support/documents/microcontrollers/pdf/an10583.pdf

Tuesday, August 14, 2007

Bare Minimum Isochronous Transfer USB Example for PIC18F2550

USB is not easy and isochronous transfer is the most difficult transfer type. I've done a bare minimim example with PICkit 2 (18F2550). However, it still needs quite some improvement both on the firmware side and the host side. Unfortunately I am quite weak especially on the host side.
http://forum.microchip.com/tm.aspx?m=270049

Wednesday, July 11, 2007

PICkit 2 as a USB Learning Tool

1. Brad Minch's Lab 2 HID example using gputils
http://www.curdes.com/gnupic/GnuPic.html

2. PICKit 2 CDC emulation ported from Microchip's PICDEM FS USB
http://forum.microchip.com/tm.aspx?m=267849

3. Mark Rages' PICKit 2 as a SPI Protocol Analyser Hack
http://vivara.net/blog/?p=55
The code is written in SDCC.
http://vivara.net/software/pickit_spi/pickit-spi.tar.gz

Sunday, July 8, 2007

PIC MCU USB Links

I have started a thread in Microchip Forum to collect the links
related to PIC MCU and USB. Many others have also contributed
to the link collections. It is here:

http://forum.microchip.com/tm.aspx?m=123533

Sunday, June 10, 2007

PICkit 2 under Linux Mini-Howto

Edit: please take note this Mini-How to is obsolete now. Please go to Microchip's PICkit 2 website to download pk2cmd codes. It now supports Linux and Mac OS X along with Windows.

PICkit 2 (http://www.microchip.com/pickit2) is a nice little USB programmer from Microchip. It now supports many Flash MCUs from Microchip. As of now, most of the PIC12F/16F/18F 8-bit PIC MCUs and PIC24/dsPIC30/dsPIC33 16bit MCUs are supported (http://ww1.microchip.com/downloads/en/DeviceDoc/PICkit%202%20Readme%20v2-30.txt).

Microchip has kindly published the source codes for PICkit 2 firmware and the standardalone PC application (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1960).

PICkit 2 works under Linux thanks to the efforts from several developers. The easiest to start with is pk2 from Jeff Post (http://home.pacbell.net/theposts/picmicro/). pk2-2.04 only supports version 1.x (up to V1.21) firmware. The upcoming pk2-3.x will support version 2.x firmware.

The following is the simple procedure to get pk2-2.04 built under Linux.
1) Make sure you have the necessary compiler (gcc/make) and libusb development package. Normally they are already included in the distribution.

2) Download pk2-2.04. Apply the follow patch for the file pk2usb.c.

//#if HAVE_LIBUSB_INTERRUPT_MODE
// latest libusb: interrupt mode, works with all kernels
# define PICKIT_USB(direction) usb_interrupt_##direction //only keep this line
//#else
// older libusb: bulk mode, will only work with older kernels
//# define PICKIT_USB(direction) usb_bulk_##direction
//#endif

3) Modify the default Makefile. Normally you should be using kernel version Linux 2.6.x and you should use the following option.
# ----- Use the following for Linux kernel 2.6.x: -----
CFLAGS=$(OPTS) -I$(LIBUSB)/include -DLINUX -DUSE_DETACH -DCLAIM_USB

4) Built pk2 with the command "make"

5) Test out pk2. Normally you need to run as root if you have not setup the proper hotplug/udev rules.

6) If it is okay, set up the hotplug/udev rules. This will depend on your distribution. The following is a quick start for you.
http://piklab.sourceforge.net/wiki/index.php/Port_connection_problems
You can read the bundled usbhotplug.txt by Linus Walleij for more information about udev/hotplug.

7) If you encounter problems with pk2, try to ask question in pickit-devel mailing list (http://groups.google.com/group/pickit-devel). Take note that you should ask general questions about PICkit 2 in Microchip Forum (http://forum.microchip.com/tt.aspx?forumid=15). There are some good information about PICkit 2 in the Microchip Forum. In paticular, if you encounter USB emuneration problem under Linux, try the hardware changes detailed in the post (http://forum.microchip.com/tm.aspx?m=245280). Only Step 2 is necessary.

8) How to help out?
From Jeff Post: http://home.pacbell.net/theposts/picmicro/helping.html

Note on 10-April-2009: it is now better to use pk2cmd at Microchip PICkit 2 websites.
http://www.microchip.com/pickit2



Friday, May 18, 2007

PIC Development Tools under FreeBSD

I am mainly a Linux user and Ubuntu is my preferred distribution. However from time to time I will also try other Linux distributions and FreeBSD.

Right now I have a small installation of FreeBSD 6 Stable. It is not as easy to use as Linux but it is definitely usable. The following is a list of links for PIC MCU development tools under FreeBSD.

FreeBSD has ports for gputils/sdcc/gpsim/picp/pikdev.
http://www.freebsd.org/ports/

It is also possible to build Piklab under FreeBSD.
http://piklab.sourceforge.net/wiki/index.php/Compilation_for_FreeBSD

PICStart+ works under FreeBSD with picp.

Wisp628 works under FreeBSD with xwisp2.
http://www.robh.nl/picsoft.php

JALv2 works under FreeBSD as well.
http://www.casadeyork.com/jalv2/
http://www.casadeyork.com/jalv2/jalv21src.zip

The main problem under FreeBSD is the lack of device drivers. But they are catching up. One of the things in development is the alternative USB stack by Hans Petter Selasky (http://www.turbocat.net/~hselasky/usb4bsd/). With his help I am now able to run pk2 and piklab to support PICKit 2 under FreeBSD.

For more detail, please refer to the following mailing list thread.

http://lists.freebsd.org/pipermail/freebsd-usb/2007-April/003182.html

You need to run the alternative USB stack (maybe you will need to use the stable or current branch) and apply the following patch to ugen.c in order to get pk2 to work. Maybe the patch is already in the latest version of the USB stack.

==== ugen.c#12 - ugen.c ====
@@ -637,9 +637,12 @@
{
return (EIO);
}
- /* setup clear stall */
- sce->xfer_out[0]->clearstall_xfer =
- sce->xfer_out[1];
+
+ if ((ed->bmAttributes & UE_XFERTYPE) == UE_BULK) {
+ /* setup clear stall */
+ sce->xfer_out[0]->clearstall_xfer =
+ sce->xfer_out[1];
+ }
break;

case UE_ISOCHRONOUS:
@@ -759,10 +762,6 @@
return (EIO);
}

- /* setup clear stall */
- sce->xfer_in[0]->clearstall_xfer =
- sce->xfer_in[1];
-
usbd_transfer_start(sce->xfer_in[0]);
PRINTFN(5, ("interrupt open done\n"));
break;
@@ -1322,6 +1321,17 @@

USBD_CHECK_STATUS(xfer);

+ tr_error:
+ if (xfer->error != USBD_CANCELLED) {
+ /* setup clear stall */
+ xfer->clearstall_xfer = sce->xfer_out[1];
+
+ /* start clear-stall */
+ usbd_start_hardware(xfer);
+ return;
+ }
+ return;
+
tr_transferred:

PRINTFN(5, ("xfer=%p actlen=%d\n",
@@ -1362,7 +1372,7 @@
return;

tr_setup:
- tr_error:
+ xfer->clearstall_xfer = NULL;
usbd_start_hardware(xfer);
return;
}

Wednesday, May 16, 2007

Microchip PIC MCU Development Tools under Linux

I've collected some links about PIC MCU Development Tools under Linux.

1. MPLAB under Linux with Wine (my mini-howto):
http://forum.microchip.com/tm.aspx?m=112347

2. PICkit 2 under Linux
pk2 by Jeff Post: http://home.pacbell.net/theposts/picmicro/
pyk by Mark Rages: search pyk http://groups.google.com/group/pickit-devel
piklab by Nicolas Hadacek: http://piklab.sourceforge.net/

3. MPLAB ICD 2 under Linux
http://piklab.sourceforge.net/

4. PICStart+ under Linux
PICP by Jeff Post: http://home.pacbell.net/theposts/picmicro/
Piklab: http://piklab.sourceforge.net/
Pista: http://gatling.ikk.sztaki.hu/~kissg/pd/pista/pista.html

5. PICDEM FS USB related project
1) PICDEM FS USB bootloader for Linux using libusb
http://www.internetking.org/fsusb/
http://forum.microchip.com/tm.aspx?m=106426
2)PICDEM FS USB demo appliation under Linux using libusb
http://www.varxec.net/picdem_fs_usb/

6. PICkit 1 under Linux
http://charm.cs.uiuc.edu/users/olawlor/projects/2003/microchip/
http://tfc.duke.free.fr/pickit.html

7. Basic tools: gputils assembler/linker, gpsim simulator and sdcc C compiler
GPutils: http://gputils.sourceforge.net/
GPSIM: http://www.dattalo.com/gnupic/gpsim.html
SDCC: http://sdcc.sourceforge.net/


SEEVAL32 EEPROM programmer

My blog is born today: 16-May-2007!

Today I borrowed a Microchip SEEVAL 32 Serial EEProm Designer Kit from local Microchip. The kit seems quite neat. The cost is US$99.

The URL for SEEVAL is at http://www.microchip.com/seeval32.

I am a big fan of Microchip PICKit 2 USB programmer and I am an active member of the pickit-devel Google group. Technically speaking, PICkit 2 (http://www.microchip.com/pickit2) should be able to support EEProm programming as well. Hopefully they can add the support soon.