Skip to content

Commit

Permalink
Merge pull request #811 from kernelkit/bootstrap-refactor
Browse files Browse the repository at this point in the history
Early bootstrap refactor

Signed-off-by: Joachim Wiberg <[email protected]>
  • Loading branch information
troglobit authored Nov 8, 2024
2 parents 57b66ec + 6bdfdbe commit 2910d8b
Show file tree
Hide file tree
Showing 47 changed files with 407 additions and 108 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ jobs:
runs-on: [ self-hosted, release ]
permissions:
contents: write
discussions: write
steps:
- uses: actions/checkout@v4
with:
Expand Down
32 changes: 28 additions & 4 deletions board/aarch64/dts/styx/dcp-sc-28p.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,38 @@
};
};

#define SWP_LED(_func) \
#define SWP_LED \
leds { \
#address-cells = <1>; \
#size-cells = <0>; \
\
led@0 { \
reg = <0>; \
function = _func; \
function = "tp"; \
color = <LED_COLOR_ID_GREEN>; \
default-state = "keep"; \
}; \
led@1 { \
reg = <1>; \
function = "aux"; \
color = <LED_COLOR_ID_GREEN>; \
default-state = "off"; \
}; \
}

/* SFP LEDs
* Rev A. LEDs do not work at all
* Rev B. only outer-most (green) LEDs work
*/

#define SFP_LED \
leds { \
#address-cells = <1>; \
#size-cells = <0>; \
\
led@0 { \
reg = <0>; \
function = "sfp"; \
color = <LED_COLOR_ID_GREEN>; \
default-state = "keep"; \
}; \
Expand All @@ -287,7 +311,7 @@
phy-mode = "10gbase-r"; \
managed = "in-band-status"; \
sfp = <_sfp>; \
SWP_LED("sfp"); \
SFP_LED; \
}

#define XSWCPU(_n, _eth) \
Expand Down Expand Up @@ -321,7 +345,7 @@
nvmem-cell-names = "mac-address"; \
phy-mode = "gmii"; \
phy-handle = <_phy>; \
SWP_LED("tp"); \
SWP_LED; \
}

#define GPHY(_n) \
Expand Down
111 changes: 111 additions & 0 deletions board/aarch64/rootfs/usr/libexec/styx/led.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/sh
# Raw switch LED Control for systems that do not run iitod


LEDS=$(find /sys/class/leds -iname '*mdio-mii*')
LINK=$(find /sys/class/leds -iname '*mdio-mii*p')

# Disable ALL switch port LEDs
clear()
{
for led in $LEDS; do
echo 0 > "${led}/brightness"
done
}

setup()
{
for led in $LINK; do
echo netdev > "${led}/trigger"
done

for led in $LINK; do
cd "$led"
# No sleep here, it's enough with the delay from previous loop
echo 1 > link
sleep 0.1
echo 1 > rx
sleep 0.1
echo 1 > tx
cd - >/dev/null
done
}

leds()
{
for led in $LINK; do
printf "%3s: %s\n" "$(cat "$led/device_name" 2>/dev/null)" "$led"
done
}

list()
{
leds | sort | while read -r port path; do
printf "%4s %s\n" "$port" "$(basename "$path")"

aux=${path%%:tp}:aux
if [ -e "$aux" ]; then
printf "%3s: %s\n" "" "$(basename "$aux")"
fi
done
}

flash()
{
sec=$1

for led in $LEDS; do
echo timer > "${led}/trigger"
done

for led in $LEDS; do
echo 84 > "${led}/delay_on"
echo 84 > "${led}/delay_off"
done

sleep "$sec"
clear
}

usage()
{
echo "usage: $0 [command]"
echo
echo "flash [SEC] Flash all LEDs to locate device in rack, default: 5 sec"
echo "list List all LEDs"
echo "setup Set up and start normal operation"
echo "start Call at system init, clears all LEDs and sets up normal op"
echo "stop Clear all LEDs, may be called at system shutdown"
echo
echo "Please ensure no other tool or daemon is already managing the LEDs."
}

cmd=$1; shift
case $cmd in
flash)
flash ${1:-5}
setup
;;
help)
usage
exit 0
;;
list | ls)
list
;;
setup)
setup
;;
start)
initctl -nbq cond clear led
clear
setup
;;
stop)
clear
;;
*)
usage
exit 1
;;
esac
1 change: 1 addition & 0 deletions board/common/rootfs/etc/default/rauc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RAUC_ARGS="-s"
1 change: 1 addition & 0 deletions board/common/rootfs/etc/machine-id
Loading

0 comments on commit 2910d8b

Please sign in to comment.