-
Notifications
You must be signed in to change notification settings - Fork 3
/
init-rpi.sh
executable file
·48 lines (48 loc) · 1.71 KB
/
init-rpi.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
#!/bin/sh
#
# This is the initialization script for a Raspberry Pi. This is based on the
# BeagleBone Black initialization script. I/O for the Raspberry Pi is much
# simpler than for the BeagleBone Black so much of the BeagleBone Black initialization
# is not applicable.
#
# Run this shell script as root to set protections on some of the device control files
# so that non-root users can access them. It seems that the protection on these gets
# set back to 644 every time the Raspberry Pi boots.
#
# The GPIO pins are not exported by default on the Raspberry Pi. The following
# commands export them. Note that these exports will cause errors if the
# sysfs interface to GPIOs has been removed. In that case, these aren't needed
# and you should use the new ioctl() based GPIO routines.
#
echo "Activating GPIO Pins"
echo 4 > /sys/class/gpio/export
echo 5 > /sys/class/gpio/export
echo 6 > /sys/class/gpio/export
echo 12 > /sys/class/gpio/export
echo 13 > /sys/class/gpio/export
echo 16 > /sys/class/gpio/export
echo 17 > /sys/class/gpio/export
echo 18 > /sys/class/gpio/export
echo 19 > /sys/class/gpio/export
echo 20 > /sys/class/gpio/export
echo 21 > /sys/class/gpio/export
echo 22 > /sys/class/gpio/export
echo 23 > /sys/class/gpio/export
echo 24 > /sys/class/gpio/export
echo 25 > /sys/class/gpio/export
echo 26 > /sys/class/gpio/export
echo 27 > /sys/class/gpio/export
#
# Set direction to "in" or "out" for input or output.
# Set value to "0" or "1" for output or read "0" or "1" for input.
#
echo "GPIO control files"
chmod 666 /sys/class/gpio/*/active_low
chmod 666 /sys/class/gpio/*/direction
chmod 666 /sys/class/gpio/*/value
#
# the I2C device file needs to be set to be accessible.
#
echo "I2C device file"
chmod 666 /dev/i2c-1
#