Skip to content
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

Add support for KCH boot progress leds #21

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions parts/files/leds/boot_40.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Boot Progress 40%
[Service]
Type=simple
ExecStart=/usr/bin/set-led 5 1

[Install]
WantedBy=basic.target
10 changes: 10 additions & 0 deletions parts/files/leds/boot_60.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Boot Progress 60%
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/set-led 12 1

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions parts/files/leds/boot_80.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Boot Progress 80%
BindsTo=runusb.service
After=runusb.service

[Service]
Type=forking
ExecStart=/usr/bin/set-led 6 1
ExecStop=/usr/bin/set-led 6 0
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
9 changes: 9 additions & 0 deletions parts/files/leds/set-led
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -ex

led_num="$1"
led_level="$2"

echo "$led_num" > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio${led_num}/direction
echo "$led_level" > /sys/class/gpio/gpio5/value
echo "$led_num" > /sys/class/gpio/unexport
10 changes: 9 additions & 1 deletion parts/robot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ systemctl enable runusb.service
group=plugdev

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

Expand All @@ -53,3 +53,11 @@ SUBSYSTEM=="tty", DRIVERS=="ftdi_sio", ATTRS{interface}=="MCV4B", GROUP="$group"
# SR servo board v4
SUBSYSTEM=="usb", ATTRS{idVendor}=="1bda", ATTRS{idProduct}=="0011", GROUP="$group", MODE="0666"
EOF

# Setup KCH leds triggered by systemd
cp /tmp/packer-files/leds/set-led /usr/bin/
chmod +x /usr/bin/set-led
cp /tmp/packer-files/leds/*.service /lib/systemd/system/
systemctl enable boot_40.service
systemctl enable boot_60.service
systemctl enable boot_80.service
Loading