Once and for All: Loading Device Tree Overlays (at runtime)

Time for another Once-And-For-All post - tasks I do periodically (but not weekly) and keep forgetting the command syntax.

Today: Loading Device tree overlays at runtime.

# Mount kernel configfs
mount -t configfs none /sys/kernel/config/

# Create the device tree node (name doesn't really matter)
mkdir /sys/kernel/config/device-tree/overlays/rotary-enc

# cat the device tree overlay to a special file
cat /boot/overlays/rotary-encoder.dtbo > /sys/kernel/config/device-tree/overlays/rotary-enc/dtbo

Note: This is raspberry-pi specific! Raspberry-Linux has a patch that allows loading overlays at runtime.