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

Subversion Repositories usb_fpga_2_14

[/] [usb_fpga_2_14/] [trunk/] [bin/] [bmpsdcc.sh] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
#!/bin/bash
2
 
3
if [ "$1" = ""  ]; then
4
    echo "Usage: $0 <C file> <bmp flags> <sdcc flags>"
5
    exit 1
6
fi
7
 
8
SDCC=$(which sdcc)
9
if [ -z "$SDCC" ]; then
10
    echo "E: bmpsdcc: sdcc is not in PATH."
11
    echo "I: sdcc is not related with ztex and ships with many Linux distributions or "
12
    echo "   is available at http://sdcc.sourceforge.net/ ."
13
    exit 1
14
fi
15
 
16
exe=""
17
if [ "$WINDIR" != "" ]; then
18
    exe=".exe"
19
fi
20
 
21
BINDIR=`dirname $0`
22
BMP=bmp
23
if [ -x "$BINDIR/bmp$exe" ]; then
24
    BMP="$BINDIR/bmp$exe"
25
fi
26
 
27
if [ -f "$BINDIR/peeph.def" ]; then
28
    PEEPH="--peep-file $BINDIR/peeph.def"
29
elif [ -f "/usr/local/share/ztex/peeph.def" ]; then
30
    PEEPH="$PEEPH --peep-file /usr/local/share/ztex/peeph.def"
31
elif [ -f "/usr/share/ztex/peeph.def" ]; then
32
    PEEPH="$PEEPH --peep-file /usr/share/ztex/peeph.def"
33
fi
34
 
35
inp="$1"
36
if [ ! -f "$inp" -a -f "$inp.c" ]; then
37
    inp="$1.c"
38
fi
39
base=${inp%*.c}
40
 
41
if [ ! -f "$inp" ]; then
42
    echo "File not found: $inp"
43
    exit 2
44
fi
45
 
46
bytePad=""
47
while true; do
48
    if [ "$LINEINFO" = "no" ]; then
49
        li='//line %2 "%1"'
50
    else
51
        li='#line %2 "%1"'
52
    fi
53
    $BMP -c -l "$li" $2 $bytePad $inp -o $base.tmp.c
54
    ec="$?"
55
    if [ "$ec" != 0 ]; then
56
        exit $ec
57
    fi
58
 
59
    "$SDCC" -mmcs51 --code-loc 0x0200 --code-size 0x3800 --xram-loc 0x3A00 --xram-size 0x600 --iram-size 256 $PEEPH $3 $base.tmp.c -o $base.ihx
60
    ec="$?"
61
    if [ "$ec" != 0 ]; then
62
        exit $ec
63
    fi
64
 
65
    addr=`grep ".*:.* _DeviceDescriptor" $base.map | (
66
        read a b c d
67
        if [ "$c" = "_DeviceDescriptor" ]; then
68
            echo 0x${b#*:}
69
        else
70
            echo 0x${a#*:}
71
        fi
72
    )`
73
    echo "Addr=$addr"
74
    if [ $((addr & 1)) = "0" ]; then
75
        exit 0
76
    else
77
        if [ "$bytePad" != "" ]; then
78
            echo "USB Descriptors not word aligned, -DPAD_BYTE has no effect"
79
            exit 3
80
        else
81
            bytePad="-D PAD_BYTE"
82
        fi
83
    fi
84
done

powered by: WebSVN 2.1.0

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