-
-
Save SFrijters/206d2c09656affb04284f076c75a1969 to your computer and use it in GitHub Desktop.
Device tree overlays to disable LEDs on a Raspberry Pi 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hardware.deviceTree = { | |
enable = true; | |
# Use source-based overlays so they are compatible with the kernel and hardware | |
# Based on: | |
# * "Device trees" documentation in https://www.raspberrypi.com/documentation/computers/configuration.html#part1, | |
# * arch/arm/boot/dts/bcm2711-rpi-4-b.dts in https://github.com/raspberrypi/linux | |
# * Example files in arch/arm/boot/dts/overlays | |
# | |
# For debugging: | |
# $ nix-shell -p dtc | |
# $ nix build /persist/etc/nixos#nixosConfigurations.phellack.config.hardware.deviceTree.package -L | |
# $ fdtget -t s ./result/broadcom/bcm2711-rpi-4-b.dtb / compatible | |
# $ dtc -I dtb -O dts ./result/broadcom/bcm2711-rpi-4-b.dtb | less | |
overlays = [ | |
# Based on disable-wifi-overlay.dts | |
{ | |
name = "disable-wifi"; | |
filter = "*rpi-4-b*"; | |
dtsText = '' | |
/dts-v1/; | |
/plugin/; | |
/{ | |
compatible = "raspberrypi,4-model-b"; | |
fragment@0 { | |
target = <&mmc>; | |
__overlay__ { | |
status = "disabled"; | |
}; | |
}; | |
fragment@1 { | |
target = <&mmcnr>; | |
__overlay__ { | |
status = "disabled"; | |
}; | |
}; | |
}; | |
''; | |
} | |
# Based on disable-bt-overlay.dts | |
{ | |
name = "disable-bt"; | |
filter = "*rpi-4-b*"; | |
dtsText = '' | |
/dts-v1/; | |
/plugin/; | |
/{ | |
compatible = "raspberrypi,4-model-b"; | |
fragment@0 { | |
target = <&bt>; | |
__overlay__ { | |
status = "disabled"; | |
}; | |
}; | |
}; | |
''; | |
} | |
# https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README | |
# eth_led0 Set mode of LED0 - amber on Pi3B+ (default "1"), | |
# green on Pi4 (default "0"). | |
# The legal values are: | |
# | |
# Pi4 | |
# | |
# 0=Speed/Activity 1=Speed | |
# 2=Flash activity 3=FDX | |
# 4=Off 5=On | |
# 6=Alt 7=Speed/Flash | |
# 8=Link 9=Activity | |
# | |
# Debugging: | |
# $ hexdump /proc/device-tree/scb/ethernet@7d580000/mdio@e14/ethernet-phy@1/led-modes | |
{ | |
name = "disable-eth-leds"; | |
filter = "*rpi-4-b*"; | |
dtsText = '' | |
/dts-v1/; | |
/plugin/; | |
/{ | |
compatible = "raspberrypi,4-model-b"; | |
fragment@0 { | |
target = <&phy1>; | |
__overlay__ { | |
led-modes = <0x04 0x04>; | |
}; | |
}; | |
}; | |
''; | |
} | |
# Debugging: | |
# $ hexdump /proc/device-tree/leds/led-act/gpios | |
# $ cat /proc/device-tree/leds/led-act/linux,default-trigger | |
{ | |
name = "disable-act-led"; | |
filter = "*rpi-4-b*"; | |
dtsText = '' | |
/dts-v1/; | |
/plugin/; | |
/{ | |
compatible = "raspberrypi,4-model-b"; | |
fragment@0 { | |
target = <&act_led>; | |
__overlay__ { | |
gpios = <&gpio 42 0>; /* first two values copied from bcm2711-rpi-4-b.dts */ | |
linux,default-trigger = "none"; | |
}; | |
}; | |
}; | |
''; | |
} | |
# Debugging: | |
# $ hexdump /proc/device-tree/leds/led-pwr/gpios | |
# $ cat /proc/device-tree/leds/led-pwr/linux,default-trigger | |
{ | |
name = "disable-pwr-led"; | |
filter = "*rpi-4-b*"; | |
dtsText = '' | |
/dts-v1/; | |
/plugin/; | |
/{ | |
compatible = "raspberrypi,4-model-b"; | |
fragment@0 { | |
target = <&pwr_led>; | |
__overlay__ { | |
gpios = <&expgpio 2 0>; /* first two values copied from bcm2711-rpi-4-b.dts */ | |
linux,default-trigger = "default-on"; | |
}; | |
}; | |
}; | |
''; | |
} | |
]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment