Kjetil's Information Center: A Blog About My Projects

GCC Toolchain for the DEMO9S12NE64 Board

I found a Freescale DEMO9S12NE64 board which is used for evaluation for a HCS12 compatible microcontroller. The board is around 20 years old now and support ended a long time ago. Nevertheless I was able to get it up and running with a uIP network stack compiled with a GCC toolchain using only open source software.

To compile the m68hc11 toolchain from scratch you will need to use a patch on an set of an existing GCC source and associated tools. The specific patch I used is m68hc1x-builder-3.1.tar.gz which needs GCC 3.3.6, binutils 2.15, GDB 6.4a and newlib 1.12.0.

I made a script to help automate the process of building the toolchain:

#!/bin/bash
set -e

tar -xvjf binutils-2.15.tar.bz2
tar -xvzf gcc-3.3.6.tar.gz
tar -xvjf gdb-6.4a.tar.bz2
tar -xvzf newlib-1.12.0.tar.gz
tar -xvzf m68hc1x-builder-3.1.tar.gz

patch -p0 -i m68hc1x-builder-3.1/binutils-2.15-m68hc1x-20040801.diffs
patch -p0 -i m68hc1x-builder-3.1/gcc-3.3.6-m68hc1x-20060122.diffs
patch -p0 -i m68hc1x-builder-3.1/gdb-6.4-m68hc1x-20060122.diffs
patch -p0 -i m68hc1x-builder-3.1/newlib-1.12.0-m68hc1x-20040801.diffs

# Some nice defines
export BINUTILS=binutils-2.15
export GCC=gcc-3.3.6
export GDB=gdb-6.4
export NEWLIB=newlib-1.12.0
export TARGET=m6811-elf
export PROGRAM_PREFIX=m6811-elf-
export INSTALLDIR=/opt/gcc-$TARGET
export MAKE=gmake

# Build binutils
cd $BINUTILS
sh ./configure --target=$TARGET \
               --prefix=$INSTALLDIR \
               --program-prefix=$PROGRAM_PREFIX
$MAKE
$MAKE install
cd ..

# Further steps require the binutils we just built
export PATH=$INSTALLDIR/bin:$PATH

# Build gcc
cd $GCC
sh ./configure --target=$TARGET \
               --prefix=$INSTALLDIR \
               --program-prefix=$PROGRAM_PREFIX \
               --enable-languages=c
$MAKE
$MAKE install
cd ..

# Build gdb
cd $GDB
sh ./configure --target=$TARGET \
               --prefix=$INSTALLDIR \
               --program-prefix=$PROGRAM_PREFIX
$MAKE
$MAKE install
cd ..

# Build newlib
mkdir build-newlib
cd build-newlib
sh ../$NEWLIB/configure \
   --target=$TARGET \
   --prefix=$INSTALLDIR \
   --program-prefix=$PROGRAM_PREFIX
$MAKE
$MAKE install
cd ..
          


Note that this script does NOT work on modern Linux distributions due to later GCC versions being incompatible with the source. I ran this on a Slackware 11.0 installation with GCC 3.4.6 inside a QEMU virtual machine.

Someone ported uIP to this architecture a long time ago and I found the source as "uIP-HCS12NE-release-1.0.zip" somewhere on the Internet. To utilize the newly built toolchain to build this, just change the top three lines in the "uip-ne64.mak" makefile to:

OC = /opt/gcc-m6811-elf/bin/m6811-elf-objcopy
CC = /opt/gcc-m6811-elf/bin/m6811-elf-gcc
RM = /bin/rm
          


And compile it:

make -f uip-ne64.mak
          


The resulting "uip-ne64.s19" S-record can be loaded on the DEMO9S12NE64 board with the hcs12mem tool in "Serial Monitor" mode like so:

./hcs12mem -i sm -t ../target/mc9s12ne64.dat -p /dev/ttyS0 -b 115200 --flash-erase
./hcs12mem -i sm -t ../target/mc9s12ne64.dat -p /dev/ttyS2 -b 115200 --flash-write uip-ne64.s19
          


Topic: Scripts and Code, by Kjetil @ 27/12-2024, Article Link