HOWTO INSTALL A CROSS DEVELOPMENT SYSTEM FOR EMBEDDED
MC680x0 SYSTEMS ON A MACHINE RUNNING LINUX


(Note: This document is very old, use with caution.)


  • MISCELLANEOUS
  • IMPORTANT
  • NOTE FOR 68K BASED LINUXERS
  • COFF vs. A.OUT
  • HOW TO DO THE INSTALLATION - A GUIDE IN TWELVE STEPS
  • STARTING UP C PROGRAMS
  • USING A LINKER SCRIPT TO DESCRIBE YOUR EMBEDDED SYSTEM
  • USING mot2bin TO CONVERT S-RECORDS INTO BINARY
  • SOME USEFUL HINTS
  • FINAL RAMBLINGS
  • SUPPLEMENT PROGRAMS



    Author: Olav Wölfelschneider
    EMail: wosch@rbg.informatik.th-darmstadt.de
    Version: 1.1
    Startet: 21. April 1995
    Last modified: 12. May 1995

    This is a rough draft. It works for me. Perhaps I made some terrible mistakes or acted otherwise totally clumsy. You have been warned.

    NO WARRANTY...
    This HOWTO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    This howto may be distributed freely as long as it is not altered.


    This howto does not want to teach you how to program an 680x0. You should at least be familiar with assembly language coding for such a beast. It is an advantage if you also roughly know how a c-compiler handles its stack, since this is very helpful when trying to code in c and assembly at the same time.

    Although this howto was written for people running linux on a non 68k based machine, 68k based linuxers should be able to extract a few hints here, too.


    If you run linux on an Amiga or Atari, that is, an 680x0 based machine, you already have a compiler/assembler/linker system fitting for your target.

    You have other caveats to manage, though: To get around those caveats, you will perhaps have to change some paths, or link the final code by hand (with an appropriate Makefile, even).

    Because I don't have an 68k based linux system, I can't help.
    (AUTHORS NOTE: Any volunteer to fill in that part?)

    If you have enough harddisk space, you can, just like the intel people, install a second gcc-system for cross-development.


    When installing gcc, you have the choice between two object formats. One is coff, the other is a.out. I don't really know the internal differences, but here is what I've found out yet:

  • Names of C functions and Variables:
  • Specifying registers in assembler sourcecode:
  • Assembler syntax:
  • Memory layout
  • Starting up C
  • Needing a crt0.o or not


    You need to get the binutils2.5.2 and the gcc2.6.3 package from or a mirror near you.

    Additionally, you need crossgcc-2.6.3.patch.gz from
    ftp.cygnus.com.

    (AUTHORS NOTE: There should be a mirror on ftp.fta-berlin.de.)



  • STEP 1
  • STEP 2
  • STEP 3
  • STEP 4
  • STEP 5
  • STEP 6
  • STEP 7
  • STEP 8
  • STEP 9
  • STEP 10
  • STEP 11
  • STEP 12



    A usual way to start up a c program is to provide a small assembly program which prepares for the actual run and cleans up the dishes afterwards.
    Classically, this file is called crt0.o. Using a.out, gcc automagically links in crt0.o when building the final executable. Using coff, you are on your own.
    The contents of crt0.o depend heavily on the target system, so this howto can't go very much into detail. However, a sample crt0.S can be found here. You can assemble it with:
      gcc68k crt0.S -o crt0.o  
    (Note: gcc knows that it should preprocess and then assemble the file)


    Nearly noone knows that ld contains a small script language which can be used to describe the system.

    A classic program consists of three sections: On an EPROM based machine, a problem arises from this:
    The .data-section must be placed into RAM and must be initialized before startup. The obvious solution is to place the initial values into an area in the EPROM and copy them to RAM before starting the actual program.

    A linker script can prepare for this by telling the linker two things: This script does this for my board. You will surely have to modify it according to your hardware.
    To use a linker script, pass -T <script-filename> to ld68k while linking. When linking through gcc, this is done with -Wl,-T,<script-filename>


    I have written a simple program for converting s-records to binary data. The source is here. To build, type:
       gcc -s -O2 -fomit-frame-pointer mot2bin.c -o mot2bin		
    Install mot2bin to /usr/local/bin, be sure not to accidentally use the cross-gcc... (:

    The use of mot2bin should be straightforward:
       mot2bin .srec -o .bin	
    The options are:
           mot2bin [--output file] [--name] [--start] [--skipzero] [file]
       or  mot2bin [-o file] [-n] [-s] [-z] [file]
    
       --output <file>, -o <file>	Place binary output to . Defaults to
    				stdout.
    
       --name, -n			If there is a record 0, print the name
    				found in that record to stdout, prefixed
    				by N:
    
       --entry, -e			Usually the start-address is found in a
    				record. This prints it to stdout as hex
    				prefixed by S:
    				Be warned, this is linker's idea of the
    				start address...
    
       --skip <addr>, -s <addr>	Ignore every data from the srecord file
    				which's address is smaller than .
    				You should also use --skipzero to truncate
    				the file.
    
       --skipzero, -z		Don't pad the output file with zeroes to
    				match addresses in the output file 1:1 with
    				real addresses.
    				Example: If the s-record file begins at
    				   address 0x2000, binary output would start
    				   with 8192 zeroes. Use this option to
    				   avoid that.
    
       If there is no inputfile on the commandline, stdin is used.
    

    Some tips and hints for using the crosdevelopment system:
    I hope i didn't make too much mistakes. If you find some, please tell me.
    Please tell me also about language errors, since english is not my native language.

    Enjoy,
    Olav ( wosch@rbg.informatik.th-darmstadt.de)


    crt0.S

    mot2bin.c

    basename.patch

    syms.patch

    ldscript


    Back to my homepage