Skip to content

Read PWM config from /boot/firmware first to support Bookworm and later OSes#230

Merged
mattjlewis merged 1 commit intomattjlewis:mainfrom
thatcomputerguy0101:Bookworm-PWM-support
Feb 2, 2026
Merged

Read PWM config from /boot/firmware first to support Bookworm and later OSes#230
mattjlewis merged 1 commit intomattjlewis:mainfrom
thatcomputerguy0101:Bookworm-PWM-support

Conversation

@thatcomputerguy0101
Copy link
Contributor

Starting in RPiOS Bookworm, the boot partition mount point moved from /boot to /boot/firmware. Due to this, config.txt is now located at /boot/firmware/config.txt for modern RPiOS versions. This change set searches the new location first, falling back to the old location if an IOException occurs (the new file is not found).

@thatcomputerguy0101
Copy link
Contributor Author

On second thought, it may be better to extract the PWM pin configuration from running pinctrl instead, since that will always report the active configuration. The current implementation might report the wrong values if the pwm dtoverlay line appears in a conditional block of config.txt.

@thatcomputerguy0101
Copy link
Contributor Author

pinctrl is backed by gpiolib which is probably more appropriate for reading the current configuration. (It also allows changing the alternate functions dynamically, but at risk of conflict with the kernel.) gpiolib also has mechanisms for getting the physical pin layout, which could act as a fallback for missing board layouts.

mcm001 pushed a commit to PhotonVision/photon-image-modifier that referenced this pull request Feb 2, 2026
This enables PWM on pins 13 and 18 to control the built-in dimmable
illumination LEDs on Limelight 2+ and 3. The symlink at
`/boot/config.txt` exists since that is the only path diozero checks for
pwm configuration right now, and should be removed once diozero is
updated to check `/boot/firmware/config.txt` or another source of PWM
information
([diozero#230](mattjlewis/diozero#230)).

Both LL2+ and LL3 have non-flickery LED dimming with these changes.

Needed to fix flickering LEDs in
[photonvision#2335](PhotonVision/photonvision#2335).
@thatcomputerguy0101
Copy link
Contributor Author

Actually, I'm probably mixing up libraries here. gpiolib is what the gpio character device api is supposed to supersede.

@mattjlewis mattjlewis merged commit 3158f21 into mattjlewis:main Feb 2, 2026
@mattjlewis
Copy link
Owner

Thank you - merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants