1 / 15

Computer System Laboratory

Computer System Laboratory. Lab3 - Cross Tools. Experimental Goal. Build a development environment for embedded systems. Cross compiler, assembler, linker Cross C standard library. C program. compiler. Assembly language program. assembler.

aram
Télécharger la présentation

Computer System Laboratory

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer System Laboratory Lab3 - Cross Tools

  2. Experimental Goal • Build a development environment for embedded systems. • 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 / 15

  3. Environment • Host System • Windows XP • Build System • VirtualBox + Ubuntu 8.04 • Target System • Creator XScale PXA270 • Software • GNU Binutils • GNU Compiler Collection (GCC) • Red Hat Newlib • makeinfo_version.patch • You can download all software from RSWiki CSL Course Software / 15

  4. Change Apt Sources List • Ubuntu 8.04 is now out of support and no longer receiving updates and security patches. There are repositories available at http://old-releases.ubuntu.com. • Step1: modify /etc/apt/sources.list. • % sudosed -i -e 's/tw.archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list • You have to be careful of the area which was set during the installation. If you chose the area other than Taiwan, you have to modify the command to the correct one. • You can type “man sed” to see more information. • Step2: upgrate the sources list. • % sudoapt-get update / 15

  5. GNU Cross-Binutils Compilation (1/2) • Prerequisite • % sudo apt-get install libc6-dev texinfo vim patch • Step1: download the source codes. • % wget http://eraser.csie.ntu.edu.tw/courses/csl/10201/lab3/software/binutils-2.16.1.tar.gz • Step2: extract the source codes. • % tar zxvf binutils-2.16.1.tar.gz • Step3: set configuration before you compile the source codes. • % cd binutils-2.16.1 • % ./configure --target=arm-elf --prefix=$HOME/<your path> • configure command is used to automatically create a Makefile according to your configurations. • Makefile is used to specify how to build your source codes. / 15

  6. GNU Cross-Binutils Compilation (2/2) • Step4: compile the cross-binutils. • % make -j4 • Step5: install the cross-binutils. • % make -j4 install • Step6: append the installation directory to PATH. • % sudo vim /etc/environment • PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$HOME/<your path>/bin" • % source /etc/environment • If you open another terminal, you need to source again. • Test your cross-binutils. • % arm-elf-as -version / 15

  7. GNU Cross-Compiler Compilation (1/2) • Step1: download the source codes. • % wget http://eraser.csie.ntu.edu.tw/courses/csl/10201/lab3/software/gcc-3.3.6.tar.gz • Step2: extract the source codes. • % tar zxvf gcc-3.3.6.tar.gz • Step3: set configuration. • % cd gcc-3.3.6 • % ./configure --target=arm-elf --prefix=$HOME/<the your path previously> --enable-languages=c --with-newlib • Step4: compile the cross-compiler. • % make -j4 / 15

  8. GNU Cross-Compiler Compilation (2/2) • Step5: install the cross-compiler. • % make -j4 install • Test your cross-compiler. • % arm-elf-gcc -v / 15

  9. GNU Cross-Newlib Compilation (1/3) • Step1: download the source codes. • % wget http://eraser.csie.ntu.edu.tw/courses/csl/10201/lab3/software/newlib-1.14.0.tar.gz • Step2: extract the source codes. • % tar zxvf newlib-1.14.0.tar.gz • Step3: apply the patch. • % cd newlib-1.14.0 • % wget http://eraser.csie.ntu.edu.tw/courses/csl/10201/lab3/software/makeinfo_version.patch • % patch < makeinfo_version.patch / 15

  10. GNU Cross-Newlib Compilation (2/3) • Step4: set configuration. • % ./configure --target=arm-elf --prefix=$HOME/<the your path previously> • Step5: compile the cross-newlib. • % make -j4 • Step6: install the cross-newlib. • % make -j4 install • Test a assembly code generation. • The test source code, test1.c, can be downloaded from our course website. • % arm-elf-gcc -S test1.c • % vim test1.s / 15

  11. GNU Cross-Newlib Compilation (3/3) • Test an executable. • % arm-elf-gcc test1.c -o test1 • % file test1 / 15

  12. Install PXA270 Cross-Compiler (1/2) • However, since previous cross-compiler does not contain related PXA270 headers and configurations, it can not compile executable for PXA270. • Actually, it can only be used for U-Boot (bootloader) only. • If we want to cross compile a program which can be executed on PXA270, we should install the cross-compiler provided by microtime (新華). • Step1: download new cross-compiler. • % wget http://eraser.csie.ntu.edu.tw/courses/csl/10201/lab3/software/arm-linux-toolchain-bin.4.0.2.tar.gz / 15

  13. Install PXA270 Cross-Compiler (2/2) • Step2: extract the tar.gz file to the home directory. • % tar zxvf arm-linux-toolchain-bin.4.0.2.tar.gz -C $HOME • Step3: append the installation directory (bin) to PATH. • Do not forget to source again to load new PATH. • Test the new cross-compiler. • % arm-unknown-linux-gnu-gcc -v / 15

  14. Compile a PXA270 Executable • Step1: use the new cross-compiler to compile test1.c. • % arm-unknown-linux-gnu-gcc -static test1.c -o test1 • Please add –static flag to compile an executable with static library. • Step2: transfer the executable to Linux on PXA270. • Step3: change the permission of the executable. • $ chmod +x test1 • Step4: try to execute test1. / 15

  15. Lab Requirement & Bonus • Show that you can cross compile a program for PXA270. • Bonus:Answer the question of lab3 on RSWiki CSL course website.Write it in your report. • Please send your report to both TAs. • csiedatou@gmail.com, meenchen79@gmail.com • Please use this title format: [CSL] G# Lab# Ver# • E.g., [CSL] G13 Lab3 Ver1 / 15

More Related