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