| 5677 |
dpurdie |
1 |
#..
|
| 6177 |
dpurdie |
2 |
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
|
| 5677 |
dpurdie |
3 |
#
|
|
|
4 |
# Module name : CORTEXM3_IAR.PL
|
|
|
5 |
# Module type : Makefile system
|
|
|
6 |
# Compiler(s) : ANSI C
|
|
|
7 |
# Environment(s): Atmel AVR
|
|
|
8 |
#
|
|
|
9 |
# Description:
|
|
|
10 |
# This file provides Toolset initialisation and plugin functions
|
|
|
11 |
# to makelib.pl2
|
|
|
12 |
#
|
|
|
13 |
# Contents: IAR rules as used for the CORTEXM3
|
|
|
14 |
# Similar to the AVR_IAR
|
|
|
15 |
#
|
|
|
16 |
#............................................................................#
|
|
|
17 |
|
|
|
18 |
use strict;
|
|
|
19 |
use JatsVersionUtils;
|
|
|
20 |
|
|
|
21 |
our $s;
|
|
|
22 |
our $o;
|
|
|
23 |
our $so;
|
|
|
24 |
our $exe;
|
|
|
25 |
my $ToolSetName = 'cortexm3_iar';
|
|
|
26 |
|
|
|
27 |
##############################################################################
|
|
|
28 |
# ToolsetInit()
|
|
|
29 |
# Runtime initialisation
|
|
|
30 |
#
|
|
|
31 |
##############################################################################
|
|
|
32 |
|
|
|
33 |
ToolsetInit();
|
|
|
34 |
|
|
|
35 |
sub ToolsetInit
|
|
|
36 |
{
|
|
|
37 |
my( @args ) = @::ScmToolsetArgs; # Toolset arguments
|
| 6925 |
dpurdie |
38 |
my( $version, $product, @defines, @dirs, @flags, @ccflags, @cxxflags, @asflags, @asdefines );
|
| 5677 |
dpurdie |
39 |
my $productFound;
|
|
|
40 |
|
|
|
41 |
#.. Parse arguments
|
|
|
42 |
#
|
|
|
43 |
Debug( "$ToolSetName:(@args)\n" );
|
|
|
44 |
|
|
|
45 |
foreach $_ ( @args ) {
|
|
|
46 |
if (/^--Version=(.*)/) { # Compiler version
|
|
|
47 |
$version = "$1";
|
|
|
48 |
} else {
|
|
|
49 |
Message( "$ToolSetName: unknown toolset argument $_ -- ignored\n" );
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
#.. Parse Platform Arguments
|
|
|
54 |
#
|
|
|
55 |
@args = @::ScmPlatformArgs; # Platform arguments
|
|
|
56 |
foreach $_ ( @args ) {
|
|
|
57 |
if (/^--product=(.*)/) { # GBE product
|
|
|
58 |
$product = $1;
|
|
|
59 |
} else {
|
|
|
60 |
Message( "$ToolSetName: unknown platform argument $_ -- ignored\n" );
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
#
|
|
|
65 |
# Definitions common to all products
|
|
|
66 |
# These will be picked up when no platform has been defined
|
|
|
67 |
#
|
|
|
68 |
push @defines, 'JATS_BUILD';
|
| 5680 |
dpurdie |
69 |
push @dirs, '$(COMPILER_HOME_AVR)/inc/c';
|
| 5677 |
dpurdie |
70 |
push @dirs, '$(COMPILER_HOME_AVR)/inc';
|
|
|
71 |
|
|
|
72 |
#
|
|
|
73 |
# Platform specific definitions
|
|
|
74 |
#
|
|
|
75 |
if ( $product eq "MS6001" )
|
|
|
76 |
{
|
|
|
77 |
$productFound = $product;
|
| 5680 |
dpurdie |
78 |
#push @flags , '--eeprom_size=32768';
|
| 5677 |
dpurdie |
79 |
|
|
|
80 |
# Compiler flags and definitions
|
| 5679 |
dpurdie |
81 |
push @defines, '_MS6001';
|
| 5677 |
dpurdie |
82 |
|
|
|
83 |
# Assembler flags and definitions
|
|
|
84 |
push @asdefines, '_MS6001';
|
|
|
85 |
}
|
|
|
86 |
elsif ( $product )
|
|
|
87 |
{
|
|
|
88 |
Message( "$ToolSetName: Unknown product: $product -- ignored\n" );
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
# common flags
|
|
|
92 |
if ( $productFound )
|
|
|
93 |
{
|
|
|
94 |
#
|
|
|
95 |
# Compiler flags and definitions
|
|
|
96 |
#
|
| 6925 |
dpurdie |
97 |
push @flags , '--endian=little';
|
|
|
98 |
push @flags , '--cpu=Cortex-M3';
|
|
|
99 |
push @flags , '--diag_suppress=Pa050,Pa091';
|
|
|
100 |
push @flags , '--fpu=None';
|
|
|
101 |
push @flags , '-Oh';
|
|
|
102 |
push @flags , '--require_prototypes';
|
|
|
103 |
push @flags , '--remarks';
|
|
|
104 |
push @flags , '--dlib_config=DLib_Config_Normal.h';
|
| 5677 |
dpurdie |
105 |
|
| 6925 |
dpurdie |
106 |
push @ccflags , '--vla'; # variable length arrays. c only. not compatible with cxx--eec++
|
|
|
107 |
push @cxxflags , '--c++'; # standard c++.
|
|
|
108 |
#push @cxxflags , '--eec++'; # extended embedded c++.
|
|
|
109 |
|
| 5680 |
dpurdie |
110 |
# Defines
|
| 5726 |
dpurdie |
111 |
#push @defines, 'xxxxxx';
|
| 5677 |
dpurdie |
112 |
|
| 5680 |
dpurdie |
113 |
|
| 5677 |
dpurdie |
114 |
#
|
|
|
115 |
# Assembler flags and definitions
|
|
|
116 |
#
|
|
|
117 |
|
| 5783 |
dpurdie |
118 |
push @asflags , '-s+'; # Case-sensitive user symbols
|
|
|
119 |
push @asflags , '-w+'; # enable all warnings
|
|
|
120 |
push @asflags , '-r'; # generate debug information
|
|
|
121 |
push @asflags , '--cpu Cortex-M3';
|
|
|
122 |
push @asflags , '--fpu None';
|
|
|
123 |
|
|
|
124 |
# Assember Defines
|
|
|
125 |
#push @asdefines, 'xxxx';
|
| 5677 |
dpurdie |
126 |
}
|
|
|
127 |
|
|
|
128 |
#.. Standard.rul requirements
|
|
|
129 |
#
|
| 5732 |
dpurdie |
130 |
$s = 's'; # Assembler source file
|
|
|
131 |
$o = 'o'; # Object file
|
|
|
132 |
$a = 'a'; # Library file
|
| 5677 |
dpurdie |
133 |
$so = ''; # Shared library
|
| 5732 |
dpurdie |
134 |
$exe = '.srec'; # Linked binary images
|
| 5677 |
dpurdie |
135 |
|
|
|
136 |
AddSourceType( ".$s", '.asm' );
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
#.. Toolset configuration
|
|
|
140 |
#
|
|
|
141 |
$::ScmToolsetVersion = "1.0.0"; # our version
|
|
|
142 |
$::ScmToolsetGenerate = 0; # generate optional
|
|
|
143 |
$::ScmToolsetProgDependancies = 0; # handle Prog dependancies myself
|
|
|
144 |
|
|
|
145 |
#.. Cleanup rules
|
|
|
146 |
#
|
| 5680 |
dpurdie |
147 |
# Files that appear to be created by the compiler
|
| 5677 |
dpurdie |
148 |
#
|
| 5680 |
dpurdie |
149 |
ToolsetGenerate( '$(OBJDIR)/tmp*' );
|
|
|
150 |
ToolsetGenerate( '$(LIBDIR)/tmp*' );
|
|
|
151 |
ToolsetGenerate( '$(BINDIR)/tmp*' );
|
| 5677 |
dpurdie |
152 |
|
|
|
153 |
#.. Define IAR environment
|
|
|
154 |
#
|
|
|
155 |
#
|
|
|
156 |
# Define initialisation targets
|
|
|
157 |
# These will be used to ensure that correct versions of the toolset are present
|
|
|
158 |
# Retain 'avr_air' so we can reuse the .RUL file
|
|
|
159 |
#
|
|
|
160 |
Init( "cortexm3" );
|
|
|
161 |
|
|
|
162 |
ToolsetDefine ( "#################################################" );
|
|
|
163 |
ToolsetDefine ( "# CORTEX IAR compiler version" );
|
|
|
164 |
ToolsetDefine ( "#" );
|
|
|
165 |
ToolsetDefine ( "avr_iar_ver = $version" );
|
|
|
166 |
ToolsetDefine ( "avr_iar_prod = $product" );
|
|
|
167 |
ToolsetDefine ( "" );
|
|
|
168 |
ToolsetDefine ( "#" );
|
| 5679 |
dpurdie |
169 |
ToolsetDefines( "cortexm3_iar.def" );
|
| 5677 |
dpurdie |
170 |
ToolsetRules ( "avr_iar.rul" );
|
|
|
171 |
ToolsetRules ( "standard.rul" );
|
|
|
172 |
|
|
|
173 |
#
|
|
|
174 |
# Specify compiler parameters
|
|
|
175 |
# Note: AVR_IAR_INCLUDES is ";" seperated as it may contain spaces
|
|
|
176 |
# when expanded ("Program Files")
|
|
|
177 |
#
|
|
|
178 |
|
|
|
179 |
PlatformEntry( "AVR_IAR_DEFINES\t=", "\n", "\\\n\t", "", @defines )
|
|
|
180 |
if ( scalar @defines );
|
| 6925 |
dpurdie |
181 |
PlatformEntry( "AVR_IAR_INCLUDES\t=", "\n", "\\\n\t", ";", @dirs )
|
| 5677 |
dpurdie |
182 |
if ( scalar @dirs );
|
| 6925 |
dpurdie |
183 |
PlatformEntry( "AVR_IAR_FLAGS\t=", "\n", "\\\n\t", "", @flags )
|
| 5677 |
dpurdie |
184 |
if ( scalar @flags );
|
| 6925 |
dpurdie |
185 |
PlatformEntry( "AVR_IAR_CC_FLAGS\t=", "\n", "\\\n\t", "", @ccflags )
|
|
|
186 |
if ( scalar @ccflags );
|
|
|
187 |
PlatformEntry( "AVR_IAR_CXX_FLAGS\t=", "\n", "\\\n\t", "", @cxxflags )
|
|
|
188 |
if ( scalar @cxxflags );
|
| 5677 |
dpurdie |
189 |
|
|
|
190 |
PlatformEntry( "AVR_IAR_ASFLAGS\t=", "\n", "\\\n\t", "", @asflags )
|
|
|
191 |
if ( scalar @asflags );
|
| 6925 |
dpurdie |
192 |
PlatformEntry( "AVR_IAR_ASDEFINES\t=", "\n", "\\\n\t", "", @asdefines )
|
| 5677 |
dpurdie |
193 |
if ( scalar @asdefines );
|
|
|
194 |
|
|
|
195 |
}
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
##############################################################################
|
|
|
199 |
# ToolsetPreprocess()
|
|
|
200 |
# Process collected data before the makefile is generated
|
|
|
201 |
# This, optional, routine is called from within MakefileGenerate()
|
|
|
202 |
# It allows the toolset to massage any of the collected data before
|
|
|
203 |
# the makefile is created
|
|
|
204 |
#
|
|
|
205 |
##############################################################################
|
|
|
206 |
|
|
|
207 |
#sub ToolsetPreprocess
|
|
|
208 |
#{
|
|
|
209 |
#}
|
|
|
210 |
|
|
|
211 |
###############################################################################
|
|
|
212 |
# ToolsetCC( $source, $obj, \@args )
|
|
|
213 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
214 |
# required to compile the source file 'source' to 'obj'
|
|
|
215 |
#
|
|
|
216 |
###############################################################################
|
|
|
217 |
|
|
|
218 |
sub ToolsetCC
|
|
|
219 |
{
|
|
|
220 |
MakePrint( "\n\t\$(CC)\n" );
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
###############################################################################
|
|
|
224 |
# ToolsetCCDepend( $depend, \@sources )
|
|
|
225 |
# This subroutine takes the user options and builds the
|
|
|
226 |
# rule(s) required to build the dependencies for the source
|
|
|
227 |
# files 'sources' to 'depend'.
|
|
|
228 |
#
|
|
|
229 |
###############################################################################
|
|
|
230 |
|
|
|
231 |
sub ToolsetCCDepend
|
|
|
232 |
{
|
|
|
233 |
MakePrint( "\t\$(CCDEPEND)\n" );
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
|
|
|
237 |
###############################################################################
|
|
|
238 |
# ToolsetCXX( $source, $obj, \@args )
|
|
|
239 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
240 |
# required to compile the source file 'source' to 'obj'
|
|
|
241 |
#
|
|
|
242 |
###############################################################################
|
|
|
243 |
|
|
|
244 |
sub ToolsetCXX
|
|
|
245 |
{
|
|
|
246 |
MakePrint( "\n\t\$(CXX)\n" );
|
|
|
247 |
}
|
|
|
248 |
|
|
|
249 |
###############################################################################
|
|
|
250 |
# ToolsetCXXDepend( $depend, \@sources )
|
|
|
251 |
# This subroutine takes the user options and builds the
|
|
|
252 |
# rule(s) required to build the dependencies for the source
|
|
|
253 |
# files 'sources' to 'depend'.
|
|
|
254 |
#
|
|
|
255 |
###############################################################################
|
|
|
256 |
|
|
|
257 |
sub ToolsetCXXDepend
|
|
|
258 |
{
|
|
|
259 |
ToolsetCCDepend();
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
|
|
|
263 |
###############################################################################
|
|
|
264 |
# ToolsetAS( $source, $obj, \@args )
|
|
|
265 |
# This subroutine takes the user options and builds the rule(s)
|
|
|
266 |
# required to compile the source file 'source' to 'obj'
|
|
|
267 |
#
|
|
|
268 |
###############################################################################
|
|
|
269 |
|
|
|
270 |
sub ToolsetAS
|
|
|
271 |
{
|
|
|
272 |
MakePrint( "\n\t\$(AS)\n" );
|
|
|
273 |
}
|
|
|
274 |
|
|
|
275 |
sub ToolsetASDepend
|
|
|
276 |
{
|
|
|
277 |
}
|
|
|
278 |
|
|
|
279 |
###############################################################################
|
|
|
280 |
# ToolsetAR( $name, \@args, \@objs )
|
|
|
281 |
# This subroutine takes the user options and builds the rules
|
|
|
282 |
# required to build the library 'name'.
|
|
|
283 |
|
|
|
284 |
#
|
|
|
285 |
# Arguments:
|
|
|
286 |
# --xxx No arguments currently defined
|
|
|
287 |
#
|
|
|
288 |
# Output:
|
|
|
289 |
# [ $(BINDIR)/name$.${a}: .... ]
|
|
|
290 |
# $(AR)
|
|
|
291 |
#
|
|
|
292 |
###############################################################################
|
|
|
293 |
|
|
|
294 |
sub ToolsetAR
|
|
|
295 |
{
|
|
|
296 |
my( $name, $pArgs, $pObjs ) = @_;
|
|
|
297 |
|
|
|
298 |
Debug("ToolsetAR");
|
|
|
299 |
|
|
|
300 |
#.. Parse arguments
|
|
|
301 |
#
|
|
|
302 |
foreach $_ ( @$pArgs ) {
|
|
|
303 |
if (/^--/) {
|
|
|
304 |
Message( "AR: unknown option $_ -- ignored\n" );
|
|
|
305 |
}
|
|
|
306 |
}
|
|
|
307 |
|
|
|
308 |
#.. Target
|
|
|
309 |
#
|
|
|
310 |
MakeEntry( "\$(LIBDIR)/$name\$(GBE_TYPE).${a}:\t", "", " \\\n\t\t", ".${o}", @$pObjs );
|
|
|
311 |
|
|
|
312 |
#.. Build library rule (just append to standard rule)
|
|
|
313 |
#
|
|
|
314 |
MakePrint( "\n\t\$(AR)\n\n" );
|
|
|
315 |
}
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
###############################################################################
|
|
|
319 |
# ToolsetARMerge()
|
|
|
320 |
# Generate the recipe to merge libraries.
|
|
|
321 |
# The dependency list is created by the caller.
|
|
|
322 |
#
|
|
|
323 |
###############################################################################
|
|
|
324 |
|
|
|
325 |
sub ToolsetARMerge
|
|
|
326 |
{
|
|
|
327 |
MakePrint( "\n\t\$(ARMERGE)\n\n" );
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
|
|
|
331 |
###############################################################################
|
|
|
332 |
# ToolsetLD( $name, \@args, \@objs, \@libraries )
|
|
|
333 |
# This subroutine takes the user options and builds the rules
|
|
|
334 |
# required to link the program 'name'.
|
|
|
335 |
#
|
|
|
336 |
# Arguments:
|
|
|
337 |
# --xxx No Arguments currently specified
|
|
|
338 |
#
|
|
|
339 |
# Linker specific:
|
|
|
340 |
# --LinkScript=filename Specify the name of a linker script file
|
|
|
341 |
# --Loader=filename Specify a loader file to be merged
|
|
|
342 |
# This will be a program
|
|
|
343 |
# --Type=typetext Text to be placed in type field
|
| 5726 |
dpurdie |
344 |
# --Entry=Name Alternate Program Entry Point
|
| 5757 |
dpurdie |
345 |
# --CrcRange=Text Text used in the elftool command for fill and checksum ranges
|
|
|
346 |
# ie: app_start-app_checksum_end+3
|
| 5677 |
dpurdie |
347 |
#
|
|
|
348 |
# Output:
|
|
|
349 |
#
|
|
|
350 |
# name.map - Loadable module
|
| 5726 |
dpurdie |
351 |
# name.out - Output from the linker
|
|
|
352 |
# name.srec - Output from the elftool
|
| 5677 |
dpurdie |
353 |
# name.d90 -
|
| 5726 |
dpurdie |
354 |
# name.sxml - Wrapped srec file
|
| 5677 |
dpurdie |
355 |
#
|
|
|
356 |
###############################################################################
|
|
|
357 |
|
|
|
358 |
sub ToolsetLD
|
|
|
359 |
{
|
|
|
360 |
my( $name, $pArgs, $pObjs, $pLibs ) = @_;
|
|
|
361 |
my( $script );
|
|
|
362 |
my( $loader, $loader_file);
|
|
|
363 |
my $type_text = '';
|
| 5726 |
dpurdie |
364 |
my $entyPoint = '__iar_program_start';
|
| 5757 |
dpurdie |
365 |
my $crcRange;
|
| 5677 |
dpurdie |
366 |
|
|
|
367 |
|
|
|
368 |
#.. Parse arguments
|
|
|
369 |
#
|
|
|
370 |
foreach $_ ( @$pArgs )
|
|
|
371 |
{
|
|
|
372 |
#.. Target specific
|
|
|
373 |
#
|
|
|
374 |
|
|
|
375 |
#.. Toolset specific
|
|
|
376 |
#
|
|
|
377 |
if (/^--Script=(.*)/) { # External file
|
|
|
378 |
$script = $1;
|
| 5726 |
dpurdie |
379 |
$script .= ".icf" unless ( $script =~ m~\.icf$~ );
|
| 5677 |
dpurdie |
380 |
|
|
|
381 |
} elsif ( /^--ProgLoader=(.*)/ ) { # Loader/Burner file
|
|
|
382 |
$loader = $1;
|
|
|
383 |
$loader =~ s~$exe$~~;
|
|
|
384 |
|
|
|
385 |
} elsif ( /^--Type=(.*)/ ) { # Type of Payload
|
|
|
386 |
$type_text = $1;
|
|
|
387 |
|
| 5726 |
dpurdie |
388 |
} elsif ( /^--Entry=(.*)/ ) { # Entry Point
|
|
|
389 |
$entyPoint = $1;
|
|
|
390 |
|
| 5757 |
dpurdie |
391 |
} elsif ( /^--CrcRange=(.*)/ ) { # Crc Range
|
|
|
392 |
$crcRange = $1;
|
|
|
393 |
|
| 5677 |
dpurdie |
394 |
} else {
|
|
|
395 |
Message( "Prog: unknown option $_ -- ignored\n" );
|
|
|
396 |
}
|
|
|
397 |
}
|
|
|
398 |
|
|
|
399 |
#
|
|
|
400 |
# Sanity check
|
|
|
401 |
# - Ensure a linker script has been provided
|
|
|
402 |
#
|
|
|
403 |
unless ( $script )
|
|
|
404 |
{
|
| 5726 |
dpurdie |
405 |
$script = "$name.icf";
|
| 5677 |
dpurdie |
406 |
Warning( "Prog: Linker Script file not provided. Using $script" );
|
|
|
407 |
}
|
|
|
408 |
|
|
|
409 |
#
|
|
|
410 |
# Locate the true path of the provided script file
|
|
|
411 |
# If it is a generate file so it will be in the SRCS hash
|
|
|
412 |
# Other wise the use will have to use Src to locate the file
|
|
|
413 |
#
|
|
|
414 |
$script = MakeSrcResolve ( $script );
|
|
|
415 |
|
|
|
416 |
#
|
|
|
417 |
# Locate the loader file, if it has been provided
|
|
|
418 |
# The file must be a program and should be created within this makefile
|
|
|
419 |
#
|
|
|
420 |
if ( $loader )
|
|
|
421 |
{
|
|
|
422 |
if ( $::PROGS->Get( $loader) )
|
|
|
423 |
{
|
|
|
424 |
$loader_file = "\$(BINDIR)/$loader$exe";
|
|
|
425 |
}
|
|
|
426 |
elsif ( $::SRCS{$loader} )
|
|
|
427 |
{
|
|
|
428 |
$loader_file = $::SRCS{$loader};
|
|
|
429 |
}
|
|
|
430 |
else
|
|
|
431 |
{
|
|
|
432 |
Error ("Prog: ProgLoader file not found" );
|
|
|
433 |
}
|
|
|
434 |
}
|
|
|
435 |
|
|
|
436 |
#
|
|
|
437 |
# Extend the list of libraries with compiler specific libraries
|
|
|
438 |
#
|
| 5679 |
dpurdie |
439 |
# push( @$pLibs, "\$(avr_linker_lib)" );
|
| 5677 |
dpurdie |
440 |
|
|
|
441 |
#
|
|
|
442 |
# Create a ToolsetPrinter
|
|
|
443 |
#
|
|
|
444 |
my ($io) = ToolsetPrinter::New();
|
|
|
445 |
my $dep = $io->SetLdTarget( $name );
|
|
|
446 |
|
|
|
447 |
#
|
|
|
448 |
# Determine the target output name
|
|
|
449 |
#
|
|
|
450 |
my $root = "\$(BINDIR)/$name";
|
|
|
451 |
my $full = $root . $::exe;
|
|
|
452 |
my $map = $root . '.map';
|
| 5726 |
dpurdie |
453 |
my $log = $root . '.log';
|
|
|
454 |
my $out = $root . '.out';
|
|
|
455 |
my $srec = $root . '.srec';
|
| 5677 |
dpurdie |
456 |
|
|
|
457 |
|
|
|
458 |
########################################################################
|
|
|
459 |
#
|
|
|
460 |
# Before this function was called, makelib.pl2 has generated a
|
|
|
461 |
# partial rule consisting of:
|
|
|
462 |
#
|
|
|
463 |
# $(BINDIR)/${name}${exe} :
|
|
|
464 |
# All the specified object files
|
|
|
465 |
#
|
|
|
466 |
# Add the names of all the other files required in the process
|
|
|
467 |
# This will then serve as a target fo all things that need to be
|
|
|
468 |
# created when a "program" is required
|
|
|
469 |
#
|
|
|
470 |
# These are:
|
|
|
471 |
# User linker script file
|
|
|
472 |
# Library dependency file
|
|
|
473 |
#
|
|
|
474 |
$io->Label( "Program", $name ); # label
|
| 5830 |
dpurdie |
475 |
$io->Prt( "$full : \t$dep" ); # Dependencies
|
| 5677 |
dpurdie |
476 |
$io->Prt( "\\\n\t\t$script" );
|
|
|
477 |
$io->Prt( " \\\n\t\t$loader_file" ) if ($loader_file);
|
|
|
478 |
$io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs ); # Object Files
|
| 5830 |
dpurdie |
479 |
$io->Prt( "\n\t\$(LD_IAR)" );
|
| 5677 |
dpurdie |
480 |
|
|
|
481 |
#
|
| 5830 |
dpurdie |
482 |
# Convert elf to srec file
|
|
|
483 |
# (if $3,--fill 0xFF;$3 --checksum checksum:4\,crc32\,0xFFFFFFFF;$3)
|
|
|
484 |
#
|
|
|
485 |
my $sRecRange = '';
|
|
|
486 |
if ($crcRange)
|
|
|
487 |
{
|
|
|
488 |
$sRecRange = "--fill \"0xFF;$crcRange\" --checksum \"checksum:4\$(comma)crc32\$(comma)0xFFFFFFFF;$crcRange\""
|
|
|
489 |
}
|
|
|
490 |
$io->Prt( "\n\t\$(call GENERATE_SREC, \\" .
|
|
|
491 |
"\n\t\t$out, \\" .
|
|
|
492 |
"\n\t\t$full, \\" .
|
|
|
493 |
"\n\t\t$sRecRange)\n");
|
|
|
494 |
|
|
|
495 |
#
|
| 5677 |
dpurdie |
496 |
# Insert post processing call if a program loader is needed
|
|
|
497 |
#
|
|
|
498 |
$io->Prt( "\t\$(call LD_IAR_PROCESS, \\" .
|
|
|
499 |
"\n\t\t$full, \\" .
|
|
|
500 |
"\n\t\t$loader_file)\n"
|
|
|
501 |
) if ($loader_file);
|
|
|
502 |
|
|
|
503 |
$io->Newline();
|
|
|
504 |
|
|
|
505 |
#
|
|
|
506 |
# Specify files created by the linker
|
|
|
507 |
# These will be added to the clean list
|
|
|
508 |
#
|
|
|
509 |
ToolsetGenerate( $map );
|
| 5726 |
dpurdie |
510 |
ToolsetGenerate( $log );
|
|
|
511 |
ToolsetGenerate( $out );
|
|
|
512 |
ToolsetGenerate( $srec );
|
| 5677 |
dpurdie |
513 |
ToolsetGenerate( "$full.keep" );
|
|
|
514 |
|
|
|
515 |
#
|
|
|
516 |
# Create a linker command file
|
|
|
517 |
# Piecing together a variable $(name_ld) which ends up in the command file.
|
|
|
518 |
# This bit of magic will be performed by the LD_IAR recipe
|
|
|
519 |
#
|
|
|
520 |
$io->SetTag( "${name}_ld" ); # macro tag
|
|
|
521 |
$io->Label( "Linker commands", $name ); # label
|
|
|
522 |
|
| 5726 |
dpurdie |
523 |
# $io->Cmd("-S" ); # Silent
|
|
|
524 |
$io->Cmd("-o $out" ); # Output file
|
|
|
525 |
$io->Cmd("--map $map" ); # Map file
|
|
|
526 |
# Configue Logging
|
|
|
527 |
$io->Cmd("--log libraries,initialization,modules,redirects,sections,veneers,unused_fragments,call_graph" );
|
|
|
528 |
$io->Cmd("--log_file $log" ); # Log file
|
|
|
529 |
$io->Cmd("--semihosting" );
|
|
|
530 |
$io->Cmd("--entry $entyPoint" );
|
|
|
531 |
$io->Cmd("--inline" );
|
|
|
532 |
$io->Cmd("--vfe" );
|
|
|
533 |
$io->Cmd("--config $script" ); # User script file
|
| 5677 |
dpurdie |
534 |
|
|
|
535 |
$io->ObjList( $name, $pObjs, \&ToolsetObjRecipe ); # Object files
|
|
|
536 |
|
|
|
537 |
#
|
|
|
538 |
# Specify the library files
|
|
|
539 |
#
|
| 5679 |
dpurdie |
540 |
# $io->Cmd( '"-I$(avr_linker_lib_dir)"' ); # Toolset library directory
|
| 5677 |
dpurdie |
541 |
$io->LibList( $name, $pLibs, \&ToolsetLibRecipe ); # Specify the libraries too
|
|
|
542 |
$io->Newline();
|
|
|
543 |
|
|
|
544 |
#.. Dependency link,
|
|
|
545 |
# Create a library dependency file
|
|
|
546 |
# Create command file to build applicaton dependency list
|
|
|
547 |
# from the list of dependent libraries
|
|
|
548 |
#
|
|
|
549 |
# Create makefile directives to include the dependency
|
|
|
550 |
# list into the makefile.
|
|
|
551 |
#
|
| 5726 |
dpurdie |
552 |
$io->DepRules( $pLibs, \&ToolsetLibRecipe, $out );
|
| 5677 |
dpurdie |
553 |
$io->LDDEPEND();
|
|
|
554 |
|
|
|
555 |
#
|
|
|
556 |
# Add the MAP file to the program package
|
|
|
557 |
#
|
|
|
558 |
PackageProgAddFiles ( $name, $full );
|
|
|
559 |
PackageProgAddFiles ( $name, $map , 'Class=map' );
|
|
|
560 |
|
| 5726 |
dpurdie |
561 |
#
|
| 5677 |
dpurdie |
562 |
# Create the .sxml file
|
|
|
563 |
#
|
|
|
564 |
my $sxml = "\$(BINDIR)/${name}.sxml";
|
|
|
565 |
my ($major, $minor, $patch, $build, $raw_patch) = SplitVersion($ScmBuildVersionFull);
|
|
|
566 |
|
|
|
567 |
$io->Label( "SXML File", $name );
|
| 5726 |
dpurdie |
568 |
$io->Prt( "$sxml: $srec\n");
|
| 5677 |
dpurdie |
569 |
$io->Prt( "\t\$(call GENERATE_SXML, \\" .
|
|
|
570 |
"\n\t\t\$(BINDIR)/${name}$exe, \\" .
|
| 5679 |
dpurdie |
571 |
"\n\t\t$sxml,$type_text,$major,$minor,$patch,$build,InsideSecure)\n"
|
| 5677 |
dpurdie |
572 |
);
|
|
|
573 |
$io->Newline();
|
|
|
574 |
|
|
|
575 |
#
|
|
|
576 |
# Generated files to be added to the program file list
|
|
|
577 |
#
|
|
|
578 |
ToolsetGenerate( $sxml );
|
|
|
579 |
PackageProgAddFiles( $name, $sxml, 'Class=extras' );
|
|
|
580 |
ProgAddExtra( $name, $sxml );
|
|
|
581 |
|
|
|
582 |
}
|
|
|
583 |
|
|
|
584 |
########################################################################
|
|
|
585 |
#
|
|
|
586 |
# Generate a linker object recipe. This is a helper function used
|
|
|
587 |
# within this toolset.
|
|
|
588 |
#
|
|
|
589 |
# Arguments:
|
|
|
590 |
# $io I/O stream
|
|
|
591 |
#
|
|
|
592 |
# $target Name of the target
|
|
|
593 |
#
|
|
|
594 |
# $obj Library specification
|
|
|
595 |
#
|
|
|
596 |
########################################################################
|
|
|
597 |
|
|
|
598 |
sub ToolsetObjRecipe
|
|
|
599 |
{
|
|
|
600 |
my ($io, $target, $obj) = @_;
|
|
|
601 |
|
|
|
602 |
$io->Cmd("$obj.$::o" );
|
|
|
603 |
}
|
|
|
604 |
|
|
|
605 |
########################################################################
|
|
|
606 |
#
|
|
|
607 |
# Generate a linker/depend library recipe. This is a helper function
|
|
|
608 |
# used within this toolset.
|
|
|
609 |
#
|
|
|
610 |
# Arguments:
|
|
|
611 |
# $io I/O stream
|
|
|
612 |
#
|
|
|
613 |
# $target Name of the target
|
|
|
614 |
#
|
|
|
615 |
# $lib Library specification
|
|
|
616 |
#
|
|
|
617 |
# $dp If building a depend list, the full target name.
|
|
|
618 |
#
|
|
|
619 |
########################################################################
|
|
|
620 |
|
|
|
621 |
sub ToolsetLibRecipe
|
|
|
622 |
{
|
|
|
623 |
my ($io, $target, $lib, $dp) = @_;
|
|
|
624 |
|
|
|
625 |
if ( !defined($dp) ) { # linker
|
| 5783 |
dpurdie |
626 |
$io->Cmd("--semihosting @(vpath2,\"$lib.$::a\",IAR_LIB)" );
|
| 5677 |
dpurdie |
627 |
} else { # depend
|
|
|
628 |
$io->Cmd( "$dp:\t@(vlib2,\"$lib.$::a\",IAR_LIB)" );
|
|
|
629 |
}
|
|
|
630 |
}
|
|
|
631 |
|
|
|
632 |
#.. Successful termination
|
|
|
633 |
1;
|
|
|
634 |
|