Installing the 68hc11/12 GNU C compiler toolset

Updated 2 October 2002 ---

Users in the Dallas Personal Robotics Group and the SRS have pointed out problems in my release files.  These problems included missing files, uppercase file names, and missing search path options in the blinky.mak file.  I've updated the file to fix the path and missing file problems. I've also added a file called blinky.txt to the .zip package, to provide additional information on the problems uncovered.  Sorry for the inconvenience...

The GNU C compiler and toolset has an excellent reputation in the embedded world, and is a tremendous tool for use in robotics, but it can be a pain to use on a Windows box.  It was developed in the Unix world, so it uses a command-line interface, lots of arcane options, and requires a high minimum level of expertise to get anything useful done.

But getting that minimal level of expertise, with proper guidance, is doable, and the results are well worth the effort.  The compiler and toolset are free, they generate high-quality code, and matching compilers exist for dozens of different processors from the smallest chips to mainframes.

NOTE:  This is a very condensed description for installing, and it may not be enough for everyone to use successfully.  I did a LARGE article for Nuts & Volts magazine describing the full procedure in detail, and I strongly urge you to consult that article if you have questions.

The GNU C compiler port for the 68hc11/68hc12 was done by Stephane Carrez and has been taken over by the Free Software Foundation.

To begin the installation, you need to collect the following files from the 68hc11 GNU C FSF website:

Click on Download, then on EXE.  You should see a list of Inno packages for Windows.  These are very similar to the Setup.exe files you are used to seeing.  Download the files for the above elements; I used the Release 1.1.1 set.  You can also download the examples 1.2.1 set; you don't have to have them to do the install, but they provide lots of information.

Save the files in a suitable folder, then execute each in turn.  Choose the same base directory for all installations; I used c:\68hc11\gcc.

You will also need a GNU-compatible make utility.  There are several available on the 'net; here is the link for the one I used.  Download and install this utility in a directory in your command search path.

Projects built with GNU C typically require a basic set of files.  The source files, both in C and assembler, are simple text files that you can create with any text editor.  You also need a make file to control the actual compilation and linking of your project.  You also need a linker script, used with GNU's ld program, to collect all of the object files required by your project and turn them into a single file that can be run on your target machine.

I've provided a set of project files for creating a program called blinky, which blinks an LED attached to line PB7 on the Technological Arts Adapt912b32 board that I used for development.  These files are a full working example of a GNU C project and should get you started in using the GNU C toolset. You can download them as a file named
blinky.c   The main program
isr.c Basic ISR handler
vectors.c Interrupt vector table
crt0.s C run-time (startup) code
blinky.ld Linker script
isr.h Include file for isr.c
ioregs12.h 68hc912b32 I/O defs
blinky.mak Project make file
blinky.txt Notes on making blinky

I've tried to make the make file and the linker script easy to understand, as they are the most important elements of GNU C development.  The GNU toolset is very well documented, both in the GNU release files and on the web.  See also the 68hc11/12 GNU C listserver for ongoing discussions.

After you have unzipped the above files into a working directory, invoke the make utility with the following command:

make -f blinky.mak

If the make succeeds, you will be left with several files, including the final executable, named blinky.s19.  Download this file into your target board, press reset, and you should see the LED on line PB7 blink several times per second.


The GNU make utility has a few quirks.  One that is almost sure to bite you involves tab characters.  Each operation within a rule for making objects MUST begin with a hard tab character; leading spaces will NOT work!  If you see an error message similar to "No rule for making xxx," check the make file carefully; you might find your editor has deleted the tab character.

My home page --