-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathb
executable file
·83 lines (63 loc) · 1.75 KB
/
b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# set -x
error () {
echo "ERROR:"
tail -n 5 build.log
exit 1
}
# make c compiler
echo "Making compiler .."
cd compiler || exit 1
make all >> ../build.log || error
cd .. || exit 1
if test -z "${1}" ; then
echo No file specified, exiting
exit 0
fi
#compile
echo "Running compiler, '${1}' .."
cp "./compiler/header.s" "am/program.s" || exit 1
cc -E "${1}" | grep -v '^#' | ./compiler/cc >> "am/program.s" 2>> build.log || error
cat "./compiler/footer.s" >> "am/program.s" || exit 1
# make assembler and assemble
echo "Making AM .."
cd am || exit 1
cc -O0 -o asm am.c >> ../build.log || error
echo "Running AM .."
./asm > bytecode.h 2>> ../build.log || error
cd .. || exit 1
LIMIT=32768
TOTAL=`wc -l < am/bytecode.h`
echo -n "Binary size: "
echo -n "${TOTAL} "
echo "bytes"
echo '*************************'
if (( $TOTAL > $LIMIT )) ; then
echo
echo "ERROR: Program exceeds program space limit (${LIMIT} bytes)!"
exit 1
fi
SCATTER=7680 # 7.5k
#burn
echo Press ENTER to burn
read EMPTYLINE
for (( i = 0; i < (($TOTAL / $SCATTER) + 1) ; i++ )) ; do
cat am/bytecode.h | tail -n $(( $TOTAL - ($i * $SCATTER) )) | head -n $(( $SCATTER )) > am/bytecode_part.h
if (( $(( `wc -l < am/bytecode_part.h` )) != 0 )) ; then
echo
echo "-- part $(($i + 1)) --"
# make burner
cd burner || exit 1
make clean || exit 1
make all || exit 1
cd .. || exit 1
#burn
avrdude -p m8 -c avrispmkII -P usb -B 4 -U flash:w:burner/burner.hex:i || exit 1
echo
echo "-- done with part $(($i + 1)) --"
if (( $(( `wc -l < am/bytecode_part.h` )) == $SCATTER )) ; then
echo " more parts coming... "
sleep 2
fi
fi
done