Upload
gladys-amber-king
View
223
Download
0
Embed Size (px)
Citation preview
1
IAR Embedded Workbench IAR Embedded Workbench for for ARMARM
Ryan ShengRyan ShengIIAR Systems AB, ShanghaiAR Systems AB, Shanghai
2005-2005-10-1710-17
2
OutlineOutline
IAR IntroductionIAR Introduction EWARM v4.30 EWARM v4.30 OverviewOverview Controlling Compiler Controlling Compiler
OptimizationOptimization Extended Compiler FeaturesExtended Compiler Features Segments and MemoriesSegments and Memories Runtime LibraryRuntime Library C-SPY Debugger SystemsC-SPY Debugger Systems
3
IARIARIntroductionIntroduction
4
IAR SystemsIAR Systems
成立于成立于 19831983 年年
总部位于瑞典第四大城市乌普萨拉总部位于瑞典第四大城市乌普萨拉
于于 19861986 年推出世界上首个嵌入式年推出世界上首个嵌入式 CC 编译器编译器
是一家世界领先的嵌入式软件开发工具供应商是一家世界领先的嵌入式软件开发工具供应商
20002000 年在瑞典斯德哥尔摩证券市场成功上市年在瑞典斯德哥尔摩证券市场成功上市
在世界各地拥有在世界各地拥有 70,00070,000 多个用户多个用户
业务遍及世界各地,业务遍及世界各地, 5050 多个代理多个代理 // 分销商分销商
中国大陆:麦克泰软件技术有限公司 中国大陆:麦克泰软件技术有限公司 (( 深圳分公司深圳分公司 : 0755-: 0755-
82971846)82971846)
http://www.iar.comhttp://www.iar.com
5
IAR ProductsIAR Products
Embedded WorkbenchEmbedded Workbench一体化的嵌入式软件集成开发环境一体化的嵌入式软件集成开发环境完整的工具链,支持整个开发流程完整的工具链,支持整个开发流程产品线覆盖产品线覆盖 3030 余种余种 8/16/32-bit8/16/32-bit 微处理器微处理器汇编、汇编、 ANSI CANSI C 、、 Embedded C++Embedded C++ 及及 IARIAR 扩展语言扩展语言
特性特性强大而灵活的强大而灵活的 Size/SpeedSize/Speed 优化功能优化功能
visualSTATEvisualSTATE针对嵌入式系统的图形化设计和建模工具针对嵌入式系统的图形化设计和建模工具基于基于 UMLUML 状态图状态图 (UML State Chart)(UML State Chart) 机制机制自动分析和检查模型中的逻辑错误自动分析和检查模型中的逻辑错误壮态机级别的模拟仿真和壮态机级别的模拟仿真和 On-TargetOn-Target 调试调试自动生成开发文档和精简紧凑的自动生成开发文档和精简紧凑的 C/C++C/C++ 代码框架代码框架
6
IAR Embedded WorkbenchIAR Embedded Workbench
Powerful IDEPowerful IDE IAR C/C++ CompilerIAR C/C++ Compiler IAR AssemblerIAR Assembler IAR XLINK LinkerIAR XLINK Linker IAR XAR & XLIB Library ToolsIAR XAR & XLIB Library Tools EditorEditor Project ManagerProject Manager C-SPY Simulator and C-SPY Simulator and
DebuggerDebugger
7
IAR Embedded WorkbenchIAR Embedded Workbench
Compiler,
Text Editor Project Manager Debugger GUI
Tool Chain
Assembler
Third Party Editors, Source Code Control Systems, etc.
Linker, Libraries
C-SPY™ Debugger Kernel
Simulator RTOS Support
CustomPlug-Ins
RDI, J-Link,
Angel, Macraigor, …
IDE Host Application
8
SoftSoftware ware Building ProcessBuilding Process
Linker
C Source
Compiler
Object File
C Source
C Source
Object File
Object File
C Library
C Runtime
Other Lib
OS
Compiler SystemCompiler System
Hardware
User CodeUser Code
Third-Party CodeThird-Party Code
Executable
9
Software Building ProcessSoftware Building Process
<design>.s79(Assembly)
IARAssembler
<design>.d79
File with UBROFObject Debug
Information
<design>.a79
<design>.map(Map File)
IARLinker
<design>.xcl(Linker File)
IARDebugger
IARJ-Link
IARSimulator
Linker can produce multiple output files, e.g. Motorola s-record, Intel hex, coff, elf/dwarf, ...
<design>.h(Head File)
<design>.c(C Code)
<design>.r79 (Object File)
IARC/C++
CompilerRTOS
Supporte.g.ORTICMXOSE
ThreadXuC/OS-IIFusion
Quadros......
ddf-File
<design>.r79 (Object File)
<library>.r79 (Library File)
RDI
Macraigor
Angel
Third-PartyEmulator
Driver
10
EWEWARM ARM v4.30v4.30
OverviewOverview
11
IAR Embedded WorkbenchIAR Embedded Workbenchversion 4.30 for ARMversion 4.30 for ARM Hierarchical Source OrganizationHierarchical Source Organization Select ARM Core or ProcessorSelect ARM Core or Processor C/C++ Language SupportC/C++ Language Support Configure Compiler OptimizationsConfigure Compiler Optimizations MISRA C SupportMISRA C Support Configurable Runtime LibraryConfigurable Runtime Library Standard Image FormatsStandard Image Formats Customizing Linker Command FileCustomizing Linker Command File Debugger & Target SystemDebugger & Target System Powerful C-SPY DebuggerPowerful C-SPY Debugger User AssistanceUser Assistance Find More on the WebFind More on the Web BenchmarksBenchmarks
12
Hierarchical Source OrganizationHierarchical Source Organization
WorkspaceWorkspace ProjectProject ConfiguratiConfigurati
onon Source Source
GroupGroup Source FileSource File
13
Select ARM Core or ProcessorSelect ARM Core or Processor
14
C/C++ Language SupportC/C++ Language Support ANSI CANSI C
ISO/IEC 9899:1994 with selected features from ISO/IEC 9899:1994 with selected features from C99C99
Embedded C++Embedded C++A proper subset of standard C++A proper subset of standard C++Defined by Embedded C++ Technical CommitteeDefined by Embedded C++ Technical CommitteeClass, Polymorphism, Overloading of Operators Class, Polymorphism, Overloading of Operators
and Functions, new and delete, Inline Functionsand Functions, new and delete, Inline Functions Extended Embedded C++Extended Embedded C++
Embedded C++ extended by IAREmbedded C++ extended by IARTemplate, Name Space, Modern Cast Operators, Template, Name Space, Modern Cast Operators,
Mutable Attribute, Standard Template Library Mutable Attribute, Standard Template Library (STL)(STL)
Tailored C++ FeaturesTailored C++ FeaturesMultiple Inheritance, Exception Handling, Multiple Inheritance, Exception Handling,
Runtime Type Information (RTTI)Runtime Type Information (RTTI)
15
Configure Compiler Configure Compiler OptimizationsOptimizations
16
MISRA C SupportMISRA C Support MISRAMISRA
Motor Industry Software Reliability AssociationMotor Industry Software Reliability Association
MISRA CMISRA C ISOISO定义了定义了 C C SSyntaxyntax,但没有指出怎样才能写出安全的,但没有指出怎样才能写出安全的 CC 代代
码码 MISRA CMISRA C定义了一套编程规则,以描述定义了一套编程规则,以描述
如何开发“安全的”如何开发“安全的” CC 代码代码 ”” GuidelinesGuidelines For the Use Of The C For the Use Of The C
Language In Vehicle Based Software”Language In Vehicle Based Software”
IARIAR 从从 20042004年起首家提供年起首家提供MISRA CMISRA C校验校验
模块,涵盖了所有模块,涵盖了所有 127127条规则条规则
http://www.misra.org.ukhttp://www.misra.org.uk
17
Configurable Runtime LibraryConfigurable Runtime Library Contents of DLIBContents of DLIB
C/C++ library definitionsC/C++ library definitionsRuntime environment support, e.g. system startup Runtime environment support, e.g. system startup
and exit codes, and some low-level library functionsand exit codes, and some low-level library functionsRuntime support libraries, e.g. low-level floating-Runtime support libraries, e.g. low-level floating-
point arithmetic routinespoint arithmetic routines Customize a pre-built library without Customize a pre-built library without
rebuildingrebuildingLibrary Configuration: Normal or FullLibrary Configuration: Normal or FullPrintf & Scanf Formatters: Tiny, Small, Large or FullPrintf & Scanf Formatters: Tiny, Small, Large or FullOverriding library modules with customized versionsOverriding library modules with customized versions
Rebuild a Customized LibraryRebuild a Customized LibraryFull source code availableFull source code available
18
Standard Image FormatsStandard Image Formats IAR Linker: XLINKIAR Linker: XLINK
Generates a wide range of industry-standard image formats.Generates a wide range of industry-standard image formats.
19
Customizing Linker Command Customizing Linker Command FileFile
20
Debugger & Target SystemDebugger & Target System
IAR C-SPY SimulatorIAR C-SPY Simulator Hardware Debugger InterfaceHardware Debugger Interface
RDI, IAR J-Link, Macraigor, Angel, ROM-RDI, IAR J-Link, Macraigor, Angel, ROM-monitor, Third-Party Emulator Driversmonitor, Third-Party Emulator Drivers
21
Powerful C-SPY DebuggerPowerful C-SPY Debugger Seamlessly integrated into the IDESeamlessly integrated into the IDE
Editing while debuggingEditing while debuggingSet breakpoints before starting the debuggerSet breakpoints before starting the debugger
C/C++ source & disassembly level C/C++ source & disassembly level debuggingdebugging
Powerful code and data breakpointsPowerful code and data breakpoints STL container awarenessSTL container awareness C-like macro system to extend C-like macro system to extend
functionalitiesfunctionalities Terminal I/O emulationTerminal I/O emulation Trace (also available for simulator)Trace (also available for simulator) Code Coverage and ProfilingCode Coverage and Profiling Generic flash loaderGeneric flash loader RTOS-aware debuggingRTOS-aware debugging Extendable for third-party RTOS or Extendable for third-party RTOS or
emulatorsemulators
22
User AssistanceUser Assistance Ready-made sample projectsReady-made sample projects Context-sensitive online help Context-sensitive online help
manuals with index and searchingmanuals with index and searching Complete PDF guides:Complete PDF guides:
ARM Assembler Reference GuideARM Assembler Reference GuideARM Embedded Workbench User GuideARM Embedded Workbench User GuideARMARM C/C++ Compiler Reference GuideC/C++ Compiler Reference GuideIAR Linker and Library Tools Reference GuideIAR Linker and Library Tools Reference GuideIAR MISRA C Reference GuideIAR MISRA C Reference Guide…………
Printed user guides with Printed user guides with extensive step-by-step tutorialsextensive step-by-step tutorials
23
Find more on the web ……Find more on the web …… http://www.iar.com/ewarmhttp://www.iar.com/ewarm
Highlights of the newest versionHighlights of the newest versionSupported ARM cores and processorsSupported ARM cores and processorsDownload 30-day evaluation versionDownload 30-day evaluation versionDownload benchmarks comparing with other toolsDownload benchmarks comparing with other toolsDownload product updatesDownload product updatesDownload demos within flash formatDownload demos within flash formatMore features of the productMore features of the product
http://www.iar.com/sthttp://www.iar.com/stIAR KickStart Kits for STR7 MicroprocessorsIAR KickStart Kits for STR7 MicroprocessorsDownload EWARMDownload EWARM KickStart v4.30 (32KB Code)KickStart v4.30 (32KB Code)Download Sample Projects for STR7 Download Sample Projects for STR7
MicroprocessorsMicroprocessorsOther Products Related to STMicroelectronicsOther Products Related to STMicroelectronics
24
BenchmarksBenchmarks
Compiler Options:
•IAR: -z9 --cpu=ARM7TDMI
•ADS: -cpu 4t –zo -Ospace -O2
•GNU: -mcpu=arm7tdmi -msoft-float -Os
•Keil: optimize(7,size) float64, uu(remove)
25
Controlling Controlling Compiler Compiler
OptOptimizationimization
26
The CompilerThe Compiler
C Source
Parser
Intermediate Code
High-Level Optimizer
Code Generator
Target CodeLow-Level Optimizer
Assembler
Object Code
CompilerCompiler
LDR R0,xLDR R1,[R0,#0]SUB R1,#15STR R1,[R0,#0]
=
–
15x
x
x = x - 15;
000100110101101111011101
27
Transformations by OptimizerTransformations by OptimizerNone (Best debug support)
Low Limited live-range for variables
Medium Live-dead analysis and optimizationDead code eliminationRedundant label eliminationRedundant branch eliminationCode hoistingPeephole optimizationRegister content analysisStatic clusteringCommon subexpression elimination
High Instruction schedulingCross jumpingAdvanced register content analysisLoop unrollingFunction inliningCode motionType-based alias analysis
28
Using Optimization SettingsUsing Optimization Settings
Use the same optimization settings for the entire project (e.g., minimal code);
Use different optimization settings for individual file or group (e.g., maximum speed for time-critical sources);
Use “#pragma optimize” to fine-tune the optimization for specific functions.
High level optimizations may make debugging more difficult.
29
CCustomizingustomizing Transformations: Transformations:Common Subexpression Elimination
temp=c*da=b+tempe=f+temp
a=b+c*de=f+c*d
•Only applicable to expressions•Cannot optimize function calls (because of side effects)•Can be done manuallyvoid bar(){
if (foo(12) && C) { … } if (!foo(12) || D) { … }}
void bar(){ BOOL b = foo(12); if (b && C) { … } if (!b || D) { … }}
30
CCustomizingustomizing Transformations: Transformations:Function Inlining
•Eliminate the overhead of function calls•May increase code size•Let the compiler to decide which functions to inline•Can be done manually: #pragma inline
void foo(){ b = y+bar(x); ...}
void foo(){ b = y+x*7; ...}
int bar(int a){ return a*7;}
31
CCustomizingustomizing Transformations: Transformations:Loop Unrolling
•Eliminate the overhead of loops•May increase code size•Let the compiler to decide which loops to unroll•Fewer jumps Good pipeline performance
/* copy 20 elements */for(i=0;i<20;++i){ a[i]=b[i];}
/* unrolled four times */for (i=0;i<20;i+=4){ a[i]=b[i]; a[i+1]=b[i+1]; a[i+2]=b[i+2]; a[i+3]=b[i+3];}
32
CCustomizingustomizing Transformations: Transformations:Code Motion
•Move loop-invariant expressions and common sub-expressions our of the loop.
b = k * c;for(i=0;i<10;i++){ p[i] = b;}
for(i=0;i<10;i++){ b = k * c; p[i] = b;}
33
CCustomizingustomizing Transformations: Transformations:Type-based Alias Analysis
•A C/C++ application that conforms to ISO/ANSI 9899:1999 standard should access objects only by their declared types or through char types.•Compiler will determine what objects may be affected when a pointer indirection (alias) is used in an assignment.•For example, assuming that the *lptr = 0 assignment will not affect the object that sptr points to.•May cause unexpected behavior for non-conforming C codes.
short f(short *sptr, long *lptr){short x = *sptr;*lptr = 0;return *sptr + x;}
short f(short *sptr, long *lptr){short x = *sptr;*lptr = 0;return x << 1;}
34
CCustomizingustomizing Transformations: Transformations:Static Clustering
•Static and global variables are arranged so that variables that are accessed in the same function are stored close to each other.•This makes it possible for the compiler to use the same base pointer for several accesses.•Alignment gaps between variables can also be eliminated.
35
CCustomizingustomizing Transformations: Transformations:Instruction Scheduling
•IAR C/C++ Compiler for ARM features an instruction scheduler to increase theperformance of the generated code.•The scheduler rearranges instructions to minimize the number of pipeline stalls caused by resource conflicts.•ARM7 processor uses a three-stage instruction pipeline:
•Fetch•Decode•Execute
36
Extended Extended CompCompiler iler FeaturesFeatures
37
Extended Compiler FeaturesExtended Compiler Features
Extended KeywordsExtended Keywords Pragma DirectivesPragma Directives Preprocessor SymbolsPreprocessor Symbols Intrinsic FunctionsIntrinsic Functions IAR Language ExtensionsIAR Language Extensions
Please refer to:Please refer to:IAR C/C++ Compiler Reference IAR C/C++ Compiler Reference
GuideGuide
38
Extended KeywordsExtended Keywords Extended Keywords are only Extended Keywords are only
available when IAR language available when IAR language extensions are enabled.extensions are enabled.
39
Extended Keywords for ARMExtended Keywords for ARM For FunctionsFor Functions
__a__arm, __thumb, __interworkrm, __thumb, __interwork__irq, __fiq, __swi__irq, __fiq, __swi__monitor, __monitor, __nested__nested__ramfunc__ramfunc
For VariablesFor Variables____no_initno_init__big_endian, __little_endian (ARMv6 or __big_endian, __little_endian (ARMv6 or
later)later) For BothFor Both
__root__root Inline AssemblyInline Assembly
asm, __asm : asm, __asm : asm(“nop");
40
Pragma DirectivesPragma Directives
Extensions of the preprocessor Control behaviors of the compiler
how it allocates memorywhether it allows extended keywordswhether it outputs warning messages……
Always enabled in the compilerAlways enabled in the compiler Manipulated during preprocessManipulated during preprocess
Macros can be substituted in pragma directives.
41
Pragma Directives for ARMPragma Directives for ARM #pragma inline#pragma inline #pragma data_alignment#pragma data_alignment #pragma language#pragma language #pragma location#pragma location #pragma pack#pragma pack #pragma object_attribute#pragma object_attribute #pragma segment#pragma segment #pragma type_attribute#pragma type_attribute #pragma optimize#pragma optimize …………
42
Preprocessor SymbolsPreprocessor Symbols Predefined Preprocessor Predefined Preprocessor
SymbolsSymbols User-defined Preprocessor User-defined Preprocessor
SymbolsSymbols
43
Predefined Preprocessor Predefined Preprocessor SymbolsSymbols __ALIGNOF__ ()__ALIGNOF__ () __CORE____CORE__ __cplusplus__cplusplus __CPU_MODE____CPU_MODE__ __IAR_SYSTEMS_ICC____IAR_SYSTEMS_ICC__ __ICCARM____ICCARM__ __LITTLE_ENDIAN____LITTLE_ENDIAN__ __STDC____STDC__ __STDC_VERSION____STDC_VERSION__ __VER____VER__ …………
44
Intrinsic FunctionsIntrinsic Functions
Intrinsic Function:Intrinsic Function:Looks like function calls, but it isn’tLooks like function calls, but it isn’tBuilt into the compilerBuilt into the compilerGenerate inline assembly instructionsGenerate inline assembly instructions
Use intrinsic functions for:Use intrinsic functions for:Providing access to special features of Providing access to special features of
the CPUthe CPUProviding functionality that cannot be Providing functionality that cannot be
expressed in Cexpressed in CGenerate more efficient code than Generate more efficient code than
traditional inline assemblytraditional inline assembly #include <intrinsic.h>#include <intrinsic.h>
45
Intrinsic Functions for ARMIntrinsic Functions for ARM
void __disable_interrupt (void); void __enable_interrupt (void); unsigned long __get_CPSR (void); void __set_CPSR (unsigned long); void __MCR (……); void __MRC (……); void * __segment_begin (segment); void * __segment_end (segment); int __segment_size (segment); void __no_operation (void); ……
46
IAR Language ExtensionsIAR Language Extensions
Extensions of the ISO/ANSI standard for C programming language.
Also can be used for C++ programming language.
Only available when “Allow IAR extensions” is selected.
Gain full control over the resources and features of the target core, and can thereby fine-tune your application.
Be aware of portability issues.
47
Absolute Address or SegmentAbsolute Address or Segment
Example 1volatile __no_init BYTE PORT1 @ 0x1000;An absolute declared variable cannot
have an initializer, which means the variable must also be __no_init or const declared.
#pragma location = address Example 2
void test (void) @ “MYOWNSEGMENT”{ ... }
The location of each segment is assigned in the linker command file.
#pragma location = segment
48
Anonymous Struct and UnionAnonymous Struct and Union C++ feature An anonymous struct or union defines
an unnamed object (not a type) whose members are promoted to the surrounding scope.struct str{
int a;union{
int b;int c;
};};struct str obj;obj.b = 0;
struct str{
int a;union{
int b;int c;
} u;};struct str obj;obj.u.b = 0;
49
Bit-fields with Non-Standard Bit-fields with Non-Standard TypesTypes In ISO/ANSI C, a bit-field must be of the
type int or unsigned int. Using IAR language extensions, any
integer types and enums may be used. Example: an unsigned char is used for
holding 3 bits. The struct will be smaller.
struct ThreeBits{
unsigned char bitOne : 1;unsigned char bitTwo : 1;unsigned char bitThree : 1;
};
50
ExampleExample: S: Syntax for SFRsyntax for SFRs Absolutely addressedAbsolutely addressed Anonymous structs and unionsAnonymous structs and unions Anonymous bit-fieldsAnonymous bit-fields Bit-fields with non-standard typesBit-fields with non-standard types
volatile __no_init unionvolatile __no_init union{{ unsigned char P0; unsigned char P0; /* Port 0 *//* Port 0 */ struct struct /* bits of Port 0 *//* bits of Port 0 */ { { unsigned char P0_0 unsigned char P0_0 :: 1;1; unsigned char P0_1 unsigned char P0_1 :: 1;1; unsigned char P0_2 unsigned char P0_2 :: 1;1; unsigned char P0_ unsigned char P0_33 :: 1;1; unsigned char P0_4 unsigned char P0_4 :: 1;1; unsigned char unsigned char :: 3;3; } }} @ 0x1000;} @ 0x1000;
51
SegmentsSegmentsandand
MemoriesMemories
52
Segments and MemoriesSegments and Memories
Critical for embedded systems:which parts of code and data are located in
where of which kind of physical memory Segment
Segment is a logical entity containing a piece of data or code that should be mapped to a physical location in memory.
IAR XLINK Linker is responsible for placing the segments in the physical memory space.
Predefined SegmentsPredefined Segments User-defined SegmentsUser-defined Segments
53
Segment Memory TypesSegment Memory Types XLINK assigns a segment memory
type to each of the segments. An individual segment may have the
same name as its segment memory type, e.g. CODE.
Segment DescriptionMemoryType
CODE For executable codeCONST For data placed in
ROM/FlashDATA For data placed in RAM
54
Predefined Segments for ARMPredefined Segments for ARM
Data SegmentsData SegmentsStatic Memory SegmentsStatic Memory SegmentsStackStackHeapHeap
Code SegmentsCode SegmentsStartup CodeStartup CodeNormal CodeNormal CodeException VectorsException Vectors
55
Static Memory SegmentsStatic Memory SegmentsCategories ofCategories of Memory Segment Memory Segment ExampleExampleDeclared DataDeclared Data Type Name Type Name
Absolute CONST DATA_AC const int a @ 0x1000 = 1;Addressedconstants
Absolute DATA DATA_AN __no_init int a @ 0x1000;addresseddata
Constants CONST DATA_C const int a = 1;
Non-zero DATA DATA_I int a = 1;initializeddata
Initializers CONST DATA_ID int a = 1;for the above
Non-initialized DATA DATA_N __no_init int a;data
Zero-initialized DATA DATA_Z int a;data
56
StackStack Stack can contain:Stack can contain:
Auto variables and parameters not stored in registers;Return value of the function (unless it is passed in
registers);Processor state during exceptions;Processor registers that should be restored before return;
Stack Segments:Stack Segments:For System & User Mode of ARM:
CSTACKFor Exception Modes of ARM:
IRQ_STACK, FIQ_STACK SVC_STACK, UND_STACK, ABT_STACK
The cstartup module initializes stack pointers (SP) to the end of each stack segments.
Linker Command File:-D_CSTACK_SIZE=2000-Z(DATA)CSTACK+_CSTACK_SIZE=RAMSTART-RAMEND
57
HeapHeap
Heap contains data allocated Heap contains data allocated dynamically by:dynamically by:C function “malloc()” (or one of its relatives);C++ operator “new”;
Heap Segment:HEAP
HEAP is only included if dynamic memory allocation is actually used.
Linker Command File:-D_HEAP_SIZE=2000-Z(DATA)HEAP+_HEAP_SIZE=RAMSTART-RAMEND
58
Code SegmentsCode Segments
Startup CodeStartup CodeICODE (CODE)ICODE (CODE)
cstartup: system setup from resetcstartup: system setup from reset cmain: runtime initializationcmain: runtime initialization cexit: system termination cexit: system termination
Normal CodeNormal CodeCODE (CODE): normal functionsCODE (CODE): normal functionsCODE_I (DATA): functions executing in CODE_I (DATA): functions executing in
RAMRAMCODE_ID (CONST): initializers for the CODE_ID (CONST): initializers for the
aboveabove Exception VectorsException Vectors
INTVEC (CODE)INTVEC (CODE)
59
Linker Command File (.xcl)Linker Command File (.xcl)
Used by XLINK to determine locations where the segments can be placed.
Default XCL Template:$TOOLKIT_DIR$\config\lnkarm.xcl
Check example projects for XCL samples of specific ARM processors.
Customize the linker command file to suit the memory layout of specific target system.
60
Linker Command File (.xcl)Linker Command File (.xcl) -c: target processor
-carm -D: define constants
-DROMSTART=00000000-DROMEND=00100000
-Z: place segments sequentially-Z(CONST)MYSEGA,MYSEGB=008000-0FFFFF
-P: place segments in not-continuous memory-P(DATA)MYDATA=100000-101FFF,110000-111FFF
-Q: scatter loadingPlace __ramfunc codes into CODE_ID segment.Symbols and debug information are still associated
with CODE_I.Contents of CODE_ID are copied to CODE_I at
runtime.-Z(DATA)CODE_I=RAMSTART-RAMEND
-Z(CONST)CODE_ID=ROMSTART-ROMEND -QCODE_I=CODE_ID
61
Runtime Runtime LibraryLibrary
62
CLIB and DLIBCLIB and DLIB
CLIB is older and smaller, C only.CLIB is older and smaller, C only. DLIB supports C and C++, better DLIB supports C and C++, better
standard compliance.standard compliance.Standard C library definitionsEmbedded C++ library definitionsRuntime environment support, e.g. system
startup and exit codesRuntime support libraries, e.g. low-level
floating-point routinesIntrinsic functions for low-level processor
operations For EWARM, only DLIB is For EWARM, only DLIB is
available.available.
63
Library ConfigurationLibrary Configuration
NoneNone NormalNormal
No locale interface, C locale, no file descriptor support, no multi-bytes in printf and scanf, and no hex floats in strtod.
FullFullFull locale interface, C locale, file Full locale interface, C locale, file
descriptor support, multi-bytes in printf descriptor support, multi-bytes in printf and scanf, and hex floats in strtod.and scanf, and hex floats in strtod.
CustomCustom
64
Library ConfigurationLibrary Configuration
65
Pre-built Runtime LibraryPre-built Runtime Library
An pre-built runtime library is configured for different combinations of following features:
ARM Architecture: v4t, v5t, v6ARM Architecture: v4t, v5t, v6 CPU Mode: arm, thumbCPU Mode: arm, thumb Interworking: yes, noInterworking: yes, no VFP: yes, noVFP: yes, no Endian: little, bigEndian: little, big Stack Alignment: 4, 8Stack Alignment: 4, 8 Library Configuration: normal, Library Configuration: normal,
fullfull
66
Customize a Pre-built Library without Customize a Pre-built Library without RebuildRebuild
Selecting formatters used by printf and scanf by setting the appropriate options.
Overriding library modules with your own customized versions.
67
Selecting FormattersSelecting Formatters
printfprintfTiny: No specifier a, A, no specifier n, no float
nor long long, no flags.Small: No specifier a, A, no specifier n, no
float nor long long.Large: No specifier a, A.Full: Full formatting.
scanfscanfSmall: No specifier n, no float nor long long,
no scan set, no assignment suppressing.Large: No specifier n, no float nor long long.Full: Full formatting.
68
Selecting FormattersSelecting Formatters
69
Overriding Library ModulesOverriding Library Modules
Copy the appropriate library_module.c (can be any source file under “src/lib”) to your project directory.
Make the required modifications to the file, and make sure to save it under the same name.
Add the customized file to your project.
Rebuild your project.
70
Rebuild a Customized DLIBRebuild a Customized DLIB
Create a new library project. Configure project options. Modify source codes as
required. Modify library configuration
file:arm\config\template\project\dlib\dlArmCustom.h
Build the customized library. Use the customized library in
your application project:Library Configuration: CustomLocate the library fileLocate the library configuration file
71
System Startup and System Startup and TerminationTermination
72
System Startup and System Startup and TerminationTermination
__program_start__program_start cstartup.s79cstartup.s79 ?cstartup?cstartup cstartup.s79cstartup.s79 ?main?main cmain.s79cmain.s79
__low_level_init__low_level_init low_level_init.s79low_level_init.s79__segment_init__segment_init segment_init.csegment_init.c__call_ctors__call_ctors cppinit.ccppinit.c
mainmain user codeuser code _exit_exit cexit.s79cexit.s79
__call_dtors__call_dtors cppinit.ccppinit.c_Close_all_Close_all xcloseall.cxcloseall.c
__exit__exit xxexit.c (halt here)xxexit.c (halt here)
73
Customize Startup SequenceCustomize Startup Sequence Overriding Library ModulesOverriding Library Modules
Modify __low_level_initModify __low_level_init Initialize memory-mapped SFRs, etc.Initialize memory-mapped SFRs, etc. return value 0 : segment_init will not be return value 0 : segment_init will not be
calledcalledsegment_initsegment_init
DATA_ID DATA_ID DATA_I DATA_I 0 0 DATA_Z DATA_Z CODE_ID CODE_ID CODE_I CODE_I
Modify ?cstartupModify ?cstartup stack pointers, arm or thumb, etc.stack pointers, arm or thumb, etc. only when absolutely neededonly when absolutely needed
Rebuild a Customized Rebuild a Customized LibraryLibraryOnly when really needed.Only when really needed.
74
CC-SPY -SPY Debugger Debugger SystemsSystems
75
C-SPY Debugger & Target C-SPY Debugger & Target SystemsSystems
76
C-SPY Debugger for ARMC-SPY Debugger for ARM
Drivers for target systems:Drivers for target systems:
IAR C-SPY SimulatorRDI (Remote Debug Interface)
CompatibleIAR J-Link JTAG interfaceMacraigor JTAG interfaceAngel Debug MonitorIAR ROM-MonitorThird-Party Systems
77
Select a Driver for the Select a Driver for the DebuggerDebugger
78
Different between C-SPY Different between C-SPY DriversDrivers
1) Cycle counter statistics are not available.2) Limited number, implemented using the ARM EmbeddedICE Macrocell.3) Profiling works provided that enough breakpoints are available, that is, the application is executed in RAM.
79
Select the Download MethodSelect the Download Method Download to RAMDownload to RAM Download to Flash: Using a Flash LoaderDownload to Flash: Using a Flash Loader Don’t Download Code (Debugging in ROM/Flash)Don’t Download Code (Debugging in ROM/Flash)
80
C-SPY Debugger Startup C-SPY Debugger Startup SequenceSequence
81
C-SPY Setup Macro FunctionsC-SPY Setup Macro Functions
execUserPreloadexecUserPreloadCalled after communication with the target system
is established but before downloading the image.Initialize the memory controller and/or critical
resources which are vital for loading data.
execUserResetexecUserResetCalled each time when the reset command is
issued.Set up and restore data.
execUserSetupexecUserSetupCalled once after the target application is
downloaded.Set up the memory map, breakpoints, etc.
82
C-SPY System MacrosC-SPY System Macros Frequently Used Macros:Frequently Used Macros:
__readMemory8__readMemory8__readMemory16__readMemory16__readMemory32__readMemory32__writeMemory8__writeMemory8__writeMemory16__writeMemory16__writeMemory32__writeMemory32
Please refer to:Please refer to:IAR Embedded Workbench User IAR Embedded Workbench User
GuideGuide Find more C-SPY system macrosFind more C-SPY system macros Find the syntax of C-SPY macro languageFind the syntax of C-SPY macro language
83
User a Setup Macro FileUser a Setup Macro File
84
ThankThankYou !You !