Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab 3 Department of Computer Science and Information Engineering National Taiwan University Lab3 - Cross Tools 2014/10/7/ 20 1.

Similar presentations


Presentation on theme: "Lab 3 Department of Computer Science and Information Engineering National Taiwan University Lab3 - Cross Tools 2014/10/7/ 20 1."— Presentation transcript:

1 Lab 3 Department of Computer Science and Information Engineering National Taiwan University Lab3 - Cross Tools 2014/10/7/ 20 1

2 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Build a development environment for embedded systems.  Cross compiler, assembler, linker  Cross C standard library 2014/10/7/ 20 2

3 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  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  Simple Linux Kernel for PXA270  Simple File System for PXA270  Cross Compiler for PXA270  You can find all software on RSWiki CSL Course Software.RSWiki CSL Course Software 2014/10/7/ 20 3

4 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  The GNU Binutils are a collection of binary tools for creating and managing binary programs, libraries, and assembly source code.  The main tools are:  ld : the GNU linker  as : the GNU assembler  The GNU binutils are typically used in conjunction with compilers such as the GNU Compiler Collection ( gcc ), build tools like make, and the GNU Debugger ( gdb ). 2014/10/7/ 20 4 Reference: http://www.gnu.org/software/binutils/http://www.gnu.org/software/binutils/

5 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Prerequisite  % sudo apt-get install libc6-dev texinfo vim patch  Step 1: download the source codes.  % cd ~  % wget http://eraser.csie.ntu.edu.tw/courses/csl/10301/lab3/software/binut ils-2.16.1.tar.gz http://eraser.csie.ntu.edu.tw/courses/csl/10301/lab3/software/binut ils-2.16.1.tar.gz  Step 2: extract the source codes.  % tar zxvf binutils-2.16.1.tar.gz  Step 3: set configuration before you compile the source codes.  % cd binutils-2.16.1  %./configure --target=arm-elf --prefix=$HOME/  configure command is used to automatically create a Makefile according to your configurations.  Makefile is used to specify how to build your source codes. 2014/10/7/ 20 5

6 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Step 4: compile the cross-binutils.  % make  Step 5: install the cross-binutils.  % make install  Step 6: append the bin directory to PATH.  % nano ~/.bashrc export PATH="$PATH:$HOME/ /bin"  % source ~/.bashrc  You can also reopen the terminal, and.bashrc will be sourced in the shell startup process.  Test your cross-binutils.  % arm-elf-as -version 2014/10/7/ 20 6

7 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  The GNU Compiler Collection (GCC) is a compiler system produced by the GNU Project supporting various programming languages.  GCC has been ported to a wide variety of processor architectures, and is widely deployed as a tool in the development of software, and it is also available for most embedded platforms.  The main tool is gcc. 2014/10/7/ 20 7 Reference: Wikipedia http://en.wikipedia.org/wiki/GNU_Compiler_Collectionhttp://en.wikipedia.org/wiki/GNU_Compiler_Collection

8 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Step 1: download the source codes.  % cd ~  % wget http://eraser.csie.ntu.edu.tw/courses/csl/10301/lab3/software/gcc- 3.3.6.tar.gz http://eraser.csie.ntu.edu.tw/courses/csl/10301/lab3/software/gcc- 3.3.6.tar.gz  Step 2: extract the source codes.  % tar zxvf gcc-3.3.6.tar.gz  Step 3: set configuration.  % cd gcc-3.3.6  %./configure --target=arm-elf --prefix=$HOME/ --enable-languages=c --with-newlib 2014/10/7/ 20 8

9 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Step 4: compile the cross-compiler.  % make  Step 5: install the cross-compiler.  % make install  Test your cross-compiler.  % arm-elf-gcc -v 2014/10/7/ 20 9

10 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  The C standard library is the standard library for the C programming language, as specified in the ANSI C standard.  There are many implementations of C library.  GNU C Library, used in Linux  Newlib  μClibc, a C standard library for embedded μClinux systems  Microsoft C Run-time Library, part of Microsoft Visual C++  Etc.  Newlib is a C standard library implementation intended for use on embedded systems. 2014/10/7/ 20 10

11 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Step 1: download the source codes.  % cd ~  % wget http://eraser.csie.ntu.edu.tw/courses/csl/10301/lab3/software/newli b-1.14.0.tar.gz http://eraser.csie.ntu.edu.tw/courses/csl/10301/lab3/software/newli b-1.14.0.tar.gz  Step 2: extract the source codes.  % tar zxvf newlib-1.14.0.tar.gz  Step 3: apply the patch.  % cd newlib-1.14.0  % wget http://eraser.csie.ntu.edu.tw/courses/csl/10301/lab3/software/makei nfo_version.patch http://eraser.csie.ntu.edu.tw/courses/csl/10301/lab3/software/makei nfo_version.patch  % patch < makeinfo_version.patch 2014/10/7/ 20 11

12 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Step 4: set configuration.  %./configure --target=arm-elf --prefix=$HOME/  Step 5: compile the cross-newlib.  % make  Step 6: install the cross-newlib.  % make install 2014/10/7/ 20 12

13 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Write a simple C program.  % cd ~  % nano test1.c #include void main() { printf("hello world\n"); }  Test a assembly code generation.  % arm-elf-gcc -S test1.c  % nano test1.s  Test an executable.  % arm-elf-gcc test1.c -o test1  % file test1 2014/10/7/ 20 13

14 Lab 3 Department of Computer Science and Information Engineering National Taiwan University 2014/10/7/ 20 14 0x00000000 0x00040000 0x00080000 0x02000000 U-Boot diag Flash 0xA0000000 0xA1080000 0xA4000000 uImage (TFTP) RAM 0x00480000 0x01380000 Linux kernel Root Filesystem 0xA1480000 rootfs (TFTP)

15 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Step 1: download uImage and rootfs into TFTP server. uImage rootfs  Step 2: enter U-Boot in PXA270, or use the debugger Domingo.  Step 3: download and copy uImage to flash address 0x80000.  You can download to RAM address 0xA1080000 for TFTP.  The erased end address is 0x47FFFF (32 sectors).  It will take about 3 minutes.  Step 4: download and copy rootfs to flash address 0x480000.  You can download to RAM address 0xA1480000 for TFTP.  The erased end address is 0x137FFFF (120 sectors).  It will take about 3 minutes.  Tips:  You can refer to the steps by which you copy U-Boot to flash in lab2. 2014/10/7/ 20 15

16 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Step 5: change U-Boot environment settings.  u-boot$ setenv linux bootm 80000  u-boot$ setenv bootcmd run linux  u-boot$ saveenv  Step 6: reset PXA270 and load Linux. 2014/10/7/ 20 16

17 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  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 ( 新華 ).  Step 1: download the precompiled cross-compiler.  % wget http://eraser.csie.ntu.edu.tw/courses/csl/10301/lab3/software/arm- linux-toolchain-bin.4.0.2.tar.gz http://eraser.csie.ntu.edu.tw/courses/csl/10301/lab3/software/arm- linux-toolchain-bin.4.0.2.tar.gz 2014/10/7/ 20 17

18 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Step 2: extract the tar.gz file to the home directory.  % tar zxvf arm-linux-toolchain-bin.4.0.2.tar.gz -C $HOME  Step 3: append the installation directory (bin) to PATH.  % nano ~/.bashrc  Do not forget to source again for new PATH.  Test the new cross-compiler.  % arm-unknown-linux-gnu-gcc -v 2014/10/7/ 20 18

19 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Step 1: 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.  Step 2: transfer the executable to Linux on PXA270 via TFTP.  $ tftp -g -r 192.168.0.10  Note that the command is different from the one in U-Boot.  Step 3: change the permission of the executable.  $ chmod +x test1  Step 4: try to execute test1.  $./test1 2014/10/7/ 20 19

20 Lab 3 Department of Computer Science and Information Engineering National Taiwan University  Show that you can cross compile a Linux program for PXA270.  Please hand in your lab report to the FTP.  Server: 140.112.90.174  Username: csl2014  Password: csl2014HomeWork  Directory: lab3  Please use this format for filename: “G# Ver#”, where G# is your group id and Ver# is revision version number.  E.g., G1 Ver2 2014/10/7/ 20 20


Download ppt "Lab 3 Department of Computer Science and Information Engineering National Taiwan University Lab3 - Cross Tools 2014/10/7/ 20 1."

Similar presentations


Ads by Google