-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathautoinstall_driver.sh
175 lines (132 loc) · 3.56 KB
/
autoinstall_driver.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
###############################################################################################################
#Description: This codes was designed for help the user Automatic install the OV9281 driver
# on all Raspbian system. There are two parts in this script.
# Part 1 is add the to modify the '/boot/config.txt'and '/boot/cmdline.txt',
# Part 2 is automatic the right driver version path and install.
# This script was done in a hurry , if you find some bug, kindly let me know. thanks in advance.
#
#USAGE: run './autoinstall_driver.sh' on the terminal of Raspbian
#
#Author: calvin ([email protected])
#
#data: 2022.05.26
#
###############################################################################################################
#Part 1
echo "------INNO-MAKER cammipi_ov9281 driver install script v1.0------"
echo "Enable i2c_vc in /boot/config.txt ..."
awk 'BEGIN{ count=0; }
{
if ( $1 == "dtparam=i2c_vc=on" )
count++;
}
END{
print "count = "count;
if ( count <= 0 ) {
print "--- Add i2c_vc=on to /boot/config.txt";
system("sudo sh -c \"sed -i.bak \"/^#dtparam=i2c_vc=on/d\" /boot/config.txt\" ");
system("sudo sh -c \"echo \"dtparam=i2c_vc=on\" >> /boot/config.txt\" ");
}
}' /boot/config.txt
awk 'BEGIN{ count2=0; }
{
if ( $1 == "dtoverlay=vc_mipi_ov9281" )
count2++;
}
END{
print "count2 = "count2;
if ( count <= 0 ) {
print "--- Add dtoverlay=vc_mipi_ov9281 to /boot/config.txt";
system("sudo sh -c \"sed -i.bak \"/^#dtoverlay=vc_mipi_ov9281/d\" /boot/config.txt\" ");
system("sudo sh -c \"echo \"dtoverlay=vc_mipi_ov9281\" >> /boot/config.txt\" ");
}
}' /boot/config.txt
str=$(sudo cat /boot/cmdline.txt)
echo "$str"
if [[ "$str" =~ .*cma=.*M ]]; then
echo "--- alread have cma=128M string"
else
echo "--- Add cma=128M to /boot/cmdline.txt"
sudo sed 's/[ \t]*$//g' /boot/cmdline.txt -i.bak
sudo sed '/console=/s/$/ cma=128M/' /boot/cmdline.txt -i.bak
fi
#Part 2
strVersion=$(awk -F " " '{print $3}' /proc/version)
strModel=$(cat /proc/device-tree/model)
strArch=$(arch)
echo $strVersion
echo $strModel
echo $strArch
version=0
model=0
arch=0
driverpath=0
case $strVersion in
*5.15.32*)
version=Linux_5.15.32
;;
*5.10.92*)
version=Linux_5.10.92
;;
*5.10.63*)
version=Linux_5.10.63
;;
*)
echo "@ Linux Version Not Match! Please contact [email protected]"
;;
esac
case $strModel in
*Pi' '4*)
model=pi4
;;
*Pi' '3*)
model=pi3
;;
*Pi' 'Compute' 'Module' '4*)
model=cm4-dual
;;
*Pi' '0*)
echo "@ This driver do not suppor pi0, Please contact [email protected]"
;;
*)
echo "@ HW Version Not Match! Please contact [email protected]"
;;
esac
case $strArch in
*armv7l*)
arch=armv7l
echo "System is 32 bit arch."
driverpath=./$version/$model
;;
*aarch64*)
arch=arm64
echo "System is 64 bit arch."
driverpath=./$version/$arch/pi3_4
;;
*)
echo "@ Unkown System Arch! Please contact [email protected]"
;;
esac
echo "driverpath: "$driverpath
if [[ $version == 0 || $model == 0 || $arch == 0 ]]; then
echo "@ Install Failed, Please contact [email protected]"
exit
fi
sudo chmod -R 777 ./tools/*
cd $driverpath
echo "PWD: "$(pwd)
sudo chmod -R 777 ./*
echo "-----make install----START:"
sudo make install
echo "-----make install----END."
echo "INNO-MAKER: reboot now?(y/n):"
read KB_INPUT
case $KB_INPUT in
'y'|'Y')
echo "reboot..."
sudo reboot
;;
*)
echo "cancel."
;;
esac