There are a lot of tools available for building embedded programs (buildroot I have used in the past for OpenWRT) but they all assume you are building a linux kernel. With only 256KB on the HK68K, linux is not an option. A relaxing evening with Google search resulted in finding the Atari 16/32 Bit Development Info page. (The Atari ST used a 68000 with a custom MMU but the same compile principles applied to the MMU-less 68000.)
The trick is to get the ‘gcc’ tools to not use the standard libraries at all. This is done using the ‘-nostdlib’ switch and then providing our own startup code as well as any stdlib replacement functions. To get to this stage I built a cross compile toolchain using ‘newlib’.
So, next up is to enhance Newlib with a HK68K specific section. Newlib is a mixture of old and new style library configs, so it is confusing. First up is to try and limit what platforms it builds for (which failed miserably, not loving the documentation!).
I attempted several ways to implement a new subdirectory in libgloss for hk68k but gave up. Instead I added the Heurikon specific files to libgloss/m68k and enhanced the Makefile there. This worked and I maintained my sanity.
Compiling now uses:
m68k-elf-gcc –m68000 –T hk68k.ld ……. to indicate that we want to compile for a plain 68k chip, and the memory map, crt0, libc libraries etc are detailed in hk68k.ld.
Links (in order of discovery/importance):
- http://bus-error.nokturnal.pl/tiki-read_article.php?articleId=12 Atari hint on startup code
- http://www.ist-schlau.de/phpBB3/viewtopic.php?f=8&t=18 Building Gcc with Newlib
- http://www.embecosm.com/appnotes/ean9/html/index.html An excellent article on porting Newlib/libgloss to a new board
- http://opencores.org/or1k/Newlib An example of how to port Newlib to a new board.
- http://www.ist-schlau.de/phpBB3/viewtopic.php?f=8&t=18 This example for building Newlib works and is what I used
- http://www.ist-schlau.de/software.html A succinct description of bare metal basics