Skip to content

Commit 2092ccc

Browse files
authored
Merge pull request #21 from sourcebots/kch-support
Add support for KCH boot progress leds
2 parents a788994 + 3059350 commit 2092ccc

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

parts/files/leds/boot_40.service

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Unit]
2+
Description=Boot Progress 40%
3+
[Service]
4+
Type=simple
5+
ExecStart=/usr/bin/set-led 5 1
6+
7+
[Install]
8+
WantedBy=basic.target

parts/files/leds/boot_60.service

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Unit]
2+
Description=Boot Progress 60%
3+
After=network.target
4+
5+
[Service]
6+
Type=simple
7+
ExecStart=/usr/bin/set-led 12 1
8+
9+
[Install]
10+
WantedBy=multi-user.target

parts/files/leds/boot_80.service

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=Boot Progress 80%
3+
BindsTo=runusb.service
4+
After=runusb.service
5+
6+
[Service]
7+
Type=forking
8+
ExecStart=/usr/bin/set-led 6 1
9+
ExecStop=/usr/bin/set-led 6 0
10+
RemainAfterExit=yes
11+
12+
[Install]
13+
WantedBy=multi-user.target

parts/files/leds/set-led

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash -ex
2+
3+
led_num="$1"
4+
led_level="$2"
5+
6+
echo "$led_num" > /sys/class/gpio/export
7+
echo out > /sys/class/gpio/gpio${led_num}/direction
8+
echo "$led_level" > /sys/class/gpio/gpio5/value
9+
echo "$led_num" > /sys/class/gpio/unexport

parts/robot.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ systemctl enable runusb.service
3434
group=plugdev
3535

3636
# Remove a buggy udev package that breaks the USB tree if FTDI chips are plugged into too many USB hubs
37-
# See https://github.com/raspberrypi/linux/issues/3779#issuecomment-709481662
37+
# See https://github.com/raspberrypi/linux/issues/3779#issuecomment-709481662
3838
# and https://groups.google.com/g/linux.debian.bugs.dist/c/5jI9dDZgfUU
3939
apt-get remove -y rpi.gpio-common
4040

@@ -53,3 +53,11 @@ SUBSYSTEM=="tty", DRIVERS=="ftdi_sio", ATTRS{interface}=="MCV4B", GROUP="$group"
5353
# SR servo board v4
5454
SUBSYSTEM=="usb", ATTRS{idVendor}=="1bda", ATTRS{idProduct}=="0011", GROUP="$group", MODE="0666"
5555
EOF
56+
57+
# Setup KCH leds triggered by systemd
58+
cp /tmp/packer-files/leds/set-led /usr/bin/
59+
chmod +x /usr/bin/set-led
60+
cp /tmp/packer-files/leds/*.service /lib/systemd/system/
61+
systemctl enable boot_40.service
62+
systemctl enable boot_60.service
63+
systemctl enable boot_80.service

0 commit comments

Comments
 (0)