Subversion Repositories DevTools

Rev

Rev 5680 | Rev 5732 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5680 Rev 5726
Line 95... Line 95...
95
        #   Compiler flags and definitions
95
        #   Compiler flags and definitions
96
        #
96
        #
97
Warning("TODO: Compiler Flags");
97
Warning("TODO: Compiler Flags");
98
       push @flags , '--endian=little';
98
       push @flags , '--endian=little';
99
       push @flags , '--cpu=Cortex-M3';
99
       push @flags , '--cpu=Cortex-M3';
100
       push @flags , '--diag_suppress=Pa050';
100
       push @flags , '--diag_suppress=Pa050,Pa091';
101
       push @flags , '-e';
101
       push @flags , '-e';
102
       push @flags , '--fpu=None';
102
       push @flags , '--fpu=None';
103
       push @flags , '-Oh';
103
       push @flags , '-Oh';
104
       push @flags , '--vla';
104
       push @flags , '--vla';
105
       push @flags , '--require_prototypes';
105
       push @flags , '--require_prototypes';
106
#       push @flags , '--dlib_config=$(COMPILER_HOME_AVR)\INC\c\DLib_Config_Normal.h';
106
       #push @flags , '--discard_unused_publics';
-
 
107
       #push @flags , '--mfc';
-
 
108
       push @flags , '--remarks';
107
       push @flags , '--dlib_config=DLib_Config_Normal.h';
109
       push @flags , '--dlib_config=DLib_Config_Normal.h';
108
 
-
 
-
 
110
       push @flags, '-lC $(OBJDIR)';
-
 
111
       push @flags, '-lA $(OBJDIR)';
109
 
112
 
110
       # Defines
113
       # Defines
111
       #push @defines, '_EEP_EOW_MODE=IDLE_EEP_WRITE';
114
       #push @defines, 'xxxxxx';
112
 
115
 
113
 
116
 
114
        #
117
        #
115
        #   Assembler flags and definitions
118
        #   Assembler flags and definitions
116
        #
119
        #
Line 130... Line 133...
130
    #
133
    #
131
    $s = 's90';             # Assembler source file
134
    $s = 's90';             # Assembler source file
132
    $o = 'r90';             # Object file
135
    $o = 'r90';             # Object file
133
    $a = 'r90';             # Library file
136
    $a = 'r90';             # Library file
134
    $so = '';               # Shared library
137
    $so = '';               # Shared library
135
    $exe = '.s19';          # Linked binary images
138
    $exe = '.srec';          # Linked binary images
136
 
139
 
137
    AddSourceType( ".$s", '.asm' );
140
    AddSourceType( ".$s", '.asm' );
138
    
141
    
139
 
142
 
140
    #.. Toolset configuration
143
    #.. Toolset configuration
Line 337... Line 340...
337
#       Linker specific:
340
#       Linker specific:
338
#       --LinkScript=filename   Specify the name of a linker script file
341
#       --LinkScript=filename   Specify the name of a linker script file
339
#       --Loader=filename       Specify a loader file to be merged
342
#       --Loader=filename       Specify a loader file to be merged
340
#                               This will be a program
343
#                               This will be a program
341
#       --Type=typetext         Text to be placed in type field
344
#       --Type=typetext         Text to be placed in type field
-
 
345
#       --Entry=Name            Alternate Program Entry Point
342
#
346
#
343
#   Output:
347
#   Output:
344
#
348
#
345
#       name.map                - Loadable module
349
#       name.map                - Loadable module
346
#       name.s19                -
350
#       name.out                - Output from the linker
-
 
351
#       name.srec               - Output from the elftool
347
#       name.d90                -
352
#       name.d90                -
348
#       name.sxml               - Wrapped s19 file
353
#       name.sxml               - Wrapped srec file
349
#
-
 
350
#   Linker Flags
-
 
351
#
354
#
352
#       -O[format]=filename         Specify output filename and format
-
 
353
#       -o filename                 Specify an output file
-
 
354
#       -r                          Output file indebug format
-
 
355
#       -z                          Reduce segment overlap errors
-
 
356
#       -l filename                 Generate a listing file
-
 
357
#       -xmsn                       Add info to the map file
-
 
358
#       -Pnnn                       Number of line per page
-
 
359
#       -Ipath                      Specify a path to search for object files
-
 
360
#       -f filename                 Read arguments from file
-
 
361
#       -C filename                 Load filename as a library
-
 
362
 
-
 
363
###############################################################################
355
###############################################################################
364
 
356
 
365
sub ToolsetLD
357
sub ToolsetLD
366
{
358
{
367
    my( $name, $pArgs, $pObjs, $pLibs ) = @_;
359
    my( $name, $pArgs, $pObjs, $pLibs ) = @_;
368
    my( $script );
360
    my( $script );
369
    my( $loader, $loader_file);
361
    my( $loader, $loader_file);
370
    my  $type_text = '';
362
    my  $type_text = '';
-
 
363
    my  $entyPoint = '__iar_program_start';
371
 
364
 
372
 
365
 
373
#.. Parse arguments
366
#.. Parse arguments
374
#
367
#
375
    foreach $_ ( @$pArgs )
368
    foreach $_ ( @$pArgs )
Line 379... Line 372...
379
 
372
 
380
    #.. Toolset specific
373
    #.. Toolset specific
381
    #
374
    #
382
        if (/^--Script=(.*)/) {           # External file
375
        if (/^--Script=(.*)/) {           # External file
383
            $script = $1;
376
            $script = $1;
384
            $script .= ".xcl" unless ( $script =~ m~\.xcl$~ );
377
            $script .= ".icf" unless ( $script =~ m~\.icf$~ );
385
 
378
 
386
        } elsif ( /^--ProgLoader=(.*)/ ) {   # Loader/Burner file
379
        } elsif ( /^--ProgLoader=(.*)/ ) {   # Loader/Burner file
387
            $loader = $1;
380
            $loader = $1;
388
            $loader =~ s~$exe$~~;
381
            $loader =~ s~$exe$~~;
389
 
382
 
390
        } elsif ( /^--Type=(.*)/ ) {        # Type of Payload
383
        } elsif ( /^--Type=(.*)/ ) {        # Type of Payload
391
            $type_text = $1;
384
            $type_text = $1;
392
 
385
 
-
 
386
        } elsif ( /^--Entry=(.*)/ ) {        # Entry Point
-
 
387
            $entyPoint = $1;
-
 
388
 
393
        } else {
389
        } else {
394
            Message( "Prog: unknown option $_ -- ignored\n" );
390
            Message( "Prog: unknown option $_ -- ignored\n" );
395
        }
391
        }
396
    }
392
    }
397
 
393
 
Line 399... Line 395...
399
#   Sanity check
395
#   Sanity check
400
#       - Ensure a linker script has been provided
396
#       - Ensure a linker script has been provided
401
#
397
#
402
unless ( $script )
398
unless ( $script )
403
{
399
{
404
    $script = "$name.xcl";
400
    $script = "$name.icf";
405
    Warning( "Prog: Linker Script file not provided. Using $script" );
401
    Warning( "Prog: Linker Script file not provided. Using $script" );
406
}
402
}
407
 
403
 
408
#
404
#
409
#   Locate the true path of the provided script file
405
#   Locate the true path of the provided script file
Line 448... Line 444...
448
#   Determine the target output name
444
#   Determine the target output name
449
#
445
#
450
    my $root = "\$(BINDIR)/$name";
446
    my $root = "\$(BINDIR)/$name";
451
    my $full = $root . $::exe;
447
    my $full = $root . $::exe;
452
    my $map = $root . '.map';
448
    my $map = $root . '.map';
-
 
449
    my $log = $root . '.log';
453
    my $d90 = $root . '.d90';
450
    my $out = $root . '.out';
454
    my $s19 = $root . '.s19';
451
    my $srec = $root . '.srec';
455
    
452
    
456
 
453
 
457
########################################################################
454
########################################################################
458
#
455
#
459
#   Before this function was called, makelib.pl2 has generated a
456
#   Before this function was called, makelib.pl2 has generated a
Line 469... Line 466...
469
#       These are:
466
#       These are:
470
#               User linker script file
467
#               User linker script file
471
#               Library dependency file
468
#               Library dependency file
472
# 
469
# 
473
    $io->Label( "Program", $name );                     # label
470
    $io->Label( "Program", $name );                     # label
474
    $io->Prt( "$full : \t$dep" );                       # Dependencies
471
    $io->Prt( "$out : \t$dep" );                       # Dependencies
475
    $io->Prt( "\\\n\t\t$script" );
472
    $io->Prt( "\\\n\t\t$script" );
476
    $io->Prt( " \\\n\t\t$loader_file" ) if ($loader_file);
473
    $io->Prt( " \\\n\t\t$loader_file" ) if ($loader_file);
477
    $io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs );  # Object Files
474
    $io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs );  # Object Files
478
    $io->Prt( "\n\t\$(LD_IAR)\n" );
475
    $io->Prt( "\n\t\$(LD_IAR)\n" );
479
 
476
 
Line 489... Line 486...
489
 
486
 
490
    #
487
    #
491
    #   Specify files created by the linker
488
    #   Specify files created by the linker
492
    #   These will be added to the clean list
489
    #   These will be added to the clean list
493
    #
490
    #
494
    ToolsetGenerate( $d90 );
-
 
495
    ToolsetGenerate( $map );
491
    ToolsetGenerate( $map );
-
 
492
    ToolsetGenerate( $log );
-
 
493
    ToolsetGenerate( $out );
-
 
494
    ToolsetGenerate( $srec );
496
    ToolsetGenerate( "$full.keep" );
495
    ToolsetGenerate( "$full.keep" );
497
 
496
 
498
    #
497
    #
499
    #   Create a linker command file
498
    #   Create a linker command file
500
    #   Piecing together a variable $(name_ld) which ends up in the command file.
499
    #   Piecing together a variable $(name_ld) which ends up in the command file.
501
    #   This bit of magic will be performed by the LD_IAR recipe
500
    #   This bit of magic will be performed by the LD_IAR recipe
502
    #
501
    #
503
    $io->SetTag( "${name}_ld" );                            # macro tag
502
    $io->SetTag( "${name}_ld" );                            # macro tag
504
    $io->Label( "Linker commands", $name );                 # label
503
    $io->Label( "Linker commands", $name );                 # label
505
 
504
 
506
#    $io->Cmd("-S" );                                        # Silent
505
#    $io->Cmd("-S" );                                       # Silent
507
#    $io->Cmd("-Omotorola=$s19" );                           # Output file
-
 
508
    $io->Cmd("-o $d90" );                                   # Output file
506
    $io->Cmd("-o $out" );                                   # Output file
509
    $io->Cmd("-l $map" );                                   # Map file
507
    $io->Cmd("--map $map" );                                # Map file
510
#    $io->Cmd("-r" );                                        # Output with debug
508
                                                            # Configue Logging
511
#    $io->Cmd("-z" );                                        # Reduce segment overlap errors
509
    $io->Cmd("--log libraries,initialization,modules,redirects,sections,veneers,unused_fragments,call_graph" );
512
    $io->Cmd("-xmsn" );                                     # Add info to the map file
510
    $io->Cmd("--log_file $log" );                           # Log file
-
 
511
    $io->Cmd("--semihosting" );
513
#    $io->Cmd("-p100" );                                     # Number of line per page
512
    $io->Cmd("--entry $entyPoint" );
-
 
513
    $io->Cmd("--inline" );
-
 
514
    $io->Cmd("--vfe" );
514
    $io->Cmd("-f $script" );                                # User script file
515
    $io->Cmd("--config $script" );                          # User script file
515
Warning("TODO: Add Linker commands");
-
 
516
 
516
 
517
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );      # Object files
517
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );      # Object files
518
 
518
 
519
    #
519
    #
520
    #   Specify the library files
520
    #   Specify the library files
Line 530... Line 530...
530
    #       from the list of dependent libraries
530
    #       from the list of dependent libraries
531
    #
531
    #
532
    #       Create makefile directives to include the dependency
532
    #       Create makefile directives to include the dependency
533
    #       list into the makefile.
533
    #       list into the makefile.
534
    #
534
    #
535
    $io->DepRules( $pLibs, \&ToolsetLibRecipe, $s19 );
535
    $io->DepRules( $pLibs, \&ToolsetLibRecipe, $out );
536
    $io->LDDEPEND(); 
536
    $io->LDDEPEND(); 
537
 
537
 
538
    #
538
    #
539
    #   Add the MAP file to the program package
539
    #   Add the MAP file to the program package
540
    #
540
    #
541
    PackageProgAddFiles ( $name, $full );
541
    PackageProgAddFiles ( $name, $full );
542
    PackageProgAddFiles ( $name, $map , 'Class=map' );
542
    PackageProgAddFiles ( $name, $map , 'Class=map' );
543
 
543
 
-
 
544
    #
-
 
545
    #   Create the .srec file
-
 
546
    #
-
 
547
    $io->Label( "SREC File", $name );
-
 
548
    $io->Prt( "$srec: $out\n");
-
 
549
    $io->Prt( "\t\$(call GENERATE_SREC $out,$srec)\n");
-
 
550
    $io->Newline();
-
 
551
 
544
 
552
 
545
    #
553
    #
546
    #   Create the .sxml file
554
    #   Create the .sxml file
547
    #
555
    #
548
    my $sxml = "\$(BINDIR)/${name}.sxml";
556
    my $sxml = "\$(BINDIR)/${name}.sxml";
549
    my ($major, $minor, $patch, $build, $raw_patch) = SplitVersion($ScmBuildVersionFull);
557
    my ($major, $minor, $patch, $build, $raw_patch) = SplitVersion($ScmBuildVersionFull);
550
 
558
 
551
    $io->Label( "SXML File", $name );
559
    $io->Label( "SXML File", $name );
552
    $io->Prt( "$sxml: $s19\n");
560
    $io->Prt( "$sxml: $srec\n");
553
    $io->Prt( "\t\$(call GENERATE_SXML, \\" .
561
    $io->Prt( "\t\$(call GENERATE_SXML, \\" .
554
              "\n\t\t\$(BINDIR)/${name}$exe, \\" .
562
              "\n\t\t\$(BINDIR)/${name}$exe, \\" .
555
              "\n\t\t$sxml,$type_text,$major,$minor,$patch,$build,InsideSecure)\n"
563
              "\n\t\t$sxml,$type_text,$major,$minor,$patch,$build,InsideSecure)\n"
556
              );
564
              );
557
    $io->Newline();
565
    $io->Newline();
Line 605... Line 613...
605
sub ToolsetLibRecipe
613
sub ToolsetLibRecipe
606
{
614
{
607
    my ($io, $target, $lib, $dp) = @_;
615
    my ($io, $target, $lib, $dp) = @_;
608
 
616
 
609
    if ( !defined($dp) ) {                      # linker
617
    if ( !defined($dp) ) {                      # linker
610
        $io->Cmd("-C @(vpath2,\"$lib.$::a\",IAR_LIB)" );
618
        $io->Cmd("--search @(vpath2,\"$lib.$::a\",IAR_LIB)" );
611
    } else {                                    # depend
619
    } else {                                    # depend
612
        $io->Cmd( "$dp:\t@(vlib2,\"$lib.$::a\",IAR_LIB)" );
620
        $io->Cmd( "$dp:\t@(vlib2,\"$lib.$::a\",IAR_LIB)" );
613
    }
621
    }
614
}
622
}
615
 
623