gcc-toolchain for freescale's MC9S12X (68HCS12) ??

Hiya folks,

as you might guess from the subject: I'm trying to find a toolchain for freescale's hcs12 or S12X family of microcontrollers. Currently i'm using Codewarrior on the Windows machine at work, but as i'm a tad dissatisfied by it's lack of decent syntax-checking and have no windows at home, i'd rather use some free compiler available for my rather unusual platform (Linux on PowerPC). So gcc would probably be the best bet.

Has any of you guys experience with that combination or another suggestion (apart from buying some windows machine)??

Greetings, Florian

Reply to
Florian E. Teply
Loading thread data ...

gcc provides better syntax checking than any other compiler I have tried. However, I don't believe there is a gcc port for the 68HCS12 - if such a thing exists, it would only be as a minor partial port. But there are a couple of other ways to achieve what you want without dropping Codeworrier.

It is quite possible to use gcc for a different target as a static analysis tool. I've done that along with a commercial compiler for a target (I've forgotten which - it was a long time ago) - gcc "compiles" the program natively for the host (linking tended to fail...). It might mean a little bit of fiddling to get the right headers at the right place, and perhaps an extra header defining macros for any compiler extensions used by the real target compiler, but it can often work well. You can also use gcc to generate the makefile dependencies at the same time.

An alternative is to use a dedicated static analysis tool. The big one is PC-Lint, which is a reasonable price on Windows (but absurdly four times the price on Linux - and I doubt they support PPC Linux). The open source option is splint, which should be fine on your system.

Reply to
David Brown

How close does this get you?

formatting link

--
Regards,
Richard.

+ http://www.FreeRTOS.org & http://www.FreeRTOS.org/shop
17 official architecture ports, more than 5000 downloads per month.

+ http://www.SafeRTOS.com
Certified by TÜV as meeting the requirements for safety related systems.
Reply to
FreeRTOS.org

Building a toolchain isn't too hard. Below is the shell script I used last time I built a toolchain for the 6812. That was probably a couple years ago I included newlib in my build, but IIRC, you can build a 6812 compiler without any libc at all if you prefer.

------------------------------build-6812.sh------------------------------ #!/bin/bash

DEST=/opt/gnu/testing TARGET=m6812-elf

BINVERS=2.15_v0501 GCCVERS=3.4.3 NLBVERS=20030821-kpit3.04 GDBVERS=6.1

HERE=$PWD SRC=$PWD/src BLD=$PWD/bld

set -e

echo "+++ cleaning old source directory" rm -rf $SRC echo "+++ cleaning old build directory" rm -rf $BLD

export PATH=$DEST/bin:$PATH

mkdir -p $SRC

function do-binutils { echo "+++ extracting binutils" tar xzvf binutils-$BINVERS.tar.gz -C $SRC echo "+++ configuring binutils" mkdir -p $BLD/binutils pushd $BLD/binutils $SRC/binutils-$BINVERS/configure \ --target=$TARGET \ --prefix=$DEST \ 2>&1 | tee configure.log echo "+++ building binutils" make 2>&1 | tee make.log echo "+++ installing binutils" make install 2>&1 | tee makeinstall.log echo "+++ finshed binutils" popd # rm -rf $SRC/binutils-* $BLD/binutils } function do-gcc { echo "=== extracting gcc" tar xzvf gcc-$GCCVERS.tar.gz -C $SRC if [ -d $HERE/patches/gcc ] then echo "=== patching gcc" pushd $SRC/gcc-$GCCVERS (for f in $HERE/patches/gcc/* do echo "==== $f" patch -p0 &1 | tee patch.log popd fi echo "=== extracting newlib" tar xzvf newlib-$NLBVERS.tar.gz -C $SRC mv $SRC/newlib-$NLBVERS/newlib $SRC/gcc-$GCCVERS mv $SRC/newlib-$NLBVERS/libgloss $SRC/gcc-$GCCVERS echo "=== configuring gcc" mkdir -p $BLD/gcc pushd $BLD/gcc $SRC/gcc-$GCCVERS/configure \ --target=$TARGET \ --prefix=$DEST \ --enable-languages=c \ --with-gnu-as \ --with-gnu-ld \ --with-newlib \ -v 2>&1 | tee configure.log echo "=== building gcc" make 2>&1 | tee make.log echo "=== installing gcc" make install 2>&1 | tee makeinstall.log echo "=== finished gcc" popd # rm -rf $SRC/gcc-* $SRC/newlib-* $BLD/gcc }

function do-gdb { echo "=== extracting gdb" tar xzvf gdb-$GDBVERS.tar.gz -C src echo "=== configuring gdb" mkdir -p $BLD/gdb pushd $BLD/gdb $SRC/gdb-$GDBVERS/configure \ --target=m6811-elf \ --prefix=$DEST \ -v 2>&1 | tee configure.log echo "=== building gdb" make 2>&1 | tee make.log echo "=== installing gdb" make install 2>&1 | tee makeinstall.log echo "=== finished gdb" popd # rm -rf $SRC/gdb-* $BLD/gdb }

do-binutils do-gcc do-gdb

-------------------------------------------------------------------------

--
Grant Edwards                   grante             Yow! HUMAN REPLICAS are
                                  at               inserted into VATS of
                               visi.com            NUTRITIONAL YEAST ...
Reply to
Grant Edwards

Yes there is.

What do you mean by a "minor partial port"? It's in the mainline gcc source tree, and it seemed to work fine for me. The code it generated was far better than the last commercial

6811 compiler I used.
--
Grant Edwards                   grante             Yow! Gee, I feel kind of
                                  at               LIGHT in the head now,
                               visi.com            knowing I can't make my
                                                   satellite dish PAYMENTS!
Reply to
Grant Edwards

Umm, i guess this is *quite* close ;-) Thanks, Florian

Reply to
Florian E. Teply

I'm not necessarily into dropping Codewarrior, i thought more like using gcc as some sort of syntax check while not at work, so i can test the stuff at home and concentrate on fixing this mess at work ;-) Proper binaries would be an added bonus though.

And -- i just checked -- the gcc man page lists in the "machine dependent options" section the options -m68hc12 and -m68hcs12 in version 4.3.0. I'll probably try and get this to work, but as said: using gcc as a mere syntax checker would already be a start.

Thanks, will have a look at splint.

Greetings, Florian

Reply to
Florian E. Teply

Understand your frustration with codewarrior, however one reason for sticking with it is the fairly good BDM in-circuit debug capability of the HCS12 family.

The pod will set you back $100, but ultimately it is worth it.

I don't know if a gcc-based tool chain will really be able to leverage that.

Reply to
cs_posting

Gcc is a single-target design: you have to build a separate gcc installation for each target architecture. IOW, you can't switch from IA32 to HC12 target architecture by merely changing the command line arguments passed to a single gcc binary.

In my experience splint is useless for real world work. It'll warn you about code like this:

uint8_t b; b = 1;

Splint is unhappy because b is 8 bits wide and "1" is 16 or 32 bits wide (depending on your target), and the assignment is loosing bits. If you turn that warning off, then you _won't_ get warned about code like this:

uint32_t u; uint8_t b; b = 123456789L; b = u; The only solution is to completely cover your code with type-casts. The result is code without splint warnings, but it's completely impossible to read/maintain. I looked into trying to fix up splint to make it useful for real work, but gave up after looking at the internals. The "owners" of splint acknowledged on the splint mailing list that splint was intended for language research and not for use with real programs.

--
Grant Edwards                   grante             Yow! Is this going to
                                  at               involve RAW human ecstasy?
                               visi.com
Reply to
Grant Edwards

Sorry, I was thinking of the 8-bit Motorola/Freescale devices, not the

16-bit devices. So I got that one completely wrong.
Reply to
David Brown

I successfully use this to develop for the HCS12X.

Note however that gcc will not compile XGATE code. AFAIK there is no open source XGATE compiler, however, there is an assembler available:

formatting link

Reply to
Andy Sinclair

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.