forked from abhishek-kakkar/BeagleLogic
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·151 lines (129 loc) · 4.41 KB
/
install.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
#!/bin/bash
# Install script for BeagleLogic from git repository
#
# This script is meant to be executed in either a chroot environment (used while
# building the BeagleLogic system image) or after doing a git clone of the
# BeagleLogic repository.
#
# This script only supports the BeagleBone Debian image which have all the
# required dependencies
DIR=$(cd `dirname $0` && pwd -P)
log="beaglelogic:"
# The kernel looks for beaglelogic-pru0-fw and beaglelogic-pru1-fw in /lib/firmware
# The firmware is installed as 'beaglelogic-pru0-fw' and 'beaglelogic-pru1-logic'
# beaglelogic-pru1-fw is further symlinked to beaglelogic-pru1-logic
# This arrangement enables running PRUDAQ by simply updating the symlink and
# reloading the beaglelogic kernel module
install_pru_firmware () {
# Required for compiling the firmware, see firmware/Makefile
if [ ! -d /usr/share/ti/cgt-pru/bin ] ; then
ln -s /usr/bin/ /usr/share/ti/cgt-pru/bin
fi
echo "${log} Building and installing PRU firmware"
export PRU_CGT=/usr/share/ti/cgt-pru
cd "${DIR}/firmware"
make
make install
cd "${DIR}/firmware/custom/prudaq"
make
make install
if [ ! "x${RUNNING_AS_CHROOT}" = "xyes" ] ; then
update-initramfs -u -k `uname -r`
fi
}
create_beaglelogic_group() {
echo "${log} Creating beaglelogic group and adding $DEFAULT_USER to it"
groupadd -f beaglelogic
usermod -aG beaglelogic ${DEFAULT_USER}
}
# Udev rules required to allow the default user to modify BeagleLogic
# sysfs attributes without requiring root permissions
install_udev_rules() {
echo "${log} Installing udev rules"
cp -v "${DIR}/scripts/90-beaglelogic.rules" "/etc/udev/rules.d/"
}
install_systemd_service() {
echo "${log} Installing systemd startup service"
cp -v "${DIR}/scripts/beaglelogic" "/etc/default/beaglelogic"
cp -v "${DIR}/scripts/beaglelogic-tcp" "/etc/default/beaglelogic-tcp"
cp -v "${DIR}/scripts/beaglelogic.service" "/lib/systemd/system/beaglelogic.service"
cp -v "${DIR}/scripts/beaglelogic-startup.service" "/lib/systemd/system/beaglelogic-startup.service"
cp -v "${DIR}/scripts/beaglelogic-tcp.service" "/lib/systemd/system/beaglelogic-tcp.service"
chown root:root "/lib/systemd/system/beaglelogic.service"
chown root:root "/lib/systemd/system/beaglelogic-startup.service"
chown root:root "/lib/systemd/system/beaglelogic-tcp.service"
sed -i -e "s:DIR:${DIR}:" "/lib/systemd/system/beaglelogic.service"
sed -i -e "s:DIR:${DIR}:" "/lib/systemd/system/beaglelogic-startup.service"
sed -i -e "s:DIR:${DIR}:" "/lib/systemd/system/beaglelogic-tcp.service"
systemctl enable beaglelogic.service || true
systemctl enable beaglelogic-startup.service || true
systemctl enable beaglelogic-tcp.service || true
}
install_sigrok() {
echo "${log} Installing sigrok and its dependencies"
# Installing just sigrok-cli pulls all dependencies
apt install -y sigrok-cli
}
install_node_modules() {
echo "${log} Installing npm components for beaglelogic-server"
cd ${DIR}/server
if [ ! -d node_modules ] ; then
/bin/su ${DEFAULT_USER} -c "npm install"
fi
}
install_go_and_compile_server() {
echo "${log} Installing Go"
apt install -y golang
echo "${log} Compiling TCP Server"
cd ${DIR}/tcp-server-go
/bin/su ${DEFAULT_USER} -c "go build server.go"
}
update_uboot_uenv_txt() {
if [ ! "x${RUNNING_AS_CHROOT}" = "xyes" ] ; then
echo "${log} Updating uEnv.txt"
sed -i -e "s:#disable_uboot_overlay_video:disable_uboot_overlay_video:" "/boot/uEnv.txt"
sed -i -e "s:uboot_overlay_pru:#uboot_overlay_pru:" "/boot/uEnv.txt"
echo '#Load BeagleLogic Cape' >> "/boot/uEnv.txt"
echo 'dtb_overlay=/lib/firmware/beaglelogic-00A0.dtbo' >> "/boot/uEnv.txt"
fi
}
display_success_message() {
if [ ! "x${RUNNING_AS_CHROOT}" = "xyes" ] ; then
echo "${log} Successfully Installed. Please reboot"
else
echo "${log} Installation Completed, uEnv.txt must be updated"
fi
}
if [ "x$1" = "x--upgrade" ] ; then
UPGRADING="yes"
else
UPGRADING="no"
fi
if [ "x$1" = "x--update-uenv-txt" ] ; then
update_uboot_uenv_txt
exit 0
fi
if [ "x$1" = "x--chroot" ] ; then
DEFAULT_USER=$2
RUNNING_AS_CHROOT="yes"
else
RUNNING_AS_CHROOT="no"
if [ ! "x$SUDO_USER" = "x" ] ; then
DEFAULT_USER=$SUDO_USER
else
DEFAULT_USER="debian"
fi
fi
install_pru_firmware
if [ "x${UPGRADING}" = "xno" ] ; then
create_beaglelogic_group
fi
install_udev_rules
install_systemd_service
install_node_modules
install_go_and_compile_server
install_sigrok
if [ "x${UPGRADING}" = "xno" ] ; then
update_uboot_uenv_txt
fi
display_success_message