-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_maker_cm4.sh
53 lines (43 loc) · 1.25 KB
/
setup_maker_cm4.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
#!/bin/bash
# Make sure the script is run as root.
if [ $(id -u) -ne 0 ]; then
echo
echo
echo "Please run as root."
exit 1
fi
# Configure the config.txt file.
config_file="/boot/config.txt"
# Disable USB OTG.
grep "#otg_mode=1" $config_file >/dev/null
if [ $? -ne 0 ]; then
sed -i "s/^otg_mode=1/#otg_mode=1/g" $config_file
fi
# Enable USB host.
grep "dtoverlay=dwc2,dr_mode=host" $config_file >/dev/null
if [ $? -ne 0 ]; then
echo "dtoverlay=dwc2,dr_mode=host" >> $config_file
fi
# Enable I2C for RTC.
grep "dtparam=i2c_vc=on" $config_file >/dev/null
if [ $? -ne 0 ]; then
echo "dtparam=i2c_vc=on" >> $config_file
echo "dtoverlay=i2c-rtc,pcf85063a,i2c_csi_dsi" >> $config_file
fi
# Remap audio.
grep "dtoverlay=audremap,pins_18_19" $config_file >/dev/null
if [ $? -ne 0 ]; then
echo "dtoverlay=audremap,pins_18_19" >> $config_file
fi
# Enable shutdown on GPIO4 falling edge
grep "dtoverlay=gpio-shutdown,gpio_pin=4" $config_file >/dev/null
if [ $? -ne 0 ]; then
echo "dtoverlay=gpio-shutdown,gpio_pin=4" >> $config_file
fi
echo
echo
echo "######################################"
echo "Cytron CM4 Maker Board Setup Completed"
echo "######################################"
echo
echo "Please reboot for the changes to take effect."