ADS Introductory Workbook.pdf

上传人:来看看 文档编号:3641581 上传时间:2019-09-19 格式:PDF 页数:31 大小:235.24KB
返回 下载 相关 举报
ADS Introductory Workbook.pdf_第1页
第1页 / 共31页
ADS Introductory Workbook.pdf_第2页
第2页 / 共31页
ADS Introductory Workbook.pdf_第3页
第3页 / 共31页
ADS Introductory Workbook.pdf_第4页
第4页 / 共31页
ADS Introductory Workbook.pdf_第5页
第5页 / 共31页
亲,该文档总共31页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《ADS Introductory Workbook.pdf》由会员分享,可在线阅读,更多相关《ADS Introductory Workbook.pdf(31页珍藏版)》请在三一文库上搜索。

1、74v05 ADS Introductory Workbook ADS 1.2 Introductory Workbook 74v05 ADS Introductory Workbook Introduction Aim This workbook provides the student with a basic introduction to the tools provided with the ARM Developer Suite version 1.2 (ADS). This will include the use of command line and GUI tools, t

2、o build and debug projects. The workbook is split into two practical sessions: Session 1 Introduction to the ARM command line tools. Session 2 Developing projects using CodeWarrior and AXD. Pre-requisites The student should be familiar with Microsoft DOS/Windows, and have a basic knowledge of the C

3、programming language. The ARM Developer Suite (version 1.2) should be available. Note: Explanation of File Extensions: .cC source file. .hC header file. .oobject file. .sARM or Thumb assembly language source file. .mcpARM Project file, as used by the CodeWarrior IDE. .axfARM Executable file, as prod

4、uced byarmlink. .txtASCII text file. Additional information This workbook is not designed to provide detailed documentation of ADS, as full on- line documentation is available. To access the on-line documentation: From the Start menu select ProgramsARM Developer Suite v1.2Online Books. This opens a

5、new window split into two panels. The left panel displays a Table of Contents for the current level of documentation. The right panel shows the titles available within the collection selected in the left panel. Double click on any book topic to view more information. To search for a specific topic e

6、nter a search string in the Find field and press carriage return. This will then display the number of entries that each book contains. Select the book (by double clicking on the book name) and a new window will open with the left hand column now displaying the chapters and listing the number of ent

7、ries per chapter. Scroll through each chapter to view each specific result found. Further help can be accessed from the on-line documentation by pressing F1 when running CodeWarrior or AXD, from the help menu, or by using the -help switch for a command line tool. The documentation is also available

8、in PDF format in thePDF directory located within the ADS installation directory. 74v05 ADS Introductory Workbook Icon conventions Various icons are used throughout the workbook to clarify the purpose of text associated with them. Icons either signify the presence of information on a particular topic

9、, or the requirement for user interaction. The following icons all indicate that user interaction is required: Indicates that command line input is required. Indicates other keyboard or mouse input is required. Button icon. This indicates that a corresponding button within the current application ca

10、n be used to perform the operation currently being discussed. Application icon. Suggests an application to be used to perform a given operation. This example shows Microsoft Notepad. To use Notepad from the command line typeNotepad . Alternatively click on the Notepad icon on the Start menu and open

11、 the required file using the FileOpen command. The following icons show information: Indicates a topic is also dealt with elsewhere in the workbook. Suggests that further help is available from other resources. Identifies a user friendly hint or tip. Highlights important information regarding the cu

12、rrent topic. Indicates the presence of a bug, logic or syntax error in code. 74v05 ADS Introductory Workbook Session 1: Command Line Tools This section covers the command line tools required to create and examine executable images from the command line. These include: armccARM C compiler. tccThumb C

13、 compiler. armlinkObject code linker. armasmAssembler for ARM/Thumb source code. armsdARM command line debugger. fromelfFile format conversion tool. Only a brief reference is made toarmasmin this workbook. Further information is available in the ADS Assembler Workbook. Help is available from the com

14、mand line for all of the tools covered in this session by typing the name of the tool followed by-help. All the tools covered in this session are documented in the online text found under ARM Developer SuiteCompiler, Linker and Utilities Guide. Consider the following simple C program which calls a s

15、ubroutine. This file is provided ashello.cinc:adspracintrosession1 /* hello.c Example code */ #include #include /*for size_t*/ void subroutine(const char *message) printf(message); int main(void) const char *greeting = “Hello from subroutinen“; printf(“Hello World from mainn“); subroutine(greeting);

16、 printf(“And Goodbye from mainnn“); return 0; 74v05 ADS Introductory Workbook Exercise 1.1 - Compiling and running the example Compile this program with the ARM C compiler: armcc -g hello.c The C source code is compiled and an ARM ELF object file,hello.o, is created. The compiler also automatically

17、invokes the linker to produce an executable with the default executable filename_image.axf. The-goption adds high level debugging information to the object/executable. Ifg is not specified then the program will still produce the same results when executed but it will not be possible to perform high

18、level language debugging operations. Thus this command will compile the C code, link with the default C library and produce an ARM ELF format executable called_image.axf. The generated image will execute on an ARM core. armsdruns the image using the ARMulator (ARM Instruction Set Simulator). Execute

19、 this program usingarmsdas follows: armsd -exec _image.axf This command informs the debugger to execute the image and then terminate. armsdresponds with: Hello World from main Hello from subroutine And Goodbye from main Program terminated normally at PC = 0x00009fb8 (_sys_exit + 0x8) +0008 0x00009fb

20、8: 0xef123456V4 :swi0x123456 Quitting 74v05 ADS Introductory Workbook Exercise 1.2 - Compilation options Different arguments can be passed to the compiler from the command line to customize the output generated. A list of the more common options, together with their effects, can be viewed by enterin

21、garmcc -helpat the command line. Some of these options are listed below: -cGenerate object code only, does not invoke the linker. -o Name the generated output file as filename. -SGenerate an assembly language listing. -S -fsGenerate assembly interleaved with source code. When the compiler is asked t

22、o generate a non-object output file, for example when using c or -S, the linker is not invoked, and an executable image will not be created. These arguments apply to both the ARM and Thumb C compilers. Use the compiler options witharmccortccto generate the following output files from hello.c: image.

23、axfAn ARM executable image. source.sAn ARM assembly source. inter.sA listing of assembly interleaved with source code. thumb.axfA Thumb executable image. thumb.sA Thumb assembly source. Run the Thumb executable image usingarmsd, the output generated should be the same as before. Use a suitable text

24、editor to view the interleaved source file. Note the sections of assembly source that correspond to the interleaved C source code. 74v05 ADS Introductory Workbook Exercise 1.3 - armlink In previous exercises we have seen how the compiler can be used to automatically invoke the linker to produce an e

25、xecutable image.armlinkcan be invoked explicitly to create an executable image by linking object files with the required library files. This exercise will use the files,main.candsub.cwhich can be linked to produce a similar executable to the one seen in the previous exercises. Use the compiler to pr

26、oduce ARM object code files from each of the two source files. Remember to use the-coption to prevent automatic linking Usearmlink main.o sub.o -o link.axfto create a new ARM executable calledlink.axf armlinkis capable of linking both ARM and Thumb objects. If the-ooption is not used an executable w

27、ith the default filename, _image.axf, will be created. Run the executable usingarmsdand check that the output is similar to before. The ability to link files in this way is particularly useful when link order is important, or when different C source modules have different compilation requirements It

28、 is also useful when linking with assembler object files. 74v05 ADS Introductory Workbook Exercise 1.4 - fromelf ARM ELF format objects and ARM ELF executable images that are produced by the compilers, assembler and/or linker can be decoded using thefromelfutility, and the output examined. Shown bel

29、ow is an example using thetextoption with the/c switch to produce decoded output, showing disassembled code areas, from the file hello.o: fromelf text/c hello.o Alternatively re-direct the output to another file to enable viewing with a text editor: fromelf text/c hello.o hello.dec Use thefromelfuti

30、lity to produce and view disassembled code listings from the main.oandsub.oobject files. A complete list of options available for fromelf can be found from the command line using fromelfhelp, or by consulting the on-line documentation. Thetext/coption can be replaced with the abbreviatedcswitch. 74v

31、05 ADS Introductory Workbook Session 1 - Review We have now seen how the command line tools can be used to compile, link and execute simple projects. armccThe compiler can be called with many different options. The-g option is required to enable source level debugging. The compiler can be used to ge

32、nerate executable images, object files and assembly listings. tccThe Thumb compiler can be used in the same way asarmcc. armasmThe assembler can be used to construct object files directly from assembly source code. armlinkThe linker can be used to produce executable images from ARM or Thumb object f

33、iles. fromelfThe fromelf facility can be used to generate disassembled code listings from ARM or Thumb object or image files. armsdCan be used to execute applications from the command line. Help is available from the command line. Alternatively, ask an instructor or consult the online documentation

34、for further information. 74v05 ADS Introductory Workbook Session 2: CodeWarrior and AXD In this session we will see how the CodeWarrior Integrated Development Environment can be used with AXD to create and develop projects. CodeWarrior is only available on Windows platforms although AXD also exists

35、on Unix versions of ADS. Some new icons are introduced here. These correspond to buttons which can be clicked upon within the current application. Activities covered in this session are documented in the online books found under ARM Developer SuiteAXD and armsd Debuggers Guide, in the chapters refer

36、ring to AXD. Help can be accessed from within AXD by pressing F1. Exercise 2.1 - Creating a header file In this exercise, we will create a new header file using CodeWarriors built-in editor. Start the IDE by clicking on the CodeWarrior IDE icon in the Windows Start Menu. Select FileNew from the menu

37、. Ensure the File tab is selected in the New dialog-box. i)Select Text File. ii)Click OK. 74v05 ADS Introductory Workbook Enter the following C struct definition: /* Struct definition */ struct DateType int day; int month; int year; ; Select FileSave As from the menu. Navigate the directory structur

38、e to: c:adspracintrosession2and enter the filename datetype.h Click Save. Click Yes to overwrite (if necessary). You have now created a very simple header file. This will be used later by the example program supplied:month.c. Leave the editor window open for use later in the exercise. 74v05 ADS Intr

39、oductory Workbook Exercise 2.2 - Creating a new project We will now create a new project and add our filesmonth.canddatetype.hto it Select FileNew from the menu. Ensure the Project tab is selected in the New dialog-box. i)Select ARM Executable Image. ii)Enter the Project name:calendar The Project ta

40、b contains the pre-defined project stationery that is available. Note that both images and object libraries are available as well as empty projects and a makefile wizard. Pre-defined project stationery is useful for quickly creating new projects. Enter the Project directory:c:adspracintrosession2 Us

41、e the Set button and click Save (if required) Click OK to create the project. The project window, calendar.mcp appears. The Files tab is highlighted and DebugRel is selected as the build target by default. Other build targets can be selected by clicking on the drop-down box. The three default target

42、 variants available refer to the level of debug information contained in the resultant image. DebugContains full debug table information and very limited optimization. ReleaseNo source level debug information, but full optimization. DebugRelA trade-off between the two. It is the DebugRel variant tha

43、t we shall use for the remainder of this workbook. 74v05 ADS Introductory Workbook We will now add our source files to the new project. Highlight the calendar.mcp window. From the menu select ProjectAdd Files Navigate toc:adspracintrosession2 Double click onmonth.c. An Add Files window appears, clic

44、k OK. Highlight the editor window, datetype.h. From the menu select ProjectAdd datetype.h to Project. Click OK. If the editor window has been closed use ProjectAdd Files again to locate datetype.h. The Files tab of the project window now shows thatdatetype.handmonth.c have been added to the project.

45、 Source files in the project window can be edited by double clicking on their icons. The Code and Data columns formonth.cboth contain0as no object code or executable image exists for the project as yet. 74v05 ADS Introductory Workbook Exercise 2.3 - Building the project (DebugRel target) Ensure the

46、DebugRel target is selected in the project window. From the menu select ProjectMake (or press F7). An Errors month.c line 17 Error: (Serious) C2363E: member year not found in struct DateType month.c line 20 The lower section of the window contains a section of the code that caused the first error me

47、ssage. Double click on the first error message. The IDE opens the editor and sets the focus on the line of code associated with the error. There is something wrong with the code; a close bracket is missing. The line should read: printf(“ne.g. 1972 02 17nn“); Correct the error by adding the missing b

48、racket and then save the updated source file. Rebuild the project (F7). The Errors hence you can end up with a previous instance of AXD still running. It is therefore good practice to close down AXD after each debug session is complete. 74v05 ADS Introductory Workbook Exercise 2.5 - Debugging the ex

49、ample Select ProjectDebug from the IDE menu. AXD will load the image ready for debugging, and will have set a breakpoint on main. The disassembled project code is visible in the Disassembly window. Select ExecuteGo from the menu. Execution will halt on the entry to themainfunction inmonth.c. Another window, C:adspracintrosession2month.c, appears. This contains the source code relevant to the currently executing image. Select ExecuteGo from the menu. You will once again be prompted to enter a date. This

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1