Computer System Laboratory Lab 1 Cross Compiler Assembler

Computer System Laboratory Lab 1 Cross Compiler, Assembler & Linker

Experimental Goal � Build an development environment for embedded system Cross compiler, assembler, linker � Cross C standard library � C program compiler Assembly language program assembler Transforms the C program into an assembly language program Object: Machine language module Object: Library routine (machine language) linker Executable: Machine language program

Environment � Host � System Windows XP � Build � System Ubuntu 8. 04 � Software GNU Binutils source code � GNU Compiler Collection source code � Red Hat Newlib source code � makeinfo_version. patch � � You � can download all the source codes from RSWiki CSL Course Software

Create Build System � Install � Virtual. Box At least 20 GB disk space � Install Guest Additions � Click Devices -> Install Guest Additions � % sudo /media/cdrom/VBox. Linux. Additions. run � Create Shared Folders Click Devices -> Shared Folders � Select Folder Path & Name, mark it to be auto-mounted � � � % mkdir /path/you/choose % sudo mount. vboxsf Folder Name /path/you/choose

GNU Cross-Binutils Compilation � Prerequisite � % apt-get install libc 6 -dev texinfo � Step 1 : download source code � % ftp sources. redhat. com (Name: ftp Password: -) � ftp> cd pub/binutils/releases � ftp> bi � ftp> get binutils-2. 16. 1. tar. gz � Step 2 : extract source code � % tar –zxvf binutils-2. 16. 1. tar. gz � Step 3 : set compilation options � % cd binutils-2. 16. 1 � %. /configure --target=arm-elf --prefix=/path/you/choose � Step 4 : compile � % make cross-binutils

GNU Cross-Binutils Compilation (Cont. ) � Step 5 : install cross-binutils � % make install � Step 6 : append installation � % vim /etc/environment directory to PATH="/usr/local/sbin: /usr/local/bin: /usr/sbin: / usr/bin: /sbin: /usr/games: /path/you/choose" �% source /etc/environment � Test � % arm-elf-as -version

GNU Cross-Compiler Compilation � Step 1 : download source code � % ftp sources. redhat. com � ftp> cd pub/gcc/releases/gcc-3. 3. 6 � ftp> bi � ftp> get gcc-3. 3. 6. tar. gz � Step 2 : extract source code � % tar –zxvf gcc-3. 3. 6. tar. gz � Step 3 : set compilation options � % cd gcc-3. 3. 6 � %. /configure --target=arm-elf --prefix=/path/you/choose --enable-languages=c --with-newlib � Step 4 : compile � % make cross-compiler

GNU Cross-Compiler Compilation (Cont. ) � Step 5 : install cross-compiler � % make install � Test � % arm-elf-gcc -v

GNU Cross-Newlib Compilation � Step 1 : download source code � % ftp sources. redhat. com � ftp> cd pub/newlib � ftp> bi � ftp> get newlib-1. 14. 0. tar. gz � Step 2 : extract source code � % tar –zxvf newlib-1. 14. 0. tar. gz � Step 3 : apply the patch � % cd newlib-1. 14. 0 � % patch < makeinfo_version. patch � Step 4 : set compilation options � %. /configure --target=arm-elf --prefix=/path/you/choose � Step 5 : compile � % make cross-newlib

GNU Cross-Newlib Compilation (Cont. ) � Step 6 : install cross-newlib � % make install � Test � % arm-elf-gcc –S test 1. c /* test 1. c */ include <stdio. h> int main(void) { printf(“Hello World!n"); return 0; }
- Slides: 10