Published on

Published in: Technology
1 Comment
No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide


  1. 1. Toolchain © 2010-14 SysPlay Workshops <> All Rights Reserved.
  2. 2. What to Expect? W's of a Toolchain W's & How's of Cross Toolchain? Building a Cross Toolchain Testing a Cross Toolchain © 2010-14 SysPlay Workshops <> 2 All Rights Reserved.
  3. 3. What is a Toolchain? Collection of Tools In Embedded context Collection of C Compiler & its Friends Categorized under 3 umbrella C Compiler (gcc) Set of C Libraries (e.g. glibc, uClibc) Binary Utilities (binutils) © 2010-14 SysPlay Workshops <> 3 All Rights Reserved.
  4. 4. Check on gcc How do you do the following? Generate Object Code Generate Assembly Code Generate Pre-processed Code Generate a Shared Library Adding Header Path Adding Library Path Linking a Library Excluding standard includes & libraries Adding a “#define” © 2010-14 SysPlay Workshops <> 4 All Rights Reserved.
  5. 5. gcc Internals .c .i IC (parse trees, ...) .S .o .exe © 2010-14 SysPlay Workshops <> 5 All Rights Reserved. Pre Processor ICG (machine independent) ICG (machine dependent) Assembler (as) Linker (ld) gcc core gcc wrapper gcc -S gcc -c gcc gcc -E
  6. 6. Set of C Libraries Generally useful Libraries C, Math, Thread, Socket, … Various Options glibc Complete featured but heavy on memory Highly standard compatible uClibc Light-weight with mostly same features But not that much standards compatible Diet libc Similar to uClibc, just that this has been done from scratch Emphasis on minimizing size & optimizing performance © 2010-14 SysPlay Workshops <> 6 All Rights Reserved.
  7. 7. Binary Utilities as – GNU Assembler ld – GNU Linker gasp – GNU Assembler Pre-processor ar – Creates & Manipulates Archives nm – Lists the symbols in an Object file objcopy – Copies & Translates Object files objdump – Displays info about Content of the Object files ranlib – Generates an index to the content of Object files readelf – Displays info about an ELF format Object file size – Lists the sizes of sections within an Object file strings – Prints the strings of printable characters in Object files strip – Strips symbols from Object files c++filt – Converts low-level, mangled assembly labels resulting from overloaded C++ functions to their user-level names addr2line – Converts addresses into line numbers within original source files © 2010-14 SysPlay Workshops <> 7 All Rights Reserved.
  8. 8. What is Cross? gcc Example: gcc vs cross gcc src Host Native gcc Target Native gcc © 2010-14 SysPlay Workshops <> 8 All Rights Reserved. Host prog src Host exe prog Target Tgt exe prog Cross gcc
  9. 9. What is a Cross Toolchain? Toolchain which has all “cross” tools © 2010-14 SysPlay Workshops <> 9 All Rights Reserved.
  10. 10. Why we need a Cross Toolchain? Embedded Systems are constrained Toolchain demands heavy memory & performance May not always have a console interface Even if there, may be minimal Ease of Development Complete accustomed Development Environment on the Host Favourite Editors, GUIs, … © 2010-14 SysPlay Workshops <> 10 All Rights Reserved.
  11. 11. How to get a Cross Toolchain? Get it pre-compiled from vendors Popular: Code sourcery Local: Requirement specific Build your own Doing it manually is a complicated process Inter Package version compatibility is the biggest challenge But various automated tools are available today to simplify the process © 2010-14 SysPlay Workshops <> 11 All Rights Reserved.
  12. 12. Automated Build Tools Crosstool Buildroot Ptxdist © 2010-14 SysPlay Workshops <> 12 All Rights Reserved.
  13. 13. Cross Toolchain Building Overview Build of various GNU Packages involved Typical Build Steps for these Packages Download & Unpack the source of the Package Configure the Package for Cross-Platform Development Build the Package (make) Install the Package (make install) Configuring involves setting up build, host, target ./configure build=... host=... target=... Using Triplet: cpu[-manufacturer][-kernel][-os/obj_file_fmt] Examples: i386-pc-linux-gnu, xscale-sun-solaris2.5/elf Tool Prefix: Same as the triplet © 2010-14 SysPlay Workshops <> 13 All Rights Reserved.
  14. 14. Cross Toolchain Headers © 2010-14 SysPlay Workshops <> 14 All Rights Reserved. Linux Kernel Headers User Specific Headers extract C Library Headers User Space Headers From the Kernel Sources /usr/include
  15. 15. Cross Toolchain Component Dependency Cross Full gcc (gcc, g++) kernel hdrs library hdrs © 2010-14 SysPlay Workshops <> 15 All Rights Reserved. Native gcc Cross binutils Cross bootstrap gcc (xgcc) Target Libraries binutils gcc library Source Code src
  16. 16. Cross Toolchain Building Steps Set up Linux Kernel Headers Ideally from the Kernel version being used Commands make ARCH=<arch> headers_check make ARCH=<arch> INSTALL_HDR_PATH=install_dir/ headers_install Build Binary Utilities Build the bootstrap Compiler (The C only Compiler) Build the C Library Build the full Compiler © 2010-14 SysPlay Workshops <> 16 All Rights Reserved.
  17. 17. Building a Toolchain using Crosstool Install the Crosstool cd cross-tool-ng ./configure –prefix=/opt/board/ make make install cp ct-ng.comp /etc/bash_completion.d/ export PATH=$PATH:/opt/board/bin/ © 2010-14 SysPlay Workshops <> 17 All Rights Reserved.
  18. 18. Building a Toolchain using Crosstool Build the Toolchain mkdir ct-build src cd ct-build/ mkdir .build cp Templates/Toolchain/sources.tgz .build/ (available from Downloads section of ct-ng menuconfig ct-ng build © 2010-14 SysPlay Workshops <> 18 All Rights Reserved.
  19. 19. Testing a Cross Toolchain Compile a C program to various stages Pre-process only Get Assembly Get Object Get Executable Compile a C program with headers Compile a C program with linking libraries Create a C Program with floating point operations Execute & Test the generated target programs Toolchain “Self Contained” Test © 2010-14 SysPlay Workshops <> 19 All Rights Reserved.
  20. 20. What all have we learnt? W's of a Toolchain Compiler Binary Utilities Set of C Libraries W's & How's of Cross Toolchain? Building a Cross Toolchain Building Steps Automated Build Tools Testing a Cross Toolchain © 2010-14 SysPlay Workshops <> 20 All Rights Reserved.
  21. 21. Any Queries? © 2010-14 SysPlay Workshops <> 21 All Rights Reserved.