Skip to content

Update arduino-linux-setup.sh #11832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 132 additions & 5 deletions build/linux/dist/arduino-linux-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Release v14 changelog :
#
# + Installing uucp package for different Linux distros
# + Rewriting UDEV rule for STM32 bootloader mode
#
# Release v13 changelog :
#
# + Disabling serial port HW flow
#
# Release v12 changelog :
#
# + Improving rules for DFU mode
#
# Release v11 changelog :
#
# + Fixing ModemManager removal for Fedora Core
# + Adding Atmel ICE Debugger CMSIS-DAP rule
#
# Release v10 changelog :
#
# + Adding support for Slackware
Expand Down Expand Up @@ -91,8 +109,11 @@ groupsfunc () {
echo "******* Add User to dialout,tty, uucp, plugdev groups *******"
echo ""

sudo groupadd plugdev
sudo groupadd tty
sudo groupadd dialout
sudo groupadd uucp
sudo groupadd plugdev

sudo usermod -a -G tty $1
sudo usermod -a -G dialout $1
sudo usermod -a -G uucp $1
Expand All @@ -116,7 +137,7 @@ EOF
openocdrules () {

echo ""
echo "# Adding Arduino M0/M0 Pro, Primo UDEV Rules for CMSIS-DAP port"
echo "# Adding Arduino M0/M0 Pro, Primo, Atmel ICE Debugger UDEV Rules for CMSIS-DAP port"
echo ""

cat <<EOF
Expand All @@ -125,6 +146,9 @@ SUBSYSTEM!="usb|tty|hidraw", GOTO="openocd_rules_end"

#Please keep this list sorted by VID:PID

#Atmel ICE Debugger
ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2141", MODE="664", GROUP="plugdev", TAG+="uaccess"

#CMSIS-DAP compatible adapters
ATTRS{product}=="*CMSIS-DAP*", MODE="664", GROUP="plugdev"

Expand Down Expand Up @@ -163,7 +187,14 @@ cat <<EOF
# Example udev rules (usually placed in /etc/udev/rules.d)
# Makes STM32 DfuSe device writeable for the "plugdev" group

# STM32
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE="664", GROUP="plugdev", TAG+="uaccess"

# GD32VF103
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="28e9", ATTRS{idProduct}=="0189", MODE="664", GROUP="plugdev", TAG+="uaccess"

# On older systems, a user group like "plugdev" can be given access:
# ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE="664", GROUP="plugdev"
EOF

}
Expand All @@ -181,6 +212,60 @@ EOF

}

usbgenericrules (){

echo ""
echo "# Arduino Generic USB rules"
echo ""

cat <<EOF
SUBSYSTEM=="usb", MODE="0660", GROUP="$(id -gn)"
EOF

}

hardwareflowdisable (){

echo ""
echo "# Disabling Hardware Control Flow on Serial"
echo "#"
echo "# https://access.redhat.com/solutions/209663"
echo ""

cat <<EOF
#
# port This file defines the possible dialout ports you have
# on your system. Normally you have only one, and it's
# most probably /dev/ttyS[0-3]. Define that port here.
#
# If you have multiple dialout ports, you can ofcourse
# define them all if you want.
#
port ACU
type modem
#
# NOTE: Make SURE this device is owned by root:dialout, mode 0660 (crw-rw---)
#
device /dev/ttyS3
dialer hayes
speed 57600

#
# Description for the TCP port - pretty trivial. DON'T DELETE.
#
port TCP
type tcp

# Everything after a '#' character is a comment.
port ttyACM0 # Port name
type direct # Direct connection to other system
device /dev/ttyACM0 # Port device node
hardflow false # No hardware flow control
speed 115200 # Line speed
EOF

}

removemm () {

echo ""
Expand All @@ -190,11 +275,12 @@ removemm () {
if [ -f /etc/SuSE-release ]
then
#Only for Suse
sudo zypper remove modemmanager
sudo zypper remove -y modemmanager
elif [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ]
then
#Only for Red Hat/Fedora/CentOS
sudo yum remove modemmanager
sudo rpm -e --nodeps ModemManager
sudo rpm -e --nodeps ModemManager-glib
elif [ -f /etc/arch-release ]
then
#Only for ArchLinux
Expand All @@ -206,7 +292,7 @@ removemm () {
elif [ -f /etc/lsb-release ] || [ -f /etc/debian_version ] || [ -f /etc/linuxmint/info ]
then
#Only for Ubuntu/Mint/Debian
sudo apt-get -y remove modemmanager
sudo apt-get -y purge modemmanager
else
echo ""
echo "Your system is not supported, please remove the ModemManager package with your package manager!"
Expand All @@ -215,6 +301,39 @@ removemm () {

}

adduucp () {

echo ""
echo "******* UUCP *******"
echo ""

if [ -f /etc/SuSE-release ]
then
#Only for Suse
sudo zypper update -y && sudo zypper in -y -n uucp
elif [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ]
then
#Only for Red Hat/Fedora/CentOS
sudo yum update -y && sudo yum install -y uucp
elif [ -f /etc/arch-release ]
then
#Only for ArchLinux
yes | sudo pacman -Sy uucp
elif [ -f /etc/slackware-version ]
then
#Only for Slackware
sudo slackpkg update && yes | sudo slackpkg install uucp
elif [ -f /etc/lsb-release ] || [ -f /etc/debian_version ] || [ -f /etc/linuxmint/info ]
then
#Only for Ubuntu/Mint/Debian
sudo apt-get update && sudo apt install -y uucp
else
echo ""
echo "Your system is not supported, please remove the ModemManager package with your package manager!"
echo ""
fi

}

if [ "$1" = "" ]
then
Expand All @@ -227,6 +346,8 @@ else

groupsfunc $1

adduucp

removemm

acmrules $1 > /tmp/90-extraacl.rules
Expand All @@ -239,8 +360,14 @@ else

dfuarduino101rules > /tmp/99-arduino-101.rules

usbgenericrules > /tmp/00-usb-permissions.rules

hardwareflowdisable > /tmp/uucp-port

sudo mv /tmp/*.rules /etc/udev/rules.d/

sudo mv /tmp/uucp-port /etc/uucp/port

refreshudev

echo ""
Expand Down