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, to 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 programming language. The ARM Developer Suite (version 1.2)
should be available.
Note: Explanation of File Extensions:
.c C source file.
.h C header file.
.o object file.
.s ARM or Thumb assembly language source file.
.mcp ARM Project file, as used by the CodeWarrior IDE.
.axf ARM Executable file, as produced by armlink.
.txt ASCII 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 Programs
ARM Developer Suite
v1.2
Online Books.
This opens a 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 enter 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 entries 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 in PDF format in the PDF
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, 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 can 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 type Notepad <filename>.
Alternatively click on the Notepad icon on the ‘Start menu’ and open
the required file using the File
Open 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 current 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:
armcc ARM C compiler.
tcc Thumb C compiler.
armlink Object code linker.
armasm Assembler for ARM/Thumb source code.
armsd ARM command line debugger.
fromelf File format conversion tool.
Only a brief reference is made to armasm in this workbook. Further
information is available in the ADS Assembler Workbook.
Help is available from the command 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 Suite
Compiler, Linker and Utilities
Guide.
Consider the following simple C program which calls a subroutine. This file is
provided as hello.c in c:\adsprac\intro\session1\
/* hello.c Example code */
#include <stdio.h>
#include <stdlib.h> /*for size_t*/
void subroutine(const char *message)
{
printf(message);
}
int main(void)
{
const char *greeting = "Hello from subroutine\n";
printf("Hello World from main\n");
subroutine(greeting);
printf("And Goodbye from main\n\n");
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 invokes the linker to produce an executable with the
default executable filename __image.axf.
The -g option adds high level debugging information to the object/executable. If –g
is not specified then the program will still produce the same results when executed
but it will not be possible to perform high 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.
armsd runs the image using the ARMulator (ARM Instruction Set
Simulator).
Execute this program using armsd as follows:
armsd -exec __image.axf
This command informs the debugger to execute the image and then terminate.
armsd responds with:
Hello World from main
Hello from subroutine
And Goodbye from main
Program terminated normally at PC = 0x00009fb8 (_sys_exit + 0x8)
+0008 0x00009fb8: 0xef123456 V4.. : swi 0x123456
Quitting