Home

Microcross i.MX GNU X

image

Contents

1. 107 char ttyarg NULL 108 Program stopped at line 106 nain c y nain v 50URCE E 6 14 Using the Console Window To send commands directly to the GDB interpreter use the Console window Figure 6 38 Figure 6 38 Console window Console Window gdb help List of classes of commonds aliases Aliases of other commands breakpoints Making program stop at certain points data Examining data files Specifying and exanining files internals Maintenance conmands obscure Obscure features running Running the program stack Examining the stack status Status inquiries support Support facilities tracepoints Tracing of program execution without stopping the program user defined User defined commands Type help followed by a class none for a list of commonds in that class Type help followed by comnand nane for full documentation Conmard name abbreviations are allowed if unambiguous gdb i MX GNU X Tools User Guide E 87 section 6 How to Use Visual GDB Debugger The Console window opens with a GDB prompt for invoking debugging commands Figure 6 38 shows the help command s available topics when using the Console window For more specific commands see MC Debugging Tools pdf in the docs directory of the i MX GNU X Tools CD or in the docs directory under Cygwin 6 15 Using the Function Browser Window To invoke the Function Browser window select View
2. O3 Enables more optimizations than O2 Try hardest of all to produce fast assembly code Note that the emphasis is on fast the resulting code may take much more room in memory because certain functions may be placed in line and loops may be unrolled as if each iteration in the for loop were written out independently Os Try to produce code that is small The emphasis is on size not speed This option uses many of the same optimization algorithms as O2 but with a different emphasis ffast math Make floating point arithmetic optimizations that violate the ANSI or IEEE standards Code compiled with this option may yield incorrect results but it will be slightly faster Be sure to test your program thoroughly finline functions Expand all simple functions into their callers The compiler gets to decide whether any function is simple or not Inline expansion is a two edged sword it can make a program faster by eliminating calling overhead or slower by making instruction cache performance worse fno inline Inhibit all inlining even inlining that is requested by the inline keyword in the source code The GCC performs inlining according to statements in the source code with both O1 and O2 the keyword is ignored if optimization is not in effect funroll loops On some CPUs loop unrolling can be a very important optimization It minimizes loop overhead and creates many opportunities
3. xtools install share gdbtcl cr add the arc path if not using the standard path described above Logout as root or su at this time Step 7 Install the test files by using the following commands assuming the standard arc path cd home cr or other desired directory tar xvzf mnt cdrom src test tgz cr tar xvzf mnt cdrom src bench tgz cr If provided with the Target Toolsuite Go to Section 2 5 to perform a setup test of the toolsuite i MX GNU X Tools User Guide E 13 Section 2 Install and Setup Procedures 2 4 Uninstall i MX GNU X Tools on Linux Host Uninstall i MX GNU X Tools Toolsuite 1 Start i MX GNU X Tools Bash Shell xterm and login as root or su 2 Type xtools remove arm elf to remove the toolsuite 2 5 Setup Test To perform a quick checkout and health status of the i MX GNU X Tools toolsuite installation follow these steps to run the cross compiler on a test directory under Cygwin home test or nome test on Linux assuming you installed the test tgz tar file in this directory For Windows users start the i MX GNU X Tools Shell by double clicking on the desktop icon red X on it and issue the following commands in the shell For Linux users start an xterm or Bash shell and issue these same commands xtools arm elf cr arm elf cd home test cr or to the directory where the test files are located on the Linux host arm elf run al
4. s Ping TCP IP address Display Error Log Reboot mpDbemon ype Command lt Enter gt will refresh screen gt o Initial JTAG speed 1 8 2 gt 4 lt Figure 6 63 Select Number of Scan Devices 2 Tera Term COM1 VT File Edit Setup Control Window Help NO 192 168 0 211 E a E a e e 0 Gateway 192 168 0 250 AC Address 00 60 bf 01 0a a7 CDREMOTE Disabled mpDemon Command Menu Set serial API baud Set DHCP option Set TCP IP Address Set TCP IP Mask Set TCP IP Gatewa Set OCDREMOTE Configuration Update License code s Ping TCP IP address Display Error Log Reboot mpDemon Type Command lt Enter gt will refresh screen gt o B D A M G a L P E R Initial JTAG speed 1 8 2 gt 4 Number of Devices in Scan Chain C0 16 gt 1 lt 12 Next select the processor device for your connection All of the options appear on the screen see Figure 6 64 The proper Personality Module connection cable must be used with the appropriate processor device selected 13 Enter the TCP IP port number recommend 8888 see Figure 6 65 14 Now reboot the mpDemon by entering R and pressing the Enter key see Figure 6 66 The banner screen will show all of your new settings You have now configured the mpDemon for use and now can perform a configuration test Go onto the next step 102 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger Fig
5. 7 Click the Run button on the tool bar to start the executable The program runs until it hits the first breakpoint The color bar on the line changes color indicating that the program is running see settings in Figure 6 47 changed in Figure 6 48 and the Source Window in Figure 6 49 after debugging stopped 92 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger Figure 6 49 Results of Setting Breakpoints at Line 105 main c Source Window File Run Yieu Control Preferences SOO P70 OS AAS OM OxO04dec3 104 100 static int batch U 01 fx Pointers to various arguments from command line x char symarg NULL _f Ul chor Porn gt breakpoint 9 at main c 105 Ox604dec9 ENA breakpoint donttouch threads all cond none k These are static so that we can take their address in an initializer static int print_help static int print_version x Pointers to all arguments of commond option x char cmdarg fk Allocated size of cmdorg x main SOURCE v 8 Open the Local Variables window Figure 6 50 by clicking the Local Variables button on the toolbar The window displays the initial values of the variables Figure 6 50 Local Variables Window Local Variables Yoriable value chor Oxotttryod 10756595902 1 i chor Os chor s2 Address Ost out of bounds chor Usb ttt ood Pagod chor 0x0 chor Us prant_help 0 print we sion 0 Ac
6. Microcross 1 MX GNU X Tools Professional Embedded Development Tools User Guide Version 3 40a 2005 Microcross Inc Licensed Materials Open Source Ready to Run v Contents ISBN N A Microcross Inc 104 Borders Way Suite 100 Warner Robins GA 31088 USA Copyright 2005 Microcross Inc All rights reserved Trademarks GNU X Tools and Microcross are all trademarks of Microcross Inc This documentation contains copyright materials and has been prepared by Microcross Technical Publications contact the Microcross Technical Publications staff for more information support microcross com ARM Thumb and ARM Powered are registered trademarks of ARM Limited All other brand and product names services names trademarks and copyrights are the property of their respective owners Disclaimer Microcross Incorporated makes no representations or warranties with respect to the contents or use of this user guide and specifically disclaims any express or implied warranties of merchantability or fitness for any particular purpose Microcross Incorporated reserves the right to revise this publication and to make changes to its content at any time without obligation to notify any person or entity of such revisions or changes Microcross Incorporated makes no representations or warranties with respect to any Microcross software and specifically disclaims any express or implied warranties of merchantability or
7. d option also e name Use the symbol name as the entry point to the executable program By default the entry point is the beginning of the first object module The GCC automatically links your object files with a run time initialization module usr lib crt0 o that starts your program and provides its initial entry point If you run the linker separately you must either put usr lib crt0 0 at the start of your object files or provide your own entry point M Produce a load map that shows where each function is located in the resulting object file where each section begins and ends and what the value of each global symbol is This option is usually used with GCC as follows WI M lt mapfile name gt where lt mapfile name gt can be any name you specify b format Read object modules in the given format To get a list of formats that Id understands give the command objdump and near the bottom of the options list are the supported targets and architectures This can be helpful in some cross development situations The b option applies to all object files and libraries following it on the command line until another b option appears In theory you can use this feature to link objects from several different formats into a single executable oformat format Create object modules in the given format Again objdump l gives you a list of formats that Id understands The Id
8. iMX GNU X Tools User Guide E 69 Section 6 How to Use Visual GDB Debugger The Visual GDB debugger opens the ELF object file that was compiled with the g debug option To run the program using the simulator click on the Run icon and when the Target dialog box opens select Simulator as the Target To familiarize yourself with all of the features of Visual GDB read on Note Examples of using JTAG hardware debuggers with Visual GDB are at the end of this section We have selected two popular JTAG debuggers to show examples Abatron BDI2000 and Macraigor mpDemon WARNING Having an inactive debugging session open when starting another debugging session with i MX GNU X Tools will close all projects All work will be unrecoverable Using the Source Window When Visual GDB first launches it displays an empty Source Window if there is no filename entered however in our example we entered pascal x as our cross executable Figure6 2 Figure 6 2 Source Window pascal c Source Window File Aun View Control Preferences Help SHC Co PP BAB Oa YO oes a g int main void pascal_initt printf CoNmt Pascal s Triangle wnn pascal_triangle 6 return 1 Program not running Click on tun icon to start pascal E main SOURCE The menu selections in the Source Window are File Run View Control Preferences and Help See Source Window Menus and Display Features on following pages for more descriptio
9. options before the l option are searched only for the case of include file they are not searched for include lt file gt If additional directories are specified with l options after I these directories are searched for all include directives Ordinarily all I directories are used this way In addition the option inhibits the use of the current directory where the current input file came from as the first search directory for include file There is no way to override this effect of I With l you can specify searching the directory that was current when the compiler was invoked That is not exactly the same as what the preprocessor does by default but it is often satisfactory I does not inhibit the use of the standard system directories for header files Thus l and nostdinc are independent Ldir Add directory dir to the list of directories to be searched for I 48 E i MX GNU X Tools User Guide Section 4 How to Use i MX GNU X Tools Bprefix This option specifies where to find the executables libraries include files and data files of the compiler itself The compiler driver program runs one or more of the subprograms cpp cc1 as and Id It tries prefix as a prefix for each program it tries to run both with and without machine version For each subprogram to be run the compiler driver first tries
10. The computer for which the compiler generates code Used both to refer to an actual physical device and to the class of devices Transmission Control Protocol based on IP This is an internet protocol that provides for the reliable delivery of streams of data across the web Standard terminal emulation protocol in the TCP IP protocol stack used for remote terminal connection enabling users to log in to remote systems thereby using resources as if connected to a local system Informal term for the collection of programs that make up a complete set of cross compilation tools Typically consists of the following example s sequence compiler gt assembler iiMX GNU X Tools User Guide E 125 Glossary of Embedded System Terminology TERM DESCRIPTION 2aarchiver gt linker gt debugger Unix operating system The uppercase spelling of Unix is used interchangeably Invented in 1969 by Ken Thompson after Bell Labs left the Multics project Unix subsequently underwent mutations and expansions at the hands of many different people resulting in a uniquely flexible and developer friendly environment By 1991 Unix had become the most widely used multi user general purpose operating system in the world Virtual Machine VM An abstract specification for a computing device that can be implemented in different ways in software or hardware Compiling to the instruction set of a virtual machine is much like compiling to the
11. lt val_1 gt lt val_2 gt macro lt name gt lt arg_1 lt arg_ 2 gt lt arg_N gt macro SHIFTLEFT a b Af b lt O MOV a a ASR b exitm endif MOV a a LSL b endm rept lt number_of_times gt Repeats a block of code the given number of times End with endr lt register name gt req lt register name gt This directive names a register It is similar to the RN directive in armasm except that you must supply a name rather than a number on the right e g acc req rO Starts a new code or data section Sections in GNU are called text a code section data an initialized data section and bss an uninitialized data section These sections have default flags and the linker understands the default names similar directive to the armasm directive AREA The following are allowable section flags for ELF format files section lt section name gt lt flags gt lt Flag gt Meaning allowable section writable section executable section set lt variable_ name gt lt variable_value gt This directive sets the value of a variable It is similar to SETA in armasm iMX GNU X Tools User Guide E 117 Appendix 1 ARM Toolsuite GNU Assembler Directive Description Description Z gt O space lt number_of_bytes gt lt fill_byte gt Reserves the given number of bytes The bytes are filled with zero or lt fill_ byte gt if specified similar to SPACE in armasm
12. man running icon does NOT work with a remotely connected target Use the CONTINUE gt icon command to invoke the program to run even from the begining 26 E i MX GNU X Tools User Guide Section 3 Quick Start Guide 3 4 2 OCDRemote Monitor Commands Monitor commands implement various functions that are not available using GDB directly and vary from CPU type to CPU type You can get the full list of monitor commands by issuing the command monitor help in the console window after GDB has attached to OcdRemote monitor help monitor allrun monitor allstop monitor char short long lt addr gt monitor char short long lt addr gt lt val gt monitor endian lt big little gt monitor halt monitor reg lt regname gt monitor reg lt regname gt lt value gt monitor reset monitor resetrun monitor runfrom lt addr gt monitor set memspace lt virtual physical gt monitor set cou lt cpu number gt monitor set clear hbreak lt address gt monitor set regobufaddr lt address gt monitor sleep lt seconds gt monitor status monitor sync cpus lt on off gt These commands are availble for all CPU types They can be executed either from within a gdbinit file or from from the GDB console window 3 4 3 Some Useful GDB Console Commands Here are some useful text mode commands to to use in the GDB console window If you use Visual GUI then all of these commands are available using the pull downs or
13. setup exe if setup does not run manually start the setup program by using Microsoft Explorer and double click on setup exe which is in the root CD directory Step 2 After starting the setup program follow the onscreen instructions for installing the program We highly advise installing the Cygwin into a root volume of any local hard drive The default setting is c Cygwin Note Two shortcuts will be installed on the Desktop one for i MX GNU X Tools Shell and one for XWindows XWindows is used for running the DDD debugger only which is described in the section on How to Use GDB Microcross Visual GDB can be started from either the i MX GNU X Tools Shell or XWindows Shell Step 3 Next click on Exit to exit the setup program Go to Section 2 5 to perform the setup tests to verify a proper installation of i MX GNU X Tools If for any reason the installation failed go to Section 2 6 for troubleshooting tips Note Once the toolsuite and Cygwin are installed the toolsuite can be uninstalled and reinstalled without reinstalling Cygwin This procedure may become necessary in the event that a toolsuite becomes corrupted or parts are accidentally deleted Simply use the i MX GNU X Tools Shell and type xtools remove lt target alias gt cr To reinstall just the toolsuite insert the i MX GNU X Tools CD into the CD ROM and from the i MX GNU X Tools Shell type xtools install lt target alias gt cr Example
14. the cursor changes into a circle A left click sets a breakpoint at the current line the breakpoint appears as a colored square in place of the minus sign A left click on any existing or temporary breakpoint removes that breakpoint A right click on any existing or temporary breakpoint brings up a pop up menu Figure 6 9 Figure 6 9 Pop Up Menu for Setting Breakpoints Continue to Here Set Breakpoint Set Temporary Breakpoint Set Breakpoint on Threads Continue to Here causes the program to run up to a location ignoring any breakpoints like the temporary breakpoint this menu selection displays as a differently shaded square than a regular breakpoint When a breakpoint has been disabled it turns for instance from red or orange to black color settings vary depending on the preferences you set see also Figure 6 5 and its accompanying descriptions Set Breakpoin sets a breakpoint on the current executable line this has the same action as left clicking on the minus sign Set Temporary Breakpoint sets a temporary breakpoint on a current executable line a temporary breakpoint displays as a differently shaded square than a regular breakpoint and is automatically removed when hit Set Breakpoint on Thread s sets a thread specific breakpoint at the current location Right click on a line with a breakpoint to invoke a pop up menu to delete breakpoints see Figure 6 10 Figure 6 10 Pop Up Menu for Deleting
15. 0a a 7 C COREMOTE Disabled mpbemon Command Menu Set Serial API baud Rate Set DHCP option Set TCP IP Address Set TCP IP Mask Set TCPrIF Sate Set OCDREMOTE Configuration Update License Codets Ping TCP IP address Display Error Log Reboot mpbemon Type Command C lt Enter gt will refresh screen gt d Use DHCP CYN gt p c Wn B D A m E D L P E R i MX GNU X Tools User Guide E 99 Section 6 How to Use Visual GDB Debugger Figure 6 58 Enter DHCP Hostname 2 Tera Term COM1 VT File Edit Setup Control Window Help 115200 Yes MPDOOOOOL 192 168 0 210 255 255 255 Q Gateway 192 168 0 250 AC Address 00 60 bf 01 0a a7 CDREMOTE Disabled mpDemon Command Menu Set Serial API baud Rate Set DHCP option Set DHCP hostName Set OCDREMOTE Configuration Update License Code s Ping TCP IP address Display Error Log Reboot mpbemon Type Command lt Enter gt will refresh screen gt n DHCP hostname gt 192 168 0 250 lt 8 Skip this step if using DHCP If entering your network settings manually instead of using DHCP then select A in the mpDemon command menu followed by Enter see Figure 6 59 Figure 6 59 Enter TCP IP Address H Tera Term COM1 VT File Edit Setup Control Window Help NO 192 168 oO 210 255 255 255 d Gateway 192 168 0 250 AC Address 0 6 bf 01 0a aF COREMOTE Disabled Mmpbemon Command Menu Serial API baud R
16. B D A M G O L P E R Set Serial API baud Rate Set DHCP option Set TCP IP Address Set TCP IP Mask Set TCP IP Set OCDREMOTE Conti Update License Code Ping TCP IP address Display Error Log Reboot mpDemon aaa s Type Command lt Enter gt will refresh screen gt ateway Address xxx xxx xxx xxx gt 192 168 0 250 lt Reboot mpDemon to run with new parameters hit any key to continue 11 Next enter O to configure the OCD Remote settings These settings include the JTAG speed number of scan devices processor device selection and TCP IP port number recommend 8888 Recommend setting the JTAG speed to 4 initially and experiment with other settings when you make a successful connection lower the setting the faster the connection speed see Figure 6 62 Since the mpDemon can scan more than one processor device through a single JTAG you can have multiple CPUs on one board with a single JTAG interface for a single processor enter 1 see Figure 6 63 iiMX GNU X Tools User Guide E 101 section 6 How to Use Visual GDB Debugger Figure 6 62 Select JTAG Speed Tera Term COM1 VT File Edit Setup Control Window Help 115200 NO 192 168 0 211 01 0a a7 CDREMOTE mpDemon Command Menu B Set Serial API baud D Set DHCP option A Set TCP IP Address Set TCP IP Mask Set TCP IP abil Set OCDREMOTE Conti M G uration L Update License coder P E R T
17. BDI2000 gt The response should be a command prompt BDI gt or custom prompt if set in the configuration file e g CSB536 gt 17 At this point you should be able to connect via GDB or Visual GDB using the appropriate TCP address and port number Connecting to the Target with the Abatron BDI2000 Command Line GDB After starting your debugger with binary you created with debug symbols in it you must issue commands to remotely connect to the target This can be done by issuing the following commands lt target alias gt gdb lt filename gt cr you must be in the directory where the binary lt filename gt is located GDB target remote lt bdi2000 TCP Addr gt 2001 cr The lt bdi2000 TCP Addr gt stands for an IP address assigned to the BDI2000 The host configuration xxxx cfg file must have an appropriate entry 2001 is the default TCP port used to communicate with the BDI Visual GDB Startup 1 Start the Visual GDB debugger with a binary built with debug symbols lt filename gt and click on File Target Setting and following the procedures below to completely setup communications within Visual GDB lt target alias gt gdbtk lt filename gt cr you must be in the directory where the binary lt filename gt is located if using Visual X Tools to start the Visual GDB debugger then simply click on the icon or menu item under Build 2 Click on Target combo box and select Remote TCP 3
18. Breakpoints Delete Breakpoint Delete Breakpoint deletes the breakpoint on the current executable line This has the same action as left clicking on the colored square see the description for Continue to Here for Figure 6 9 With the cursor over a line a breakpoint opens a breakpoint information balloon see Figure 6 11 for an example of such a tool tip Figure 6 11 Breakpoint Information Balloon 5 x 104 fx Pointers to various arguments from command line x L AA A m char symarg NUL 104 char xexecarg NULL J Li k These are static so that we can take their address in an initializer static int print_help static int print_version Pointers to all arguments of commond option x char cmdarg fk Allocated size of cmdorg x SOURCE i MX GNU X Tools User Guide E 75 Section 6 How to Use Visual GDB Debugger 6 5 Right Column Functionality for the Source Window The following documentation discusses the functionality of how the mouse works in the right column of the Source Window With the cursor over a global or local variable the value of that variable displays With the cursor over a pointer to a structure or class view the type of structure or class and the address of the structure or class Double clicking an expression selects it Right clicking an expression invokes a pop up menu see Figure 6 12 Figure 6 12 Pop Up Window for Expressions Add get_run_tim
19. Controlling gdb 67 Controlling Linker 45 cpio 108 cpp 41 CPU Clock Rate 9 Creating Updating Libraries 57 58 crto 57 cvs 108 Cygwin 107 108 120 Cygwin Key Features 107 Cygwin Related Problems 14 D Debug format 122 Debug protocol 122 Debugger 122 debugging 40 49 51 55 112 122 123 125 Deleting Breakpoints 75 diff 41 diff3 41 diffutils 108 DOS style 15 DWARF 122 E e name 56 ECOFF 122 Editing Local Variables 84 Elements of a Variable Structure 85 ELF 122 Environment Variables 14 Exception handling 122 Executable file 122 Executing your Program 63 Execution Control 64 expect 108 Expressions 65 F ffast math 50 file 108 File Drop Down List Box 77 fileutils 108 findutils 108 finline functions 50 i MX GNU X Tools User Guide E 127 Index flex 108 fno inline 50 fortune 108 Free Disk Space 9 Free Software Foundation 7 121 FSP 7 47 51 52 ftp 108 Function Browser Window 88 89 Function Drop Down Combo Box 77 funroll loops 50 G gt 4 gas 108 122 gasp 41 gawk 108 gcc 41 108 123 gcj 123 gdb 41 108 123 gdb debugging session 60 gdb Quick Reference 62 gdb Scripts 66 gdb under GNU Emacs 68 gdbserver 123 gdbstub 123 gdbtk 41 General Public License 7 Getting Started 11 Glibc 123 Global Preferences Dialog 72 Glossa
20. E E EEEE E ee 32 3 8 2 Other Useful MicroMonitor Commands 1ccccsceccccsecccsseeccsuecceseeeesusessaeeessseeesueeesseeeesseeessseeessaecesseeessnesesaes 34 SECTION 4 HOW TO USE I MX GNU X TOOLS occ cece ee eeeeeeneeeeseneeneseeseneeneseneeee 35 AT MOGUO Tea E EE A E A E 35 4 2 Using the i MX GNU X Tools Command Line Tool XtOOlS cccceccceccceeeeceeeeee cece eeeeeeeeeeeseeeseeees 35 Bo Mvoking LMAX GNU X TOOIS csser oeio e e seen a Oi 36 4 4 Using the i MX GNU X Tools TOolsuite ccc cece scceeeeceeeceeeeeeeeceeeeeeeeseeeeseeeseeeesneeseeesseeeseeeeeeeess 37 aT MO EX 2 1 6 oren n E ee eee ne eee 37 4 4 2 i MX GNU X Tools Toolsuite DOSCIIPCION cccccccccseecccsnceecsueeecsueessseecssuecesseeessueeessusessseeessaeeesssesessneeessecssaes 38 dA CONDO FTON aM OC O einan E NEEE EEE EEE EEEE OE ERE E EENE E eee ne eee E eee EA 39 4 5 Controlling the Tools Using the GOC 0 0 2 cecccccccseeeeeeece cece eeseeeeseceseeeeeeeseeessueeseeseueesaeesseeseneeess 42 43 1 GCC OPNS COMMOMY USOU ccccteh eet ate resis sits denen bene a sonine a tase R ETE E A ETE AE ET T 43 4 6 Controlling Linker from GCO so ccccsiecindecesencesusdadccun dolewsas n REEE Aa EAER Aa AREEN RESE ENES Nan ENER 45 4 7 Compilation Options ccc cecceecceeecseecneecneecneceseceneceeeceeecseceeeeneseeeseetaeeeeeeeaeeeeeeceeeeaeeteneneeetaeetaeeeaes 46 ArT DISDIAVING COMPICl DENAVION oz scacssczsescsccapatperineesseeoievscehensen
21. GCC program is actually a control program that executes the compiler components to produce the desired output which is usually a compiled and linked executable program image By manipulating the many GCC options and controlling the input file types the functions of GCC are greatly expanded The GCC however is but a single component It is actually a control program that calls other components that perform separate steps to create an executable binary The components are described as follows and show graphically in Figure 4 1 preprocessor Performed by cpp which is invoked by GCC the preprocessor resolves directives like define include and if Preprocessing establishes the type of source code to process compiler Performed by GCC the compiler pass which produces assembly language from the input files and passes the assembly source directly to the assembler phase assembler Performed from GCC by as the GNU assembler It takes the assembly language as input and produces object files with o extensions The assembler output is relocatable object code 0 linker Performed by ld the GNU linker Linking completes the compilation process combining all object files newly compiled and those specified as input into an executable file This step completes the final stage where the o modules are placed in their proper places in the executable file Library functions that the program refers to are also place
22. Gaeee sass agen aa i 107 7 ges aa CVOwWIN COMPONENTS sporangia ee E ncn a a ee ne ee re 107 7 3 1 Cygwin Package List tools utilities and programs that make UP CYQWIN cccssccccsseeccseeeesneeeesneesesneeees 107 7 3 2 User Information How to use the tools utilities and programs IN Cygwin cccccecccsseeccsneeeeseeeeseeeseaneeees 108 APPENDIX 1 ARM TOOLSUIT E oer ene ene eer ere eer ene ee eee 110 BIBLIOGRAPHY wrest cen sae cee cen came suencegucaiee sen ania ecan sane veeacuun sien seen aa A 120 GLOSSARY OF EMBEDDED SYSTEM TERMINOLOGY ccccsceeeeeeeeeeeeeeeeeneeeeeeeeeeees 122 INDEX oiie dinate ecg eis cc ote eciste E sueweeeusauesaceceuenecsaciaceceses 127 vi E i MX GNU X Tools User Guide Section 1 Introduction Section 1 Introduction 1 1 What is 1 MX GNU X Tools The 1 MX GNU X Tools product is a cross tools development toolsuite consisting of C C compilers assembler archiver binary utilities C C libraries and debugger The GNU cross tools collection is made up of open source cross compilation and debugging tools designed to support professional embedded systems development for ARM9 ARM11 target processors on the Linux and Windows host platforms Microcross builds debugs patches documents and brands their product for the Freescale Semiconductor i MX processors Background The GNU tools are the evolutionary embodiment of the Free Software Foundation FSF GNU Compiler Collect
23. RAM e 256 MB 4 Free Disk Space e 200 MB See the appropriate target appendix for specific requirements by target The i MX GNU X Tools toolsuite has been installed built and tested on the following Linux distributions Red Hat Linux Ver 7 3 Red Hat Linux Ver 9 0 Red Hat Enterprise Linux WS v3 3 or newer Linspire Ver 3 5 Debian Ver 2 4 22 iiMX GNU X Tools User Guide E 9 Section 1 Introduction 1 6 Compatible RTOS OS Software The i MX GNU X Tools has been used by customers and internal staff to build many of the most popular operating systems with board support packages boot ROMs network stacks and single multithreaded applications since its first release in September 2000 A partial list follows Accelerated Technology Nucleus RTOS and TCP IP Stack EBSnet RTKernel RTOS File System and TCP IP Stack Embedded Linux BSPs Express Logic ThreadX RTOS and TCP IP Stack Interniche TCP IP Stack Micrium u COS II RTOS and TCP IP Stack MicroMonitor Boot ROM by Ed Sutter Real Time for Embedded Multiprocessor Systems RTEMS RTOS and TCP IP Stack Quadros RTXC RTOS and TCP IP Stack WindRiver vxWorks RTOS and TCP IP Stack 1 7 Compatible JTAG BDM Hardware The i MX GNU X Tools has been used with a variety of JTAG BDM debuggers Although the following list is not comprehensive we have high confidence in their ability to seamlessly integrate with the i MX GNU X Tools Abatron BDI2000 with bdiGDB American Arium SC LC
24. The purpose of a debugger such as GDB is to allow you to see what is going on inside another program while it executes or what another program was doing at the moment it crashed GDB can do four main kinds of things to help you catch bugs in an embedded system 1 Start your program specifying anything that might affect its behavior 2 Make your program stop on specified conditions 3 Examine what has happened when your program has stopped 4 Change things in your program so you can experiment with correcting the effects of one bug and go on to learn about another You can use GDB to debug programs written in C and C GDB standard remote protocol An existing ROM monitor used as a GDB backend Process and interfacing software to implement a protocol which is used for communication between the GDB debugger running on the host machine and the GDB debugger running on the target machine In general terms the scheme looks as follows 1 On the host GDB already understands how to use this protocol when everything else is set up you can simply use the target remote command 2 On the target You must link with your program a few special purpose subroutines that implement the GDB remote serial protocol The file containing these subroutines is called a debugging stub This is a control program for Unix like systems which allows you to connect your program with a remote GDB via target remote but without li
25. Workspace file testsub c C subroutine source for example program Debug crt o Object file for startup rountine Debug test o Object file for test c source file Debug test x Executable ELF image with debug symbols Debug testsub o Object file for testsub c source file Assumptions Visual X Tools IDE is installed free 30 day evaluation is available on the i MX GNU X Tools CD ROM To install Visual X Tools insert the i MX GNU X Tools CD ROM open Windows Explorer and navigate to the vxtools directory Double click on setup exe and follow the onscreen instructions to install Visual X Tools A user guide is also available in this directory The other assumptions include i MX GNU X Tools are installed on Windows host the i MX LiteKit board is connected including serial Ethernet usoDemon and power Moreover the OCD Commander and its utility usoDemon Finder are installed To find out what USB device number to use execute the usoDemon Finder utility using the desktop usoDemon Finder icon and note the device number of the usbDemon the USB cable has to be connected to the board while powered on in order to get this device number Step 1 Startup Visual X Tools IDE from a desktop icon See the Visual X Tools IDE icon in Figure 3 3 V visual Tools Figure 3 3 Visual X Tools IDE Icon Step 2 Click on Project Open Workspace from the menu Navigate to the following directory Cygwin home vxtools example Open the
26. You have two options to setup the network file monrc in MicroMonitor manual settings or DHCP BootP Consult your system administrator if you need help in determining your network settings Manual network settings The settings shown are notional and are for reference of the procedure only Consult your network administrator if you do not understand how to setup network settings for your network Use the UMON command line interface in your serial terminal session to enter these commands with your substituted settings UMON gt set c cr UMON gt set IPADD 192 168 0 110 cr IP address UMON gt set NETMASK 255 255 255 0 cr network mask UMON gt set GIPADD 192 168 0 250 cr gateway IP address UMON gt set f monrc cr UMON gt reset cr DHCP BOOTP network settings Follow this example and enter the commands using your serial terminal UMON command line interface UMON gt set c cr UMON gt set IPADD DHCP cr or DHCPv or DHCPV or BOOTP UMON gt set f monrc cr UMON gt reset cr 18 E i MX GNU X Tools User Guide Section 3 Quick Start Guide Select only one for IPADD setting DHCP No verbosity enabled DHCPv_ Limited verbosity enabled DHCPV Extreme verbosity enabled BOOTP Runs BootP IMPORTANT After configuring the network settings and initiating the reset command the target board will reboot MicroMonitor Notice that in the serial terminal interface that the new IP address is displayed if the
27. are extremely helpful for debugging and tuning code under development but should not be used for production release versions of your program Link the program for profiling with prof When you execute a program compiled with this option it produces a file named mon out that contains program execution statistics The profiler prof reads this file and produces a table describing your program s execution pg Link the program for profiling with gprof Executing a program compiled with this option produces a file named gmon out that includes execution statistics The profiler gprof reads this file and produces detailed information about your program s execution For example the following command compiles the file program f generating code for profiling with gprof lt target alias gt gcc pg program f cr Generate a symbol table for debugging The g option enables debugging with the GNU debugger GDB or Visual GDB The symbols used with standard GDB are called stabs When compiling with Microcross cross compilers set the g option to produce the stabs symbols you may use gstabs as a verbose switch if you like Other symbol options include gcoff gdwarf and gdwarf2 the gcoff symbols are not supported in Microcross GNU cross compilers however gdwarf and gdwarf2 are supported in most target CPU toolsuites IMPORTANT NOTES To perform assembly debugging of str
28. cpuinfo Show information such as bogomips architecture and manufacture information 22 E i MX GNU X Tools User Guide Section 3 Quick Start Guide reboot Reboots system into UMON Microcross has a complete Professional Platform edition of GX Linux that has all of the board drivers documentation and total rebuild environment with master makefile and components of a complete board support package For those serious users of Embedded Linux the GX Linux Professional Platform edition is a necessary and affordable time saver to jump start your project with Linux As required by the General Public License GPL all GNU sources are available on the distribution CD ROM in the src directory Contact Microcross for details on how you can get a discount by already being a Freescale customer 3 4 Debug with usbDemon Example First Time User of usbDemon IMPORTANT The first time user will need to install OCD Commander to get the right USB drivers installed on the host machine Skip to 3 4 1 if OCD Commander and USB drivers were previously installed To install OCD Commander open an Explorer file browser on your host machine and navigate to Cygwin home ocd commander directory i MX GNU X Tools Windows host version must be already installed Make sure that the usoDemon USB cable is disconnected before installing OCD Commander Execute the ocd commander exe installation utility by double clicking on the filename and follow the on scr
29. debug support has to be linked to your application There is also no need for any BDI specific changes in the application sources Your application must be fully linked because no dynamic loading is supported Target Setup Target initialization may be done at two places First with the BDI configuration file second within the application The setup in the configuration file must at least enable access to the target memory where the application will be loaded Disabling the watchdog timer and setting the CPU clock rate should also be done in the BDI configuration file Application specific initializations like setting the timer rate are best located in the application startup sequence Steps to a Quick Setup BDI2000 Simplified Configuration Steps for Board Support 1 Unzip the BDI2000 zip file of programs and configuration scripts that come with the BDI2000 into a directory on your local host hard drive hereafter referred to as the bdi2000 directory Connect the BDI2000 serial port connector to the BDI2000 and your host computer You may connect your Ethernet cable to a hub or have a cross over cable to directly connect to the host computer and BDI2000 Power up the BDI2000 Run a program called B2ZOARMGD exe that is in your bdi2000 directory Click on the menu Setup BDI2000 Click on the Connect button and establish communications Ensure you have a valid serial connection before proceeding Enter the configuration informati
30. designated toolsuite from the system In the unusual case where the toolsuite has been manually installed to some root prefix other than usr the second option can be used to specify the root prefix such as usr bin from which removal of all toolsuite files is desired This command is most useful if you have performed a build from sources and subsequent install to an alternate root prefix path and now desire to remove the installed tools 6 xtools remove all go path prefix The remove all command allows the user to summarily remove all toolsuites from the system With the exception of the files usr bin xtools usr bin xtools rc and etc profile Cygwin only this command affects a complete removal of i MX GNU X Tools toolsuite binaries from your system 7 xtools install libs lt target alias gt arcpath This option allows an administrator to update or reinstall toolsuite libraries only This feature is useful for selectively reinstalling libraries that have been over written or updating the libraries from a newer toolsuite version without updating the entire toolsuite This option updates the following files usr lt target alias gt lib libc a usr lt target alias gt lib libstdc a This step extracts the library files from a Microcross i MX GNU X Tools Toolsuite distribution CD ROM or filesystem image The optional arcpath parameter may be used to locate the update files 8 x
31. gt cr Where list of options is a series of assembly options and list of source files is one or more assembly language files s S capital S requires GCC to direct the source file to the preprocessor and then on to the assembler Unlike most Unix assemblers the GNU assembler can work on several files at a time The assembler has many options most of them are architecture specific and are used to describe the target processor more precisely These options will be important to you if you are cross compiling check the FSF s manual for more details Each appendix in this user guide briefly discusses the target dependent compiler and assembler options The following are a set of options and controls that are generally useful for invoking all GNU assemblers Common assembler switch options to all Targets a cdhins file D defsym sym value f gstabs help I dir J K JDL keep locals o objfile R statistics a a v version version W w x Z __ mbig endian mlittle endian if implemented __ mfpa10 mfpa11 mfpe old mno fpu if implemented EB EL if implemented o o O oS a Lo EB EL if implemented O n N b no relax nocpp G num mcpu CPU if implemented emulation name J ptf fles o OS These assembler switch options are discussed in depth within
32. in Source Window Having Enabled a Breakpoint main c Source Window e File Run Viev Control Preferences SOO P70 OS amp A S O OxO04decd 104 ae static int batch U 1 Pointers to various arguments from command line x 4 char yea NULL I char enra h eakpoint 9 at main c 105 Ox80ddec9 ENA breakpoint donttouch threads all cond none k These are static so that we can take their address in an initializer static int print_help static int print_version Pointers to all arguments of commond option char cmdarg x Allocated size of cmdorg SOURCE Using the Breakpoint menu toggle between the normal and temporary setting of a selected breakpoint A normal breakpoint remains valid no matter how many times it is hit A temporary breakpoint is removed automatically the first time it is hit A single check mark for either setting shows the state of the selected breakpoint When a breakpoint is set to temporary the line in the Source Window no longer has a colored square as shown by comparing Figure 6 36 with Figure 6 37 Figure 6 37 Results in Source Window Having Set a Breakpoint as Temporary main c Source Window File Run Yiev Control Preferences PP PPE amp AS oA OxB0ddedS 106 static int quiet 0 static int batch 0 fx Pointers to various arguments from command line char symarg NULL char esecarg NULL 105 char corearg NULL
33. instead of vanilla C source code In addition g uses different default libraries If you want either to preserve the output of GCC at some intermediate stage for debugging purposes or to manipulate the code directly you can do so Here is how each stage works preprocessing A E option in GCC sends the preprocessed code to the standard output instead of compiling the program compilation To save the assembly language output run GCC with the S option This produces files whose names end with S in place of the source file s c assembly As we have seen running with c produces object files whose names end with o We have just finished a long discussion of the many kinds of input that the compiler takes and the different kinds of output that it can provide Pictures are not always worth a thousand words particularly when it comes to summarizing a lot of disparate information But it may help you to remember this information if you view the compiler as a kind of machine with different inputs and outputs as outlined earlier 40 E i MX GNU X Tools User Guide Section 4 How to Use i MX GNU X Tools The input file s name determines where it goes into the machine The c S cc cpp and C files go to the preprocessor i and ii files go straight to the compiler and so on Compilation options determine which stage of the machine produces output i e how
34. library included with Cygwin delivers the interesting subset of UNIX SVR4 BSD and POSIX APIs to enable quick ports of UNIX Linux applications to the Windows platform The license for Cygwin dll is covered by the GNU General Public License and only Open Free Source projects can be built and distributed with the Cygwin dll The commercial software with the Cygwin dll may be purchased separately The Microcross i MX GNU X Tools are bound to the GPL license however users of i MX GNU X Tools who use the preconfigured Newlib C and Math libraries are not subject to the GPL license The Newlib is completely unrestricted and may be used with confidence that your proprietary source code is protected In addition to providing an environment for Open Free Source development on the Windows platform Cygwin delivers a large collection of these Open Free Source programs in a contributed directory Through this collection of Open Free Source UNIX Linux programs Cygwin provides basic commands and utilities for remote system administration including all the standard remote internal daemons e g ftp telnet tar cpio rlogin 7 2 Cygwin Key Features e Provides a shell environment for the Windows Platform e Comes with the latest Intel Pentium II optimizing GNU native compiler e Includes the largest collection of Open Source Linux projects ported to Windows making it the standard Open Source distribution for the Windows platform e The Cygwi
35. like print but does not display void x Nuf expr examine memory at address expr optional mem format spec follows slash N count of how many units to display PM unit size one of b individual bytes h halfwords two bytes w words four bytes g giant words eight bytes X t C f u f printing format Any print format or s null terminated string i machine instructions disassem addr display memory as machine instructions Table 5 11 Automatic Display Command Syntax display f expr show value of expr each time program stops according to format f display display all enabled expressions on list undisplay n remove number s n from list of automatically displayed expressions disable disp n disable display for expression s number n enable disp n enable display for expression s number n info display numbered list of display expressions Table 5 12 Expressions type addr read memory at addr as specified type most recent displayed value iMX GNU X Tools User Guide E 65 Section 5 How to Use Command Line GDB i lastiaddress examined with x _ _ O Z O i valuerataddress o S O Table 5 13 Symbol Table whatis expr show data type of expr or without ptype expr evaluating ptype gives more detail ptype type describe type struct union or enum Table 5 14 GDB Scripts Command Syntax read execute GDB commands from file script define cmd create new GDB command cmd execute scri
36. necessary to include a variety of paths The current working directory is always searched first after that as searches any l directories in the same order as they were specified left to right on the command line Don t warn about signed overflow Issue warnings when difference tables altered for long displacements Keep in the symbol table local symbols starting with L keep locals Keep in the symbol table local symbols On traditional a out systems these start with L but different systems have different local label prefixes M or mri This changes the syntax and pseudo op handling of as to make it compatible with the ASM68K or the ASM960 depending upon the configured target assembler from Microtec Research as can generate a dependency file for the file it creates This file consists of a single rule suitable for make describing the dependencies of the main source file objfile Name the object file output from as objfile By default it has the name a out or b out for Intel 960 targets only You use this option which takes exactly one filename to give the object file a different name Fold the data section into the text section Statistics Print the maximum space in bytes and total time in seconds used by assembly Remove local absolute symbols from the outgoing symbol table w Strip local absolute i MX GNU X Tools User Guide E 53 Section 4 How to Use i MX GN
37. new IP address does not show up on the display go back to the previous step and make the necessary corrections to monrc When using DHCP BootP the new IP address should be annotated in your notes because you will need this IP address for loading GX Linux files via TFTP If your DHCP BootP server assigns a different IP address every time you reboot MicroMonitor you may want to consider manually setting the network IP address while in the development phase of your project because the IP address is a key parameter to your TFTP communications between the host development platform and the target board 3 2 Build Load and Run Example Applications on MicroMonitor Assumptions All necessary steps in Section 3 1 are completed and the board is ready to communicate via TFTP In addition the LiteKit expansion module board is connected to serial Ethernet and powered on This section explains how to build load and run a basic single threaded example application and MicroWindows Minesweeper program on MicroMonitor For the first example the application code is located in Cygwin home umon umon_apps user_manual main1 c and provides a target independent example of hooking up a Hello embedded world application to a target running MicroMonitor System dependent information is normally set in the makefile using any text editor to make changes the makefile is located in Cygwin home umon umon_apps user_manual directory however note
38. of the Intel x86 family Members include 386 486 Pentium i586 and Pentium Pro i686 IDE Integrated Development Environment a GUI tool or a set of tools that uses GUI functionality Instruction Set Architecture An object oriented write once run anywhere programming language developed by Sun Microsystems JDK A software development environment for writing applets and applications in the Java programming language developed by Sun Microsystems JIT Just in time compiler that converts all of the byte code into native machine code just as a Java program is run resulting in run time speed improvements over code interpreted by a Java Virtual Machine JVM Joint Test Advisory Group referring to a type of hardware interface that allows the testing of chips and boards within a complete system programs running on processors with JTAG support may be controlled through the processor s JTAG port responsible for interpreting Java byte codes LD See linker lipgloss The library for GNU Low level OS Support contains the startup code the I O support for GCC and newilib the C library and the target board support packages to which you need to port the GNU tools for an embedded execution target Linker A tool that merges object files and library archives such as compiled classes building an executable a complete program or a single executable file A free Unix operating system for many kinds of computers crea
39. out or a exe Cygwin Linked Executable named Compilands 0 4 6 Controlling Linker from GCC Another common compilation option is I which specifies a library and L which specifies the path to a non standard library Important I must be specified at the end of the command after the source object filenames while all other options are specified before the source object filenames The examples shown are with GCC but the user can substitute g in place of gcc along with the appropriate C files and libraries needing linked Here s a typical command the inputs are object files so the command just runs the linker lt target alias gt gcc o example L src local lib main o first o Im cr This command tells GCC to look for libraries first in src local lib path then in the standard location If someone has put a local version of a library in src local lib that version is used in preference to the standard version in usr lib The lm specifies the library name actual library name is libm a The prefix and suffix to the library name can be dropped on all library names The naming convention for GNU libraries is lib lt name of lib gt a static libs and lib lt name of lib gt so shared libs Unix Linux linkers search libraries in the order in which they occur on the command line and only resolve the references that are outstanding at the time the library is search
40. probably don t care your program just uses an ifdef directive to check whether it s set E Stop after the preprocessing stage do not run the compiler proper The output is in the form of preprocessed source code which is sent to the standard output Input files which don t require preprocessing are ignored i MX GNU X Tools User Guide E 43 Section 4 How to Use i MX GNU X Tools S Stop after the stage of compilation proper do not assemble The output is in the form of an assembler code file for each non assembler input file specified By default the assembler file name for a source file is made by replacing the suffix c i etc with s Input files that don t require compilation are ignored V Print on standard error output the commands executed to run the stages of compilation Also print the version number of the compiler driver program and of the preprocessor and the compiler proper HHH Like v except the commands are not executed and all command arguments are quoted This is useful for shell scripts to capture the driver generated command lines pipe Use pipes rather than temporary files for communication between the various stages of compilation This fails to work on some systems where the assembler is unable to read from a pipe but the GNU assembler has no trouble help Print on the standard output a description of the command line options understood by gcc If the v option is also specifi
41. rules if any and all the rules have many exceptions In general it is a good idea to place modules that call each other near each other on the command line The reasoning behind the heuristic is simple if function A makes many calls to function B and both A and B can fit into the cache simultaneously you will not pay a penalty for cache miss Your best chance of fitting both functions into the cache simultaneously occurs when they are located next to each other in the object file The M option which produces a load map shows you how the object file is arranged it will help you investigate cache performance Normally rearranging the order of the object modules on the command line is sufficient for experimenting with link order optimization However you can get very fine control over your executable file by writing a linker script If you have a thorough knowledge of your target machine s architecture you may be able to use this to your advantage though you will probably reach the point of diminishing returns fairly quickly 4 9 5 The C Runtime crt0 To link and run C or C programs you need to define a small module usually written in assembly as crtO s but sometimes written as a C file as crtO c to initialize hardware using C conventions before calling main There are some examples available in the sources of Newlib C library perform a simple search through the source tree for crt0 s code as well as exampl
42. scanning and text processing program The GNU Compiler Collection with C compiler The GNU Debugger GNU s Chess game play against a user or it plays against itself Display call graph profile data Print lines matching a pattern a very powerful search utility Front end for the gruff document formatting system Compress or expand files All Internet utilities in Cygwin Object oriented extensions to Tcl Framework for building mega widgets in Tcl Tk Public domain Korn shell Programmed dialog with interactive programs 108 E i MX GNU X Tools User Guide section 7 Introduction to Cygwin Tool Utility Program Description ids GNU linker less Opposite of more less does not have to read the entire input file before starting Library containing all drivers and files for terminal server Library for reading and writing JPEG files Library for reading and writing TIFF files M4 Implementation of a traditional Unix macro processor M Cs GNU make supports POSIX 1003 2 and is used to manage large programming projects Format and display on line manual pages more Display paginator supports backward and forward movement though a file and searches ncurses CRT screen handling and optimization package used as include lt curses h gt library routines giving the user a terminal independent method of updating character screens with reasonable optimization perl Practical Extraction and Report Language designed for scanni
43. target alias gt gcc c g Wa alh L source c cr Listings that include both assembly and source code are interesting from two standpoints You may want to see how your code has been compiled this is instructive whether or not you are optimizing and even if you are not interested in assembly level debugging What is more important though is that you can generate a C assembly listing for optimized code This can be very helpful for debugging under optimization The big problem with debugging optimized code is that there is no longer a simple mapping from your source code into assembly language therefore the debugger cannot single step and perform symbolic debugging With a listing you can find out exactly what the compiler did to your code and get a much better idea of what the code is doing 4 8 Using the GNU Assembler The GNU assembler is really many assemblers folded into one or many different programs with the same name depending on how you look at it You can usually ignore the assembler the compiler invokes it automatically and is usually able to specify everything the assembler needs to know about your environment In rare cases you may need to ask for an assembly option explicitly in these cases you will need to run the assembler as a separate program or use GCC s Wa option to pass additional options to the assembler The assembler arguments must be separated from each other and the Wa by commas For e
44. than loading it in the prologue for each function The run time system is responsible for initializing this register with an appropriate value before execution begins mpic register lt reg gt Specify the register to be used for PIC addressing The default is r10 unless stack checking is enabled when r9 is used Must be used with fpic option to be valid mcirrus fix invalid Insert NOPs into the instruction stream to in order to work insns around problems with invalid Maverick instruction combinations This option is only valid if the mcpu ep9312 option has been used to enable generation of instructions for the Cirrus Maverick floating point co processor This option is not enabled by default since the problem is only present in older Maverick implementations The default can be re enabled by use of the mno cirrus fix invalid insns switch mpoke function name_ Write the name of each function into the text section directly preceding the function prologue The generated code is similar to this tO ascii arm_poke_function_ name O 114 E i MX GNU X Tools User Guide Appendix 1 ARM Toolsuite Option S align t1 word Oxff000000 t1 tO arm_poke_function_name mov ip sp stmfd sp fp ip Ir pc sub fp ip 4 When performing a stack backtrace code can inspect the value of pc stored at fp O If the trace function then looks at location pc 12 and the top 8 bits are set then we know that there is a
45. the B prefix if any If the name is not found or if B was not specified the driver tries two standard prefixes which are usr lib gcc lib and usr local lib gcc lib If neither of those results in a file name that is found the unmodified program name is searched for using the directories specified in your PATH environment variable B prefixes that effectively specify directory names also apply to libraries in the linker because the compiler translates these options into L options for the linker They also apply to includes files in the preprocessor because the compiler translates these options into isystem options for the preprocessor In this case the compiler appends include to the prefix The run time support library file libgcc a can also be searched for using the B prefix if needed specs file Process file after the compiler reads in the standard specs file in order to override the defaults that the gcc driver program uses when determining what switches to pass to cc1 cc1plus as Id etc More than one specs file can be specified on the command line and they are processed in order from left to right 4 7 5 Debugging and Profiling Options These options request the compiler to create additional code and an expanded symbol table for the various profilers and debuggers dbx prof gprof and the branch count profiler They
46. the command line Also shown in Figure 6 1 is the filename of the cross executable pascal x A simple GDB ini file can be configured in the source and executable s file directory The GDB ini file can include the cross executable s filename board register initialization settings and any other initialization settings necessary for startup that may be needed to perform on chip debug e g debug agents used with i MX GNU X Tools include the Abatron BDI2000 and Macraigor Systems Wiggler Raven mpDemon see documentation listed in the references that describe using GDB Figure 6 1 Program to debug window GNU X Tools Shell c Microcross e Free CAPTORES Foundation tc Cygnus Support Hosts of Contributors ee lt target alias gt to set up for a cross target xtools arm e eae Le help to get help on xtools commands help to get Bash Shell help Ctrl d to exit xtools arm e lf etting up Shell for arm elf rm elf GNU amp Tools Shell Ready rm elf cd home test rm elf qec g o pascal x pascal c rm elfsqdbtk Becca x Figure 6 1 shows the following commands using an ARM toolsuite substitute your target alias if different Start i MX GNU X Tools Shell Windows or xterm Linux Issue these commands xtools arm elf cr arm elf cd home test or appropriate directory cr arm elf gcc g o pascal x pascal c cr arm elf gdbtk pascal x cr
47. the i MX GNU X Tools command tool from the Bash shell by executing the following commands cd cr tar xvzf mnt cdrom bin rcfiles tgz cr At this point you should be able to execute the i MX GNU X Tools command tool inside of the Bash shell by its name The command xtools cr should invoke the abbreviated tool help screen that shows the basic operating commands see Section 4 for a complete description of the command tool Step 5 To install an individual toolsuite simply execute the command xtools install arm elf cr The command tool will extract the toolsuite tarball installing all files in their appropriate locations The install command assumes the default archive source path is mnt cdrom bin using mnt cdrom as the CD ROM mount point If your default mount point is different you can change the default value by editing usr bin xtools file If you would like to override the default path to the distribution medium you may enter the command as xtools install arm elf lt arc path gt The arc path should always end in bin as the tar archives are in the bin directory on the CD ROM e g xtools install arm elf mnt cdrom1 bin Step 6 If you do not have the tcl8 4 tk8 4 library installed in your Linux distribution check your system documentation for details on how to make the check here is the command to execute and install the library from Microcross CD ROM
48. the manual MC Utilities pdf docs directory on i MX GNU X Tools CD ROM and in Cygwin docs In addition each assembler has target specific switch options The target specific switch options are located in the Appendices of this User Guide Unlike older assemblers as is designed to assemble a source program in one pass of the source file This has a subtle impact on the org directive These options enable listing output from the assembler By itself a requests high level assembly and symbols listing You can use other letters to select specific options for the list ah requests a high level language listing al requests an output program assembly listing and as requests a symbol table listing High level listings require that a compiler debugging option like g be used and that assembly listings al be requested also Use the ac option to omit false conditionals from a listing Any lines which are not assembled because of a false If or ifdef or any other conditional or a true if followed by an else will be omitted from the listing Use the ad option to omit debugging directives from the listing Once you have specified one of these options you can further control listing output and its appearance using the directives list nolist psize eject title and sbttl The an option turns off all forms processing If you do 52 E
49. this initialization routine is linked to your program Alternatively you can link by using the GCC command without any C source files When GCC invokes the linker it automatically adds crt0 o and many other libraries in the proper place For example the command gcc exp o generates the following Id command 54 E i MX GNU X Tools User Guide section 4 How to Use i MX GNU X Tools lt target alias gt Id dc dp e start X o o a out usr lt target alias gt lib crt0 o Ic cr In this command the run time initialization module usr lt target alias gt lib crt0 o appears explicitly in addition to requests to resolve references to the C library the general runtime library You can see what Id command is generating when you compile a program on your system by invoking GCC with the v verbose option 4 9 2 Linker Options The GCC passes any options it does not recognize to the linker The most important options can therefore be placed directly on the GCC command line These options are 0 name x Instead of naming the executable output file a out or a exe native builds under Cygwin it names it name x Other popular naming extensions for embedded applications include name elf name coff name srec and name bin Microcross has standardized all of its cross executable names to the x extension Iname Link the program to the library named libname a The
50. to close out each i MX GNU X Tools shell window 3 8 MicroMonitor Familiarization and Tips MicroMonitor is the boot ROM that comes with each Cogent development board It is very useful in initializing hardware starting serial and Ethernet services and creating a tiny filesystem to store applications and the embedded Linux startup binaries Moreover MicroMonitor facilitates loading the GX Linux binaries using TFTP services over Ethernet or XModem through the serial port We will focus on the TFTP across Ethernet transfer solution due to the size of the images and the time it takes to load binaries 3 8 1 Manual TFTP Up Load Procedure Microcross ships each board pre configured with the Linux script startlinux and two binaries zlmage kernel and romfs img root filesystem and Busybox utilities To manually up load files follow the steps in this section The upload address lt target P address gt is the IP address of the target board 32 E i MX GNU X Tools User Guide Section 3 Quick Start Guide Reload startlinux Startup Script To reload startlinux script on the target board you have three options to control your linux bootup e Load startlinux for manual bootup requires serial connection to use the UMON command line interface to execute startlinux cd lt build dir gt boot cr ttftp lt target IP address gt put startlinux startlinux e cr e Load startlinux for autoboot
51. with MKS application software Both Borland and MKS conflicts can be easily fixed The user can fix the problem in one of two ways 1 Edit the path settings in the Advanced tab of the Windows System Properties in the Control Panel and make sure that the Cygwin paths are before the Borland or MKS paths move Cygwin paths to the left of the other program paths or 2 The user can remove the bothersome programs from the host machine Obviously the easiest and preferred method is to place the Cygwin paths to the left of the conflicting paths Remember to separate each path and terminate with a semicolon 2 6 3 Remove Carriage Returns in Source and Make Files The user may experience compile errors if DOS style files are compiled directly with i MX GNU X Tools This is due to the i MX GNU X Tools being configured for UNIX style file line feed termination instead of the DOS carriage return and line feed Source files that have macro definitions and line continuation characters are always going to cause a compile error If your source files are already in the DOS style format with carriage returns and line feeds follow one of these steps to fix the source files 1 If using Visual X Tools open the source files and execute a Save As from the File menu and select the Line Format from the click down text box at the bottom of the Save As dialog box click on Unix do this for each source file and c
52. with abort query cd lt build dir gt boot cr ttftp lt target IP address gt put startlinux startlinux eB cr e Load startlinux for autoboot without abort query warning there is no way to recover an error without disaster recovery efforts using a JTAG emulator to reload MicroMonitor into RAM and then write back to flash cd lt build dir gt boot cr ttftp lt target IP address gt put startlinux startlinux eb cr Change startlinux Attribute Options There is another option to change startlinux script flags without having to reload startlinux again by using the serial UMON command line interface Microcross startlinux is preloaded with the e flag attribute set which is the manual bootup setting Two other boot options are available and can be set issuing one of the following commands 1 Autoboot with abort query case sensitive UMON gt tfs feB cp startlinux startlinux cr 2 Autoboot without abort query case sensitive WARNING there is no way to recover from an error without disaster recovery efforts using a JTAG emulator to reload MicroMonitor into RAM and then write back to flash UMON gt tfs feb cp startlinux startlinux cr MicroMonitor training material is available by Microcross Here is a link to more information documentation http www microcross com html micromonitor html Reload zimage Procedure Similarly to the upload procedures a
53. workspace file test vxw and go onto the next step Step 3 28 E i MX GNU X Tools User Guide Section 3 Quick Start Guide On the Visual X Tools menu click on Build Set Active Configuration and select Debug Step 4 On the Mini Toolbar see Figure 3 4 click on Clean amp Build Project icons eee Compile Clean Build Clean amp Run GHOU Windows Visual GOB Clear Binaries Project Build Debugger Bash Shell Command Debugger Process Butt Figure 3 4 Mini Toolbar Description These commands are also located under the Build menu The Build window at the bottom of Visual X Tools shows the verbose output of the build After completion of the build go to the next step Step 5 Click on the i MX GNU X Tools Bash Shell icon red X icon in Figure 3 4 Make connections to the target LiteKit board USB cable null modem serial cable Ethernet cable and power cable turn power on to the board and start OCDRemote in a second i MX GNU X Tools Shell Always prior to running GDB Visual GDB you must first start OcdRemote This stand alone utility listens to a TCP IP port and converts incoming GDB commands to JTAG signals Here is the standard Macraigor command line format lt GDB gt TCP IP port lt OcdRemote gt LPTx lt MacraigorDevice gt JTAG lt ARM920T CPU gt USBx COMx OCDRemote takes additional OPTIONAL parameters that allows you to modify it s modes of operation OCDRemote c lt
54. xtools remove arm elf cr xtools install arm elf cr Use the same CD ROM drive that the original installation was made from i MX GNU X Tools User Guide E 11 Section 2 Install and Setup Procedures 2 2 Uninstall i MX GNU X Tools on Windows Host Uninstall i MX GNU X Tools and Cygwin 1 Start the Control Panel from the Start menu 2 Click on Add or Remove Programs 3 Scroll down to find i MX GNU X Tools with and click on Remove The above remove procedure should remove the program and environment settings however in the event that anything should happen out of the ordinary follow the next three steps to manually return your computer back to its pristine state To verify i MX GNU X Tools environment is uninstalled completely 1 Run regedit from the Start Run command 2 Look for the following Registry Keys HKEY LOCAL _MACHINE Software Cygnus Solutions HKEY CURRENT USER Software Cygnus Solutions 3 If they exist manually delete them by selecting the key and pressing the Delete key To verify removal of environment variables 1 Start the Control Panel from the Start menu 2 Click on System and select the Advanced Tab 3 Click on Environment Variables 4 On System Variables window Click on Path and then on the Edit button 5 Make sure all instances of Cygwin bin Cygwin usr bin and Cygwin usr local bin along
55. you must first start OcdRemote This stand alone utility listens to a TCP IP port and converts incoming GDB commands to JTAG signals Here is the standard Macraigor command line format lt GDB gt TCP IP port lt OcdRemote gt LP Tx lt MacraigorDevice gt J TAG lt ARM920T CPU gt USBx COMx OCDRemote takes additional OPTIONAL parameters that allows you to modify it s modes of operation OCDRemote c lt CPU type gt lt CPU type gt p lt port number gt d lt device gt a lt device address gt s lt speed gt where lt CPU type gt ARM920T enter ocdremote for a complete CPU list lt port number gt tcp ip port default 8888 lt device gt WIGGLER RAVEN MPDEMON_SERIAL MPDEMON_PARALLEL MPDEMON_ETHERNET USB default RAVEN lt device address gt WIGGLER RAVEN MPDEMON_PARALLLEL LPT number 1 4 MPDEMON_SERIAL COM number 1 4 MPDEMON_ETHERNET tcp ip address in the format XXX XXX XXX XXX USB macraigor USB device number 0 15 default 1 lt speed gt JTAG clock rate 1 8 default 1 fastest see GNU TOOLS FAQ page for a device speed vs jtag clock rate table Here is an example In the second i MX GNU X Tools Shell enter the following command line assuming the usoDemon is assigned device 0 at JTAG speed 1 6 Mhz 24 E i MX GNU X Tools User Guide Section 3 Quick Start Guide ocdremote c ARM920T d USB a 0 s 1 cr Feedback from the computer assumi
56. 00 Oxc35dec69 0 869104d8b Ox60000000 Oxes000000 Oxf ft tft fe 0x0c558b06 OxO1fc45c 0x0066850f0 0x63e58955 Ox5589F045 0x00006803 Oxf ff ttt fe Use Addresses Auto Update to update the contents of the Memory window automatically whenever the target s state changes this is the default setting Use Addresses Update Now to update the Memory window s view of the target s memory 80 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger Figure 6 23 Memory Preferences Dialog for the Memory window Memory Preferences Size w Byte A Word w Float w Half Word w Double Word wy Double Float Format w Binary vy Octal y Sigred Decimal w Unsigned Decimal Number of Bytes Depends on window size w Fixed 128 bytes Miscellaneous Bytes Per Row 16 x M Display ASCII Control Char OK Cancel Apply e Use Addresses Preferences to invoke the Memory Preferences dialog to set memory options e Select the size of the individual cells to display with Size options Byte Half Word Word Double Word Float or Double Float are the settings with Word being the default selection e Select the format of the memory that displays with Format options Binary Signed Decimal Octal Unsigned Decimal or Hex Hexadecimal are the settings with Hex being the default selection e Set the number of bytes to display with Number of Bytes
57. 3744044 chor Osb fff 758 1075659597 1073744036 struct stat su uct stat vee ichar 1 Ox40000000 iFTELF 00I 001001 chor 1 0x0 1073747220 time_at_startup 24 Double click the mouse with the cursor in the Local Variables window to edit a variable Figure 6 31 Figure 6 31 Editing Local Variables Local Variables fecr g corearg cdarg ttyarg print_help print version Acmdarq cndsize ncmo dirsize ndir homebuf homedir homeinit 1 time_at_stor tup 84 E i MX GNU X Tools User Guide ichar Osbtftt Gad 1075459897 0 0 chor Oxi ichar Ose lt Address Ose out of bounds chor Ox chor Osi 0 0 chor Ox40000210 1073743452 1073744044 chor Osbt ttt 753 1075859692 1073744036 struct stot struct stat 4 chor Ox40000000 1 77ELF 0014001 4001 chor w x 1073747220 ed Section 6 How to Use Visual GDB Debugger Single click the mouse with the cursor on the plus sign to the left of a structure variable to see the elements of that structure compare the variable structure for homebuf in Figure 6 30 with the results in Figure 6 32 To close the structure elements click the minus sign to the left of an open structure compare the variable structure in Figure 6 32 with what the window had displayed in Figure 6 30 Figure 6 32 Displaying the Elements of a Variable Structure _ocal Variables chor x Ovbt ff rood 1075459897 Oo 0
58. CPU type gt lt CPU type gt p lt port number gt d lt device gt a lt device address gt s lt speed gt where lt CPU type gt ARM920T enter ocdremote for a complete CPU list lt port number gt tcp ip port default 8888 lt device gt WIGGLER RAVEN MPDEMON_SERIAL MPDEMON_PARALLEL MPDEMON_ETHERNET USB default RAVEN lt device address gt WIGGLER RAVEN MPDEMON_PARALLLEL LPT number 1 4 MPDEMON_SERIAL COM number 1 4 MPDEMON_ETHERNET tcp ip address in the format XXX XXX XXX XXX USB macraigor USB device number 0 15 default 1 lt speed gt JTAG clock rate 1 8 default 1 fastest i MX GNU X Tools User Guide E 29 Section 3 Quick Start Guide see GNU TOOLS FAQ page for a device speed vs jtag clock rate table Here is an example In the GNU X Tools Shell enter the following command line assuming the usbDemon is assigned device 0 at JTAG speed 1 6 Mhz ocdremote c ARM920T d USB a 0 s 1 cr Feedback from the computer assuming the USB cable is connected and the LiteKit board is powered on is the following JTAG SDO lt CPU 1 ARM920T listening on port 8888 lt JTAG SDI Important Each time you connect and disconnect Visual GDB you must repeat this step The Socket automatically shuts down when GDB Visual GDB disconnects Step Click on Visual GDB Debugger icon on the Mini Toolbar see Figure 3 4 This command will run Visual G
59. DB load test x and stop at breakpoint on main If the target settings dialog pops up select Target Remote TCP Hostname localhost and Port 8888 click on OK Each subsequent run will automatically remember these settings until you change them again To single step or perform other GDB commands you may use the visual buttons that reflect equivalent functions as the command line version or you may enter the command line version in the console Window click on View Console if it is not viewed upon start of Visual GDB To exit click on File Exit on the menu Figure 3 2 above shows a Visual GDB on chip debug session with Console Window visible The Console Window needs to be started to get control over the GUI after setting the first Enter s for step in the Console window to enable all of the GUI functions on the Visual GDB From here you can single step all the way through the program view registers view memory etc To get more specific information on how to use Visual X Tools consult the Visual X Tools User Guide END OF EXAMPLE PROGRAM 3 6 LCD Tests To test the LCD for color and touch screen use there are two simple programs that are preconfigured for this purpose in MicroMonitor Follow the simple procedures below to test the system with these programs Assumptions The LiteKit board is connected to a host serial terminal and powered on Step 1 In a serial terminal shell with MicroMonitor booted issu
60. Depends on Window Size or Fixed Depends on Window Size selection is default e Display a string representation of memory with Miscellaneous Bytes Per Row or Display ASCII selections Control Char displays non ASCII characters the default control character is the period 6 11 Using the Watch Expressions Window The Watch Expressions window displays the name and current value of user specified expressions Figure 6 24 Figure 6 24 Watch Expressions Window Watch Expressions r r char Oxd chor Ovo Add Hatch i MX GNU X Tools User Guide E 81 Section 6 How to Use Visual GDB Debugger The Watch Expressions window has the following functionality e Single click on an expression to select it e Right click in the display pane having selected an expression to invoke an expression specific Watch menu Figure 6 25 Figure 6 25 Watch Menu in the Watch Expressions Window Watch Expressions ttyar Fornat Remove Edit A Decimal A Bindry ctal A Natural add Hatch Use Watch Edit to edit the value in an expression an example of an expression capable of being edited is shown in Figure 6 26 Use the Esc key to abort editing Figure 6 26 Editing the Value in an Expression Watch Expressions corearg cdarg ttyarg chor Ox add Hatch Use Watch Format to invoke another pop up menu for displaying a selected expression s value in Hex Hexadecimal Decimal Binary or Octal forma
61. ETE EAEE ER EER 63 Table 8 9 EXECUTING VOUS PIOQIAIN ssenarisinin eari ioin E TER E EE NARE EEEE REEE EEEE EEE E 63 Tabe S6 Shel COmMaNUS perie irir ii iririere oide a EE Eaa ENERE AA EE EEEE AAEE AAE EARNE EEEE REA 63 Table 5 7 Breakpoints and WatChPOINts ccccccccsseccsecccsuccseecsueessuessseessueessueesseeeseessseessueessueenseeseseesseessessaneesans 63 PODES o Man FO TO Gere ee ne ne T EAE E AAA A eee eee 64 TO a Eec On CO O aT N EA E A E E ee 64 AEST D P e ett at nee errr etre A E R E E rer eee E E E errr 65 OES TT AU Ome D D y er E E A S E E E A E T G 65 POE ST O SO T E ATA A et eee eee eer 65 POEST SO a kz 0 eee E A E A E TA TE 66 OE Te OR T E EEE EEE ee ee 66 TOET S e E E eee E E EAE TEE E 66 Tabie 3 10 Dopugging TAN OCS eessen ceteris EESE ENEE EENE AEON 66 Tadeo T7 CONTON ODB sssrin anin EEEE ES EEEE 67 Tablo 9 18 VV OVA FIOS peresisserii nsaisan ee NNE alarejsieas entnioar EEEE sh aatenatgatectoest alenteaaseitoset 67 PETS a PU ET O a E E E E ee E eee 68 SECTION 6 HOW TO USE VISUAL GDB DEBUGGER cece cece eee eeeeeeeeeeeeneeeeeeneenes 69 o1 Using Visual SUC Si ass areata ets iesersc ersten saeancetens cease ee ate see eeen meena eeee a aesranteesnsheseesaaree 69 6 2 Visual GDB An Alternative Interface to Command Line 2 0 0 0 cece cee eee eceecececeeeeceeeeeeeeeeeeeeeeeeeeaeaeees 69 6 3 Using the Mouse in the Source WINdOW ccccccceccceccceeceeeeeseeeseeeeaececeeeeseeeseeeeseeesseesse
62. Enter the TCP IP address of the Abatron BDI2000 4 Enter port address if setup as instructed it should be 2001 5 Select the desired check boxes 6 Click on More Options enter any desired Run Options and click OK If debugging on the hardware target select the run option continue since a program cannot be run in the traditional sense through the JTAG 7 Set your breakpoints if necessary and click on run and thereafter you can single step or continue Click on View to select view options like registers memory console function browser etc Review Section 5 for more details on how to use Visual GDB i MX GNU X Tools User Guide E 97 section 6 How to Use Visual GDB Debugger 5 19 2 Macraigor mpDemon Setup and Debug with Visual GDB Introduction The Macraigor mpDemon version 3 0 0 x can now communicate directly with one or more GDB sessions via Ethernet to it s internal OCDRemote GDB stub interface Initially prior to starting the Visual GDB or command line GDB session s on your host you must first configure the mpDemon s OCDRemote for your target board and local network settings OCDRemote converts GDB commands to JTAG BDM signals that control your target board s CPU s To configure your mpDemon you must connect it to your network make a serial connection to a host computer and follow a few simple steps to get up and running with Visual GDB Follow these steps to quickl
63. Function Browser from the Source Window The Function Browser window has several fields that provide search and browsing capability for source code debugging Figure 6 39 Descriptions follow of the Filter Files Functions and View Source fields Figure 6 39 Function Browser Window Function Browser function matches regexp w Functions m2 valprint c a main machire gnon h print_gdb_help machmede def machmede h macro c madvice c main c maint c makeccntert c malloc c malloc h math h _j Hide h files Select All Breakpoints Delete Set b yiew Source The Filter group at the top of the Function Browser window contains the Show if function drop down list box and a text edit field Show if function allows you to match the character string in the text edit field to its right by any of the four alternatives Using the Show if function drop down list box Figure 6 40 starts with shows functions that start with the character string in the text edit field entry contains shows functions that contain the character string in the text edit field entry ends with shows functions that end with the character string in the text edit field entry matches regexp makes the search routines use regular expression matching for example searching for ab matches all functions starting with either a or b letters Figure 6 40 Show if Function Drop Down List Box eT Show if function matches r
64. GDB was configured as host 1686 pc cygwin target arm elf gdb target sim Connected to the simulator gdb load Loading section init size Oxlc vma 0x8000 Loading section text size Ox91f8 vma Ox80Ol1c Loading section fini size 0x18 vma 0x11214 Loading section rodata size 0x2f8 vma 0x1122c Loading section data size Ox8bc vma 0x11624 Loading section eh_frame size 0x4 vma OxlleeO Loading section ctors size 0x8 vma Oxllee4 Loading section dtors size 0x8 vma Oxlleec Loading section jcr size 0x4 vma Oxllef4 Start address 0x8110 ransfer rate 323520 bits in lt 1 sec gdb run Starting program home test div x Performing 3000 random integer Multiply Divide tests Program exited normally gdb _ 4 5 1 4 Startup of GDB with DDD To use the Data Display Debugger DDD with the i MX GNU X Tools command line version of GDB follow these easy steps to get started and refer to distribution documentation for details ddd pdf in the docs directory on the distribution CD or in Cygwin docs Start XWin using the desktop icon in Windows which was created by the i MX GNU X Tools installation manager In Linux refer to your distribution s documentation for installing and invoking DDD We are assuming a Windows host for the following procedures Issue the following commands in the XWindows Shell Substitute your target alias as appropriate Example xtools arm elf cr arm elf cd home
65. Guide Appendix 1 ARM Toolsuite The ARM Toolsuite consists of the following tools Tool Description Version GNU Compiler Collection GCC arm elf as arm elf ld arm elf addr2line arm elf ar arm elf gcov arm elf nm arm elf objcopy arm elf objdump arm elf ranlib arm elf readelf arm elf size arm elf strings Arm elf strip GNU assembler as 2 15 GNU linker Id Converts addresses to file names amp line Creates object code archives Test coverage program for analysis Lists symbols from object files Copies and translates object files Displays information from object files Generates index to archive contents Displays information about ELF objects Lists file section sizes and total sizes Lists printable strings from files Strips debug symbols from binaries arm elf gdb GDB debugger arm elf gdbtk Visual GDB arm elf run Instruction Set Simulator libc a and libm a Unrestricted Newlib C and Math Libraries 1 12 lipbstdc a GNU Standard C and Template Library 3 40 File Count in Distribution Type usr bin arm elf usr arm elf usr arm elf lib usr arm elf include usr lib gcc lib arm elf usr man man1 arm elf binary images binary images library files include files compiler lib man pages Total Files TARGET CPU DEPENDENT INFORMATION 776 This toolsuite comprises a complete development environment for the ARM processor family Included in this section of the Appendix are the req
66. JTAG Debuggers and SourcePoint EPI Tools MAJIC series Macraigor mpDemon Raven Wiggler Nohau EMUL ARM Signum Systems Chameleon JTAG Debugger ARM Multi lICE 10 E i MX GNU X Tools User Guide Section 2 Install and Setup Procedures Section 2 Install and Setup Procedures There are two host versions of i MX GNU X Tools Windows and Linux Read the system requirements in Section 1 0 before proceeding further The information in this Section gives the user details of installation environment configuration removal of toolsuite setup testing and troubleshooting Section 2 1 Install i MX GNU X Tools on Windows Host Section 2 2 Uninstall i MX GNU X Tools on Windows host Section 2 3 Install i MX GNU X Tools on Linux Host Section 2 4 Uninstall i MX GNU X Tools on Linux Host Section 2 5 Setup test Section 2 6 Troubleshooting Guide for Installation Problems 2 1 Install i MX GNU X Tools on Windows Host The following steps describe how to install the i MX toolsuite The README file on disk describes the contents of the i MX GNU X Tools distribution CD Insure that the system requirements have been met especially RAM and free disk space On Windows NT 2000 XP hosts login as administrator or have full permissions to the root directory of the destination disk volume Step 1 Insert the Microcross i MX GNU X Tools distribution CD into the PC CD ROM drive On most systems the installer will auto start the i MX GNU X Tools installation manager
67. NA LER SC NO eer e A E E E E E EE E 17 3 2 Build Load and Run Example Applications on MicroMonitor ccccecceeceeeeeceeeeeeeeteeteceeeeeeeees 19 3 3 Build Load and Run GX Linux and Example Applications ccccccccececeeeceeeseeeeeeceeeeseeeeeeteetaess 20 iMX GNU X Tools User Guide E iii Contents 3 4 Debug with usbDemon Example cccccccceeccseecececeeecueecueccecauecauecacecaeecsuecueecueesueeaeesaeeseessaeegas 23 ne Pe EAT EF TOI I 6 en eee eee E ea ne ce eee eee er a ee eee 23 3 4 2 OGCDREMOIG Monit r ComMandS sessirnir ia Eaa E E eea AEE E ERA canals 27 3 4 3 Some Useful GDB Console COMIMANAS ccccssccccssescccseeccseesessueessuseessusessausessseessuneessnsessausesssuesssaesessnesesans 27 39 Visual X Tool Example errioan EEEE EEA EEE EAST EN EE 28 SE LCD TESIS oer eE E E EEEE E E E E E E EEE EEE EE EE E E E EN 30 3 7 Rebuild MicroMonitor and Reflash Board ccccccccceeccesccceeecseeeceeeeeeceseeeeeueeseeessueeseeeseueeseeessneesaees 31 37 1 Normal Reflash Procedure sossarserinen nurani EEE EEEE EENIA EE ESTEE SEEE E AET ATEN 31 3 7 2 Dissaster Recovery Procedure 1ccsccccnsescssesccsecscusensusnausensusensusensussausensusensusnausensusessussaussessusenaussausensusenaass 31 3 8 MicroMonitor Familiarization and TipS cccccccccecceceseeceeeecceeceeeeeeceeeaeeseeeeeeseeteeeeeceeesseteesseetseeaeeeaes 32 36 1 Man al TFIIF Up LOad FrOCOQU O Aree i E ee EEEE EE AE
68. U X Tools Suppress warning messages Generate an object file even after errors Standard input or source files files to assemble This option is accepted for script compatibility with calls to other assemblers 4 9 Using the Linker The Id linker combines several object modules and libraries into a single executable file It resolves references to external variables external procedures and libraries creating a complete self sufficient program You never need to invoke Id explicitly In most cases it is simpler to use the GCC command to link files even if you do not have any source files to compile The GCC guarantees that certain libraries will be present in the proper order even if they are not listed on the command line If you use Id as a linker you need to mention these libraries explicitly 4 9 1 Invoking Id The rules for invoking ld if you must do so are the same as for GCC or as The basic ld command is as follows lt target alias gt Id lt list of options gt lt list of files and libraries gt cr Where list of files and libraries is a series of filenames and library specifications To include a library in this list use the notation Iname where the name of the library file is either lib libname a or usr lib libname a The linker processes the list of files and libraries in order When it reaches a library it extracts only those modules that it currently needs to resolve externa
69. WIl nostdlib If you plan on augmenting the standard libraries with your own libraries then do not use this option Use a GROUP and SEARCH_DIR statement with appropriate arguments in the linker script see the Visual X Tools IDE User Guide or the i MX GNU X Tools Training Guide for examples on how to create linker scripts and startfiles nostdinc Do not search the standard system directories for header files Only the directories you have specified with I options and the current project directory are searched By using both nostdinc and I you can limit the include file search path to only those directories you specify explicitly Static Link only to static libraries not shared libraries When used with GCC add the correct option WI static In i MX GNU X Tools static link is the default setting shared If shared libraries are available use them wherever possible rather than static libraries When used with GCC add the correct option WI shared Idir Add the directory dir to the head of the list of directories to be searched for header files This can be used to override a system header file substituting your own version since these directories are searched before the system header file directories If you use more than one I option the directories are scanned in left to right order the standard system directories come after Any directories you specify with l
70. X Tools User Guide Section 6 How to Use Visual GDB Debugger Figure 6 7 Toolbars Menu a Break points Finish Continue nsole Line number display frame Lb Program counter sili frame a Watch Expressions _ Local Variables ae Run Stop Step Registers ieee Vemory M Stack ce EXT Teori m a tee Ti Step assembler instruction Next assembler instruction z ie ra he Ae Up Stack Frame a Down Stack One Frame a Go to Bottom of b The following descriptions discuss the use of the default debugger toolbar buttons The Run button starts the debugging process for an executable file If there is no executable open the Load New Executable dialog displays to open an executable g During the debugging process the Run button turns into the Stop button to interrupt the debugging You cannot interrupt some targets you will instead have to disconnect from the target ral The Step button steps to next executable line of source code Also the Step button steps into called functions ig The Next button steps to the next executable line of source code in the current file Unlike the Step button the Next button steps over called functions The Finish button finishes execution of a current frame If clicked while in a function it finishes the function and returns to the line that called the function The Continue button continues execution until a breakpoint watchpoint o
71. ad and execute compiled programs Visual GDB Debugger Targets Cisco Serial Cisco TCP ARM Angel Serial ARM Angel Ethernet ARM Remote Serial ARM Remote TCP Remote Serial Remote TCP Simulator GDBserver Serial GDBserver TCP Compiler Machine Dependent Options Section 3 describes all of the common compiler linker and assembler options used in Microcross GNU cross tools in addition these m options are defined for ARM architectures Option si Description S O mapcs frame Generate a stack frame that is compliant with the ARM Procedure Call Standard for all functions even if this is not strictly necessary for correct execution of the code Specifying fomit frame pointer with this option will cause the stack frames not to be generated for leaf functions The default is mno apcs frame mapcs 32 Generate code for a processor running with a 32 bit program counter and conforming to the function calling standards for the APCS 32 bit option This option replaces the m6 option of previous releases of the compiler and is now the default mapcs stack check Generate code to check the amount of stack space available upon entry to every function that actually uses some stack space If there is insufficient space available then either the function __rt_stkovf_split_small or __rt_stkovf_split_big will be called depending upon the amount of stack space required The run time system is required to provide the
72. adar g chor w1 Os4op0izig cndsize 1073743452 nice 1073744044 ichar a DsbttftTES dirsize 1075659697 ndir 1073744036 Struct stat t Acwdbur struct stat honed r chor 040000000 S17 FELF O01 001 S001 honeinit ichar 0x0 j BEATE SETAL 1 tine _ot_ startup 24 9 Click the Continue button in the tool bar to move to the next breakpoint The variables that have changed value turn color in the Local Variables window see results in Figure 6 51 for line 105 in the main c example i MX GNU X Tools User Guide E 93 section 6 How to Use Visual GDB Debugger Figure 6 51 Local Variables Window after Setting Breakpoints Local Variables Yor Loble Nome Vole argc 1 Chor Osbrr trond count 1075859992 quiet i batch sunarg chor Oxd execarg chor 0x0 coreo g chor Oxd cdarg chor 0x0 ttyarg chor Ox print_help 0 pint version 0 chor Ox40000210 cmdsize 07374452 ncnd 1073744044 chor Osbrr try ySa 1075859992 IN PST 44054 struct stat struct stat chor Os40000000 51 77ELF 00 40015001 honeinit chor 0x0 i 1073747220 tine at_stor tup z4 10 Click the Continue button two more times to step through the next two breakpoints and notice that the values of the local variables change compare results from the main c example program in Figure 6 49 and results in Figure 6 52 Repeat with the Continue button to step through breakpoints and notice the
73. aeesueeeseeeseass 87 6 15 USING the Function Browser VVINGOW iscectceaswersdetas cred sseczeessaensanseaceeicattwsaceven sactuansanowaimastabetaeuseaedes 88 6 16 Using the Processes Window for Threads c ccccceccceccceeeeeeeeceeeceeeeaeeeceeeesceseeeesueeseeeseneesaeessnees 89 6 17 Using the Help Wind ow ccccccccseccececeecceeceecceeeceeeseeesaeecaessaeesaeesueeeueseusseeesaeesseesaeeseeeseesseeseesas 89 6 18 Examples of Debugging with Visual GDB ccc ccccceccceeeceeeeceeeceeeeeeeeeeeeseeeseueeseeeseeeeseeesaneeaaees 90 6 18 1 Selecting and EXAMINING a Source Fle ce ccecccssecccsseeccseeccsuecssuseceseeessaeeessseeessueeesseessseeessseeeesqeeessneessseeees 90 6 18 2 Setting Breakpoints ON Multiple TACAS ccccccccsecccssecccseeccsueeensucessseeessseeessueeessueeesseeessseeesseeesseessseeees 94 6 19 Visual GDB with JTAG BDM Debug Agents ccc cece ceccceeccceeeceeeeeeeeeeeeeseeeseeeeaeeeseeeeseeeseueeseeesaess 95 6 19 1 Abatron BDI2000 Setup and Debug with Visual GDB ccccccsecccssecccseeccseeecesueessueeesseeesssesesseeeesnesssseeees 96 5 19 2 Macraigor moDemon Setup and Debug with Visual GDB ccccccecccssccccseeccseeeesueessseecssseeesseeeessesesseeeeaes 98 SECTION 7 INTRODUCTION TO CYGWIN ccccccceccecceeceeceeseeseeeeneensenseaeeneeneeneeneeneeeesaes 107 TaN WOREOCUICING 2 y Qiao ccates cocoa E E EE E 107 DZ CVYOWIN Key OA SS ets See cs Spe io creat caesar snes ee eed
74. aight assembly language files s or S files you must use g or gstabs because the assembler will not generate any other symbol formats The C C compiler however will generate appropriate symbols for either gdwarf or gdwarf2 in addition to stabs When compiling with any debug option do not use optimization options You cannot optimize code and debug it correctly using the GNU tools i MX GNU X Tools User Guide E 49 Section 4 How to Use i MX GNU X Tools 4 7 6 Optimization iMX GNU X Tools GCC incorporates a sophisticated optimizing compiler and for most target systems it usually generates faster code than with the native compiler Any Ox optimization can be used with any fx option e g gcc Os funroll loops ffast math o outfile x infile c Here are the most commonly used compilation options O0 No optimization This is the default With optimization turned off GCC tries to generate code that is easy to debug you can set a breakpoint between any two statements and modify variables and the program will behave exactly as it should The GCC also tries to generate code quickly 01 The compiler tries to moderately to reduce both the size of the compiled code and the execution time Compilation is slower than with O0 and requires more memory 02 Enables more optimizations than 01 Compilation time is even slower the resulting code should be even smaller and faster
75. alias gt where the target alias is arm elf in our example The following simple example shows you quickly how easy it is to get a program compiled linked and executed in an Instruction Set Simulator ISS and debug it using Visual GDB xtools arm elf cr arm elf cd home test cr In the last step we assumed that the Microcross test directory either was installed in Cygwin s nome test or Linux s nome test arm elf gcc g o pascal x pascal c cr arm elf run pascal x cr The program was compiled and linked in one step and then run in the simulator Now issue the following command arm elf gdbtk pascal x cr The Visual GDB debugger is invoked and loads the target executable pascal x for symbolic debugging Click on File Target Settings and click on Connection Target and select Simulator and click OK Click on the Run icon left most icon near menu and begin single stepping To see the program output click on View Console i MX GNU X Tools User Guide E 37 section 4 How to Use i MX GNU X Tools When finished click on File Exit This concludes the simple example showing how easy it is to compile and run a program with i MX GNU X Tools The i MX GNU X Tools toolsuite is very powerful and can build any conceivable program a developer can code Now we need to go into more detail on how the i MX GNU X Tools work 4 4 2 i MX GNU X Tools Toolsuite Description The
76. ameters hit any key to continue lt HT Figure 6 66 Reboot the mpDemon H Tera Term COM1 VT File Edit Setup Control Window Help 115200 NO 192 168 0 211 255 255 2455 0 Gateway 192 168 0 250 4c Address 00 60 67 01 0a a COREMOTE ITAG speed 4 JTAG Too lt PLIARMO 8888 lt TOI Mmpbemon command Menu B Set serial API baud Rate Set DHCP option Set TCP IP Address set TCP IP mask Set TCP IP a Set OCDREMOTE Configuration Test OCDREMOTE Configuration Update License Codecs Ping TCP IP address Display Error Log kR Reboot mpbemon Type Command lt Enter gt will refresh screen gt mur Aganistro iiMX GNU X Tools User Guide E 103 section 6 How to Use Visual GDB Debugger 15 Press T and the Enter key to test the OCDREMOTE configuration you will be prompted as indicated in Figure 6 67 for a JTAG speed Press 1 and the Enter key to see if the staus returns a correct response The status should read Stopped Figure 6 67 shows Running therefore the JTAG speed is set too fast Repeat this step except enter a higher number see Figure 6 68 which shows the correct status Stopped Figure 6 67 mpDemon Configuration Test E Tera Term COM1 VT PO M E a L E R T Edit Setup Control window Help serial API baud Rate CHEF option TEPIP Address TCP IP Mask Set TCP IP See SET OCDREMOTE Con Tgurat ion Test OCDREMOTE Configura
77. ate DHCP option TCP IP Address TCP IP Mask TCP IP eatery OCDREMOTE Configuration Update License Codets Ping TCP IP address Display Error Log Reboot mpbemon Type Command lt Enter gt will refresh screen gt a CPYIP Address Bytes xxx xxx xxx wxx gt 192 168 0 211 Reboot mpDemon to run with new parameters hit any key to continue Eam B D Ae M a O a P E R 9 Skip this step if using DHCP 100 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger Figure 6 60 Enter Mask Tera Term COM1 VT File Edit Setup Control Window Help SmMULlonietroag hit any Mil NO 192 168 0 211 2 255 255 255 0 Gateway 192 168 0 250 AC Address 00 60 bf 01 0a a CDREMOTE Disabled mpDemon Command Menu Set serial API baud Rate Set DHCP option Set TCP IP Address Set TCRYIP Mask Set TCP IP e Set OCDREMOTE conti Update License code rail 5 Ping TCP IP address Display Error Log Reboot mptbemon Type Command lt Enter gt will refresh screen gt m ask Bytes xxx xxx exe eee 3255 255 255 0 Reboot ewes to run with new parameters ey to continue 10 Skip this step if using DHCP Figure 6 61 Enter Gateway Address Tera Term COM1 VT Fie Edit Setup Control Window Help gt NO 192 168 0 211 e 2992992 Gateway 192 168 0 250 AC Address 00 60 bf 01 0a a7 CDREMOTE Disabled mpDbemon command Menu
78. ave either a DB 9 connector or USB to DB 9 adapter e HyperTerminal serial communications software or equivalent software uCon is in the Cygwin home ucon directory if you desire to install it from the self extracting exe file we highly encourage using uCon over HyperTerminal it is much easier to use and has special MicroMonitor hook features e Ethernet cross over cable or hub connection to a LAN e 115 VAC Power Step 1 Setup Serial Terminal e Insure that the board is not powered on and your host computer is booted up e Connect the provided null modem serial cable to the target board and host computer s DB 9 Serial Port or alternatively e Configure your preferred Serial Terminal software with the following settings 38400 baud 8 data bits No parity 1 stop bit no flow control i MX GNU X Tools User Guide E 17 Section 3 Quick Start Guide e Connect power supply to the board and the serial terminal should show the MicroMonitor startup banner and the UMON gt command prompt Figure 3 1 shows a diagram of board connections to the host computer and power Figure 3 1 Diagram of Board Connections to Host Computer Ethernet crossover cable Keyboard Mouse Monitor AC Power Null modem serial cable ETHO COMI ttySO Serial 0 Ethernet Host Development Liana r 12VDC Power Computer g P S Step 2 Setup uMON AC rower
79. ays by using the code display drop down list box Figure 6 16 i MX GNU X Tools User Guide E 77 section 6 How to Use Visual GDB Debugger Figure 6 16 Code Display Drop Down List Box SOURCE SOURCE ASSEMBLY HIXED SRC ASH The selections in the code display drop down list box provide the following different ways to display code in the Source Window SOURCE displays source code ASSEMBLY displays assembly code MIXED displays both source code and assembly code interspersed within the Source Window SRC ASM displays a program s source and assembly code in separate panes Type a character string into the search text box Figure 6 17 Press Enter to perform a forward search on the source file for the first instance of a specific character string Figure 6 17 Search Text Box main After having specified main in the search text box the example program in Figure 6 18 shows the jump to a main function Figure 6 18 Searching for a Word in Source Code main c Source Window File Run Y iew Control Preferences HP Po PAA S a A 82 include lt sys cyguin h gt for cygwin32_cony_to_posix_path 83 endif 84 85 int 86 main argc argv int argc char argy int count 9 static int quiet D Program not running Click on run icon to start main c y moi SOURCE v Use the Shift and Enter keys simultaneously to search for the string Use the Enter key or the Shift and En
80. behaves differently in each case Werror Make all warnings into errors that is don t attempt to produce an object file if a warning has occurred Now we ll discuss how to control various features of the C and C languages There are basically three options to worry about traditional ansi and pedantic In most cases it s fairly easy to tell which you want Older C code code that pedants the standard should be compiled with traditional Newer code that has been written to conform to the ANSI standard should be compiled with ansi Either option can accept prototypes where you specify the arguments on the same line as the function name as in func char arg 46 E i MX GNU X Tools User Guide Section 4 How to Use i MX GNU X Tools Note that the ANSI C standard and traditional Kernighan and Ritchie C both define the behavior of the preprocessor either explicitly or implicitly Therefore the options listed below affect both cpp C preprocessor and GCC traditional Supports the traditional C language including lots of questionable but common practices The traditional option also supports all of the FSF s extensions to the C language ansi Supports the ANSI C standard though somewhat loosely The FSF s extensions are recognized except for a few that are incompatible with the ANSI standard Thus ANSI programs compile correctly but the compiler doesn t try too
81. bove you can add the zlmage Linux kernel to the TFS on uMON cd lt directory to linux zlmage binary gt cr ttftp lt target IP address gt put zImage zlmage cr i MX GNU X Tools User Guide E 33 Section 3 Quick Start Guide Reload romfs img Procedure Similarly to the upload procedures above you can add the romfs img root filesystem and Busybox utilities to the TFS on uMON cd lt build directory gt cr ttftp lt target IP address gt put romfs img romfs img cr 3 8 2 Other Useful MicroMonitor Commands UMON gt tfs Is List files in the Tiny File System uMON gt tfs clean Defrag the Tiny File System without deleting files uMON gt tfs init Deletes all files and defrags the Tiny File System requires network setup uMON gt tfs rm lt file name gt Delete a specific file named lt file name gt uMON gt help Shows all of the available commands uMON gt help lt command name gt Shows specific help on command name uMON gt set Shows all settings in memory UMON gt flash info Shows all flash sectors and which ones are locked and erased UMON gt flash unlock x y Unlocks sectors x lower bound to y upper bound UMON gt flash erase x y Erase sectors x lower bound to y upper bound 34 E i MX GNU X Tools User Guide Section 4 How to Use i MX GNU X Tools Section 4 How to Use i MX GNU X Tools 4 1 Introduction This section is intended to provide an abbreviated overview of
82. buttons S Sl C b C set Step single step a C source code line Step Instruction single step a machine code instruction Continue run the processor after a step or breakpoint Breakpoint set a breakpoint at specified location Control C stop execution from the keyboard For Visual GDB the GUI this will only work under a Linux host to stop the program under Cygwin you need to press the Stop button List show the source code being executed Examine show the contents of memory Info registers show the contents of all registers Set change the contents of ram or a register i MX GNU X Tools User Guide E 27 Section 3 Quick Start Guide 3 5 Visual X Tools Example The following steps describe the operation of the Visual X Tools with an example application program for the i MX LiteKit The example program was created with the Visual X Tools wizard and is setup to work with Visual GDB and the Macraigor usbDemon that is built in to the LiteKit module The following files are included in home vxtools example directory under Cygwin gdbinit GDB Initialization File for the i MX LiteKit board crt0 S Assembly source for C initialization code Idscript Linker script test c Main C source file for example program test mak Autogenerated maintained GNU style makefile for Visual X Tools test vpwhist Project history file test vig Tag database file test vxp Visual X Tools Project file test vxw Visual X Tools
83. c demos elsdemo cr make mine cr builds application minesweeper and downloads file to the target board Step 3 At the Serial Terminal uMON gt command line issue the following command to run the application UMON gt mine cr Follow the onscreen instructions to play minesweeper Cycle power to quit the game and return to MicroMonitor 3 3 Build Load and Run GX Linux and Example Applications Assumptions All necessary steps in Section 3 1 are completed and the board is ready to communicate via TFTP In addition the LiteKit expansion module board is connected to serial Ethernet and powered on This section explains how to build and load applications into the target Freescale development board using the Windows Cygwin host provided by Microcross on the Standard GX Linux Platform Since kernel and library 20 E i MX GNU X Tools User Guide Section 3 Quick Start Guide building are not provided on a Windows Cygwin host Microcross pre built the kernel and libraries on a Linux host and installed them on the Windows Cygwin host for those who want to evaluate GX Linux build applications and run them Step 1 Edit Makefile Open your favorite text editor Visual X Tools IDE Notepad WordPad etc and open Cygwin home gxlinux Makefile and edit line 44 Enter your board s IP address that you assigned in Section 3 1 Save this file and proceed to the next step Step 2 Make All Start a i MX GNU X Tools Shell by click
84. chor Ox chor Ox2 Address Oxe out of Bbounds gt chor OxbFfff994 Pod chor Od chor Oxf print_help pint version 0 cmdarg chor 04000010 cmdsize 1073743452 107374444 chor eh Osbrrrr se 1075059892 1073744036 EE RAE 1073420520 134522000 137222108 134526560 1074939112 46114602255221 37432 21699 137221900 32212238644 10717435320 134536649 137221900 137223636 _unuseds 1075047720 unused _UnUSseds zcela cudbuf struct stat homedir chor Oe40000000 STP TELF AO 0015001 6 13 Using the Breakpoints Window The Breakpoints window displays the currently set breakpoints See Figure 6 33 for the main c example program breakpoints running in the Source Window and see Figure 6 36 for the results in the Source Window WARNING Breakpoints and exceptions may not work especially if debugging C code and the Breakpoints window may be inoperative i MX GNU X Tools User Guide E 85 section 6 How to Use Visual GDB Debugger Figure 6 33 Breakpoints Window Breakpoints Ereakpoint Global Address File Line Function 0x804debl main c 103 main Ox604dec1 main c 104 main Ox804ded2 main c 106 main 0x804dedb moin c 107 main 0x804dec9 main c 105 main Single click the mouse with the cursor over a check box for a breakpoint to select that breakpoint see the breakpoint results in Figure 6 34 Figure 6 34 Selecting a Breakpoint Breakpoin
85. cify libraries 47 OSF 1 124 P p 49 Passing Options to the Assembler or Linker 51 patch 41 Patch 125 PE 125 pedantic 47 perl 109 pg 49 POSIX 59 108 122 123 preprocessing 40 preprocessor 38 Preprocessor options 47 Profiling Options 49 Program Stack 64 PROM 125 Index R r 56 RAM 125 ranlib 41 58 rc file 13 RDI 125 RDP 125 readelf 41 Registers 125 Registers Window 79 registry entries 14 Remove Carriage Returns 15 Required CFLAGS LFLAGS 59 RISC 125 ROM 125 root 11 12 36 RTOS 125 run 41 Run button 70 S S 55 sdiff 41 Search Text Box 78 sed 109 Selecting a Breakpoint 86 Selecting a Variabl 84 Setting Breakpoints 75 91 shared 48 Shell Commands 63 Signals 66 simulator 112 size 41 Solaris 122 125 Source Browser 89 Source File Selection 90 Source Files 68 Source Preferences Dialog 71 Source Window 70 74 Sparc 125 Stabs 125 Stack Window 79 Starting gdb 63 static 48 Status Text Box 77 Stop button 71 Stopping gdb 63 strings 41 strip 41 stub 123 125 Sun 124 125 i MX GNU X Tools User Guide E 129 Index Symbol Table 66 System Requirements 9 T tar 109 tarball 13 36 Target 125 Targets 8 tcl 109 TCP IP 125 telnet 109 125 Temporary Breakpoints 86 texinfo 109 textutils 109 Thread
86. cony_to_posix_path x Hendif int main argc argv 87 int argc char ar gy Jf int count static int quiet D Program not running Click on run icon to start jain c w main SOURCE 5 Use the Shift and Enter keys simultaneously to search for the string Use the Enter key or the Shift and Enter keys to repeat the search Type with a number in the search text box and press Enter to jump to a specific line number in the source code The example program in Figure 4 46 shows a jump to the line 86 Figure 6 46 Searching for a Specific Line in Source Code main c Source Window File Run Y iev Control Preferences Th A A 8 a Ao xc 95 81 include lt windows h gt for MAX_PATH 82 include lt sys cygwin h gt for cyqwin32_conv_to_posix_path 83 endit 64 85 int 86 main argc argv 87 int argc char argy int count Program not running Click on run icon to start rain c x main source Setting Breakpoints and Viewing Local Variables A breakpoint can be set at any executable line in a source file Executable lines are marked by a minus sign in the left margin of the Source Window When the cursor is in the left column and it is over an executable line it changes into a circle When the cursor is in this state a breakpoint can be set The following exercise steps you through setting four breakpoints in a function as well as running
87. ction with the target To specify preferences of how source code appears and to change debugging settings select Preferences Source from the Source Window The Source Preferences dialog opens Figure 6 5 Figure 6 5 Source Preferences Dialog Source Preferences Colors Pe Normal Breakpoint Stack aa Browse Thread Breakpoint E Tenporary Breakpoint Mixed Source Tracepoint Mouse Button 1 Behavior variable Balloons v wy oi A wy Off T5 aj Tab Size 4 OK Apply Cancel Left click any of the colored squares to open the Choose color dialog with which you can modify the display colors of the Source Window Mouse Button 1 Behavior sets and clears either breakpoints or tracepoints points in the source code with an associated text string the default is for setting breakpoints Variable Balloons lets you display a balloon of text whenever the cursor is over a variable in the Source Window the balloon displays the value of the variable see Figure 6 11 for an example On is the default selection Selecting Tab Size sets the number of spaces for a tab character in the Source Window The Source Window has the following functionality and display features when using the Source Preferences dialog settings e When the executable is running in a debugging process the location of the current program counter displays as a line with a colored background PC e When the
88. d in the file GCC performs this task by internally invoking the linker GCC also cleans up by deleting any object files that it created from source files however it does not cleanup any pre existing object files that you specified on the command line GCC normally invokes all of these compilation steps when converting a C source program into an executable By using command line options for GCC these steps may be invoked separately or in some combinations This provides some flexibility when building large programs or using assembly language sources or debugging 38 E i MX GNU X Tools User Guide Section 4 How to Use i MX GNU X Tools Figure 4 1 i MX GNU X Tools Flow Diagram Sou rce Files c ANSI C Source cc C ANSI C Source S C Style Assembly Source goes through CPP s Assembly Source no preprocess bypass CPP j Java Source f Fortran Source GCC G Options CFLAGS LFLAGS _ y z gt cpp a Ss eo S mcpu cc1 cc1plus gcj g 7 C TCO Cc j f S Control Program Assembly gas a Source Files Wa gt C Ss a a 6 Librarian l ar i Precompiled 0 y WI T Idscript gt Linker Libraries Libraries Id e ra lib a LD Scripts ooo Id X Alternate ae Binary mooo Output Exec
89. d usr bin cr Is cr shows all examples to execute examples perform the next step hello x cr executes hello world program There are approximately 20 other programs that can be executed in the same manner Tryout as many of the examples as you wish Read the next section to become more familiarized with MicroMonitor Step 6 How to Add Your Own Applications The fastest way to get your own Linux application on the target board is to copy your application named with a x file extension into the examples directory which is under the build directory and issue the following command in the xterm Bash shell make install apps romfs cr make load cr reload your images to the target board After uploading three files to the target board startlinux zZimage and romfs img you can manually start GX Linux by issuing the following commands cr get a command prompt after upload reset cr get the board in a refresh state startlinux cr Linux boots to a user prompt On the target board in the usr bin directory are example programs including the one you just created and copied into the examples directory Issue the following commands cd usr bin cr Is cr You can see all examples they have a x file extension on them To run any example issue the by name command double x cr float x cr hello x cr etc Step 7 Useful Linux Commands cat proc
90. database _ A toolkit of widgets graphical objects for the Tcl programming system Show full path of commands _ _ SSS O A compression utility compress and uncompress files ____ iMX GNU X Tools User Guide E 109 Appendix 1 ARM Toolsuite Appendix 1 ARM Toolsuite ARM Advanced RISC Machines alias arm elf Freescale Semiconductor Inc RISC Von Neumann 32 Bit Fixed Instructions 16 Bit Thumb mode 64MB Linear Endian Selectable CYCLE RATE Core Dependent APPROX INSTRUCTION THROUGHPUT PIPELINED 5 Load Store 8 Exceptions 2 External Interrupts normal fast ARM 2 250 3 6 60 600 610 620 ARM 7 7m 7d 7dm 7di 7dmi 70 700 700i 7 10 7 1xxc 75xxfe 7tdmi ARM 8 810 9 9e 920 920t 926ejs 940t 9tdmi Pe ARM 1020t 1026ejs StrongARM 110 1100 Depends on core variant ARM 1136js 1136jfs XScale iwmmxt ep9312 Architectures armv2 armv2a armv3 armv3m armv4 armv4t armv5 armvot armvote armv6j iwmmxt Based on current independent studies the ARM is the most popular RISC processor for embedded applications Its architectural specification is highly scalable and a number of ATTRIBUTES variants have been defined and produced by several manufacturers As a result a wide range of configurations and performance levels exist giving embedded designers many flexible design options The simple instruction set architecture is easy to learn yet powerful and optimized for compilers 110 E i MX GNU X Tools User
91. dled as in a list of tasks or specifically the contiguous parts of the data associated with one call to a specified function in a frame The frame contains the arguments given to the function the function s local variables and the address at which the program is executing The Stack window displays the current state of the call stack Figure 6 20 where each line represents a stack frame the line with the main c executable had been selected for the example Figure 6 20 Stack Window __libe_stort_main Click a frame to select or highlight that frame The source window automatically shows the source code that corresponds to the selected frame If the frame points to an assembly instruction the source window changes to assembly code the corresponding source line s background in the source window also changes to the stack color 6 9 Using the Registers Window The Registers window Figure 6 21 dynamically displays registers and their contents Figure 6 21 Registers Window Registers Register QxG2dddod et0 Ox af fe de 0x OO OO OO Ox OO OO OO 0x OO OO OO Ox 00 00 00 Ox 3f fe 80 Oxbffffood ste Ox 3f fe 80 00 00 00 00 00 00 00 1 Mat st Ox 40 ic f4 00 00 00 00 00 i OxBO4ddebO fetrl Oxf fProstr 0x246 ji Oxf fF FO000 ftag Oxf fPrrrrr Ox25 Ds80564c6 Oxf ff foo2b Oxbfff c50 07d F i MX GNU X Tools User Guide E 79 section 6 How to Use Visual GDB Debugger To change the prope
92. documentation that you have the option of installing is html based and you can find the documentation in a directory named html in the Cygwin root directory Create a desktop shortcut if desire to reach the help index in the html subdirectory of Cygwin Below is a short description of the tools utilities and programs listed above The best place to get more information on Cygwin is to go to the Cygwin home page on the web www cygwin com Tool Utility Program Description bash GNU Bourne Again Shell sh compatible command language interpreter IEEE POSIX shell An arbitrary precision calculator language binutils An assortment of GNU utilities including ar nm objcopy ranlib size strings strip c filt addr2line nlmconv windres GNU Project parser generator yacc replacement An LALR 1 parser generator A compression utility Copy files to and from archives like tar Concurrent Versions System a version control system for managing source code A Unix Linux portability application layer on Windows OS diffutils Includes file comparison utilities cmp diff diff3 sdiff Determine file type GNU file utilities including chmod chown chgrp cp dd df dir dircolors du install ginstall Is In mkdir mkfifo mknod mv rm rmdir sync touch vdir Programs for finding files Replacement for the lex scanner generator Print a random hopefully interesting adage ARPANET file transfer program GNU assembler A pattern
93. e the following command UMON gt Icd_tst cr Input any key to change the LCD color repeat To exit press x key 30 E i MX GNU X Tools User Guide Section 3 Quick Start Guide Step 2 In the same terminal shell with MicroMonitor booted to a prompt issue the following command UMON gt ads cr Press on the LCD screen at various points and observe the serial terminal display Computations of pen up and pen down X and Y parameters will display on the screen To exit press x key This concludes the simple LCD tests 3 7 Rebuild MicroMonitor and Reflash Board 3 7 1 Normal Reflash Procedure In the event that you want to modify MicroMonitor and reflash the board with the newly built MicroMonitor here is the procedure to rebuild load and run the new MicroMonitor image This procedure assumes you have a working MicroMonitor in flash If for any reason that MicroMonitor becomes corrupted in flash and will not boot correctly you will need to use the JTAG port on the expansion board or the usoDemon on the module board to load a RAM image and use it to reflash memory with a binary image Follow the procedure in Section 3 5 2 below Otherwise use the following procedure to reflash MicroMonitor Step 1 Open ai MX GNU X Tools Shell Step 2 Issue the following commands cd home umon umon_ports csb536fs cr for MXL port substitute csb535fs for MX21 bashrc cr dot space bashrc sets dependency path
94. e to Watch Dunp Memory at get_run_tine Open Another Source Window Open Source in external editor Add lt selected expression gt to Watch opens the Watch Expressions window _ lt selected expression gt in the example was get_run_time and adds a variable expression to the list of expressions in the window Dump Memory at lt selected expression gt opens the Memory window which displays a memory dump at an expression Open Another Source Window opens another Source Window for displaying a program in an alternate format see Figure 6 16 and its accompanying descriptions Open Source in external editor opens the program in an alternate editor such as Xemacs 6 6 Source Window Menus and Display Features The Source Window has the following menu items many of which correspond to the toolbar buttons e File has the following menu items Edit Source allows direct editing of the source code Open invokes the Load New Executable dialog Source invokes the Choose GDB Command File dialog Exit closes the Visual GDB program O O O O e Run has the following usage Attach to Process attaches thread processes for debugging see Using the Processes Window for Threads in this Section Download downloads an executable to a target Run runs the executable e View displays the following windows Stack Figure 6 20 Registers Figure 6 21 Memo
95. ec symbolsrec tekhex binary and ihex Depending on the compiler options used the input bfdname will change e g compile for big endian as opposed to little endian The default output of the ARM is elf32 littlearm or elf32 little xtools arm elf cr arm elf cd home test cr arm elf gcc o div x div c cr arm elf objcopy S l elf32 littlearm O binary div x div bin cr Note The S strips all symbols out to make the object as small as possible The I is specifying the input target format bfdname and the O specifies the output target format bfdname The input file is div x and the output file is div bin 4 11 Creating Updating Libraries The command ar creates libraries or archives of object modules They are similar to the Unix Linux utilities with the same names except that you do not need a separate ranlib This section gives a brief description of how to use these utilities in the i MX GNU X Tools command shell In naming a library for use with i MX GNU X Tools always use the prefix lib and suffix extension a with your static library name this is the GNU convention and is necessary for GCC to automatically scan the library at link time so the syntax for linking a particular library say libm a the math library is Im To create a new library use the ar command as follows lt target alias gt ar rs lib lt name gt a list of files cr The option r indicate
96. ed Therefore the order of libraries and object modules on the command line can be critical this is why lI options come after the filenames Consider the command lt target alias gt gcc l mine first c cr This command searches for the library file libmine a to resolve any function references needed for linking however the linker has not yet processed the object module for file4 o created by the GCC command and normally deleted if compilation and linking are successful Therefore there are no outstanding function references and the library search has no effect If the program needs this library the GCC command produces Undefined symbol messages during the loading phase and the linker does not produce an executable file To perform this compilation correctly enter the command lt target alias gt gcc first c Imine i MX GNU X Tools User Guide E 45 Section 4 How to Use i MX GNU X Tools Now the loader searches the library after processing first c and is able to resolve any references requiring this library When compiling a C program you often don t need to list any libraries explicitly on the command line The GCC automatically searches the system call library I O library and run time initialization routines If you use any math routines you ll need to search for the math library Im if you re compiling C code you need to include the C libraries lstdc 4 7 Comp
97. ed then help will also be passed on to the various processes invoked by gcc so that they can display the command line options they accept If the Wextra option is also specified then command line options which have no documentation associated with them will also be displayed target help Print on the standard output a description of target specific command line options for each tool version Display the version number and copyrights of the invoked GCC Uname Some symbols usually those identifying the type of computer system you re compiling on are automatically defined by the compiler If you want to suppress one of these symbols use the Uname option This is equivalent to putting undef name at the beginning of each source file If you have an include file in a non standard directory specify this directory in a l option For example suppose you have two directories for code usr src for source files and usr neaders for header files While you re compiling in the usr src directory you can tell GCC where to find the header files through the command lt target alias gt gcc l headers example c Figure 4 2 below summarizes the three primary modes of GCC with switch actions 44 mi MX GNU X Tools User Guide Section 4 How to Use i MX GNU X Tools Figure 4 2 Three Primary Modes of GCC GCC Switch Options Default Executable a
98. eeeeseeeeeeeeneeeesaes 11 2 1 Install i MX GNU X Tools ON Windows HOSt ccccceccceeceeeceeeeseeeeeeeeeeeeeeeeeeeeeeseeeneeesesseeseesaeenaaees 11 2 2 Uninstall i MX GNU X Tools on Windows Host cccceecceeeceeeeeeeteeeteeeceeeceeeseesseeeseeeueeeeetseetaeenaess 12 2 3 Install iMX GNU X Tools on Linux HOSt annannonnennensnnnnnsnnnnennsrronrsrrorrerrerrsrrrrrerrrrrrrerrorrerrerrrerrerre 12 2 4 Uninstall i MX GNU X Tools on Linux Host ccc cecc cece eee ence eeeeeeeteeeteeeeeeeeaeeeeeeeeeeseeseeteeeeeeaeaees 14 2o SOUND HOSE ies tcestcap ner E E E E E E EAEE EAE T E EE E EAE EE EAEE 14 2 6 Troubleshooting Guide for Installation Problems cccccccccesecece sees cece eeeeeeeseeeseeeeseeseeeeaeeesaees 14 2 6 1 Windows Cygwin Related Problems sccccccseecccsnececssaeeeesaeeeeesaaeeeessaneeeesaaeeeessaeeeesaaneesaaeneeessaaeeessageneeeas 14 2 6 2 Make exe Related Problems cccccccccccscccseenseensuensuetsuecsuecsuenssensuensuensuensuensuensuensuenseesessnsececuessuessnessuessnesanes 15 2 6 3 Remove Carriage Returns in Source And Make FIl S cccccccccccsecccsseecssseceesueesseeecesuecessusessseeessesesseessaeees 15 2 6 4 xtools install Command Fails ON LINUX HOSt ccccccecccsecccneecceeecseeceeeessuseesesenseensesenseesseeessesesseneseneeesneessnsees 16 SECTION 3 QUICK START GUIDE cccccccceessecsecescesceeeeeeseeeeeeesueeeeeeseeeeeneeeneeeeeeneenesaeeaes 17 od E
99. een instructions for installing OCD Commander and USB drivers After installation reboot the host machine so that the new drivers are available to install Connect the LiteKit provided USB cable between the host computer and target module The Windows operating system should detect the USB connection and prompt the user to install the appropriate drivers The host computer should respond with Found New Hardware Wizard dialog box Select Install the Software Automatically and click on Next Click on Continue Anyway on the Hardware Installation dialog Click on Finish to complete the first of two drivers installation procedure The second Found New Hardware Wizard will pop up and you will need to repeat exactly the same inputs as described above for installing the first driver Now that both drivers are installed the usoDemon is now useable from this host machine Double click on the desktop icon for usoDemon Finder which was installed with OCD Commander The usbDemon finder will display the device number assigned to the usoDemon that is connected Write this device number down for future reference when we activate the OCDRemote Close the usbDemon Finder and proceed to the example program 3 4 1 Example Program Under the Cygwin directory nhome debug example there is an example i MXL program that can be debugged in a remote target session using GDB Visual GDB and the built in Macraigor usoDemo
100. eeseessneeeaes 74 6 4 Left column functionality for the Source WINKOW cccceccceececeeeceeeeceeeeeeeeseeeeaeeseeeceeeeseeeseeeseeenaes 75 6 5 Right Column Functionality for the Source Window ccccccccceecccececeeeeeeeeseeeeeeceseeeeseeseeesaneeseeeeaes 76 i MX GNU X Tools User Guide E v Contents 6 6 Source Window Menus and Display Features ccccccecce cece eeceaeeeceeceseeeeeeececeseeeeseeeseeeeseeesaeesaeees 76 6 7 Below the Horizontal Scroll Bar of the Source WINdOW cccccececececeeeeceeeceeeeseeeeeeeeseeeeeueeaaeesaees 77 0S USME Stack WINdOW ession ospi ern EEEa EE EAA AENA 79 6 9 Using the Registers VVINGOW oo cicccteesoweces cendemnvessacusance nates bene enonbandsnsecosdactetionvaueeisaxcaSarasuscanreuecacesedueeaste 19 6 10 Using the Memory Window ccccccccecccecece eee eeseeca seca eeseeeseeeseeeseeeseeeseeeaeesseeseeeseeeseeeseeesueesaeeseeeses 80 6 11 Using the Watch Expressions VVINGOW cosccestcecnteecntetecaniesedneseutessecesdboccdbuch pivecste Sonkedeahecawedacdeences tees 81 6 12 Using the Local Variables WiIndOW ccccccceccceecceeeceeeeeeeeeeeeeeeeeeseeese esse eeseeeeeseeesaeesaeeseesaeeeeeeees 83 6 13 USING the Breakpoints VVINGOW sicc2ccncisccatnccenscensccepecceeecnoenigetectiventanesdaciecscseeieerende gare euignegseendedindeentes 85 6 14 Using the Console Window ccccccccceecceseeceeeceeeecuceceeeceeeeseuecsaeeseeeaueeseeesaueesaeessuees
101. egexp ha starts with contains ends with matches regexp The Files group limits the search to highlighted files Click individual file names to select or deselect that file The list of matching files refreshes when any search parameter changes Hide h files if checked disallows h header files to display Select All selects all listed files The Functions group matches all functions in the selected file s Breakpoints has two available buttons Delete or Set Delete removes a breakpoint previously set at the first executable line of the selected function while Set sets a breakpoint at the first executable line of the selected function Both of these will work on any and all selected functions in the listing If all functions are selected they all get or lose a breakpoint View Source Hide Source allows you to toggle between displaying or hiding a file in a source browser Figure 6 41 the source browser has the same functionality as when using the Source Window 88 m i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger Figure 6 41 Function Browser Window with Source Browser Show if funtion notches regexp Files s hice h files Select All br eckpcints Delete Set y Hide Source J int cont 39 static int quiet 10 static int batch There are four display and selection fields below the horizontal scroll bar the same functionality as using the Source Window the status text box F
102. es of system calls with sub routines To write your own crt0 s or crt0 c module you need specific information about your target see MC Embedded Systems pdf in the i MX GNU X Tools CD docs directory also in Cygwin docs for details on how to create the C runtime environment 4 10 Object Translation ELF to Binary SREC etc Most of the i MX GNU X Tools toolsuites produce an Extended Linker Format ELF object file as the default format and it can be used during debug and testing however the final code needs to be stripped and translated to another format It is beyond the scope of the user guide to explain all of the various formats which include COFF ECOFF binary srec tekhex ihex symbolsrec etc i MX GNU X Tools User Guide E 57 Section 4 How to Use i MX GNU X Tools Here is a quick example of how to use objcopy refer to the binutils documentation in the docs directory on the distribution CD or in the Cygwin docs directory for details on how to use From the Shell issue the following commands substitute your target alias and bfdname as necessary To see what bfdnames are available issue the command lt target alias gt objcopy cr All of the objcopy options appear in the Shell and at the bottom of the screen is a list of the target bfdnames that can be used to specify the input and output formats The ARM for example has 9 bfdname names elf32 littlearm elf32 bigarm elf32 little elf32 bit sr
103. executable has finished running the background color changes Browse When looking at a stack backtrace the background color changes to another different color Stack To set other preferences for a debugging session select Preferences Global from the Source Window The Global Preferences dialog opens Figure 6 6 where you select a specific font and type size for the text in the windows for Visual GDB i MX GNU X Tools User Guide E 71 section 6 How to Use Visual GDB Debugger Figure6 6 Global Preferences Dialog Global Preferences Toone Windown style Toon Bk FBCOBPabow POL Sia S679 Ag Pont REZDEF a bogel zat le ABCORPsboweTOLZ IA 37g z 1 An Default Pont ta ji ABCORPSboaeTOLSIAS67E9 r Statue Far Pont rier F ues wmwiltin image ae icon Uee Webecape bo View Help Filer J Tracing features dieablLed Figure 6 6 Global Preferences dialog icons allows you to select the appearance of the toolbar buttons as the Windows style icon Set the default see Figure 6 7 or the Basic Icon Set see Insight s Help menu for more information e Fonts is for selecting font family and size e Fixed Font sets the font for the source code display panes e Default Font sets the default font for list boxes buttons and other controls e Status Bar Font sets the font for the status bar e Tracing features disabled disables setting tracepoints 72 E i MX GNU
104. f source demangled or internal form for C symbols p asm dem on off demangle C symbols in machine instruction output p elements limit number of array elements to display p object on off print C derived types for objects p pretty off on struct display compact or indented p union on off display of union members p vtbl off on display of C virtual function tables show commands show last 10 commands show commands n show 10 commands around number n show commands show next 10 commands Table 5 18 Working Files Command Syntax file file use file for both symbols and executable with no arg discard both core file read file as coredump or discard exec file use file as executable only or discard symbol file use symbol table from file or discard load file o load file display working files and targets in use iMX GNU X Tools User Guide E 67 Section 5 How to Use Command Line GDB Table 5 19 Source Files show previous ten lines list lines display source surrounding lines specified as line number in named file file Jnum beginning of function in named file file function off lines after last printed off off lines previous to last printed off line containing address address list from line f to line info line num show starting ending addresses of compiled code for source line num Table 5 20 GDB under GNU Emacs Ms si Steponeline step S Mn st mextline nex S Mi i step one ins
105. fitness for any particular purpose iMX GNU X Tools User Guide Supports Product Part Number 336 75397 October 2005 i E i MX GNU X Tools User Guide Contents CONTENTS SECTION 1 INTRODUCTION c cccccccecsessecescesceseeseeceeeeeeeseeneeeeseeeecaeeeseeeueseesaeeseesaenaeaeeaeeas T7 LIT Ware LMA GNUX TOOS M Z o caesar cociincicnuednnne rr E eE E ETE NEE T 12 Acknoweedgeme NiS sses EE EE EAE Aae T ko ICE MS SONOS CIN essieu a a a a eE T 1 4 T olsuite C MpPONEN S sessies innia nnana E a E Eaa ETa 8 1 4 1 Naming Conventions Used in GNU X TOOIS ccccccscccccseecccsnecccseeesseecesseeessueeessneeesseeeessesessseeesaesessasesessneesssanes 8 LAL T a E E E EEE E E E E E E EE 8 1 5 System Requirements and PrerequiSiteS ccccecceecceecceeeceeceseceseeeseteeeteeteeetaeeteeesaeeeaeeeueeeeetaneenaes 9 1 5 1 System Requirements Windows Host Version cccccseecccceneeeeeaseeeeesaueessaueeeessaeneessaueeeesaneesssaeeessaenessanes 9 1 5 2 System Requirements Linux Host Version 1cccccsccccccnseseccnsccecensasuecausesensausecnsaususesausesensaussensanesecsansesensans 9 16 Compatible RTOS OS Sofware scinciccsncahvssvanenrdiascyacnaniddsoiennawsnnoexduneteucnrteiraledeneaneiiaasioerseseesaparearateans 10 1 7 Compatible JTAG BDM Hardwat e ccccccceecceectsecceeeceeeneecnneceseceeecseeteeeteeesecsueeeueeeeeeseeteeeeeeeees 10 SECTION 2 INSTALL AND SETUP PROCEDUREG ccccecseceeceeeeeeeeeee
106. for further optimizations With the funroll loops option GCC unrolls all loops that have a fixed iteration count known at the time of compilation Loop unrolling is another risky optimization it can improve performance but it can also penalize performance significantly the object file becomes larger which can significantly hurt cache performance Compile time also increases 50 E i MX GNU X Tools User Guide Section 4 How to Use i MX GNU X Tools 4 7 7 Passing Options to the Assembler or Linker The GCC allows you to pass options directly to the assembler or linker when they are involved Wa options Pass the options to the assembler Wl options Pass the options to the linker In both cases the option list is just a list of options recognized by the assembler or the linker There must not be any spaces in the list options in the list are separated by commas Here is an example that is both instructive and useful producing a listing of the assembly language generated together with C source listings To do this we need to pass the alh options to the assembler generate listings of assembly code and high level source we also need to pass the L option to the assembler retain local labels And we need GCC s g option generate additional symbols for debugging the additional symbols tell the assembler where to find the source code The resulting command looks like this lt
107. function name embedded immediately preceding this location and has length pc 3 amp OxffOO0000 mthumb Generate code for the 16 bit Thumb instruction set The default is to use the 32 bit ARM instruction set Generally this option is used with the mthumb interwork mtpcs frame Generate a stack frame that is compliant with the Thumb Procedure Call Standard for all non leaf functions A leaf function is one that does not call any other functions The default is mno tpcs frame mtpcs leaf frame Generate a stack frame that is compliant with the Thumb Procedure Call Standard for all leaf functions A leaf function is one that does not call any other functions The default is mno apcs leaf frame mcallee super Gives all externally visible functions in the file being compiled interworking an ARM instruction set header which switches to Thumb mode before executing the rest of the function This allows these functions to be called from non interworking code mcaller super Allows calls via function pointers including virtual functions interworking to execute correctly regardless of whether the target code has been compiled for interworking or not There is a small overhead in the cost of executing a function pointer if this option is enabled Compiler Defined Symbols and Standard Search Directories From the command line in i MX GNU X Tools Shell type xtools arm elf cr arm elf gcc v E cr You will ge
108. hard to reject non conformant programs or programs using non ANSI features pedantic Issues all the warning messages that are required by the ANSI C standard Forbids the use of all the FSF extensions to the C language and considers the use of such extensions errors As the GCC manual points out pedantic is not a complete check for ANSI conformance it only issues errors that are required by the ANSI standard 4 7 3 Preprocessor options The following set of options control the cpp preprocessor from the command line M Read the source files figure out which files they include and output lists of dependences for make There is one dependency list for each source file The dependency lists are sent to standard output and compilation doesn t proceed past preprocessing i e M implies E This option can make it much easier to generate correct makefiles C The preprocessor normally deletes all comments from the program With C it doesn t This flag may be useful in conjunction with E when you are trying to make sure that the preprocessor is doing what you intended In such cases leaving you comments in may be handy The C option doesn t automatically imply E but GCC won t let you use C on the command line unless E is also present 4 7 4 Options to Specify Libraries Paths and Startup Files The following options are common for embedded developers but not in nati
109. his value function It will be executed if the function tries to return mlong calls Tells the compiler to perform function calls by first loading the mno long calls address of the function into a register and then performing a subroutine call on this register This switch is needed if the target function will lie outside of the 64 megabyte addressing range of the offset based version of subroutine call instruction Even if this switch is enabled not all function calls will be turned into long calls The heuristic is that static functions functions which have the short call attribute functions that are inside the scope of a pragma no_long_calls directive and functions whose definitions have already been compiled within the current compilation unit will not be turned into long calls The exception to this rule is that weak function definitions functions with the long call attribute or the section attribute and functions that are within the scope of a pragma long_calls directive will always be turned into long calls This feature is not enabled by default Specifying no long calls will restore the default behavior as will placing the function calls within the scope of a pragma long_calls_ off directive Note these switches have no effect on how the compiler generates code to handle function calls via function pointers msingle pic base Treat the register used for PIC addressing as read only rather
110. i MX GNU X Tools User Guide Section 4 How to Use i MX GNU X Tools not request listing output with one of the a options the listing control directives have no effect The letters after a may be combined into one option e g aln a cdhimns Turn on listings in any of a variety of ways ad __ Omit debugging directives _____ _ al ac ah Include assembly am Include macro expansions Omit forms processing Include symbols Set the name of the listing file You may combine these options for example use aln for assembly listing without forms processing The file option if used must be the last one By itself a defaults to ahls PDO ignore defsym sym value Define the symbol sym to be value before assembling the input file value must be an integer constant As in C a leading Ox indicates a hexadecimal value and a leading 0 indicates an octal value f Fast skip white space and comment preprocessing assume source is compiler output Warning if you use f when the files actually need to be preprocessed if they contain comments for example as does not work correctly Generate stabs debugging information for each assembler line This may help debugging assembler code if the debugger can handle it Print a summary of the command line options and exit Add directory dir to the search list for include directives You may use as many times as
111. ide Appendix 1 ARM Toolsuite ltorg Start a new literal pool Opcodes For detailed information on the machine instruction set see this manual ARM Architecture Reference Manual Addison Wesley ISBN 0 201 73719 1 Here is a recommended book to get a lot of system developer information on the ARM architecture ARM System Developer s Guide Morgan Kaufmann Publishers ISBN 1 55860 874 5 alk paper authors Andrew N Sloss Dominic Symes Chris Wright 2004 NOTES amp ERRATA iMX GNU X Tools User Guide E 119 Bibliography Bibliography 1 Comparing amp Merging Files David Mackenzie Paul Eggert amp Richard Stallman Free Software Foundation 1996 2 Cygwin For Windows NT Cygnus Solutions Inc 1999 3 GNUPro Auxiliary Development Tools Red Hat Inc 2001 4 GNUPro Development Tools Red Hat Inc 2001 5 GNUPro Compiler Tools Cygnus Solutions Inc 1998 6 GNUPro Compiler Tools Red Hat Inc 2001 7 GNUPro Debugging Tools Cygnus Solutions Inc 1998 8 GNUPro Debugging Tools Red Hat Inc 2001 9 GNUPro Libraries Cygnus Solutions Inc 1998 10 GNUPro Libraries Red Hat Inc 2001 11 GNUPro Utilities Cygnus Solutions Inc 1998 12 GNUPro Utilities Cygnus Solutions Inc 1999 13 GNUPro Toolkit Cygnus Solutions Inc 1998 14 GNUPro Toolkit Getting Started Guide Red Hat Inc 2001 15 GNUPro Tools for Embedded Systems Cygnus Solutions Inc 1998 16 GNUPro Tools for Embedded Syste
112. igure 6 13 the function drop down combo box Figure 6 14 and the code display drop down list box Figure 6 16 see the figures and their accompanying explanations for specific information 6 16 Using the Processes Window for Threads The Processes window dynamically displays the state of currently running threads WARNING Threads support is not available for all targets The Processes window will display a list of threads and or processes of an executable that you are debugging The exact contents are specific to each operating system The first column is the thread number used internally by the debugger to track the thread This number is also used by the command line interface in the Console window when referring to threads The rest of the columns are dependent on information coming from the operating system The Source Window displays the current location and source for a current thread or process To change the current thread click on the desired thread in the Processes window and the debugger will switch contexts updating all windows The current thread will highlight Having set a breakpoint on a line or function stop execution and return control to the debugger for every thread that hits a set location To seta breakpoint on a specific thread or threads use the Source Window See also Setting Breakpoints and Viewing Local Variables and Setting Breakpoints on Multiple Threads in this Section 6 17 Using the Help Window Invoke the He
113. ilation Options The following sections discuss other important options that are available with the GCC There are many many other options perhaps several hundred all together that control various details of compilation and optimization The chances are that you will never need these but it won t hurt to familiarize yourself with the complete documentation for GCC Complete coverage of GCC options is provided in Using and Porting GNU CC reference 20 4 7 1 Displaying compiler behavior The v verbose option prints the compilers version number and complete details about how each pass is executed This option is particularly useful for finding out exactly which options your program is being linked with 4 7 2 C Language Options We ll start by listing a few options for controlling the warning messages that GCC produces There are many options for controlling warnings it s possible to request or inhibit many warning messages on a per message basis We re not sure that s really useful we ll limit ourselves to a few options that control large group of messages W Suppress all warning messages W Produce some additional warning messages about legal but questionable coding practices Wall Produce even more warning messages about questionable coding practices Wtraditional Produce warning messages about code that is legal in both the Kernighan and Ritchie and ANSI definitions of the C language but
114. iler that produces assembly language code from the processed C files e target alias gdb Invokes the GNU Debugger with command line input see Debugging with GDB in the PDF files on the i MX GNU X Tools CD e target alias gdbtk Invokes the GNU Debugger with a visual GUI interface called Visual GDB by Microcross a k a Insight target alias as Invokes the GNU assembler that produces binary code from the assembly language code and puts it into an object file e target alias d Invokes the linker that binds the code to addresses links the startup file and libraries to the object file and produces the executable binary image 4 4 Using the 1 MX GNU X Tools Toolsuite The first step to developing code with the i MX GNU X Tools toolsuite is creating and editing the source code Microcross provides the Visual X Tools IDE as companion product for code editing and project management however a programmer can use any text line editor to create source files and makefiles and use the i MX GNU X Tools as the production build environment Free editors under Cygwin include VIM an improved VI editor clone and Xemacs a powerful editor and project manager Under Linux the user also has a wide variety of choices including the Microcross Visual X Tools IDE and GNU Xemacs edit see docs in the Linux distribution 4 4 1 Simple Example Start a shell xterm on Linux and i MX GNU X Tools Shell on Windows Cygwin and issue the command xtools lt target
115. ine executable programs The term may also refer specifically to the tool that translates from source to assembly language Debugger A tool that allows programmers to examine and control a nl program typically for the purpose of finding errors in the program The layout of debugging information within an object file format Debug formats include stabs COFF DWARF and DWARF 2 the program being debugged include DWARF 1 1 1 2 amp extensions to 2 both for workstations amp embedded uses ELF Extended Linker Format Appeared with Unix SVR4 and used on many systems including Solaris SunOS Irix and Linux Many embedded systems also use ELF becoming very popular EL IX A set of configurable API s based on a suitable subset of POSIX 1 and ISO C99 together with some extensions from Linux GNU BSD and SYSV that are applicable to embedded applications Exception handling Event that occurs when a block of code reacts to a specific type of exception If the exception is for an error from which the tool the debugger for instance can recover the debugger resumes its process Executable file A binary format file containing machine instructions in a ready to run form Acronym for the GNU assembler Interchangeably used with 122 E i MX GNU X Tools User Guide Glossary of Embedded System Terminology DESCRIPTION Fs capitalization as GAS GDBstub GCC Main debugger used with GNU command line interface
116. ing on the desktop icon installed If there is no icon you may not have the Application Development Platform on Windows installed correctly go back to Section 2 and follow the installation instructions Make the example programs and create a ROM image for the romfs img filesystem by issuing the following commands cd home gxlinux cr make all cr builds example applications installs them and re generates a ROM filesystem Step 3 Load Binaries and Startup Script At this point we assume that the target board is powered up connected to Ethernet and the uMON prompt is displayed in a serial terminal If not in this configuration go back and get the board ready From the i MX GNU X Tools Shell and assuming you are still in the build directory issue the following command that will load the GX Linux binaries and startup script make load cr Three images should start uploading to the board see the serial terminal interface for upload response in MicroMonitor The images loaded are as follows 1 zlmage kernel 2 romfs img ROM root filesystem and 3 startlinux startup script Step 4 Boot Linux From the serial terminal window issue the following command uMON gt startlinux cr this script calls the Linux kernel and filesystem to execute The Linux kernel should uncompress and mount a ROM filesystem If there are any errors recycle power on the board and repeat this step Occasiona
117. instruction set of a microprocessor using a byte code instruction set a set of registers a stack a garbage collected heap and an area for storing methods An allegedly over sized over featured over engineered and incredibly over complicated window system developed at MIT and widely used on Unix systems With its sources freely available it is a vehicle that is widespread since developers can modify and customize it according to their requirements Name for the Intel 8086 architecture family XCOFF eXtended COFF IBM s object file format for RS 6000 and PowerPC systems 126 E i MX GNU X Tools User Guide Index A Abatron BDI2000 96 ABI 122 Acknowledgements 7 addr2line 41 ahls 53 aln 53 ansi 47 API 122 ar 41 58 ARM Toolsuite 110 as 41 assembler 38 assembly 40 Assembly 40 Automatic Display 65 B b format 56 bash 108 Bash Shell 14 120 bc 108 Bench 8 Bibliography 120 binutils 108 bison 108 Breakpoint Information Balloon 75 Breakpoints and Watchpoints 63 Breakpoints Window 85 92 BSP 122 Build 122 byacc 108 bzip2 108 C C 47 C language options 46 C 7 40 41 46 123 Changing Local Variables Values 94 Code Display Drop Down List Box 78 COFF 122 Command Line gdb 60 compilation 40 Compilation Options 46 compiler 38 Compiler 122 Index Console Window 87 Control Programs 39
118. ion GCC as envisioned by Richard Stallman of the FSF in the mid to late eighties Through the collective efforts of hundreds of volunteers and organizations see Section 1 2 the GNU Tools has grown to be a mature and robust suite of tools that is readily available in source form The source code is freely distributable under the license terms of the General Public License GPL from the FSF see www gnu org however building a toolsuite is a complex and time consuming task Microcross contribution to value add is to build test package document distribute and support the GNU toolsuites in ready to run form making them accessible at low cost to both casual and professional users The The i MX GNU X Tools provides all of the components an embedded developer needs in order to evaluate and use the GNU cross toolsuites GDBTK also branded by Microcross as Visual GDB a k a Red Hat Insight debugger is seamlessly integrated as the GUI debugger for the i MX GNU X Tools toolsuite 1 2 Acknowledgements The GNU Tools and utilities represent the essence of the free and open source movement in fact all who participate in using and improving them are benefactors as well as contributors Microcross is certainly no exception and as such we gratefully acknowledge the following individuals and organizations for their contributions to the open source universe e Richard Stallman founder of the GCC and the Free Software Foundation e The Free Software Fo
119. ir values change Figure 6 52 File after Changing Local Variables Values main c Source Window File Run Yiew Control Preferences QO 70 TM ZAS A B Cx804dod5 106 static int quiet 0 static int batch D x Pointers to various orgurents from command line char sumarg NULL char execarg NULL char corearg NULL char amp ttyarg NULL SCURCE 6 18 2 Setting Breakpoints on Multiple Threads With Visual GDB processing in a multi thread environment select threads and set breakpoints on one or more threads when debugging WARNING Multiple thread functionality does not work similarly on all embedded targets When debugging C code for instance breakpoints and exceptions may not work on multiple threads A process can have multiple threads running concurrently each performing a different task such as waiting for events or something time consuming that a program doesn t need to complete before resuming When a thread finishes its job the debugger suspends or destroys the thread running in the debugging process The thread debugging facility allows you to observe all threads while your program runs However whenever the debugging process is active one thread in particular is always the focus of debugging This thread is called the current thread The precise semantics of threads and the use of threads differs depending on operating systems In general the threads of a single program are like multi
120. iriatssabcetesapceasienteeeeeegsdoeelense ee egadereneesoetedoe ae iekee 46 cy fey aa Oe IE 2 TU OD 0 gee er ee A ee eer ee eee eee ee ee eee oe ee ere 46 7 fee d 2 8 0161 2 118 a8 6 0 9 ce ee ee ee ee een ee ee ere ene eee ee eer eee E ee 47 4 7 4 Options to Specify Libraries Paths and Startup Files ccccccccseccccsccccseeecccsecesecesueesssseesseeessseeeeseesessnesesaes 47 47 9 Debugging ANG Profiling OQDUONS sicezctecvsesiresenciovesouesdsaniaseddntietnnstesnensaentaverad AARET ERAS E EREE REESE eE RENN 49 a OP O Pere E ee ee ee ee T E A ee ee ee ee 50 4 1 7 Passing Options to the Assembler or LINKED cccccsccccssecccseecccsecccseecesueeessueesesuecssueeessesessaeeessaeeessneeesaeeenaes 51 4 8 USING The GNU Assembler sercccienceseanianvccansnsensaxnennesed denciibnadeseealesigtanibiereseuuseadanaieursaicdins dasicenecienveh detabeasincebnaeabse 51 A9 Usma the LINKO cuiri desea a ony oe cenqasnacce se asacaue ems cue aees aeaa NOT NE EAE 54 a VO T ee E E E E E E EEEE E E EEE E AEE EEE 54 ADD ENE CONG aerea E E EAE EA EE AE ENERE EEE EE EEEE E EE E EEEE EEE 55 DS ENET S CIOS ae see E EE E NEEE EEEE EE EEE E E EEN 56 4 9 4 Link Order Optimization ccccccccscccssecccsneccnssecsssecsssessaeesseeeesauessnseessusessaesessausessaueesaussessausessausessaasensnseesans 57 iv E i MX GNU X Tools User Guide Contents PDD TeC Tae 00 htaccess acid age E titania to each aieate alone saad aenencadenene ia duane 57 4 10 Object T
121. is configured to produce the most reasonable output format for its target machine Its assumptions about what is reasonable are probably true about 99 99 percent of the time But there may be special purpose situations in which you would want another output format Here is an example of a customized Id command lt target alias gt Id r o bigofile o prog1 o prog2 0 Imylib cr This command links the files prog1 o and prog2 o and the library file usr lib libmylib a The resulting file is named bigofile o it can be linked further and may still contain unresolved references 4 9 3 Linker Scripts One advanced feature of the GNU linker is its ability to work from scripts written in its own command language If you are a true masochist you might be able to avoid running GCC altogether you might be able to implement your own compiler as a linker script There are a few situations in which you would actually need a linker script but you should be aware that they exist for purposes like e Gaining tight control over the format of the output file perhaps so an embedded application will fit into the smallest possible ROM perhaps to optimize link order e Supporting an object format that Id does not provide perhaps an object format of your own design or an object format for some special purpose operating system 56 E i MX GNU X Tools User Guide Section 4 How to Use i MX GNU X Tools Microcross recomme
122. ive terms of the Lucent Public License iiMX GNU X Tools User Guide E 7 Section 1 Introduction 1 4 Toolsuite Components 1 4 1 Naming Conventions Used in GNU X Tools Because the GNU cross tools have a one to one correspondence in function and naming across targets all of the GNU cross tools are named using a target specific prefix This target specific prefix also called the target alias is pre pended to the name of each program binary name so that ambiguity with the host platform GNU Tools and other target toolsuites is prevented The standard toolsuite components for each processor supported are listed in Table 1 1 Other components of the product are listed in Table 1 2 A feature of the i MX GNU X Tools 3 40 command shell environment is that it provides alias names for each target specific program so that you may refer to it by its generic name when running within to the tool shell For example after opening a GNU X Tools Shell using the command xtools arm elf you can refer to the arm elf gcc compiler simply as GCC The alias remains in effect until you exit the shell at which time the command GCC reverts to the native compiler Table 1 1 i MX GNU X Tools Standard Toolsuite Components Tool Name lt target alias gt gcc lt target alias gt g lt target alias gt as lt target alias gt Id lt target alias gt run lt target alias gt addr2line lt target alias gt ar lt target alias gt gcov lt target a
123. l cr dot forward slash run all The cross compiler will compile and run several test programs in the target Instruction Set Simulator ISS which is shown running in the shell If there are errors of any kind then there is a problem with the installation Read the troubleshooting guide in Section 2 6 for additional information concerning possible problems and their solution If the run all test passes then go onto testing the C cross compiler environment using Bench This next procedure could take up to 30 minutes depending on the speed of your computer and the target toolsuite used Bench is an AT amp T C test suite that is shipped with the i MX GNU X Tools as a bonus test environment for toolsuites supported by Microcross Bench tests most of the standard C language constructs in the latest GCC release and is a good indicator of a healthy i MX GNU X Tools C development environment If you have any comments or suggestions to improve this test suite please send your comments to support microcross com arm elf cd home bench cr or to the directory where the Bench test files are located on Linux host arm elf make clean all cr 2 6 Troubleshooting Guide for Installation Problems 2 6 1 Windows Cygwin Related Problems Many developers have installed one version or another of Cygwin in the past and have experienced problems installing a newer version over the older version The problems are most often due to an unclean uni
124. l references Consequently the position in which libraries appear in this list is Important For example the command lt target alias gt Id prog1 o Im prog2 o cr results in an Undefined symbol message if prog2 o refers to any programs in the library usr lib libm a unless you happen to be lucky and prog2 o only uses routines that the linker extracted for the sake of progi o Note that libraries may refer to other libraries thus the command lt target alias gt Id prog1 o lat lfo cr leads to Undefined symbol messages if the fo library requires any routines from at This situation is more complex for a user generated library Such a library should contain an index so that the linker can find each module regardless of its order within the library Some systems always generate an index when you create or modify the library with the ar command the GNU ar does this On other systems you have to put in the index yourself by using the ranlib command If you want to create an executable file the beginning of the first file in the list of files must be the program s entry point This is not the same as the apparent entry point to your C source program Before your program begins executing the computer must execute a standard run time initialization routine To ensure that this is in place lib crt0 o must be the first file in the list of files and libraries This ensures that
125. lash procedure Step 3 Issue the following command in the first i MX GNU X Tools Shell ocdremote c ARM920T d USB a 0 s 1 cr assuming O is the USB device number use the usoDemon Finder utility that accompanies the OCD Commander icon on the desktop if you are unsure of the device number This shell should echo back the following JTAG SDO lt CPU 1 ARM9Z20T listening on port 8888 lt JTAG SDI Each time a GDB session is open and closed the OCDRemote utility will need to be recycled Issue the following commands in the second i MX GNU X Tools Shell cd home umon recovery cr arm elf gdb ramtst elf cr wait until the program has completely loaded into RAM and MicroMonitor autoboots as evident in the serial terminal session Step 4 Open a third i MX GNU X Tools Shell window and issue the following commands cd home umon umon_ports csb536fs cr for MXL port substitute csb535fs for MX21 bashrc cr dot space bashrc sets dependency paths make TARGET_ IP xxx xxx xXxx xxx newmon cr substitute actual board IP address Wait for approximately 30 seconds and power cycle the board to restart MicroMonitor You will be prompted to input the last four digits of the MAC address Use the last four digits on the label that is affixed to the board and separate the every two digits with a colon Confirm the new MAC address when prompted and you are done Click on X
126. lation code block see if ifdef ifndef similar endif to ENDIF in armasm endm endr equ lt symbol name gt lt value gt err exitm Exit a macro partway through see macro similar to MEXIT in armasm global lt symbol gt This directive gives the symbol external linkage similar to EXPORT in armasm Aword lt short1 gt lt short2 gt Inserts a list of 16 bit values as data into the assembly similar to DCW in armasm if lt logical_ expression gt Makes a block of code conditional End the block using endif similar to IF in armasm See also else ifdef lt symbol gt Include a block of code if lt symbol gt is defined End the block with endif ifndef lt symbol gt Include a block of code if lt symbol gt is not defined End the block with endif include lt filename gt Includes the indicated source file similar to INCLUDE in armasm or include in C Repeats a block of code once for each value in the value list Mark the end of the block using a endr directive In the repeated code block use lt param gt to substitute the associated value in the value list Defines an assembler macro called lt name gt with N parameters The macro definition must end with endm To escape from the macro at an earlier point use exitm These directives are similar to MACRO MEND and MEXIT in armasm You must precede the dummy macro parameters by For example irp lt param gt
127. lias gt nm lt target alias gt objcopy lt target alias gt objdump lt target alias gt size lt target alias gt strings lt target alias gt strip lt target alias gt gdb lt target alias gt gdbtk libc a and libm a libstdc a Table 1 2 Sources for Other Components bench A comprehensive set of C benchmarks that may be used to verify correct operation of the toolsuites and serve as the basis of user programs Bench is completely described in the user notes for Bench in the docs directory on the i MX GNU X Tools CD ROM lt target alias gt ranlib Generates index to archive contents lt target alias gt readelf Displays information about ELF format object files Newlib Newlib i MX C source tree This library does not have restrictions based on the General Public License GPL This library is completely unrestricted Contact Microcross for more information 1 4 2 Targets The array of target processors supported by i MX GNU X Tools is based on the current Freescale Semiconductor i MX targets including MXL MX1 MX21 and MX31 variants The objective of i MX GNU X Tools Release 3 40 is to 8 E i MX GNU X Tools User Guide Section 1 Introduction provide a baselined toolsuite for each target platform and each host From this baseline new hosts targets and target enhancements will be added in future releases 1 5 System Requirements and Prerequisites The i MX GNU X Tools provides a GNU Unix Linux like devel
128. library used by ARM Remote Debugging Protocol a protocol used with ARM s Demon monitor Registers are settings representing values that serve as temporary storage devices in a processor allowing for faster access to data Registers are divided into several classes pseudo registers temporary registers and machine registers Reduced Instruction Set Computer machines typically having fixed length instructions limited addressing modes many registers and visible pipelines Examples include MIPS ARM SH PowerPC and StrongARM Read Only Memory non volatile memory that can be read but not written by the microprocessor Sun s current version of Unix superseding SunOS Based on SVR4 Unix Sun officially calls it SunOS 5 x with versions including 2 0 2 6 or as Sun refers to them 5 0 5 6 Name for the family of RISC processors based on Sun s SPARC architecture Members include SPARClite SPARClet UltraSPARC v7 v8 v9 Based on symbol tables a debug format originally introduced with the Berkeley Unix system which records debugging information in certain symbols in the object file s symbol table stabs information may also be encapsulated in COFF or ELF files A small piece of code that executes on the target and communicates with the debugger acting as its agent collecting registers setting memory values etc Also in a native shared library system the part of the shared library that actually gets linked with a program
129. lick Save or 2 Open a BASH GNU X Tools Shell and navigate the command line using Unix Linux style commands to the directory of the file you wish to clean the CRs out Enter the following commands verbatim tr d r lt filename gt tmpfile cr rm f filename cr mv tmpfile filename cr Note the lt and gt are nececssary as part of the syntax The filename is the file you want to remove the contents except for the carriage returns and place the contents in a tmpfile then the next two procedures simply remove the original file and rename the tmpfile to the orignal filename These three commands are necessary to remove the carriage returns from a DOS style source file so that a user may use Cygwin to compile the source file into object code Generally here are a couple of suggestions when using Cygwin and i MX GNU X Tools with source files Besides carriage return issues with DOS files do not put spaces in filenames and folder names the user will experience problems with Unix style files in Cygwin as well as Linux Unix Use EMACS as your text editor on Windows using the xWin desktop icon to launch emacs simply type emacs after xWin starts a shell EMACS is a Unix style editor that will not put carriage returns in your text files i MX GNU X Tools User Guide E 15 Section 2 Install and Setup Procedures 2 6 4 xtools install Command Fails on Linux Host Description In some Linux versio
130. linker looks in the directories lib and usr lib to find this library Note that the GNU linker truncates the name s prefix and extension i e lib and a are not necessary for libname a as a linked library file If you create your own libraries to link into your program you will need to name them libname a and link in as Iname Ldir To find any libraries look in the directory dir before looking in the standard library directories lib and usr lib 5 Remove the symbol table from the executable output file This makes the output file significantly smaller but makes debugging nearly impossible Therefore this option should not be used until the program works successfully Note that using the program strip has the same effect X Remove all local symbols from the output file Global symbols subprograms and common block names remain in the output file This reduces the object file s size Ignored unless s is specified i MX GNU X Tools User Guide E 55 Section 4 How to Use i MX GNU X Tools N Make the text segment read only zi Create an object file that can be included in further linking runs i e further passes through Id Among other things this inhibits Undefined symbol messages because the symbols may be defined in a later Id pass and prevents Id from creating common storage immediately If you wish to create common storage at this time use the
131. lly the kernel aborts on a bootup due to a corrupted flash file system Follow steps in the MicroMonitor tips section to issue a command uMON gt tfs clean to defrag the flash file system The Linux startup script is set with a Tiny Filesystem attribute that makes startlinux an executable like a batch file in DOS To change this attribute so that you can automatically boot into Linux with a query to stop after MicroMonitor boots up issue the following command after boot up of MicroMonitor uMON gt tfs feB cp startlinux startlinux cr i MX GNU X Tools User Guide E 21 Section 3 Quick Start Guide WARNING feB is case sensitive and if you use a lower case b in the switch option you will not be able to boot into UMON again without re flashing through the JTAG which is complicated and time consuming To change the attribute back to manual boot substitute fe in place of feB in the above command above To stop the automatic boot press any key while UMON is booting and before Linux boots The bootup will stop at the UMON command prompt Step 5 Run Example Applications in GX Linux When the GX Linux boots to a Linux command shell prompt you can enter the following commands in the serial terminal to get acquainted with all of the example programs loaded in the usr bin each example file has a x file extension In the serial terminal command line interface window issue the following commands c
132. lp window Figure 6 42 using the Help menu to get HTML based navigable help by topic i MX GNU X Tools User Guide E 89 section 6 How to Use Visual GDB Debugger Figure 6 42 Help Window Showing the Help Topic s Index The Help window has two menus File and Topics The File menu makes the following options functional Back moves back one HTML help page relative to previous forward page movements Forward moves forward one HTML help page relative to previous back page movement Home returns to the main HTML help Table of Contents page Close closes the Help window The Topics menu displays information for each menu item Content changes in the Help window to represent a selected topic The first menu item index returns to the main Help window Figure 6 42 The second item Attach Dialog is only for a host system s use when attaching to another debugging process and not for use by embedded targets The remaining menus document the Insight windows Stack Figure 6 20 Registers Figure 6 21 Memory Figure 6 22 Watch Expressions Figure 6 24 Local Variables Figure 6 29 Breakpoints Figure 6 33 Console Figure 6 38 Function Browser Figure 6 39 and Threads for the Processes window when working with threads the window contents are dependent on the operating system in use 6 18 Examples of Debugging with Visual GDB The following documentation contains examples of debugging session procedures for using Visual GDB the con
133. m the list of options and press Enter See Figure 6 56 for a screen shot of this option 98 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger Figure 6 56 Set Serial API Baud Rate Tera Term COM1 VT File Edit Setup Control Window Help 192 168 0 211 255 255 255 Gateway 192 168 0 250 AC Address 00 60 bf 01 0a a7 CDREMOTE Disabled mpDemon Command Menu Set Serial API baud Rate Set DHCP option Set TCP IP Address Set TCP IP Mask Set TCP IP Sealed A Set OCDREMOTE Conriquration Update License Code s Ping TCP IP address Display Error Log Reboot mpbemon Type Command lt Enter gt will refresh screen gt b Baud 115200 76800 56700 38400 19200 14400 9600 4800 1200 gt 115200 NOTE This rate used ONLY when mpDemon is in Serial API mode Reboot poen to run with new parameters hit any key to continue zm AmMuronstsrogn Ask your network administrator for details about your network configuration so you can assign an IP address gateway network mask or alternatively you can enter DHCP configuration by selecting D in the mpDemon command menu and press Enter and then enter Y see Figures 6 57 and 6 58 Next enter the DHCP host name or IP address Figure 6 57 Use DHCP Gi Tera Term COM1 VT File Edit Setup Control Window Help PI Baud Rate 115200 NO 192 168 217 7 255 255 255 Gateway 192 168 0 250 AZ Address 6 bf 01L
134. many stages of the machine you run The S means that you stop after the assembler and the output filename ends with s If you keep this picture in mind the compiler s machinations will not seem so strange you will stop seeing preprocessing compilation assembly and linking as separate steps and come to see compilation as one big assembly line for which GCC is the production manager The following tools listed in Tables 4 2 4 3 and 4 4 are the main tools for developing projects with a i MX GNU X Tools Toolsuite Table 4 2 i MX GNU X Tools Compiler and Development Tools gdb GNU debugger for source and assembly debugging with commandline ___ _ gdbtk Debugger using a graphical user interface called Visual GDB a k a Insight Optimizing ISO tracking GNU C compiler GNU assembler preprocessor Id GNU Linker Table 4 3 i MX GNU X Tools Libraries Non restricted ANSI C runtime library Newlib for cross development Support library for embedded targets board support for cross development deprecated will be replaced by a future product Table 4 4 i MX GNU X Tools Binary Utilities Utility Description Target Dependent addr2line Converts addresses into file names and line numbers Creates modifies and extracts from object code archives diff Comparison tools for text files no diff3 Sdiff nm The Adobe Acrobat PDF files listed in Table 4 5 are available on the i MX GNU X Tools or Cygwin docs di
135. ms Cygnus Solutions Inc 1999 17 GNU Online Documentation Brian J Fox Free Software Foundation 1994 18 GNUPro Libraries Cygnus Solutions 1998 19 GNU Make Richard Stallman amp Roland McGrath Free Software Foundation 1995 20 Learning the Bash Shell Cameron Newham amp Bill Rosenblatt O Reilly and Associates Inc 1998 21 Learning GNU Emacs Debra Cameron amp Bill Rosenblatt O Reilly and Associates Inc 1991 22 Man Pages Free Software Foundation Inc 2001 23 Porting Unix Software Greg Lehey O Reilly and Associates Inc 1995 24 Programming with GNU Software Mike Loukides amp Andy Oram O Reilly and Associates Inc 1997 ISBN 1 56592 112 7 25 The C Preprocessor Richard Stallman Free Software Foundation 1995 120 E i MX GNU X Tools User Guide 26 27 28 29 30 31 32 33 34 35 36 Bibliography The GNU C Library Reference Manual Volume One Volume Two Sandra Loosemore Richard M Stallman Roland McGrath Andrew Oram amp Ulrich Drepper Free Software Foundation 1999 Unix in a Nutshell Daniel Gilly and the Staff of O Reilly and Associates Inc O Reilly Associates Inc 1992 Using and Porting GNU CC Version 2 8 Richard M Stallman Free Software Foundation 1998 Using and Porting GNU CC Version 2 95 Richard M Stallman Free Software Foundation 1999 Using GASP Roland Pesch Free Software Foundation 1996 VIDE User Guide Dr Bruce Wampler 2001 XScale Ge
136. ms Executable sizes of 50 to 100 megabytes occur regularly and there are reports of programs approaching 1 gigabyte in size GDB should be able to run everywhere No other debugger is available for even half as many configurations as GDB supports 5 1 3 Startup GDB To start a GDB debugging session open a i MX GNU X Tools bash shell or xterm on Linux and issue the following commands xtools lt target alias gt cr lt target alias gt gdb lt program name gt _ cr Its that simple to start GDB and load a program for any one of the toolsuites supported by Microcross See Figure 5 1 which shows GDB for arm elf opening a binary and running a program called div x through the simulator We 60 E i MX GNU X Tools User Guide Section 5 How to Use Command Line GDB recommend getting acquainted with mc debug pdf for details on how to use GDB if you are not familiar with some of the commands presented in the Reference Card below The GDB as well as C Reference Cards can be downloaded from the following web site http www refcards com Figure 5 1 A GDB Example in View arm elf gdb div x a GNU gdb 6 1 Copyright 2004 Free Software Foundation Inc GDB is free software covered by the GNU General Public License and you are elcome to change it and or distribute copies of it under certain conditions ype show copying to see the conditions here is absolutely no warranty for GDB Type show warranty for details his
137. n JTAG interface Note The Macraigor USB devices are currently not supported under Linux The following files are included in home debug example directory under Cygwin gdbinit GDB Initialization File crt0 S Assembly source for C initialization code Idscript Linker script Makefile Compiles and links source files using i MX GNU X Tools README The readme file test c C source for example program testsub c C subroutine source for example program i MX GNU X Tools User Guide E 23 Section 3 Quick Start Guide Assumptions OCD Commander and its utility usoDemon Finder are installed before starting this Demo Program To find out what USB device number to use execute the usoDemon Finder utility using the desktop icon and note the device number of the usoDemon the USB cable has to be connected and the board while powered on in order to get this device number To Run the example on the Cogent CSB536FS LiteKit board you need to connect the board to the host computer via the USB cable and power on the board Next follow the steps below Step 1 Construct an example application On Windows host start a i MX GNU X Tools Shell and then enter cd home debug example cr make cr Step 2 Make connections to the target LiteKit board USB cable null modem serial cable Ethernet cable and power cable turn power on to the board and start OCDRemote in a second i MX GNU X Tools Shell Always prior to running GDB Visual GDB
138. n dll portability library provides the capability to port UNIX Linux Open Source projects to Windows e Cygwin dll allows for compiling UNIX applications on Windows 7 3 Cygwin Components UNIX Linux shell environment such as bash Open Source Internet daemons such as telnet GNU Development Tools optimized for the Intel Pentium family of processors Cygwin dll portability library 7 3 1 Cygwin Package List tools utilities and programs that make up Cygwin bash bc binutils bison byacc bzip2 cpio Cvs cygwin diffutils expect file fileutils findutils flex fortune ftp gas gawk gcc i MX GNU X Tools User Guide m 107 Section 7 Introduction to Cygwin GDB gnuchess gprof grep groff Gzip inetutils itcl itk ksh ld less libcurses libjpeg libtermcap libtiff login m4 make man more Ncurses perl rx regex sed shell utils tar tcl tcsh telnet termcap texinfo textutuils time tix tk vim vi wget which Xemacs Zip unzip zlib 7 3 2 User Information How to use the tools utilities and programs in Cygwin Start a i MX GNU X Tools shell and type man and the name of the tool utility or program you wish to learn about at the command prompt Type q to quit man pages The Cygwin CD ROM provided with the Cygwin version of iMX GNU X Tools has an option to install Cygwin documentation We highly recommend that you install the documentation and take advantage of some very powerful programs tools and utilities The
139. n is silent command list reached silent suppresses default display end of command list catch event break at event which may be catch throw exec fork vfork load or unload Table 5 8 Program Stack Command Syntax n if no n display current frame arguments of selected frame frame all reg includes floating point Table 5 9 Execution Control continue count continue running if count specified ignore step count execute until another line reached repeat si count source lines next count execute next line including any function calls ngog SES e nadaan tetona nexti count next machine instruction rather than o until ocation run until next instruction or location run until selected stack frame returns 64 E i MX GNU X Tools User Guide Section 5 How to Use Command Line GDB Command Syntax return expr pop selected stack frame without executing setting return value signal num resume execution with signal s none if 0 jump line resume execution at specified line number jump address or address set var expr evaluate expr without displaying it use for altering program variables Table 5 10 Display Command Syntax Description print f expr show value of expr or last value p f expr according to format f Hexadecimal signed decimal unsigned decimal octal Go OU eo to inary pa Fo u address absolute and relative character floating point call f expr
140. ndline options S o describe command line options Table 5 3 Stopping GDB Command Syntax exit GDB also q or EOF e g C d exit GDB alsoqorEOF eg C d o INTERRUPT eg C c terminate current command or send to running process Table 5 4 Getting Help Table 5 5 Executing your Program start your program with arglist specify empty argument list display argument list show env var Table 5 6 Shell Commands print working directory Table 5 7 Breakpoints and Watchpoints Command Syntax break file line set breakpoint at line number in file le _ g break main c 37_ _ o O B file line e g break main c 37 break file func set breakpoint at func in file set breakpoint at next instruction iMX GNU X Tools User Guide E 63 Section 5 How to USe Command Line GDB Command Syntax break if expr break conditionally on nonzero expr cond n expr new conditional expression on breakpoint n make unconditional if no expr toreak temporary break disable when reached rbreak regex break on all functions matching regex watch expr set a watchpoint for expression expr info break info watch Clear clear file fun clear file line delete n disable n enable n enable once n enable breakpoints or breakpoint n disable again when reached enable del n enable breakpoints or breakpoint n delete when reached ignore n count commands n execute GDB command list every time breakpoint
141. nds starting with the default linker script and modifying it to meet your needs To extract the standard linker script into a file type the command lt target alias gt Id verbose gt linker Id cr This command will create a file named linker Id and you will need to open this file in an editor to delete the header lines before and including and the footer single line Then the script file can be saved or copied into a source directory and be used with the GCC option WI T linker ld to replace the standard linker script Now you can modify the linker script with confidence that you have a working startup script 4 9 4 Link Order Optimization If you have done a lot of development work you have probably noticed that the order in which you link your files can have a significant effect on performance By changing the link order you are changing the way the executable file lies in the instruction cache The cache is a fast area of memory that stores pages of instructions so that the processor does not have to go back to slower parts of memory or even worse the disk for every new instruction Certain link orders minimize instruction cache miss The effect usually is not large but in pathological cases a really bad link order on a machine that is very sensitive to cache miss link optimization can speed up runtime by 50 percent Unfortunately not much can be said about link order optimization There are few
142. ng files generating reports and manipulating text and other small programming tasks combines many features of C awk sed and shell programmin A stream editor based on the line editor ed shell utils GNU Shell Utilities designed for use in shell scripts and batch files Program used to create and manipulate Tape ARchives tar A basic programming language very useful for graphical interface facilities User interface to the TELNET protocol which is used to communicate with another host computer Set of utilities that generates both printed manuals and on line hepertext style documentation textutils GNU Text Utilities to manipulate textual data Manipulate Tix internal state options are set using the X resource database A toolkit of widgets graphical objects for the Tcl programming system Vim Vi Improved a programmers text editor renamed to vi Show full path of commands Xemacs Emacs the Next Generation of text editor a very powerful source code editor zip unzip A compression utility compress and uncompress files g A stream editor based on the line editored ___ _ o o GNU Shell Utilities designed for use in shell scripts and batch files Program used to create and manipulate Tape ARchives tar _ A basic programming language very useful for graphical interface facilities GNU Text Utilities to manipulate textualdata ___ _ _ O Manipulate Tix internal state options are set using the X resource
143. ng functions may be invoked from any Bash Shell prompt 1 xtools enter Execution of the xtools command without arguments will show an abbreviated help screen that summarizes the command options described in this section In addition execution of an incomplete command insufficient or incorrect arguments will produce a help dialog for that command 2 xtools lt target alias gt This command starts a new bash shell having the appropriate environment variables and aliases initialized such that the cross toolsuite components for the designated target are invoked by the familiar command names in lieu of the native tool chain elements For example after starting a shell using the command line xtools arm elf the command GCC would actually start the compiler arm elf gcc This facility allows the command line user to execute the cross tools using the same command names as used in the native shell environment This remapping of tool command names remains in effect until the shell is exited via Ctrl D or the exit command 3 xtools status path prefix This command generates a Summary screen which displays the installation status of each i MX GNU X Tools cross toolsuite in terms of the types counts and locations of files associated with each toolsuite The command displays the toolsuite status by target alias vs the population of files in the following format Column 0 Target Name target alias for this to
144. ng the USB cable is connected and the LiteKit board is powered on is the following JTAG SDO lt CPU 1 ARM920T listening on port 8888 lt JTAG SDI Important Each time you connect and disconnect GDB Visual GDB you must repeat this step The Socket automatically shuts down when GDB Visual GDB disconnects Step 3 Start either GDB or Visual GDB GDB with a GUI interface to start download and debug Command Line GDB Example In the first Shell enter the following assuming you are still in the same directory that contains the test image file built by make nome debug example arm elf gdb test x cr This command will run the command line version of GDB load the program using gdbinit and stop ata breakpoint on main To single step or perform other GDB commands review the list of GDB commands below Here are some examples i MX gdb ir cr Shows register contents i MX gdb s cr single step i MX gdb c cr continue to next breakpoint or end of program i MX gdb ctrl C cr exit debug i MX gdb quit cr exit GDB Visual GDB Example In the first Shell enter the following command assuming you are still in the same directory that contains the test image file built by make nome debug example arm elf gdbtk test x This command will run Visual GDB load test x and stop at breakpoint on main If the target settings dialog pops up select Target Remote TCP Hostname localh
145. nking in the usual debugging stub The GDBserver is not a complete replacement for the debugging stubs as it requires essentially the same operating system facilities that GDB itself does In fact a system that can run GDBserver to connect to a remote GDB could also run GDB locally Acronym for the GNU Compiler Collection directly controls the C compiler Interchangeably used with capitalization as gcc Front end to GCC that is able to read Java class files generating assembly code A Standard compliant library that has been ported to a number of operating systems and provides ANSI ISO POSIX BSD and System V compatibility Recursive acronym for GNU s Not Unix A project to build a free operating system started by Richard Stallman in 1985 with many useful spinoffs such as the Emacs text editor a C i MX GNU X Tools User Guide E 123 Glossary of Embedded System Terminology TERM GUI Graphical User Interface which refers to an interface and the techniques involved in using a keyboard or a mouse for instance to provide an easy to use interface to some software HAL Hardware Abstraction Layer which provides a portability layer to the operating system so that higher layers do not need to be aware of the specifics of the architecture and platform This layer is designed to be comparatively small and simple to implement and is also component orientated to allow sharing between related platforms Name for the 32 bit members
146. ns of the Source Window To work with the other windows for debugging purposes specific to your project use the View menu or the buttons in the toolbar Figure 6 7 If we had not initially specified a cross executable file to open we would now select a specific file by clicking on File Open in the Source Window The file s contents will then be passed to the GDB interpreter for execution To start debugging click the Run button Figure 6 3 from the Source Window Figure 6 3 Run button When the debugger runs the button turns into the Stop button Figure 6 4 If not connected to a target debug agent i e serial TCP etc you can specify the Simulator if your toolsuite has one to run the program 70 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger Figure 6 4 Stop button The Stop button interrupts the debugging process for a project provided that the underlying hardware and protocols support such interruptions Generally machines that are connected to boards cannot interrupt programs on those boards so the Stop button has no functionality it will appear unavailable or grayed out For more information on the toolbar buttons see Figure 6 7 WARNING When debugging a target do not click on the Run button during an active debugging process or it will de activate the process The Run button will become the Stop button and Visual GDB will lose conne
147. ns the xtools install command described in the i MX GNU _ X Tools install procedures fails claiming it cannot find unzip Even though this problem has been fixed in the current xtools procedure we offer a remedy in case a future problem erupts A Linux vendor may come out with a new product tomorrow and change the OSTYPE to an unknown name that xtools does not recognize so we offer the following procedure to insure users can resolve the problem themselves Resolution The xtools procedure utilizes the shell variable called OSTYPE to determine whether the current environment is Cygwin or Linux We have discovered that different Linux distributions and versions set this variable differently some using linux and some using linux gnu for example The xtools control script usr bin xtools checks the value of OSTYPE to determine which install procedure to use Procedure to Fix OSTYPE e Follow the normal installation procedure as described in Sec 2 3 up through step 4 e From a shell change directory to usr bin Enter the command echo OSTYPE and record the value of OSTYPE reported e Edit the file xtools in usr bin Go to the line that contains if s OSTYPE linux gnu then and edit it If the reported OSTYPE is not linux gnu then the enter the appropriate reported OSTYPE Save and exit the edit session You should now be able to continue the installation process following the rest of the in
148. nstall A user should cleanly uninstall other versions of Cygwin before installing the Microcross version To cleanly uninstall Cygwin manually of all registry entries and path settings follow these steps e Run regedit from the Start Run command e Look for the following Registry Keys o HKEY CURRENT USER Software Cygnus Solutions o HKEY LOCAL MACHINE Software Cygnus Solutions e If they exist manually delete them by selecting the key and pressing the Delete key To Verify and or Clean the Environment Variables perform the following steps 14 E i MX GNU X Tools User Guide Section 2 Install and Setup Procedures Start Control Panel from the Start menu Click on System and select the Advanced Tab Click on Environment Variables On System Variables window Click on Path and then on the Edit button Make sure all instances of Cygwin bin Cygwin usr local bin and Cygwin usr bin along with the drive letter are removed 2 6 2 Make exe Related Problems If the user has any version of Borland development tools on his her machine the user might experience a problem using the GNU Make The reason there is a conflict is because Borland Make and GNU Make have the same tool name make exe Microsoft s make utility is called nmake therefore the user will not experience any problems with the Windows development tools from Microsoft Another conflict has been noted
149. olsuite i e arm elf in our case Column 1 usr bin lt target alias files Column 2 usr lt target alias gt bin files Column 3 usr lt target alias gt lib files Column 4 usr lt target alias gt include files Column 5 usr lib gcc lib lt target alias gt files Column 6 usr man man1 lt target alias gt files Column 7 Total file count for this toolsuite QL A m The optional path prefix argument allows the utility to examine the installation state in which the user may have elected to manually install or build install toolsuite s into an alternate location other than usr i MX GNU X Tools User Guide E 35 Section 4 How to Use i MX GNU X Tools 4 xtools install lt target alias gt archive path This command will install a complete cross toolsuite from the distribution tarball on the specified archive path All files are unarchived to the proper location see above regardless of the current directory state and subsequent invocation of a bash shell using the xtools lt target alias gt command will render the toolsuite ready to use If the archive path is not provided a default path is selected The command xtools install will display the default path which is mnt cdrom unless it has been changed or overridden by the global environment variable 6XTOOLS ARC_PATH 5 xtools remove lt target alias gt path prefix This command allows the user to selectively remove a
150. om the filesystem Each of the five example applications can be built loaded and run in the manner described above i e app1 app2 app3 app4 and app5 Some example applications take arguments that are passed in at execution e g app2 arg1 arg2 arg3 The MicroMonitor User Manual is a great resource to learn more see Cygwin docs directory Example 2 Minesweeper Build Load Run Procedure Step 1 Start an X Windows session using the xWin icon on the desktop and issue the command emacs When EMACS starts up click on File Open File and the cursor on the window will be at the bottom Enter the path to the Makefile as follows assuming Cygwin is installed on the c drive otherwise substitute accordingly cygdrive c Cygwin home uwindows src demos elsdemo Makefile Edit line number 8 with the correct TARGET_IP address to your target board Save and exit the file and close XWin Note that the XWindows server will stay memory resident until exited using the mini icon in the memory resident program viewer on the taskbar or when the computer is rebooted Restarting xWin without stopping the server will prompt an error unless the server is manually stopped Step 2 Start a i MX GNU X Tools Shell using the red X icon on the desktop Connect your target board to a network or a cross over Ethernet cable and power it on On your host machine issue these commands in the i MX GNU X Tools Shell cd home uwindows sr
151. on a BDI IP Address one you will assign that is not duplicated on your network b Subnet mask c Default Gateway d Config Host IP Address the host machine you have the configuration software running on along with where TFTP server program that resides in the bdi2000 directory 8 You may check the status of your firmware by clicking on the Current button If out of date version click on the Update button 9 Save the configuration data into a file of your choosing using the File Save As in the menu 10 Click on Transmit to send this configuration to the BDI2000 via serial 11 Exit the B20ARMGD exe application 12 Edit the xxxxx cfg file Modifying the following lines a Line where Host IP is located Enter Host IP address where TFTP runs from a DOS command shell use ipconfig to find out what the Host IP address is b Enter the REGS file path path should be same as step 1 bdi2000 directory 13 Create a shortcut to tftpsrv exe that is located in the bdi2000 directory and execute it to start the TFTP Server before going to the next step very important N al N 96 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger 14 Unplug power to the board and BDI2000 and then connect the JTAG connector to the development board 15 Powerup the board and BDI2000 16 Start a DOS command shell and enter the command telnet lt IP address assigned to
152. on 6 How to Use Visual GDB Debugger Figure 6 69 Visual GDB Screenshot a BAA app c Source Window Sele Fie Run View Control Preferences Help SOT OO OS SAS AE rin zaal E orig_ main SOURCE Ox4 a i ze fx 8 6x2 08008 Establish a stack pointer f xA asm ldr sp AppStack 1626 4 oxa How jump to what was orginally main xf 8x 021188 orig main Bx A Ox7F 81 int orig _ main void ax INTSU err extern char 655 start 8x 8241e88 extern char _bss_end__ volatile register char ramstart asm r 8x8 Clear BSS space xf 8x2 82 16ea8 ramstart amp bss_start while ramstart lt amp bss end 8x2 6216eac xramstart 8x2 6216e9c monConnect int UMON ENTRY POINT void NULL void NULL f Restart the monitor f non warmstartfWARMSTART ALL i fi ae stopper el at line 82 serene 32 E 2 console window Seles rs Program received signal SIGTRAP Trace breakpoint trap Address spc Target is LITTLE endian x10012c74 in 77 a 4 c ASCII Loading section text size xaa76 lma 6x265000068 xe1aGc 00d 6xe92dd808 Oxe24cb004 Oxe24dde18 _ Loading section rodata size x2e8 lma x2050aa7 B22 050081c xe 1a c bd Gxe92dd666 Oee24cb ees Qxe2hdd618 Start address 6 20500000 load size 44368 0x2050002c Oxe59F H0d8 Gxe59F30d8 Bxe 1500003 0122000004 Transfer rate 29578 bits sec 188 bytes urite 0x2050003c O
153. ontal Scroll Bar of the Source Window There are four display and selection fields below the horizontal scroll bar the status text box Figure 6 13 the file drop down combo box Figure 6 15 the function drop down combo box Figure 6 14 and the code display drop down list box Figure 6 16 At the top of the horizontal scroll bar text details the current status of the debugger the status text box in Figure 6 13 shows program stopped at line 19 as the message The Function Browser window provides even more powerful tools for locating files and functions within your source code for more information Figure 6 13 Status Text Box The function drop down list box Figure 6 14 displays all the functions of a selected source c or header h file that an executable uses Select a function by clicking in the list or by typing directly into the text field for the function drop down list box Figure 6 14 Function Drop Down Combo Box df puts_unfiltered init_proc Moir proc_remove_foreign print_gdb_help The file drop down list box Figure 6 15 displays the source c and header h files associated with an executable Select files by clicking the arrow to the right of the drop down list and then selecting one of the files in the list or by typing the file s name directly into the list s text field Figure 6 15 File Drop Down List Box iain main print_gdb_help Select how the code in the source Window displ
154. ontrol the link step use the option WI lt linker flag gt to pass the option to the linker Table 4 6 Required CFLAGS LFLAGS for i MX GNU X Tools Simulator Builds Target Alias Tool Name Compiler Flags Linker Flag shown with WI lt linker flag gt for passing options using GCC None S OS arm elf gcc g None i MX GNU X Tools User Guide E 59 Section 5 How to Use Command Line GDB Section 5 How to Use Command Line GDB 5 1 Summary of GDB the GNU Debugger The purpose of a debugger such as the GNU debugger GDB is to allow you to see what is going on inside another program while it executes or what another program was doing at the moment it stopped The GDB can do four things to help you catch bugs e Start your program specifying anything that might affect its behavior e Make your program stop on specified conditions e Examine what has happened when your program has stopped e Change things in your program so you can experiment with correcting the effects of one bug and go on to learn about another problem affecting your program 5 1 1 GDB as Free Software The GNU debugger GDB is free software protected by the GNU General Public License GPL The GPL gives you the freedom to copy or adapt a licensed program but every person getting a copy also gets with it the freedom to modify that copy which means that they must get access to the source code and the freedom to distribute further copie
155. opment environment on Windows and Linux hosts Microcross presumes that the user has a working knowledge of Unix Linux command line utilities and software tools If not the user should acquire training materials to get acquainted with Linux Cygwin This user guide is ideally suited for developers who have some prior experience either with GNU as a cross compiler toolsuite or as a native development system If you need additional familiarization with the Unix Linux environment a wide variety of publications are available several of which are listed in the bibliography The text Programming with GNU Software Loukides and Oram is available from O Reilly Publishing and is an excellent resource for the programmer who is just starting out with GNU tools see bibliography references also the Cygwin web site at www cygwin com has user documentation and the latest Cygwin information 1 5 1 System Requirements Windows Host Version 1 Intel architecture 1586 1686 PC running one of the following Microsoft operating systems e Windows XP Professional or Home Edition or newer e Windows 2000 Professional e Windows NT 4 0 and Windows 95 98 are no longer supported or recommended 2 CPU Clock Rate e 500 MHZ or higher 3 Minimum System RAM e 256 MB 4 Free Disk Space e 1GB 1 5 2 System Requirements Linux Host Version 1 Intel architecture 1586 1686 PC running a Linux 2 x kernel 2 CPU Clock Rate e 500 MHZ or higher 3 Minimum System
156. ost and Port 8888 click on OK Each subsequent run will automatically remember these settings until you change them again To single step or perform other GDB commands you may use the visual buttons that reflect equivalent functions as the command line version or you may enter the command line version in the console Window click on View Console if it is not viewed upon start of Visual GDB To exit click on File Exit on the menu Figure 3 2 shows a Visual GDB on chip debug session with Console Window visible The Console Window needs to be started to get control over the GUI after setting the first Enter s for step in the Console window to enable all of the GUI functions on the Visual GDB From here you can single step all the way through the program view registers view memory etc Figure 3 2 Visual GDB On Chip Debug Session i MX GNU X Tools User Guide E 25 Section 3 Quick Start Guide os C Cygwin bin bash EXE Socdremote c ARM 2 T d USB a s 1 ocdremote 2 12 USB via LPT at speed 1 JTAG SDO lt i CPUC1 gt ARM92 T listening on port 8888 i lt JTAG SDI CPULi Accepted gdb connection on port 8888 test c Source Window MTPO DS SASAMA rina dda test c v main SOURCE int varc 6x23456789 static char test 36 abcdefghijklmnopqrstuywxyz char test_result 36 unsigned long loop passes 6 extern unsigned long shiftit int sval int vard main star
157. ple processes except that they share one address space that is they can all examine and modify the same variables Additionally each thread has its own registers and execution stack and perhaps private memory 94 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger 1 In the Source Window right click on an executable line without a breakpoint to open the breakpoint pop up menu see Figure 6 53 Figure 6 53 Breakpoint Pop Up Menu in the Source Window nance Source Window File Run Yiew Control Preferences AMP 8 70 MMP AAS A BW Ox804deds 106 static int quiet 0 static int batch D fx Pointers to various orguments from command lire x char sumarg NULL char execarg NULL char eeracar n NIII Set Breakpoint F set Temporary Breakpoint Set Breakpcint on Threads SOURCE j 2 Select the Set Breakpoint on Thread s menu item The Processes window displays 3 By clicking on specific breakpoints select one or more threads A breakpoint sets in the Source Window at the executable line only for the selected threads Having selected threads the results display in the Processes window With the cursor over a breakpoint at line 105 in the sample program in the Source Window a breakpoint information balloon displays to show where the selected thread begins Figure 6 54 Figure 6 54 Breakpoint Balloon with Thread Information in Source Window main c Sou
158. pt defined by command list command list end of command list document cmd create online documentation for new GDB command cmd help text end of help text Table 5 15 Signals Command Syntax handle signal act specify GDB actions for signal pe sient Tor signa halt execution on signal do not halt execution allow your program to handle signal do not allow your program to see signal show table of signals GDB action for each Table 5 16 Debugging Targets Command Syntax target type param connect to target machine process or file help target display available targets attach param connect to another process release target from GDB control 66 E i MX GNU X Tools User Guide Section 5 How to Use Command Line GDB Table 5 17 Controlling GDB set one of GDB s internal parameters display current setting of parameter Parameters understood by set and show write on off Allow or forbid patching binary core files when reopened with exec or core history groups with the following options h h exp off on disable enable readline history expansion file for recording h file filename GDB command history h size size number of commands kept in history list h save off on control use of external file for command history print groups with the following options p address on off print memory addresses in stacks values p array off on compact or attractive format for arrays p demangl on of
159. r exception 1s encountered or until execution completes al The Registers button invokes the Registers window for viewing or changing register properties for a program s content Al The Memory button invokes the Memory window for displaying and editing the state of memory and addresses The Stack button invokes the Stack window for displaying and navigating the current call stack where each line represents a stack frame i MX GNU X Tools User Guide E 73 section 6 How to Use Visual GDB Debugger Figure 6 7 Toolbars Menu cont Al The Watch Expressions button invokes the Watch Expressions window for entering expressions which will be updated every time that the executable stops The Local Variable button invokes the Local Variables window for displaying all local variables and their structure z The Breakpoints button invokes the Breakpoints window for examining breakpoints and changing their settings a he Console button invokes the Console window as a command line interface for debugging gdb is the prompt The left hand read only frame displays the program counter pc osso oF the current frame 5 iid The right hand read only frame displays the line number which contains the program counter Tl The Step assembler button steps through one assembler machine instruction Also the Step assembler button steps into subroutines T The Next assembler button steps to the next assembler instruction The Next a
160. r performance can be obtained by using this option This specifies the name of the target ARM architecture GCC uses this name to determine what kind of instructions it can use when generating assembly code This option can be used in conjunction iiMX GNU X Tools User Guide E 113 Appendix 1 ARM Toolsuite Option i Description S with or instead of the mcpu option Permissible names are armv2 armv2a armv3 armv3m armv4 the default setting armv4t armvo armvote arm6j iwmmxt mfpe lt number gt This specifies the version of the floating point emulation available on mfp lt number gt the target Permissible values are 2 and 3 mfp is a synonym for mfpe to support older versions of GCC mstructure size The size of all structures and unions will be rounded up to a multiple boundary lt n gt of the number of bits set by this option Permissible values are 8 and 32 The default value varies for different toolsuites For the COFF targeted toolsuite the default value is 8 Specifying the larger number can produce faster more efficient code but can also increase the size of the program The two values are potentially incompatible Code compiled with one value cannot necessarily expect to work with code or libraries compiled with the other value if they exchange information using structures or unions Programmers are encouraged to use the 32 value as future versions of the toolsuite may default to t
161. racted files is the time at which ar recreated them If you use the option xo instead of x ar sets the timestamp of the extracted files to the time recorded in the archive You can still create an ordered index less library with ar and invoke ranlib as a separate step if you want which is the convention of older Unix Systems However there is no longer any good reason for doing that when using GNU tools 4 12 GNU Libraries If you are familiar with Unix Linux and C programming the libraries you will find in the i MX GNU X Tools development environment should not confuse you The libraries you expect will all be there standard I O the math library the strings library etc The libraries are ANSI C and POSIX compliant Moreover there are many functions that Unix Linux programmers expect but are not specified by either of these standards Some C functions have been standardized and found in the GNU environment but system calls and math libraries are not the same as those found in a typical DOS Windows environment You will have to re learn these functions A good resource for learning the GNU Libraries is on the i MX GNU X Tools CD Docs directory MC Libraries pdf and Math_lib pdf 4 13 Instruction Set Simulator ISS Options Refer to Table 4 6 for your target s required ISS CFLAGS and LFLAGS The CFLAGS and LFLAGS my be necessary for compiling an application to run in the simulator When using GCC to c
162. ranslation ELF to Binary SREC eCtc ccc ceccccecccececeeeeseeeseeeeeeeeseeeseueeseesenesseeesaaees 57 4 11 Creating Updatng LIDFANIGS secieinicaccasecteosenndnecehawncceseseuansoaveet pn OEE i anaE 58 We COIN ION NSS saria E S E teson eetdern oueucenes 59 4 13 Instruction Set Simulator ISS Options ccc ccccceeeeeeeeceneeseceseeeesaeeeeaeeseeeseueesaeeseueeseeeesaeessass 59 SECTION 5 HOW TO USE COMMAND LINE GDB occ cece cence eeeeeeneeeeseneenesensenes 60 5 1 Summary of GDB the GNU DebDUGGE ccc cccccececeeeeceeeeeeceseeeseaeeseseesaeeseeeesaeesaueesaeeseeeesaeeeeas 60 LLI ODB AS F TOE GOWA ee ee en oe nen eee eee ee ne eee eee cr ene eer ee eee eee Ce ee E ee ee ee 60 91 2 TREGUICIMENIS OF GOD basis sieves acdesseciandavirnescicdevesenaddcencigedevonctesdectadiondeustetaadeeeddnadavdadogiavetinaadd veteaSetenteedevencesdeciateges 60 Oey Res rs 2 g1 EE B cere eee EE Seen een E E eee E A eee E eee ee eR A ne ene ne eee 60 314 Slalup OF GDB ais he ec acdc wee e dae eaaietie reese E OE toda RNa 61 5 2 GDB Comprehensive Quick Reference cccceccsececeeceeecseeeeeeceeeteeeteeeteeteeeseeeneessecsueeseeeeetseeteaes 62 FDIS Tin SSE COTA Serisini EEEE EE TAEAE ENEE EEEE AE A 62 Tane DZ SUNG sp sista ar r EE EE eds earns a ceca EEE E eaudeiegemeneaeas 63 Tadeo STOP DIAG ODD vgs srei seh sr essed a E EEE AAE E dares aces seas eda EE E E ER E S 63 Tales 4 GOING ACID erisin eas EE REE EEE aE ENE EA
163. rce Window ilaj x 0x804dec 3 104 stotic int batch 0 f x Pointers to various a guments from comnond line chor s_marg NULL These are static so that we can take their address in an initializer x stotic int print_help stotic int print_version j Pointers to all a guments of comnond option w chor cmdorg Allocated size of cmdarg breakpoint 9 at moin c 105 Ox8Uddecd main c wi ain w SOURCE This concludes our Section on how to use Visual GDB More information may be gotten using the on line help in Visual GDB 6 19 Visual GDB with JTAG BDM Debug Agents Microcross is partnered with several JTAG BDM tool vendors including Abatron American Arium EPI Tools Macraigor Nohau and Signum Each of these vendors support the GDB stub protocol and test their tools using the Microcross i MX GNU X Tools In this section we present two examples how how to use Visual GDB with an Abatron BDI2000 and a Macraigor mpDemon i MX GNU X Tools User Guide E 95 section 6 How to Use Visual GDB Debugger 6 19 1 Abatron BDI2000 Setup and Debug with Visual GDB Introduction Refer to Abatron s User Manual to install the CPU target firmware and configure on a network Microcross will discuss tools specific information necessary to use Visual GDB or for that matter command line GDB and get up and going with the BDI2000 debug agent Debugging with GDB Because the target runs within the BDI no
164. rectory CD ROM for reference or hard copy duplication iMX GNU X Tools User Guide E 41 Section 4 How to Use i MX GNU X Tools Table 4 5 PDF Documentation on CD ROM No FileName Description ee Pages Ss 1 Bench pdf By Joe Orost Bench is designed to 15 measure the performance of the code generated by C compilers not hardware performance Debugger v3 3 9 15 January 2004 Man pages pdf A Concise Reference Document for all of the Tools in Unix Man Page Format MC Auxiliary Tools pdf Using as Using binutils Using cygwin Using info Using the C Preprocessor MC Debugging Tools pdf Debugging with GDB Insight the GNUPro Debugger GUI Interface MC Embedded Systems pdf GNU Tools for Embedded Systems Everything you want to know about using GNU tools with embedded target processors MC Libraries pdf GNU C Library GNU Math Library GNU C iostream Library 11 MC Development Tools pdf Using Id Using make Using diff amp patch 12 MC Utilities pdf Using as Using Id Using binutils Using make Using diff amp patch Using info 4 5 Controlling the Tools Using the GCC The GCC GNU Compiler Collection control program can be run like the following producing an executable file from a number of C or C source files Both examples assume that the target toolsuite is installed prior to executing the build commands The examples shown are with GCC which controls the compilation of C C and assembly file
165. rties of registers use the following methods e To select a register single left click on it e To edit the contents of a register double click on it Alternatively use Register Edit to change the contents after selecting a register Use the Esc key to abort the editing e Use Register Format to invoke another pop up menu to display the contents of a selected register in Hex Hexadecimal Decimal Natural Binary Octal or Raw formats Hex is the default display format Natural format refers to and Raw refers to the source format The other formats are self explanatory e Use Register Remove from Display to remove a selected register from the window all registers will display if you close and reopen the window unless you have already selected this feature e Use Register Display All Registers to display all the registers this menu item is only active when one or more registers have been removed from display 6 10 Using the Memory Window The Memory window Figure 6 22 dynamically displays the state of memory Double click a memory location with the cursor in the window and edit its contents Figure 6 22 Memory Window Memory Addresses Address Oxf0 0x458d0000 Oxc35dec69 0x69104d8b Ox6q0000000 Oxe8000000 Ox458b10ec Oxf64089f4 0x458d0000 j2 0x466850f0 0x83e58955 0x5589f045 0x000068603 Oxff ft fffe Ox0 c558b08 OxOlfc45c 0x466850f0 Oxe8000000 Ox456b10ec Oxf84c09f4 0x458d00
166. ry Figure 6 22 Watch Expressions Figure 6 24 Local Variables Figure 6 29 Breakpoints Figure 6 33 Console Figure 6 38 Function Browser Figure 6 39 and Processes for threads use the Threads List menu item e Control has the following usage Step steps to next executable line of source code and steps into called functions Next steps to next executable line of source code in the current file and steps over called functions Finish finishes execution of a current frame and if clicked while in a function finishes the function and returns to the line that called the function Continue continues execution until a breakpoint watchpoint or exception is encountered or until execution completes Step Asm Inst steps through one assembler machine instruction and steps into subroutines Next Asm Inst steps to the next assembler instruction but steps over subroutines e Preferences has the following usage Global opens Global Preferences Figure 6 6 for changing how text appears Source opens the Source Preferences Figure 6 5 to show how colors display e Help has the following usage Help displays the Help window Figure 6 42 About Visual GDB displays the version number copyright notices for Visual GDB 76 i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger 6 7 Below the Horiz
167. ry of Embedded System Terminology 122 GNU 123 GNU Libraries 59 GNU X Tools Command Line Tool 35 gnuchess 108 GPL 7 gprof 108 grep 108 groff 108 GUI 124 gzip 108 H Horizontal Scroll Bar 77 I i386 124 IDE 124 inetutils 108 128 E i MX GNU X Tools User Guide Invoking GNU X Tools 36 Invoking Id 54 ISA 124 itcl 108 itk 108 J Java 124 JDK 124 JIT 124 JTAG 124 JVM 124 K ksh 108 L Id 41 109 124 Ldir 55 less 109 libcurses 109 libgloss 41 124 libjpeg 109 liom 41 libstdc 41 Libstdc 7 libtiff 109 License Agreement 7 linker 38 Linker 124 Linker Options 55 Linker Scripts 56 Link Order Optimization 57 Linux 9 11 12 122 124 Iname 55 Local Variables window 93 Local Variables Window 83 M M 47 56 M4 109 m68k coff 35 make 41 109 Make Related Problems 15 man 108 109 Memory Preferences Dialog 81 Memory Window 80 Menus and Display Features 76 Minimum System RAM 9 Modes of gcc 45 more 109 Mount 13 Multiple Threads 94 N N 56 Naming Conventions 8 ncurses 109 newlib 7 41 Newlib 124 nm 41 nostartfiles 47 nostdlib 48 O O name x 55 O0 50 O1 50 02 50 objcopy 41 objdump 41 object file 124 object file format 124 oformat format 56 Optimization 50 Options to spe
168. s make rebuild cr cleans and rebuilds binary images make TARGET_ IP xxx xxx Xxxx xxx newmon cr Substitute actual IP address Wait for approximately 30 seconds and power cycle the board to restart MicroMonitor You will be prompted to input the last four digits of the MAC address Use the last four digits on the label that is on the board and separate the every two digits with a colon Confirm the new MAC address when prompted and you are done 3 2 Dissaster Recovery Procedure Perform this procedure only if the module board flash has become corrupted and MicroMonitor fails to bootup This procedure assumes that the user has installed OCD Commander as directed in Section 3 4 above Step 1 Open two i MX GNU X Tools Shells One will run the OCDRemote program while the other will be used to load the binary to the board i MX GNU X Tools User Guide E 31 Section 3 Quick Start Guide Step 2 Connect the provided USB cable to the usbDemon connector on the module board and the other end to the host computer USB connector Connect the Ethernet and serial cables to the target expansion board and power on the board Start your serial terminal HyperTerminal uCon or equivalent to monitor board activity which should be nothing at this point if disaster recovery is truly needed If the board boots into MicroMonitor then do not proceed from here disconnect the usoDemon go back to the previous section and perform the normal ref
169. s 89 tix 109 tk 109 toolchain 13 35 36 111 Toolchain Flow Diagram 39 toolchains 35 36 Toolsuite 125 Toolsuite Components 8 traditional 47 U Unix 126 UNIX 9 45 52 58 59 120 121 126 unzip 109 Using the GNU Assembler 51 Using the Linker 54 V verbose 46 VES 126 130 E i MX GNU X Tools User Guide vi 109 VIDE 121 Viewing Local Variables 91 vim 109 Virtual Machine 126 Visual gdb 69 Visual gdb with External Debug Agents 95 W W 46 W 46 Wa option list 51 Wall 46 Watch Expressions Window 81 Watch Menu 82 Werror 46 which 109 Window for Expressions 76 Windows 2000 9 Windows 95 125 Windows NT 9 120 WI option list 51 Working Files 67 Wtraditional 46 X X 55 x86 126 XCOFF 126 Xemacs 109 Z zip 109
170. s Also the user must name the C files with the c extension and C files with C cpp or cc extensions target alias gcc options o lt program out name gt lt first c gt lt second c gt lt third c gt lt fourth c gt cr Or xtools lt target alias gt cr lt target alias gt gcc options o lt program out name gt lt first c gt lt second c gt cr 42 mi MX GNU X Tools User Guide Section 4 How to Use i MX GNU X Tools Or xtools lt target alias gt cr lt target alias gt gcc options one_or_more_source_files c o program out name cr Or lt target alias gt gcc options c source _file c cr lt target alias gt gcc options file1 o fileN o o program cr All alternatives actually look the same to the compiler parts The program executed under the name of GCC is just a front that handles options and temporary files and calls the real compiler parts cpp the C preprocessor It takes care of preprocessor directives such as include files and macro expansions It also removes comments The result is a file with the C code lots of white space and some line numbering directives that the compiler core can use in warning and error messages The o filter argument tells GCC to name the executable file program If you don t specify an o argument GCC chooses the default name a out which is not particularly informative and would ca
171. s Typical software companies use copyrights to limit your freedoms the Free Software Foundation uses the GPL to preserve these freedoms Fundamentally the General Public License is a license that says you have these freedoms and that you cannot take these freedoms away from anyone else To see the GNU General Public License see license txt on i MX GNU X Tools CD ROM 5 1 2 Requirements of GDB Before using GDB you should understand the formal requirements and other expectations for GDB Although some of these may seem obvious there have been proposals for GDB that have run counter to these requirements First of all GDB is a debugger It s not designed to be a front panel for embedded systems It s not a text editor It s not a shell It s not a programming environment GDB is an interactive tool Although a batch mode is available GDB s primary role is to interact with a human programmer The GDB should be responsive to the user A programmer hot on the trail of a nasty bug and operating under a looming deadline is going to be very impatient of everything including the response time to debugger commands GDB should be relatively permissive such as for expressions While the compiler should be picky or have the option to be made picky since source code lives for a long time usually the programmer doing debugging shouldn t be spending time figuring out to mollify the debugger GDB will be called upon to deal with really large progra
172. s that the command ar should add the files named in the list of files to the library named name creating a new library if necessary If a file is mentioned twice in the list of files ar includes it in the archive twice The s option tells ar to produce an index for the archive this is the function that ranlib would perform If you include the s option whenever you create or modify a library you will not need to use ranlib To update a library use the command lt target alias gt ar rus lib lt name gt a list of files cr This compares the dates of any listed files with the version of the file in the library If the file in list of files is more recent than the version contained in the library ar substitutes the newer version for the older version The s option updates the library s index To delete one or more files from a library use the command lt target alias gt ar ds lib lt name gt a list of files cr This option deletes all the files found in list of files To extract one or more files from a library use the command lt target alias gt ar x lib lt name gt a list of files cr 58 E i MX GNU X Tools User Guide Section 4 How to Use i MX GNU X Tools This does not modify the library file itself It extracts the files named in the list of files from the library regenerating them in the current directory with their original names Normally the timestamp of the ext
173. se functions The default is mno apcs stack check since this produces smaller code mthumb interwork Generate code which supports calling between the ARM and Thumb instruction sets Without this option the two instruction sets cannot be reliably used inside one program The default is mno thumb interwork since slightly larger code is generated when mthumb interwork is specified mno sched prolog Prevent the reordering of instructions in the function prolog or the merging of those instruction with the instructions in the function s body This means that all functions will start with a recognizable set of instructions or in fact one of a choice from a small set of different function prologues and this information can be used to locate the start if functions inside an executable piece of code The default is 112 E i MX GNU X Tools User Guide mhard float Appendix 1 ARM Toolsuite Description Generate output containing floating point instructions Note The Instruction Set Simulator ISS will only run code generated with the default software floating point emulation This is the default and it is not necessary to specify it The Instruction Set Simulator ISS will only run code generated with the default software floating point emulation mlittle endian Generate code for a processor running in little endian mode This is the default for all standard configurations msoft float mwords lit
174. ssembler button then executes subroutines and steps to the next instruction The Down Stack Frame button moves down the stack frame one level a The Up Stack Frame button moves up the stack frame one level The Go to Bottom of Stack Frame button moves to the bottom of the stack frame 6 3 Using the Mouse in the Source Window The mouse has many uses within the main display pane of the Source Window Divided into two columns Figure 6 8 the window s left column extends from the left edge of the display pane to the last character of the line number while the right column extends from the last character of the line number to the right edge of the display pane Within each column the mouse has different effects Figure 6 8 Using the Mouse in the Source Window Left column Right column main c Source Window if print_help print version ABS use_windows 0 ifdef TUL 427 Disable the TUI as well x tui_version 0 if 432 ifdef TUL 433 An explicit tui flog overrides the defoult UI which is the window system 434 435 if tui_version 43 use_windows 0 437 fendif Program stopped at line 97 nain c A main x SOURCE v 74 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger 6 4 Left column functionality for the Source Window When the cursor is in the left column over an executable line it appears as a minus sign When a breakpoint is set at this point
175. stead of the serial connection Visual GDB Startup with the mpDemon 1 Start the Visual GDB debugger with a binary with debug symbols lt filename gt and click on File Target Setting and following the procedures below to completely setup communications within Visual GDB lt target alias gt gdbtk lt filename gt cr you must be in the directory where the binary lt filename gt is located if using Visual X Tools to start the Visual GDB debugger then simply click on the icon or menu item under Build Click on Target combo box and select Remote TCP Enter the TCP IP address of the mpDemon Enter port address if setup as instructed it should be 8888 Select the desired check boxes Click on More Options enter any desired Run Options and click OK If debugging on the hardware target select the run option continue since a program cannot be run in the traditional sense through the JTAG Set your breakpoints if necessary and click on run and thereafter you can single step or continue Click on View to select view options like registers memory console function browser etc Review Section 5 for more details on how to use Visual GDB Figure 6 69 shows a screenshot of a program running and stopping at its first breakpoint it also shows views of registers memory and console along with the main source window i MX GNU X Tools User Guide m 105 Secti
176. structions 16 E i MX GNU X Tools User Guide Section 3 Quick Start Guide Section 3 Quick Start Guide 3 1 1 MX LiteKit Setup Windows Host Software Included in Home Installation The Windows host solution package on Cywin contains all of the tools utilities and sources to perform testing validation experimentation and application development for OS less single thread and embedded Linux environments Here is a summary of the directories under Cygwin home that offer a quick start to understanding and working with the i MX LiteKit Directory contents Cygwin home bench C test benchmarks from AT amp T for validating C tools debug example Macraigor usoDemon debug test example gxlinux GX Linux standard platform source directory ocd commander Macraigor OCD Commander installation software splash splash binary and autostart script test C example test code directory from Microcross ucon uCon Serial Terminal Software alternative to HyperTerminal umon MicroMonitor source directory umon recovery Recovery files for MicroMonitor uwindows MicroWindows Minesweeper example vxtools example Visual X Tools build and debug example The i MX LiteKit setup procedure follows and offers insight into the complete solution and how to get started using i MX technology Requirements e Host computer with Windows and i MX GNU X Tools pre installed see Section 2 e Host computer must h
177. t Canon fons int i vara varb vara 6x12345678 for i 6 i lt 6x166 i lt Vara Varb 2 varb Vara inc_var void shiftit i loop_passes for i O i lt sizeof test i lt Beek s r Program stopped at line 15 8260054 OxfFFFFFFF 6xb1126366 6xb1126366 6x8 6x81128366 6x81128366 6x345ca661 Size 0x200 lma 6x8266666 Size 6x24 lma 6x8266266 4384 bits in lt 1 sec 182 bytes write Warning the current language does not match this frame Breakpoint 1 at 6x826004c file test c line 14 Breakpoint 1 main at test c 14 i MX gdb s i MX gdb Construction of the gdbinit File In the gdbinit file are setup calls to the JTAG The following two lines are commented out but are available to users of large files that need debugging set remote memory write packet size 1024 set remote memory write packet size fixed These increase the frame size that GDB uses to communicate with OcdRemote These lines are not necessary but increase the download speed significantly GDB will prompt you to approve this change in the packet size enter yes lf GDB is run in GUI mode the gdbinit file leaves the GUI in the unattached state i e the execution control buttons are grayed out This state can be cleared by opening a console window and issuing a step command The execution control buttons will then be made active The RUN command
178. t all of the compiler defined symbols printed out on the screen Press Ctrl C to exit this mode Assembler Machine Dependent Options The following options are available when as is configured for the ARM processor family Options Description S O marm2 Arm 2 processor marm250 marm3 Arm 250 and Arm 3 processor marm6 Arm 6 processor marm tdmi Arm 7 processors marm8 10 Arm 8 processors marm9 20 tdmi Arm 9 processors mstrongarm110 0 StrongARM processors marmv2 marmv2a Arm architectures iiMX GNU X Tools User Guide E 115 Appendix 1 ARM Toolsuite Options i Description gt O marmv3 marmv3m marmv4 marmv4t marmv5 marmvdte marmv6 marmv6j mthumb Thumb mode mall Assemble All ARM Thumb instructions mno fpu Disable all floating point Select which procedure calling convention is in use mapcs 32 32 bit APCS mapcs 26 16 bit APCS mthumb interwork Code supports Arm Thumb Interworking EB EL Select either big endian EB or little endian EL output GNU ARM Assembler Quick Reference A summary of useful commands and expressions for the ARM architecture using the GNU assembler is presented briefly in the concluding portion of this Appendix Each assembly line has the following format lt label gt lt instruction or directive gt comment Unlike the ARM assembler using the GNU assembler does not require you to indent instructions and directives Labels are recognized by
179. ted by Linus Torvalds and friends starting about 1990 the pronunciation of lee nuhks is preferred accenting the first syllable since the name Linus has an ee sound in Swedish The Cygnus libraries which include the C library libc and the math library libm i386 Java U JTAG Linux Newlib object file A binary format file containing machine instructions and possibly symbolic relocation information Typically produced by an assembler object file format The layout of object files and executable files Common formats include a out or b out for Intel 960 targets only COFF amp ELF OSF 1 The Open Software Foundation s version of Unix used in Digital s Alpha machines 124 E i MX GNU X Tools User Guide TERM Patch PROM m AJ gt lt Registers RISC A O z RTOS Solaris Sparc stabs stub Target TCP IP telnet Toolsuite Glossary of Embedded System Terminology DESCRIPTION A change in source code to correct or enhance processes Portable Executable Microsoft s object file format for Windows 95 and NT operating systems It is basically COFF with additional header information Programmable Read Only Memory ROM that can be programmed using special equipment PROMS can be programmed only once Compare with EPROM Random Access Memory referring to volatile memory that can be read and written by a microprocessor Remote debugging
180. tent assumes familiarity with GDB and its main debugging procedures 6 18 1 Selecting and Examining a Source File To select a source file or to specify what to display when examining a source file when debugging use the following process 1 Select a source file from the file drop down list at the bottom left of the Source Window main c in the example in Figure 6 43 Figure 4 43 Source File Selection Progran not running Click on run icon to start v w SOURCE m Lang h m2 tupeprint c m valprint c mochmode def mochmode h macro c moin c moint c moth nA mothcalls h mothdef h mothinline h mdebugr ead c mem break c 90 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger 2 Select a function from the function drop down list to the right of the file drop down list or type its name in the text field above the list to locate a function 3 Type a character string into the search text box Figure 4 44 Figure 4 44 Search Text Box noon 4 Press Enter to perform a forward search on the source file for the first instance of a specific character string After having specified main in the search text box the example program in Figure 6 45 shows the jump to a main function Figure 6 45 Searching for a Word in Source Code main c Source Window File Run Yiev Control Preferences om amp B63 2 2 Oxc 95 2 include lt sys cygwin h gt for cygqwin32_
181. ter keys to repeat the search Type with a number in the search text box and press Enter to jump to a specific line number in the source code The example program in Figure 6 19 shows a jump to the line 86 Figure 6 19 Searching for a Specific Line in Source Code main c Source Window File Run iew Control Preferences 3H P P uR e Bo EE Oxc 95 81 include lt windows h gt for MAX_PATH 82 Hinclude lt sys cygwin h gt for cygwin32_cony_to_posix_path 83 H endif 84 85 int 86 main argc argv 87 int argc 88 char argv 9 90 int count Program not running Click on run icon to start main c main w SOURCE 78 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger 6 8 Using the Stack Window Each time your program performs a function call information about the call generates That information includes the location of the call in your program the arguments of the call and the local variables of the function being called The information is saved in a block of data called a stack frame The stack frames are allocated in a region of memory called the call stack When your program stops you can examine the stack you to see this information A stack refers to the layers TCP IP and sometimes others through which all data passes at both client and server ends of a data exchange The call stack is the data area or buffer used for storing requests that need to be han
182. test cr arm elf gcc g o div x div c cr arm elf ddd div x debugger arm elf gdb cr i MX GNU X Tools User Guide E 61 Section 5 How to Use Command Line GDB Start DDD In General ddd lt name of elf object gt debugger lt target alias gt gdb cr This concludes our short DDD example There is a complete user guide on DDD in the docs directory on the i Mx GNU X Tools CD ROM 5 2 GDB Comprehensive Quick Reference Table 5 1 Essential Commands info stack print int 0x10000 set int 0x1000 0x123 info registers set lt reg name gt lt value gt runs next line of code step into file lt name of object gt loads file for debugging load loads object sections selects lt name gt remote serial sim gdbserver etc ru run a program in the simulator before using this command a sequence must be executed as follows lt target alias gt gdb lt filename gt object file with debug symbols target sim load run x FMT display modifier where FMT is x print in hex d print in decimal s print as string w print in 32 bit words h print in 16 bit words b print in 8 bit words print number of items 62 E i MX GNU X Tools User Guide Section 5 How to Use Command Line GDB Table 5 2 Starting GDB Command Syntax start GDB with no debugging files GDB program begin debugging program GDB program core debug coredump core produced by program describe comma
183. that we have already configured most settings for the i MXL module with the exception of an IP address for your specific network settings Open the makefile with any editor and enter the IP address that you assigned the target board The following are all of the environment variables that normally need setting in the makefile Double check your board settings as a drill in this example ARCH Set ARCH to one of the accepted CPU architectures i e MIPS PPC ARM COLDFIRE MONCOMPTR Retrieve MONCOMPTR from the output of set APPRAMBASE Set APPRAMBASE to the content of the APPRAMBASE shell variable or a bit higher TARGET IP Set TARGET_IP to the IP address of your target Example 1 Hello Embedded World Build Load Run Procedure Step 1 Start a i MX GNU X Tools Shell using the red X icon on the desktop assuming the toolsuite is installed i MX GNU X Tools User Guide E 19 Section 3 Quick Start Guide Step 2 Issue these commands in the Shell cd home umon umon_apps user_manual cr make app1 cr builds application make appidid cr downloads application to the board Step 3 In the Serial Terminal at the UMON gt command line issue the following command to run the application UMON gt app1 cr run the example application UMON gt Hello embedded world prints out from the example program UMON gt tfs Is cr shows filesystem contents UMON gt tfs rm app1 cr removes deletes app1 fr
184. the following colon instead of their position at the start of a line An example follows showing a simple assembly program defining a function add that returns the sum of two input arguments 6 99 section text x global add give the symbol add external linkage add ADD _ 10 r0 r1 add input arguments MOV pe Ir return from subroutine end of program GNU Assembler Directives for ARM The follow is an alphabetical listing of the more command GNU assembler directives GNU Assembler Directive Inserts the string as data into the assembly like DCB in armasm Like ascii but follows the string with a zero byte balign lt power_of_2 gt lt fill_ value gt Aligns the address to lt power_of_2 gt bytes The assembler aligns by lt max_padding gt adding bytes of value lt fill_ value gt or a suitable default The alignment will not occur if more than lt max_padding gt fill bytes are required similar to ALIGN in armasm byte lt byte1 gt lt byte2 gt Inserts a list of byte values as data into the assembly like DCB in armasm code lt number_of_bits gt Sets the instruction width in bits Use 16 for Thumb and 32 for ARM assembly similar to CODE16 and CODE32 in armasm Use with if and endif similar to ELSE in armasm Marks the end of the assembly file usually omitted 116 E i MX GNU X Tools User Guide Appendix 1 ARM Toolsuite GNU Assembler Directive Ends a conditional compi
185. the program and viewing the changing values in the local variables i MX GNU X Tools User Guide E 91 section 6 How to Use Visual GDB Debugger 1 With the Source Window active and the main c source file open the cursor was placed over the minus sign on line 6 2 When the minus sign changes into a circle click the left mouse button this sets the breakpoint indicated by a colored square 3 Click on a breakpoint to remove the breakpoint 4 Repeat the process to set breakpoints at specific lines 5 Open the Breakpoints window Figure 6 47 Figure 6 47 Breakpoints Window Ereakpoints EBreakpoint Global Address File Line Function Oxo04debl main c 103 main Qxo04dec 1 main c 104 main 0s804ded main c 106 main O 804dedb moin c 10 moin 0x804dec9 main c 105 main 6 Click the check box for a line to set a breakpoint in an executable The box s color changes and the square s color of the line in the Source Window changes Figure 6 48 This color change indicates a disabling of the breakpoint Re enable the breakpoint at the line by clicking the check box in the Breakpoints window Figure 6 48 Disabling a Breakpoint in Breakpoints Window Breakpoints Breakpoint Global Thread Address File Line Function ALL OxeQ4ddebl woin c 103 main E ALL x lddeci nain c 104 main ALL OxeQddede wdin c 106 main E ALL Ov 80d4dedb noin c 107 moin F Ove0ddecd nain c 105 main L
186. tion update License Codes Ping TCP IP address Display Error Log Reboot mpbemon SET SET Set Set ype Command i lt sEnter gt will refresh screen gt t OCDREMOTE Configuration Test Test at JTAG Speed 1 8 gt 1 Idx CPU Type 1 Hit any key to continue Status ARMO RUN Ag Figure 6 68 mpDemon Configuration Test W Tera Term COM1 VT POM damurcrlacne Edit Setup Control Window Help Serial API baud Rate CHEF option TCP IP Address TCP IP Mask Set TCP IP Sea Set OCDREMOTE Configuration Test OCDREMOTE Configuration Update License Codes Ping TCP IP address Display Error Log Reboot mptemon Set Set Set Set ype Command C lt Enter gt will refresh screen gt t OCDREMOTE Configuration Test Test at JTAG Speed 1 8 gt 2 Ig status 1 Hit any key to continue CPU Type ARM Stopped 104 E i MX GNU X Tools User Guide aca Section 6 How to Use Visual GDB Debugger Conclusion of the mpDemon Setup The configuration of the mpDemon only has to be entered once for a given target system It is stored in the mpDemon s flash and will remain active until it is changed by the user To use the web based interface to configure the mpDemon you can plug in the Ethernet cable to your network and open a web browser and enter the TCP IP address that you configured into the mpDemon e g http 192 168 0 220 Changes to a configuration can then be made through the browser in
187. tle endian malignment traps mno alignment traps mcpu lt name gt mtune lt name gt march lt name gt Generate code for a processor running in big endian mode the default is to compile code for a little endian processor This option only applies when generating code for big endian processors Generate code for a little endian word order but a big endian byte order That is a byte order of the form 32107654 Note this option should only be used if you require compatibility with code for big endian ARM processors generated by versions of the compiler prior to 2 8 Generate code that will not trap if the MMU has alignment traps enabled On ARM architectures prior to ARMv4 there were no instructions to access half word objects stored in memory However when reading from memory a feature of the ARM architecture allows a word load to be used even if the address is unaligned and the processor core will rotate the data as it is being loaded This option tells the compiler that such misaligned accesses will cause a MMU trap and that it should instead synthesize the access as a series of byte accesses The compiler can still use word accesses to load half word data if it knows that the address is aligned to a word boundary This option is ignored when compiling for ARM architecture 4 or later since these processors have instructions to directly access half word objects in memory Generate code that assumes that the MMU
188. tools install hdrs lt target alias gt arcpath This option like option 7 allows incremental updates to an installed toolsuite except that it updates the library headers files It updates the following files usr lt target alias gt include h 4 3 Invoking i MX GNU X Tools To invoke i MX GNU X Tools from the command line in the shell type xtools target alias and from that point on you do not need to type the alias at any point further The target alias will become part of the command line prefix i e target alias To change or exit the target alias mode type exit at the command line From Command Shell type xtools arm elf cr The prompt will now show arm elf To show the GCC version arm elf gcc v cr Issuing the following commands can be accomplished using the shortened version of tool name i e gcc as ar etc provided that you perform the xtools lt target alias gt command as shown above e target alias gcc Invokes all the necessary GNU compiler passes for the specific target processor toolsuite using i e arm elf mips elf ppc elf etc e target alias cpp Invokes the preprocessor that processes all of the header files and macros that the target requires e target alias gcc Invokes the C compiler that produces assembly language code from the processed C files 36 E i MX GNU X Tools User Guide Section 4 How to Use i MX GNU X Tools e target alias g Invokes the C comp
189. truction stepi S M M M M continue cont o M M down arg frames down C x amp copy number from point insert at end C x SPC in source file set break at point S n i C continue cont u d Mec S Mu upg frames up Mda S Cx amp S 68 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger Section 6 How to Use Visual GDB Debugger 6 1 Using Visual GDB Debugger Microcross builds and packages the popular GDBTK a k a Insight and calls it Visual GDB to differentiate the product from the FSF GDBTK and other vendors products Red Hat Insight Visual GDB has all of the features accustomed to Red Hat Insight and we provide a short introduction on how to use the features of Visual GDB 6 2 Visual GDB An Alternative Interface to Command Line The following documentation serves as a general reference for i MX GNU X Tools graphical user interface its visual debugger Visual GDB for more information see also Visual GDB s Help menu for discussion of general functionality and use of menus buttons or other features and Examples of Debugging with Visual GDB in this Section If using a i MX GNU X Tools Bash Shell compile your program into a cross executable In Figure 5 1 we started the i MX GNU X Tools Bash Shell and show a simple demonstration using the arm elf toolsuite to create a cross executable for loading into Visual GDB Note GDBTK is the Visual GDB executable at
190. ts Breakpoint Global Thread Address File Line Function ALL Ox604deb1 nain c 103 main ALL 0x8l4dect nain c 104 main ALL Ox6 4ded2 noin c 106 main ALL Ox804decdb noin c 10 main ALL 0x8lidec9 nain c 105 main Single click with the mouse with the cursor over a check box of a breakpoint to disable the breakpoint The color of the square in the Breakpoint window changes Line 101 in Figure 6 35 and the line s breakpoint status changes in the Source Window Figure 6 35 Setting Temporary Breakpoints in the Breakpoints Window Breakpoints Breakpoint Global Thread Address File Line Functicn ALL Ox804deb1 nain c 103 main ALL Ox 604dec noin c 104 main Ox804ded2 nain c 106 main Ox804dedb noin c 10 main O 804dec9 nain c 105 main Using the Breakpoint menu for the Breakpoints window toggle the enabled or disabled state of a selected breakpoint The single check mark between them shows the state of the selected breakpoint Remove removes the selected breakpoint Using the Global menu for the Breakpoints window Disable All disables all breakpoints Enable All enables all breakpoints and Remove All removes all breakpoints Single click an empty check box of a disabled breakpoint to re enable a breakpoint Figure 6 36 A check reappears and the color of the square in the Source Window changes see Figure 6 37 86 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger Figure 6 36 Results
191. ts by default pointers display in hexadecimal with all other expressions as decimal Use Watch Remove to remove a selected expression from the watch list Use the text edit field and the Add Watch button at the bottom of the window to add registers to the Watch Expression window or by typing register convenience variables into the text edit field add an expression to the watch list see corearg added in Figure 6 27 with its results in Figure 6 28 Figure 6 27 Using the Add Watch Button for the Watch Expressions Window 82 E i MX GNU X Tools User Guide Section 6 How to Use Visual GDB Debugger Every register has a corresponding convenience variable The register convenience variables consist of a dollar sign followed by the register name Spc is the program counter s convenience variable for example while fp is the frame pointer s convenience variable Re cast other types to which a pointer was cast by typing it in the text edit field For example typing struct foo bar in the text edit field the bar pointer is cast as a struct foo pointer Invalid expressions are ignored Figure 6 28 Results of Using Add Watch Button for the Watch Expressions Window Whi atc hi Ex H fess j ons cdarg chor 0x0 ttyarg cho 0x0 corearg char Oxbffrfogd Prsa corearg Format Rencyre Edit Ts Add Hatch 6 12 Using the Local Variables Window The Local Variables window Figure 6 29 displays the c
192. tting Started Guide Red Hat 2001 Free Software Foundation Web Site http www gnu org 2004 Macraigor mpDemon User Manual 2004 Abatron BDI2000 User Manual 2004 ARM System Developer s Guide Andrew Sloss Dominic Symes and Chris Wright Morgan Kaufmann 2004 iMX GNU X Tools User Guide E 121 Glossary of Embedded System Terminology Glossary of Embedded System Terminology TERM DESCRIPTION ABI Application Binary Interface which defines how programs should interface with the operating system including specifications such as executable format calling conventions and chip specific requirements Application Programming Interface defining how programmers write source code that makes use of a library s or operating A B P system s facilities by accessing the behavior and state of classes and objects SP Board Support Package typically referring to the low level code or scripts that build programs running on a particular CPU ona particular circuit board Also refers to the ROM that boots an RTOS onto a specific board Exact meaning varies Also used as a noun to denote the results of the process COFF Common Object File Format This debug format appeared with Unix SVR3 formerly common for Unix and still used by some embedded systems The Microsoft PE format for Windows is based on COFF specification Compiler A tool that translates high level source code in a language such as C or Pascal into mach
193. uired compiler and linker flags a list of debugger targets for both command line GDB and Visual GDB machine compiler and assembler dependent options and notes Required Compiler Linker Flags The following compiler linker options are required to build for execution with the simulator CFLAGS none required LFLAGS none required Command Line GDB Debugger Targets async Use a remote computer via a serial line cisco Use a remote machine via TCP exec Use an executable file as a target extended async Use a remote computer via a serial line extended remote Use a remote computer via a serial line iMX GNU X Tools User Guide E 111 Appendix 1 ARM Toolsuite rdi Connects to target running ARM Angel Monitor To connect to an external target using the rdi Angel monitor use the GDB command target rdi N where N equals 1 or 2 to select serial port 1 or 2 as the interface port rdp Use a remote ARM system that uses the ARM Remote Debugging Protocol remote Allows the GDB to connect to a remote target running the GDB remote debugging protocol via a serial port or a TCP socket connection The GDB debugger can connect to a board via Abatron s BDI2000 or EPl s JEENI JTAG debug agents across Ethernet Any debug agent that communicates using the GDB Stub protocol can be accessed through GDB Visual GDB sim The GDB debugger contains a integrated simulator based target that can lo
194. undation for their role in focusing and managing open source development e Cygnus Solutions and now Red Hat for their leadership and contributions toward the GNU Tools as a viable cross development platform e Linus Torvalds for creating the Linux kernel and founding the crusade to level the OS playing field e Many thousands of individual contributors whose names can be found buried in the source files that they spent long nights developing debugging and perfecting e Additional acknowledgements are noted in the contributors file of each subdirectory of the source tree 1 3 License Agreement The i MX GNU X Tools is distributed under the license terms of the General Public License GPL You may read this license at www gnu org or on the distribution CD for i MX GNU X Tools The following exceptions apply e The C and Math Libraries Newlib are distributed under an unrestricted license so that linked library binaries may be distributed as part of user developed applications without restrictions from the GPL e Libstdc the C class and template libraries are distributed under the FSF GNU Lesser General Public License LGPL e The i MX GNU X Tools and Cygwin Windows installers are licensed software material from Microcross e The i MX GNU X Tools and Cygwin CDs may not be reproduced without prior written consent from Microcross e The MicroMonitor source code boot ROM for Cogent i MX single board computers is available under non restrict
195. ure 6 64 Select Device m Tera Term COM1 VT File Edit Setup Control Window Help JTAG spee Number of Devices in Scan Chain C0 16 gt 1 Device List ARM 7 9 Families ARM ARMS Netsilicon LH7A40Xx MIPS 32 bit Family MIPS32_4Kc MIPS32_4kKe AULxOO MIPS 64 bit Family MIPS64 TX49 PowerPc Family PPC40x PPC55X PPC56xX PPC603 PPC7X0 PPC X5 PPC8X lt PPC5554 PPC8240 PPC8 amp 245 PPC8247 PPC8248 PPCB270 PPCB271 PPCB272 PPC8275 PPC8280 PPC825xX PPC826xX PPC amp 5x0 Intel xScale Family 80200 80219 IOP303 IOP321 PXA210 PXAZ5x PXA2Z6x XSCALE 5IR IOP331 IOP332 IXC1100 IxP42x IKP2400 IxP2800 IXP2850 PXA27X XSCALE 7IR IOP315 XSCALE 5IRSLAVE UNKNOWN lt ir bits gt lt bypass bits gt Deyvicel gt ARMS Figure 6 65 Select Port Number H Tera Term COM1 VT Fie Edit Setup Control Window Help ARM 79 Families ARMY ARMS Nets5silicon LH7A4 0x MIPS 32 bit Family MIPS3s2_4kKkc MIPS3s2_4kKe AUL OO MIPS 64 bit Family MIPS64 Tx49 PowerPC Family Pec4a0 gt PPo5S5S PPCS6 PPCeOsS PPCY O PPI PPOB PPC5554 PPCe240 PPCHZ45 PPCH4 PPCHZ48 PPCBRSZ YO PPCS271 PPCRe 2 PPCB 275 PPCRZ8O PPCH2Z5 amp PPCRZ6X PPCHS O Inte Scale Family 50200 80219 IGP303 IOFP321 PxXAZ10 Phe oe PWAZJ6X MSCALE 5SIR IOP331 IoPs3se2 IMC1100 IXP42e IXP2400 IxXP2800 IXP2850 PAZ MSCALE YIR IOP315 SCALE SIRSLAVE UNKNOWN lt ir bits gt lt bypass bits Dewicel gt ARMS CPYIP port number 8888 8888 Reboot m to run with new par
196. urrent value of all local variables Figure 6 29 Local Variables Window Local Variables Yoriable char s Oxbt ttt ad 1075659492 0 0 char Oxi evecarg chor Ose sAddress Ox out of bounds gt corearg char Oxbffff994 P xo3 cdarg char 0x0 ttyorg char Ox0 orint_help print_wersion 0 char a Ox40000210 1079749452 1073744044 chor Oxbt tr rye 1075659492 1073744036 struct stat struct stat homedir chor x Ox40000000 177ELF001 001 001 homed nit chor Ox i 1073747220 time_at_sto tup 24 Use Variable Edit to change the value of a selected variable that you want edit Using the Escape key Esc aborts editing Use Variable Format to invoke another pop up menu to display a selected variable s value in Hex Hexadecimal Decimal Binary or Octal formats By default pointers display in hexadecimal and all other i MX GNU X Tools User Guide E 83 section 6 How to Use Visual GDB Debugger expressions as decimal Single click the mouse with the cursor over a variable in the Local Variables window to select the variable Figure 6 30 Figure 6 30 Selecting a Variable _ocal Variables cdorg ttyarg print_help print wersion cmdsize ncmd Adirarg dirsize ndir homebuf cwdbuf homedir homeinit 1 char Usbr tt toad 1075659897 0 i chor 0x0 Oee Address One out of bounds 0x0 0 coor x Ox40000210 1073743452 107
197. use multiple executables to overwrite each other So most programmers use the o argument to name the program Since the inputs to the last example above are all object files no compilation or assembly is required GCC always invokes the linker Using GCC to invoke the linker is preferable to using Id separately because GCC ensures that the program is linked with the correct libraries and initialization routines 4 5 1 GCC Options Commonly Used C Compile or assemble the source files but do not link The linking stage simply is not done The ultimate output is in the form of an object file for each source file O file The o and not c tells GCC to create a linked executable with a user defined filename as its output file Not specifying c or o will tell GCC to create a default executable named a out for all cross compilers and a exe for the native Cygwin compiler D One the D option acts like define in the source code it sets the value of a symbol lt target alias gt gcc c D first info D second example c cr The first D option sets first to the string info because of the backslashes the quotation marks actually become part of the symbol s definition This can be useful for controlling which file a program opens The second D option defines the second symbol It happens to set it to the value 1 the default but you
198. using the GNU compiler and tools to generate executable programs for a target processor Mastering the toolsuite and using it to develop embedded systems on a practical scale requires greater in depth knowledge than can be covered here If you are considering the GNU cross tools for full scale development it is suggested that you acquire the manuals listed in the bibliography see Bibliography The ones having unrestricted reproduction rights are included in the docs directory on the i MX GNU X Tools CD ROM The O Reilly book Programming with GNU Software by Mike Loukides and Andy Oram is highly recommended being complementary to this User Guide as well as a comprehensive guide to the GNU tools The remaining texts provide more in depth knowledge for specific toolsuite components as needed In addition Microcross offers a GNU X Tools Training Guide as a complimentary product It is based on an on site three day training course for beginning to intermediate level audiences The course material is tailored to the i MX GNU X Tools for embedded development and the format is geared to a self paced training program 4 2 Using the i MX GNU X Tools Command Line Tool xtools The i MX GNU X Tools command line tool is a shell tool designed to provide several functions that facilitate convenient management of the i MX GNU X Tools cross toolsuites from a command shell environment For many developers this method is more convenient than using a GUI The followi
199. utable Formats ae 4 4 3 Control Program GCC Exactly how the GCC processes any file depends on the file s name The control program strips the initial part of the name and then determines how to process the file on the basis of the filename s extension In each case the control program passes the file to the appropriate program for preprocessing compilation or assembly and it links iMX GNU X Tools User Guide E 39 Section 4 How to Use i MX GNU X Tools all resulting object modules together to produce an executable file The following table shows how the control program recognizes different file types Table 4 1 Controlling Compilation Linking Input File Interpretation Action S Lower case file extension Upper case file extension All other files together with options that GCC does not recognize are passed to ld the linker either the native linker supplied by your vendor or the GNU linker As a result almost all linker options are available directly through GCC In the commands shown earlier in this Section the l and L options were actually passed to the linker In general GCC passes on unrecognized options to the linker so you can specify linker options without having to invoke the linker separately If you re writing C code you can use the g command instead of GCC You re actually getting the same compiler however when it is invoked as g the compiler expects C
200. ve environments nostarttiles Don t use the standard system startup files when linking Normally the crt0 o file gets linked in as the standard start file however most embedded developers will need to replace the standard start file with a custom start file When used with GCC add the correct option WI nostartfiles and add the custom startfile with appropriate entry symbol to the linker script e g ENTRY _start To learn more about how to create linker scripts and startfiles read the i MX GNU X Tools Training Guide or the Microcross Visual X Tools User Guide nodefaultlibs Do not use the standard system libraries when linking Only the libraries you specify will be passed to the linker The standard startup files and used normally unless nostartfiles is used The compiler may generate calls to i MX GNU X Tools User Guide E 47 Section 4 How to Use i MX GNU X Tools memcmp memset and memcpy for System V and ANSI C environments or to bcopy and bzero for BSD environments These entries are usually resolved by entries in libc These entry points should be supplied through some other mechanism when this option is specified nostdlib When linking this option tells the linker do not use the standard libraries or startup files This option is useful when you want to provide your own libraries overriding the default libraries and use your own custom startup files When used with GCC add the correct option
201. will not trap unaligned accesses This produces better code when the target instruction set does not have half word memory operations implementations prior to ARMv4 Note that you cannot use this option to access unaligned word objects since the processor will only fetch one 32 bit aligned object from memory The default setting for most targets is mno alignment traps since this produces better code when there are no half word memory instructions available This specifies the name of the target ARM processor GCC uses this name to determine what kind of instructions it can use when generating assembly code Permissible names are arm2 arm250 arm3 arm6 arm60 arm600 arm610 arm620 arm7 arm7m the default setting arm7d arm7dm arm 7di arm7dmi arm70 arm700 arm700i arm710 arm710c arm7100 arm7500 arm7500fe arm tdmi arm8 strongarm strongarm110 strongarm1100 arm8 arm810 arm9 arm920 arm920t arm9tdmi arm9e arm926ejs arm1020t arm1026ejs arm1136js arm1136jfs iwmmxt and ep9312 This option is very similar to the mcpu option except that instead of specifying the actual target processor type and hence restricting which instructions can be used it specifies that GCC should tune the performance of the code as if the target were of the type specified in this option but still choosing the instructions that it will generate based on the CPU specified by a mcpu option For some arm implementations bette
202. with the drive letter are removed Delete the Cygwin directory 1 Open Windows Explorer 2 Click on the Cygwin directory and press the delete key 2 3 Install i MX GNU X Tools on Linux Host The following procedures is for installation of the i MX GNU X Tools toolsuite on a Linux host Insure that the system requirements have been met especially RAM and free disk space The Linux installation procedure for i MX GNU X Tools is a command line procedure and is very simple and straightforward We assume that you have a Linux OS running on your workstation or server before getting started with this installation All commands are done from the Bash Shell xterm Step7 Insert the i MX GNU X Tools distribution CD into the CD ROM drive Step 2 Start a Bash Shell xterm and login as root or use su You will need to do this each time you install or uninstall i MX GNU X Tools because you will need write access to the usr bin and usr lib directories where the toolsuite is installed 12 E i MX GNU X Tools User Guide Section 2 Install and Setup Procedures Step 3 Mount the i MX GNU X Tools distribution CD on the CD ROM drive using the mount command Example mount t iso9660 dev cdrom mnt cdrom cr The system will announce that it has mounted the CD ROM as read only Note On some Linux systems the CD ROM will be mounted by an automounter which means step 3 may not be required Step 4 Install
203. word lt word1 gt lt word2 gt Inserts a list of 32 bit word values as data into the assembly similar to DCD in armasm Assembler Special Characters Syntax Inline comment char Line comment char F Statement separator pi Immediate operand prefix or Register Names General registers r0 r15 0 const 0 FP registers fO Yof7 Non saved temp regs r0 r3 r12 Saved registers r4 Yri10 Stack ptr register Sp Frame ptr register ofp Link retn register olr Program counter Yip Status register psw Status register flags xPSR x C current xPSR_all x S saved xPSR_f xPSR_xX xPSR_ctl xPSR_fs xPSR_fx xPSR_fc xPSR_cs xPSR_cf xPSR_cx and so on Arm Procedure Call Standard APCS Conventions Argument registers a0 Yad aliased to r0 r4 Returned value regs v1 v6 aliased to r4 r9 Addressing Modes rn in the following refers to any of the numbered registers but not the control registers addr Absolute addressing mode Yorn Register direct Yorn Register indirect or indexed Yorn n Register based with offset imm Immediate data Machine Dependent Directives arm Assemble using arm mode thumb Assemble using thumb mode code16 Assemble using thumb mode code32 Assemble using arm mode force thumb Force thumb mode even if not supported thumb_func Mark entry point as thumb coded force bx entry 118 E i MX GNU X Tools User Gu
204. xample lt target alias gt gcc c g O Wa alh L file c cr This above example emits a listing to standard output with high level and assembly source Usually you do not need to use this Wa mechanism since many compiler command line options are automatically passed to the assembler by the compiler You can call the GNU compiler driver with the v option to see precisely what options it passes to each compilation pass including the assembler Next we discuss what the assembler does We will not discuss the assembly language itself The FSF s documentation explains the general syntax of assembly language but refers you to the vendor s architecture manual for CPU dependent details overall architecture instruction set etc i MX GNU X Tools User Guide E 51 Section 4 How to Use i MX GNU X Tools The assembler takes a program written in an assembly language and produces an object module By convention assembly language programs have the extension s If no errors occur during assembly and if the object module contains no references to external imported symbols the assembler makes the file executable and names it a out If the object module includes references to external symbols a out is not an executable The linker is able to link this object module with other modules to produce an executable program To invoke the assembler enter the command lt target alias gt as options lt list of source files
205. xe 1203000 0xe3a02000 0xe5c32000 9xe2800001 0x2050004c OxeafffFF7 Oxe59Ff30bc Oxe5930008 Oxe3a01000 Breakpoint 3 main at app c 73 0x2050005c 0xe3a02000 0xeb 002290 0xe3e 00000 Oxeb00295F Breakpoint 4 orig _ main at app c 82 0x2050006c AxebAANAdF Oxe59F O06 OxebOH257a OxebooH3cc B 0x2050007c 0xe3a0300a 0xe58d3000 0xe59f3090 Oxe5803004 0 0 0 0 gdb 0x2050008c Oxe3a03b02 0xe58d3008 Oxe3a03009 Oxe58d3 08c erent PEREREY i eee PESE 4 106 E i MX GNU X Tools User Guide section 7 Introduction to Cygwin Section 7 Introduction to Cygwin 7 1 Introducing Cygwin One of the largest problems developers face today is supporting their applications on disparate platforms Many of the new Windows workstations are being added to an environment already populated by Solaris HP UX AIX and Linux systems Using Cygwin developers can manage heterogeneous environments in a consistent efficient way Cygwin brings a standard UNIX Linux shell environment including many of its most useful commands to the Windows platform so software managers can effectively deploy trained staff and leverage existing investments in UNIX Linux source code and shell scripts Cygwin delivers the Free Source standard GNU GCC compiler and GDB debugger on Windows In addition it provides for a standard UNIX Linux development environment on Windows including APIs and command shells The Cygwin dll
206. y configure the mpDemon 1 With power off connect the appropriate JTAG BDM header connector to the board and the other end to the mpDemon 2 Connect the Macraigor supplied serial cable to the host computer s available serial port and the other end into the mpDemon Connect the power cable to the mpDemon and target board The mpDemon will show power indication on the front panel with an LED lit Start a Serial Terminal serial communications program Set the serial connection speed to 19 200 baud no parity 8 data bits 1 stop bit and no flow control Press the Enter key on the keyboard and you should get a boot setup screen showing up in your serial monitor program Figure 6 55 shows the first boot screen oi Figure 6 55 Basic Boot Screen of mpDemon for Setup Tera Term COM1 VT DER File Edit Setup Control Window Help Macraigor Systems mpbemonttm wersion 3 0 0 0 petal PI Baud Rate 115200 NO 197 168 Oo 211 255 255 255 0 Gateway 192 168 0 250 AC Address 00 60 bf 0L 0a aF COREMOTE Disabled mptemon Command Menu Set serial API baud Rate Set DHCP option Set TCP IP Address Set TCP IP Mask Set TCP IP Gatewa Set OCDREMOTE Configuration Update License aude Ping TCP IP address Display Error Log Reboot mpbemon POM damor ons ype Command lt Enter gt will refresh screen gt amp f gu 6 Enter the letter B to set the serial API baud rate Enter a desired value fro

Download Pdf Manuals

image

Related Search

Related Contents

QOSMIO X300  PowerTeacher 2.0 User Guide  CARDIO  LotusLive iNotes: LotusLive iNotes Benutzerhandbuch  Olympia ECS 518.4 CCD  USER MANUAL - Trade Connect  Voilures ailes de secours Manuel d`entretien et de pliage Ram  2ページ  Locke FP User's Manual  MANUAL DE INSTRUCCIONES PARA SOLDADORAS DE ARCO  

Copyright © All rights reserved.
Failed to retrieve file