Skip to content

Commit 31a26cb

Browse files
artynetfacchinm
authored andcommitted
adding arduino-linux-setup.sh script
1 parent 8363831 commit 31a26cb

File tree

3 files changed

+226
-0
lines changed

3 files changed

+226
-0
lines changed

build/build.xml

+1
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@
632632

633633
<copy todir="linux/work" file="linux/dist/arduino" />
634634
<copy todir="linux/work" file="linux/dist/install.sh" />
635+
<copy todir="linux/work" file="linux/dist/arduino-linux-setup.sh" />
635636
<copy todir="linux/work" file="linux/dist/uninstall.sh" />
636637

637638
<chmod perm="ugo+x">
+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
# arduino-linux-setup.sh : A simple Arduino setup script for Linux systems
2+
# Copyright (C) 2015 Arduino Srl
3+
#
4+
# Author : Arturo Rinaldi
5+
6+
# Project URL : https://github.com/artynet/arduino-linux-setup
7+
#
8+
# This program is free software: you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation, either version 3 of the License, or
11+
# (at your option) any later version.
12+
#
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License
19+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
#
21+
# Release v8 changelog :
22+
#
23+
# + rules are now created in /tmp folder
24+
#
25+
# Release v7 changelog :
26+
#
27+
# + Adding project URL
28+
# + minor bugfixing
29+
#
30+
# Release v6 changelog :
31+
#
32+
# + removing sudocheck function and control
33+
#
34+
# Release v5 changelog :
35+
#
36+
# + adding UDEV rule for stm32 DFU mode
37+
#
38+
# Release v4 changelog :
39+
#
40+
# + The rules are generated in a temporary folder
41+
#
42+
# + the user should run it without sudo while having its permissions
43+
#
44+
# Release v3 changelog :
45+
#
46+
# + The most common linux distros are now fully supported
47+
#
48+
# + now the script checks for SUDO permissions
49+
#
50+
51+
#! /bin/bash
52+
53+
# if [[ $EUID != 0 ]] ; then
54+
# echo This must be run as root!
55+
# exit 1
56+
# fi
57+
58+
refreshudev () {
59+
60+
echo ""
61+
echo "Restarting udev"
62+
echo ""
63+
64+
sudo service udev restart
65+
sudo udevadm control --reload-rules
66+
sudo udevadm trigger
67+
68+
}
69+
70+
groupsfunc () {
71+
72+
echo ""
73+
echo "******* Add User to dialout,tty, uucp, plugdev groups *******"
74+
echo ""
75+
76+
sudo usermod -a -G tty $1
77+
sudo usermod -a -G dialout $1
78+
sudo usermod -a -G uucp $1
79+
sudo groupadd plugdev
80+
sudo usermod -a -G plugdev $1
81+
82+
}
83+
84+
acmrules () {
85+
86+
echo ""
87+
echo "# Setting serial port rules"
88+
echo ""
89+
90+
cat <<EOF
91+
"KERNEL="ttyUSB[0-9]*", TAG+="udev-acl", TAG+="uaccess", OWNER="$1"
92+
"KERNEL="ttyACM[0-9]*", TAG+="udev-acl", TAG+="uaccess", OWNER="$1"
93+
EOF
94+
95+
}
96+
97+
openocdrules () {
98+
99+
echo ""
100+
echo "# Adding Arduino M0/M0 Pro, Primo UDEV Rules for CMSIS-DAP port"
101+
echo ""
102+
103+
cat <<EOF
104+
ACTION!="add|change", GOTO="openocd_rules_end"
105+
SUBSYSTEM!="usb|tty|hidraw", GOTO="openocd_rules_end"
106+
107+
#Please keep this list sorted by VID:PID
108+
109+
#CMSIS-DAP compatible adapters
110+
ATTRS{product}=="*CMSIS-DAP*", MODE="664", GROUP="plugdev"
111+
112+
LABEL="openocd_rules_end"
113+
EOF
114+
115+
}
116+
117+
avrisprules () {
118+
119+
echo ""
120+
echo "# Adding AVRisp UDEV rules"
121+
echo ""
122+
123+
cat <<EOF
124+
SUBSYSTEM!="usb_device", ACTION!="add", GOTO="avrisp_end"
125+
# Atmel Corp. JTAG ICE mkII
126+
ATTR{idVendor}=="03eb", ATTRS{idProduct}=="2103", MODE="660", GROUP="dialout"
127+
# Atmel Corp. AVRISP mkII
128+
ATTR{idVendor}=="03eb", ATTRS{idProduct}=="2104", MODE="660", GROUP="dialout"
129+
# Atmel Corp. Dragon
130+
ATTR{idVendor}=="03eb", ATTRS{idProduct}=="2107", MODE="660", GROUP="dialout"
131+
132+
LABEL="avrisp_end"
133+
EOF
134+
135+
}
136+
137+
dfustm32rules () {
138+
139+
echo ""
140+
echo "# Adding STM32 bootloader mode UDEV rules"
141+
echo ""
142+
143+
cat <<EOF
144+
# Example udev rules (usually placed in /etc/udev/rules.d)
145+
# Makes STM32 DfuSe device writeable for the "plugdev" group
146+
147+
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE="664", GROUP="plugdev", TAG+="uaccess"
148+
EOF
149+
150+
}
151+
152+
dfuarduino101rules (){
153+
154+
echo ""
155+
echo "# Arduino 101 in DFU Mode"
156+
echo ""
157+
158+
cat <<EOF
159+
SUBSYSTEM=="tty", ENV{ID_REVISION}=="8087", ENV{ID_MODEL_ID}=="0ab6", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_CANDIDATE}="0"
160+
SUBSYSTEM=="usb", ATTR{idVendor}=="8087", ATTR{idProduct}=="0aba", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"
161+
EOF
162+
163+
}
164+
165+
removemm () {
166+
167+
echo ""
168+
echo "******* Removing modem manager *******"
169+
echo ""
170+
171+
if [ -f /etc/lsb-release -a ! -f /etc/SuSE-release ] || [ -f /etc/debian_version ] || [ -f /etc/linuxmint/info ]
172+
then
173+
#Only for Ubuntu/Mint/Debian
174+
sudo apt-get -y remove modemmanager
175+
elif [ -f /etc/SuSE-release ]
176+
then
177+
#Only for Suse
178+
sudo zypper remove modemmanager
179+
elif [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ]
180+
then
181+
#Only for Red Hat/Fedora/CentOS
182+
sudo yum remove modemmanager
183+
else
184+
echo ""
185+
echo "Your system is not supported, please take care of it with your package manager"
186+
echo ""
187+
fi
188+
189+
}
190+
191+
192+
if [ "$1" = "" ]
193+
then
194+
echo ""
195+
echo "Run the script with command ./arduino-linux-setup.sh \$USER"
196+
echo ""
197+
else
198+
199+
[ `whoami` != $1 ] && echo "" && echo "The user name is not the right one, please double-check it !" && echo "" && exit 1
200+
201+
groupsfunc $1
202+
203+
removemm
204+
205+
acmrules $1 > /tmp/90-extraacl.rules
206+
207+
openocdrules > /tmp/98-openocd.rules
208+
209+
avrisprules > /tmp/avrisp.rules
210+
211+
dfustm32rules > /tmp/40-dfuse.rules
212+
213+
dfuarduino101rules > /tmp/99-arduino-101.rules
214+
215+
sudo mv /tmp/*.rules /etc/udev/rules.d/
216+
217+
refreshudev
218+
219+
echo ""
220+
echo "*********** Please Reboot your system ************"
221+
echo ""
222+
fi

build/linux/dist/install.sh

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ xdg_install_f() {
7070
rm "${TMP_DIR}/${RESOURCE_NAME}.desktop"
7171
rmdir "$TMP_DIR"
7272

73+
# Launching arduino-linux-setup.sh script
74+
#./arduino-linux-setup.sh $(whoami)
75+
7376
}
7477

7578
# Install by simply copying desktop file (fallback)

0 commit comments

Comments
 (0)