WZab's animated logo

Simple evaluation board and Linux programmer for C8051F320

First of all I must warn you!!! This is a free, experimental design. It has worked for me, but I do not give you any warranty, that it is error free. I could make any mistake when preparing this material for publication, there can be some not discovered bugs in both my hardware and software. It can also infringe someones patents... (however I don't know anything about it). So keep in mind - you use it on your own risk and responsibility!!!

One of very nice USB capable microcontrollers is the C8051F320 produced by Silabs (formerly Cygnal). Unfortunately to start playing with this chip you need to buy a rather expensive development kit. On this page I present some alternatives for building a cheaper toolset.

The first component is a simple and cheap development board with C8051F320. The schematic is based on the original development board from Silabs. It has been designed as single layer PCB, and therefore it is really easy to be produced at home.

The PCB design has been prepared with the free PCB program. For those of you, who are not able to run PCB (eg. because yur PC runs only under the broken operating system® ) I've provided the PDF file.

The schematic diagram has been prepared with the free gschem program, but again the PDF version is also available.

The board itself however is useless without the programmer. To keep the costs as low as possible, I've prepared a simple programmer (here are the schematics sources in a XFig format) connected directly to the PC's LPT port.

The programmer is controlled with a dedicated software, written in C language. The software (source available under GPL) consists of two parts. The first one is a dedicated Linux driver, and the next one is a program "cygprog". To use the programmer you need first to load the driver (as root):

# insmod cygnal_c2 io_base=0x378 major=233

(certainly you should adjust the io_base to the LPT port address in your PC, and the "major" number to a free value; you can also don't set the major - it will be allocated dynamically and then you'll need to find the allocated number in the /proc/devices).

Then you should create the appropriate device node. Now the programmer expects to find it in its working directory, under the "cygnal" name (you can modify sources if you want to).

# mknod cygnal c 233 0

Then you can use the program. It is wise to give the normal user access to the cygnal device and use the program as a normal user:

# chown user.user cygnal

One important remark - my driver is not "parport" compatible. It is necessary to remove "parport" driver and/or "lp" driver, before using the cygnal device.

My programmer software now understands only the raw binary files starting from address 0. You can convert standard "ihx" files (as produced by the SDCC compiler) into the binary files, using the "srec_cat" tool (available eg. in the Debian "srecord" package). You should use a command line like this:

$srec_cat -Output test.bin -Binary wzab.ihx -Intel

to convert the "ihx" file into the binary one.

Then you can use the cygprog to write your program into the device's memory:

$./cygprog p test.bin

The software can also verify the program (./cygprog v test.bin) and dump the device's memory into the file (./cygprog r output.bin).

Certainly this only the first draft version (however it is usable for me), so any corrections and suggestions are appreciated.

I've received some messages, that it is not possible to compile the driver for kernel 2.6. I've checked it, and cleaned up the source a little. Here you can find the source modified for kernel 2.6. The archive contains two subdirectories: "driver" and "program". Make command in the "driver" subdirectory should build a driver module (however some warnings may be issued during the compilation), while make in the "program" directory should build the user mode part of the programmer software.

Things to do

Improvements sent by Matt Otto

A few days ago I have received the improved version of the programmer, prepared by Matt Otto. This is what he says in the README file:
This is an enhancement to Wojtek Zabolotny's C2 programmer. There are two significant enhancements:
  1. I have included the source code for a new program, c2mon.c, which demonstrates how to perform debugging operations with the C2 interface. It is very crude as far as programs go (there's no user interaction), but the source code shows how to perform any debugging task you may need.
  2. In order to support some undocumented behaviors of the C2 interface, I needed to enhance Wojtek's driver and schematic. The enhancements allow for sending and receiving short C2CK pulses.

In addition to the C2CK enhancements, I also added Plug and Play (PNP) support to the driver so that it would work on my PC (I don't know if my PC hardware is different or if my 2.6.12 kernel requires it).
Instead of trying to make c2mon useful as a stand-alone program, I am starting to integrate c2mon into SDCDB, the debugger that comes with the SDCC compiler. (Currently, SDCDB only knows how to interface with the uCsim simulator.) Until I finish that project, hopefully the c2mon.c sample code will be useful.
Matt Otto matt@__NO_SPAM__klox.net

Wojtek Zabolotny
Last modified: Mon Aug 22 19:57:36 CEST 2005