load SD card image on either a RPi4 or Pi 400 pick a GPIO pin e.g. 24 enter the following as root; #gpioctl -l | grep 24 */you will see the status of pin 24 usually defaults as an <IN>put with value 0 */pin 24: 0 24<IN> */Let's set this input as Pulled-Up #gpioctl -c 24 IN PU #gpioctl -l | grep 24 */you will see the configuration change to */pin 24: 0 24<IN,PU> */but the pin value of 0 should be 1 now, since it has been pulled-up I verified that this is exclusive to the RPi 4 family only. Tested on a RPi3B+ and it works properly. Lastly, these are all certified Raspberry Pi products not knock-offs.
Created attachment 242178 [details] patch-sys_arm_broadcom_bcm2835_bcm2835__gpio.c
It's a bit outdated bug report but surely it's still existing and the one I've intended to fix. From 4th generation of Raspberry Pi, or at least those come with BCM2711, the way to configure the GPIO pins' internal pull up/down was changed. At this moment, FreeBSD can't handle the internal pull on ie. RPi4B, instead an external resistor must be wired to pull GPIO pins up or down, which is quite annoying. NetBSD has a patch to support the newer method for BCM2711, and of course Linux also does. I've imported the NetBSD patch with some modification, tested on RPi4B to make sure the pull can be configured successfully, and it worked well. The patch has also be tested on RPi2B and RPi3B+ to not have any side-effect. https://github.com/NetBSD/src/commit/bb88cfa64ad8045456ec4afef04a834d067c8cb1
(In reply to t_uemura from comment #2) Hi, thanks for your work on this. I looked at the change, and functionally it seems fine to me. There are some small cosmetic issues with the patch, so I have suggestions for how it could be improved. Bugzilla is not a great tool for code review, but recently we have been experimenting with GitHub pull requests. Would you be able to submit this patch again as a pull request against the freebsd-src repo? See: https://github.com/freebsd/freebsd-src/blob/main/CONTRIBUTING.md That will allow me to give feedback more easily, and merge the change more quickly. Thanks, and if this does not work for you, let me know.
(In reply to Mitchell Horne from comment #3) I'll try to do so. If I have any difficulty, I will ask you.
(In reply to Mitchell Horne from comment #3) Hi. I've successfully managed to create a pull-request. Thanks in advance for reviewing. https://github.com/freebsd/freebsd-src/pull/746
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=9d35469e9a6892b3845f66d3513f5c528fe68a77 commit 9d35469e9a6892b3845f66d3513f5c528fe68a77 Author: Tetsuya Uemura <t_uemura@macome.co.jp> AuthorDate: 2023-05-28 12:56:21 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2023-05-29 18:47:12 +0000 bcm2835_gpio: Handle BCM2711 pin configuration Add support for GPIO internal pull up/down configuration on RPi4 family. BCM2711 SoC on 4th generation Raspberry Pi changed the way to configure its GPIO pins' internal pull up/down resistors. NetBSD already have support for this change, and port it to FreeBSD is trivial. This patch, based on the NetBSD commit adds the appropriate method for BCM2711 and now we can properly configure the GPIO pins' pull status. PR: 256372 Reviewed by: mhorne Obtained from: NetBSD bb88cfa64ad8 Pull Request: https://github.com/freebsd/freebsd-src/pull/746 sys/arm/broadcom/bcm2835/bcm2835_gpio.c | 81 +++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 20 deletions(-)
Done. Thank you for your contribution! I will close the bug after 1 week when I merge the change to stable/13 branch.
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=4a0ea7a98b9260462e22f3144eb08e9bd8ba2765 commit 4a0ea7a98b9260462e22f3144eb08e9bd8ba2765 Author: Tetsuya Uemura <t_uemura@macome.co.jp> AuthorDate: 2023-05-28 12:56:21 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2023-06-09 19:48:07 +0000 bcm2835_gpio: Handle BCM2711 pin configuration Add support for GPIO internal pull up/down configuration on RPi4 family. BCM2711 SoC on 4th generation Raspberry Pi changed the way to configure its GPIO pins' internal pull up/down resistors. NetBSD already have support for this change, and port it to FreeBSD is trivial. This patch, based on the NetBSD commit adds the appropriate method for BCM2711 and now we can properly configure the GPIO pins' pull status. PR: 256372 Reviewed by: mhorne Obtained from: NetBSD bb88cfa64ad8 Pull Request: https://github.com/freebsd/freebsd-src/pull/746 (cherry picked from commit 9d35469e9a6892b3845f66d3513f5c528fe68a77) sys/arm/broadcom/bcm2835/bcm2835_gpio.c | 81 +++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 20 deletions(-)