
Example MCF51QE Project for GNU Tools
Neil Klingensmith
2012-08-20

Overview
--------

This project includes a makefile, linker scripts, and skeleton
source files for building a basic project. The makefile has
two targets: flash and ram. The flash target starts the vector
table at address 0x2000, and places code directly after it.
The ram target starts the vector table at address 0x800000,
and places the code directly above it. Both targets are
intended to be used with the 51QE bootloader, available at:

http://pages.cs.wisc.edu/~klingens

This example project requires the development system to have
gcc built as a cross compiler for the m68k target. Binary
distributions of the gcc cross compiler are available from
CodeSourcery (www.codesourcery.com) or can be built from
source by following the instructions available from:

http://pages.cs.wisc.edu/~klingens


Start Code
----------

The startup code for the ram target is fairly simple because
both data and code are loaded into memory that can be both
read and written. The only thing it needs to do is initialize
the supervisor registers (SR and VBR) and call main. However,
the flash target's startup code must also copy the data segment
from flash into RAM before calling main. Without such code,
initialized global variables would not get the correct values
when the program started.

In order to support both targets with one assembly file,
preprocessor directives are used. In order to force gcc to pass
the assembly file through the preprocessor, its extension must
be .sx instead of .s.


Linker Scripts
--------------

Most programmers have an instinctive and healthy fear of linker
scripts. The syntax is esoteric as well as unintuitive, and it
is often difficult to know what the linker script needs to do
in the first place.

The linker scripts included with this project strive to be as
simple as possible while providing the basic functionality
required.

The basic functionality of the linker scripts in this example
project is:

1) Place all code and data in the correct location.
2) Define the necessary symbols for the startup code.

These linker scripts do not support advanced functinality such
as constructors for C++. The CSS linker scripts published by
CodeSourcery (now owned by Mentor Graphics) do include such
functionality.


