Last active
February 28, 2026 08:57
-
-
Save oliora/81139a236395d616b4838965fed9da13 to your computer and use it in GitHub Desktop.
RaspberryPi 5 DeviceTree Overlays for 4 channel PWM0 (choose one of the two available GPIO pin mappings for PWM)
This file contains hidden or 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
| // SPDX-License-Identifier: GPL-2.0-only | |
| // This file is released under the GPL v2.0 License, and comes without warranty, express or implied. | |
| // (C) Andrey Upadyshev, 2026 | |
| /* | |
| This overlay activates four PWM0 channels of RaspberryPi 5 on the following GPIO pins: | |
| GPIO 12: PWM0_CHAN0 (Alt0) | |
| GPIO 13: PWM0_CHAN1 (Alt0) | |
| GPIO 18: PWM0_CHAN2 (Alt3) | |
| GPIO 19: PWM0_CHAN3 (Alt3) | |
| Alternatively use: | |
| - `pwm-4chan-pi5` overlay to activate 4 PWM0 channels on pins 12, 13, 14 and 15 | |
| - `pwm-2chan` and `pwm` overlays to activate 2 and 1 PWM channels accordingly | |
| */ | |
| /dts-v1/; | |
| /plugin/; | |
| / { | |
| compatible = "brcm,bcm2712"; | |
| fragment@0 { | |
| target = <&gpio>; | |
| __overlay__ { | |
| pwm_pins: pwm_pins { | |
| function = "pwm0"; | |
| pins = "gpio12", "gpio13", "gpio18", "gpio19"; | |
| }; | |
| }; | |
| }; | |
| fragment@1 { | |
| target = <&rp1_pwm0>; | |
| frag1: __overlay__ { | |
| pinctrl-names = "default"; | |
| pinctrl-0 = <&pwm_pins>; | |
| status = "okay"; | |
| }; | |
| }; | |
| }; |
This file contains hidden or 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
| // SPDX-License-Identifier: GPL-2.0-only | |
| // This file is released under the GPL v2.0 License, and comes without warranty, express or implied. | |
| // (C) Andrey Upadyshev, 2026 | |
| /* | |
| This overlay activates four PWM0 channels of RaspberryPi 5 on the following GPIO pins: | |
| GPIO 12: PWM0_CHAN0 (Alt0) | |
| GPIO 13: PWM0_CHAN1 (Alt0) | |
| GPIO 14: PWM0_CHAN2 (Alt0) | |
| GPIO 15: PWM0_CHAN3 (Alt0) | |
| Alternatively use: | |
| - `pwm-4chan-alt-pi5` overlay to activate 4 PWM0 channels on pins 12, 13, 18 and 19 | |
| - `pwm-2chan` and `pwm` overlays to activate 2 and 1 PWM channels accordingly | |
| */ | |
| /dts-v1/; | |
| /plugin/; | |
| / { | |
| compatible = "brcm,bcm2712"; | |
| fragment@0 { | |
| target = <&gpio>; | |
| __overlay__ { | |
| pwm_pins: pwm_pins { | |
| function = "pwm0"; | |
| pins = "gpio12", "gpio13", "gpio14", "gpio15"; | |
| }; | |
| }; | |
| }; | |
| fragment@1 { | |
| target = <&rp1_pwm0>; | |
| frag1: __overlay__ { | |
| pinctrl-names = "default"; | |
| pinctrl-0 = <&pwm_pins>; | |
| status = "okay"; | |
| }; | |
| }; | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before using, compile the above overlay source files and copy the result DTBOs to the overlays directory (
/boot/overlaysby default):Enable either by adding
dtoverlay=pwm-4chan-pi5line to/boot/firmware/config.txt(preferably under[pi5]section) or dynamic viasudo dtoverlay pwm-4chan-pi5command.Note that you cannot remove PWM overlays dynamically via
dtoverlay -r. The removal causes a kernel segfault which requires a reboot to fix the system. This may be fixed in newer version of the kernel/PWM driverNote that only one PWM overlay can be activated at the same time time