summaryrefslogtreecommitdiff
path: root/extra/usb_serial/install
blob: eba1d2ac83df74a954eb6bbdae9efecc67909983 (plain)
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
#!/bin/sh -e
#
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Build and install raiden module and udev rules

bold=$(tput bold)
normal=$(tput sgr0)

error() {
    echo "${bold}Install failed${normal}"
}

trap "error $LINENO" ERR

fallback=false

if [ "$1" = "--fallback" ]; then
    fallback=true
    shift
fi

if [ $# -ne 0 ]; then
    echo ""
    echo "Usage: ${bold}$0${normal} [--fallback]"
    echo ""
    echo "Install Raiden kernel module and udev rules for working with Case"
    echo "Closed Debug enabled devices."
    echo ""
    echo "${bold}--fallback${normal}"
    echo "    Install udev rules to use usbserial directly without installing"
    echo "    the raiden module.  This can be used when the raiden module fails"
    echo "    to build, or can not be used for other reasons."
    echo ""
    echo "    The fallback solution will generate extra /dev/ttyUSB? entries"
    echo "    for the SPI and possibly other CCD bridges.  These should be"
    echo "    ignored by you.  Flashrom is smart enough to detach the kernel"
    echo "    driver from the SPI bridge, so they will not interfere with"
    echo "    flashing new firmware images over CCD."
    echo ""
    exit 1
fi

if [ "$fallback" = "false" ]; then
    #
    # The normal path builds and installs the raiden module
    #
    {
	#
	# Don't build the module as root so it's easier to clean up after
	#
	make modules &&

	#
	# Install the new module and update dependency and alias information
	#
	sudo make modules_install &&
	sudo depmod -a
    } || {
	echo $bold
	echo "Building and/or installing the raiden module failed, you may"
	echo "want to use the --fallback option."
	echo $normal
	exit 1;
    }
else
    #
    # The fallback path installs the fallback udev rule and its helper script.
    #
    sudo install -m644 51-google-serial-fallback.rules /etc/udev/rules.d
    sudo install add_usb_serial_id /lib/udev
fi

#
# Install the udev rule for creating /dev/google symlinks.
#
sudo install -m644  51-google-serial.rules /etc/udev/rules.d

#
# Trigger udev to create the symlinks for any attached devices that have the
# Google Vendor ID.  Limiting triggering like this prevents unwanted resetting
# of some device state, even with the change action specified.
#
for syspath in $(dirname $(grep -rxl --include=idVendor 18d1 /sys/devices)); do
    sudo udevadm trigger --action=change --parent-match=${syspath}
done