no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | cybiko:unixh8compiler [2009/11/27 17:54] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Cross-developmental environment for Hitachi H8 microprocessor family====== | ||
+ | These instructions are taken from those supplied [[http:// | ||
+ | |||
+ | It explains how to build a cross development environment on Linux/ | ||
+ | ---- | ||
+ | The [[http:// | ||
+ | |||
+ | It was built using the following versions of these components | ||
+ | * binutils-2.16.1 | ||
+ | * gcc-4.0.1 | ||
+ | * newlib-1.13.0 | ||
+ | < | ||
+ | cd /tools | ||
+ | tar jxf h8.tar.bz2 | ||
+ | | ||
+ | </ | ||
+ | =====Introduction===== | ||
+ | |||
+ | To create an executable file for target CPUs, we need assembler, compiler, library, and linker. GNU provides powerful tool set, binutils (binary utilities) and gcc, which can generate object codes targetting diverse CPUs. GNU also presents a C library (glibc), but it is so huge and not suitable for embedding systems. So, I recommend yout to utilize newlib instead of glibc. In addition, there is a nice and sophisticated debugger, gdb, for helping software development (surprisingly, | ||
+ | |||
+ | =====Getting source codes===== | ||
+ | |||
+ | The lastest bundles of each of these tools can be found on the tools home page, if you want the latest and greatest source then you may follow the CVS checkout procedures for each of these components. | ||
+ | |||
+ | ====binutils (GNU)==== | ||
+ | |||
+ | * http:// | ||
+ | * http:// | ||
+ | < | ||
+ | % cd /usr/src | ||
+ | % mkdir cvs-binutils | ||
+ | % cd cvs-binutils | ||
+ | % cvs -z 9 -d : | ||
+ | {enter " | ||
+ | % cvs -z 9 -d : | ||
+ | </ | ||
+ | |||
+ | ====gcc (GNU)==== | ||
+ | |||
+ | * http:// | ||
+ | * http:// | ||
+ | < | ||
+ | % cd /usr/src | ||
+ | % mkdir cvs-gcc | ||
+ | % cd cvs-gcc | ||
+ | % cvs -z 9 -d : | ||
+ | ( enter " | ||
+ | % cvs -z 9 -d : | ||
+ | ( the latest source tree will be expanded in ../gcc ) | ||
+ | </ | ||
+ | ====newlib C library (cygnus/ | ||
+ | |||
+ | * http:// | ||
+ | < | ||
+ | % cd /usr/src | ||
+ | % mkdir newlib-cvs | ||
+ | % cd newlib-cvs | ||
+ | % cvs -z 9 -d : | ||
+ | ( enter " | ||
+ | % cvs -z 9 -d : | ||
+ | ( the latest source tree will be expanded in ../ | ||
+ | </ | ||
+ | |||
+ | =====Cross-making===== | ||
+ | |||
+ | I expanded the source trees in /usr/src as follows | ||
+ | * binutils / | ||
+ | * gcc / | ||
+ | * newlib / | ||
+ | * gdb / | ||
+ | |||
+ | and I created links to them for easy-typing. | ||
+ | < | ||
+ | / | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | =====Binutils===== | ||
+ | **First of all, we have to build up binutils** since gcc calls archiver, linker, and assembler. | ||
+ | |||
+ | All of GNU compliant tools are initially configured by //" | ||
+ | * **--target** | ||
+ | * **--prefix** | ||
+ | < | ||
+ | $ mkdir / | ||
+ | $ cd /usr/src/h8 | ||
+ | $ mkdir **build-binutils** | ||
+ | $ cd build-binutils | ||
+ | $ / | ||
+ | $ make **CFLAGS=" | ||
+ | $ su | ||
+ | # make install | ||
+ | $ export PATH=$PATH:/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====GCC==== | ||
+ | Next target is gcc-4.x. There are additional configure options you should consult. | ||
+ | |||
+ | * --enable-languages | ||
+ | * --with-newlib | ||
+ | * --with-headers | ||
+ | * --disable-libssl | ||
+ | * --disable-libada | ||
+ | |||
+ | Default Makefile produces codes for C++, JAVA, Fortran77, and Chill in addtion to ANSI C. Since almost of us do not need these optional languages, let's ignore them by using --enable-languages option (C is essential and we can not exclude it). | ||
+ | |||
+ | glibc is too huge and complex for small systems, so we have to choice another compact C library. **Newlib** is one of the most hard-tested library, and **gcc can be adopted for it** by --with-newlib option. In this case, you have to specify --with-headers option. gcc itself creates libgcc.a and libiberty.a libraries, and standard include files are required for their compilation. **Standard headers files for newlib are collected in its source tree** (newlib/ | ||
+ | |||
+ | **NOTICE: --with-headers option is very important one for cross-making. Do not forget it!** | ||
+ | |||
+ | As described above, we should ignore " | ||
+ | |||
+ | You may consider not bothering with the c++ compiler as its library is huge! | ||
+ | < | ||
+ | % cd /usr/src/h8 | ||
+ | % mkdir build-gcc | ||
+ | % cd build-gcc | ||
+ | % / | ||
+ | | ||
+ | | ||
+ | % make CFLAGS=" | ||
+ | % su | ||
+ | # make LANGUAGES=" | ||
+ | </ | ||
+ | |||
+ | ====Newlib==== | ||
+ | |||
+ | Ok, now we are ready to cross-compile newlib package. The procedure is just same as binutils. | ||
+ | < | ||
+ | $ cd /usr/src/h8 | ||
+ | $ mkdir build-newlib | ||
+ | $ cd build-newlib | ||
+ | $ / | ||
+ | $ make CFLAGS=" | ||
+ | $ su | ||
+ | # make install | ||
+ | </ | ||
+ | |||
+ | {{tag> |