OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [bin/] [asm2ihex.sh] - Blame information for rev 202

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 73 olivier.gi
#!/bin/bash
2 2 olivier.gi
#------------------------------------------------------------------------------
3
# Copyright (C) 2001 Authors
4
#
5
# This source file may be used and distributed without restriction provided
6
# that this copyright statement is not removed from the file and that any
7
# derivative work contains the original copyright notice and the associated
8
# disclaimer.
9
#
10
# This source file is free software; you can redistribute it and/or modify
11
# it under the terms of the GNU Lesser General Public License as published
12
# by the Free Software Foundation; either version 2.1 of the License, or
13 134 olivier.gi
# (at your option) any later version.1
14 2 olivier.gi
#
15
# This source is distributed in the hope that it will be useful, but WITHOUT
16
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18
# License for more details.
19
#
20
# You should have received a copy of the GNU Lesser General Public License
21
# along with this source; if not, write to the Free Software Foundation,
22
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
#
24
#------------------------------------------------------------------------------
25 200 olivier.gi
#
26 2 olivier.gi
# File Name: asm2ihex.sh
27 200 olivier.gi
#
28 17 olivier.gi
# Author(s):
29
#             - Olivier Girard,    olgirard@gmail.com
30
#
31 2 olivier.gi
#------------------------------------------------------------------------------
32 17 olivier.gi
# $Rev: 202 $
33
# $LastChangedBy: olivier.girard $
34
# $LastChangedDate: 2015-07-01 23:13:32 +0200 (Wed, 01 Jul 2015) $
35
#------------------------------------------------------------------------------
36 2 olivier.gi
 
37
###############################################################################
38
#                            Parameter Check                                  #
39
###############################################################################
40 141 olivier.gi
EXPECTED_ARGS=7
41 2 olivier.gi
if [ $# -ne $EXPECTED_ARGS ]; then
42
  echo "ERROR    : wrong number of arguments"
43 141 olivier.gi
  echo "USAGE    : asm2ihex.sh <test name> <test assembler file> <linker script> <assembler define>  <prog mem size> <data mem size> <peripheral addr space size>"
44
  echo "Example  : asm2ihex.sh c-jump_jge  ../src/c-jump_jge.s43 ../bin/template.x ../bin/pmem.h 2048            128             512"
45 2 olivier.gi
  exit 1
46
fi
47
 
48 200 olivier.gi
# MSPGCC version prefix
49 202 olivier.gi
if [ -z "$MSPGCC_PFX" ]; then
50
    if command -v msp430-gcc >/dev/null; then
51
        MSPGCC_PFX=msp430
52
    else
53
        MSPGCC_PFX=msp430-elf
54
    fi
55
fi
56 2 olivier.gi
 
57
###############################################################################
58
#               Check if definition & assembler files exist                   #
59
###############################################################################
60
 
61
if [ ! -e $2 ]; then
62
    echo "Assembler file doesn't exist: $2"
63
    exit 1
64
fi
65
if [ ! -e $3 ]; then
66
    echo "Linker definition file template doesn't exist: $3"
67
    exit 1
68
fi
69 141 olivier.gi
if [ ! -e $4 ]; then
70
    echo "Assembler definition file template doesn't exist: $4"
71
    exit 1
72
fi
73 2 olivier.gi
 
74
 
75
###############################################################################
76
#               Generate the linker definition file                           #
77
###############################################################################
78
 
79 141 olivier.gi
PER_SIZE=$7
80
DMEM_SIZE=$6
81
PMEM_SIZE=$5
82 33 olivier.gi
PMEM_BASE=$((0x10000-$PMEM_SIZE))
83 111 olivier.gi
STACK_INIT=$((PER_SIZE+0x0080))
84 2 olivier.gi
 
85 134 olivier.gi
cp  $3  ./pmem.x
86 141 olivier.gi
cp  $4  ./pmem_defs.asm
87 200 olivier.gi
sed -i "s/PMEM_BASE/$PMEM_BASE/g"         pmem.x
88
sed -i "s/PMEM_SIZE/$PMEM_SIZE/g"         pmem.x
89
sed -i "s/DMEM_SIZE/$DMEM_SIZE/g"         pmem.x
90
sed -i "s/PER_SIZE/$PER_SIZE/g"           pmem.x
91
sed -i "s/STACK_INIT/$STACK_INIT/g"       pmem.x
92 2 olivier.gi
 
93 200 olivier.gi
sed -i "s/PMEM_SIZE/$PMEM_SIZE/g"         pmem_defs.asm
94
sed -i "s/PER_SIZE_HEX/$PER_SIZE/g"       pmem_defs.asm
95
if [ $MSPGCC_PFX == "msp430-elf" ]; then
96
    sed -i "s/PER_SIZE/.data/g"           pmem_defs.asm
97 202 olivier.gi
    sed -i "s/PMEM_BASE_VAL/.text/g"      pmem_defs.asm
98 200 olivier.gi
    sed -i "s/PMEM_EDE_SIZE/0/g"          pmem_defs.asm
99
else
100
    sed -i "s/PER_SIZE/$PER_SIZE/g"       pmem_defs.asm
101 202 olivier.gi
    sed -i "s/PMEM_BASE_VAL/$PMEM_BASE/g" pmem_defs.asm
102 200 olivier.gi
    sed -i "s/PMEM_EDE_SIZE/$PMEM_SIZE/g" pmem_defs.asm
103
fi
104 2 olivier.gi
 
105 141 olivier.gi
 
106 2 olivier.gi
###############################################################################
107
#                  Compile, link & generate IHEX file                         #
108
###############################################################################
109 200 olivier.gi
echo ""
110
echo "\$ $MSPGCC_PFX-as      -alsm $2 -o $1.o > $1.l43"
111
$MSPGCC_PFX-as      -alsm         $2     -o $1.o     > $1.l43
112
echo "\$ $MSPGCC_PFX-objdump -xdsStr $1.o >> $1.l43"
113
$MSPGCC_PFX-objdump -xdsStr       $1.o              >> $1.l43
114
echo "\$ $MSPGCC_PFX-ld      -T ./pmem.x $1.o -o $1.elf"
115
$MSPGCC_PFX-ld      -T ./pmem.x   $1.o   -o $1.elf
116
echo "\$ $MSPGCC_PFX-objcopy -O ihex $1.elf $1.ihex"
117
$MSPGCC_PFX-objcopy -O ihex       $1.elf    $1.ihex
118
echo ""

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.