-
Notifications
You must be signed in to change notification settings - Fork 18
/
configure.sh
executable file
·105 lines (95 loc) · 2.05 KB
/
configure.sh
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
#SECU-3 - An open source, free engine control unit
#Copyright (C) 2007 Alexey A. Shabelnikov. Ukraine, Kiev
# Script for building of the SECU-3 project firmware under Linux. This script will
# configure Makefile for you and build project.
# Created by Alexey A. Shabelnikov, Kiev 24 July 2011.
# Updated 22 Jan 2018
# Note: It requires AVR-GCC toolchain
USAGE="USAGE: configure.sh <platform> <toolchain> \n Supported platforms: M644, M1284, Supported toolchains: IAR, GCC"
PLATFORM=Undefined
CFGFILE="platform_cfg"
MAKEFILE="Makefile_gcc"
CFG_MCU=Undefined
CFG_BL_START=Undefined
CFG_FWD_START=Undefined
CFG_EE_SIZE=Undefined
CFG_LNKXCL=Undefined
TC=Undefined
#check number of command line arguments
if [ $# -eq 1 ]
then
TC="GCC"
elif [ $# -eq 2 ]
then
TC=$2
else
echo "Invalid command line arguments."
echo " "$USAGE
exit 1 #error
fi
# Check validity of command line option
if [ $1 = "M644" ]
then
CFG_BL_START="F800"
CFG_FWD_START="B410"
CFG_EE_SIZE="2048"
CFG_LNKXCL="lnkm644s.xcl"
elif [ $1 = "M1284" ]
then
CFG_BL_START="1F800"
CFG_FWD_START="1B410"
CFG_EE_SIZE="4096"
CFG_LNKXCL="lnkm1284s.xcl"
else
echo "Invalid platform!"
echo " "$USAGE
exit 1 #error
fi
if [ $TC = "IAR" ]
then
if [ $1 = "M644" ]
then
CFG_MCU="m644"
elif [ $1 = "M1284" ]
then
CFG_MCU="m1284"
fi
MAKEFILE="Makefile_iar"
elif [ $TC = "GCC" ]
then
if [ $1 = "M644" ]
then
CFG_MCU="atmega644"
elif [ $1 = "M1284" ]
then
CFG_MCU="atmega1284"
fi
MAKEFILE="Makefile_gcc"
else
echo "Invalid toolchain!"
echo " "$USAGE
exit 1 #error
fi
# Generate configuration file
echo "MCU="$CFG_MCU > $CFGFILE
echo "BL_START="$CFG_BL_START >> $CFGFILE
echo "FWD_START="$CFG_FWD_START >> $CFGFILE
echo "EE_SIZE="$CFG_EE_SIZE >> $CFGFILE
echo "LNKXCL="$CFG_LNKXCL >> $CFGFILE
#check presence of soure Makefile
if [ ! -e "$MAKEFILE" ]
then
echo "ERROR: Can not find file "$MAKEFILE
exit 1 #error
fi
make clean
cp $MAKEFILE Makefile
#start build and check for errors
make -f $MAKEFILE
if [ $? -ne 0 ]
then
exit 1 #error
fi
#OK. All operations were completed successfully
exit 0