GPIO Pins on Raspberry Pi 4B; How to use them in FreeBSD.

 GPIO Pins  on Raspberry Pi 4B;   How to use them in FreeBSD.


Useful  RaspberryPi and FreeBSD documentation to help understand UART3 usage on a Raspberry Pi 4B.    Looking to enable and setup UART3 for a serial 9600 baud GPS data stream.



GPIO device understanding blog,  KHubla Blog 2013,


Latest January 2023  Raspberry Pi firmware from Raspberrypi.com


FreeBSD ARM mailing list entry

From: Mark Millard <marklmi_at_yahoo.com>
Date: Fri, 03 Feb 2023 03:50:35 UTC

[Also sending this to the arm list.]

You can see the *.dts* sources for 1-20210303 (the RPi* firmware
release FreeBSD is set up to use) via:

and:

You can find other versions via the tags visible via:


via:

Click on the tag name.
On the new page, click on the left most instance of the same tag name.
Traverse the directory structure.

Much more direct for what I wanted to accomplish
than I was doing before.

https://github.com/raspberrypi/linux/tags/ pages also allow clicking
on tar.gz links to download the full RPi Linux source code for local
access.


https://wiki.freebsd.org/GPIO
https://wiki.freebsd.org/GPIO/Hardware
https://man.freebsd.org/cgi/man.cgi?query=gpioctl&sektion=8&apropos=0&manpath=FreeBSD+13.1-RELEASE+and+Ports


EXAMPLE:  Log into Raspi4B via SSH

ssh root@192.168.1.7
The authenticity of host '192.168.1.7 (192.168.1.7)' can't be established.
ED25519 key fingerprint is SHA256:RB3cF7Vfv1tOcJG4NU3XG7jqKosEwaB3csC9ERWMMSQ.
No matching host key fingerprint found in DNS.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added '192.168.1.7' (ED25519) to the list of known hosts.
(root@192.168.1.7) Password for root@Fred_RasPi4B:
Last login: Sun Feb  5 10:28:42 2023 from fredtc93-pc
FreeBSD 14.0-CURRENT #6 main-n259952-7e2600ea7be2-dirty: Sun Jan 15 18:14:05 PST 2023     root@Fred_RasPi4B:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC-VCHIQ

Welcome to FreeBSD!

Release Notes, Errata: https://www.FreeBSD.org/releases/
Security Advisories:   https://www.FreeBSD.org/security/
FreeBSD Handbook:      https://www.FreeBSD.org/handbook/
FreeBSD FAQ:           https://www.FreeBSD.org/faq/
Questions List:        https://www.FreeBSD.org/lists/questions/
FreeBSD Forums:        https://forums.FreeBSD.org/

Documents installed with the system are in the /usr/local/share/doc/freebsd/
directory, or can be installed later with:  pkg install en-freebsd-doc
For other languages, replace "en" with a language code like de or fr.

Show the version of FreeBSD installed:  freebsd-version ; uname -a
Please include that output and any error messages when posting questions.
Introduction to manual pages:  man man
FreeBSD directory layout:      man hier

To change this login announcement, see motd(5).
root@Fred_RasPi4B:~ # 

 ls -lht /dev/gpio*
crw-------  1 root  wheel   0x2c Feb  3 14:51 /dev/gpioc0
crw-------  1 root  wheel   0x39 Feb  3 14:51 /dev/gpioc1


gpioctl -f /dev/gpioc1 -l
pin 00: 1 BT_ON<IN>
pin 01: 1 WL_ON<IN>
pin 02: 0 PWR_LED_OFF<OUT>
pin 03: 1 GLOBAL_RESET<IN>
pin 04: 1 VDD_SD_IO_SEL<OUT>
pin 05: 1 CAM_GPIO<IN>
pin 06: 0 SD_PWR_ON<IN>
pin 07: 1 SD_OC_N<IN>
root@Fred_RasPi4B:~ # 

 gpioctl -f /dev/gpioc1 -lv
pin 00: 1 BT_ON<IN>, caps:<IN,OUT>
pin 01: 1 WL_ON<IN>, caps:<IN,OUT>
pin 02: 0 PWR_LED_OFF<OUT>, caps:<IN,OUT>
pin 03: 1 GLOBAL_RESET<IN>, caps:<IN,OUT>
pin 04: 1 VDD_SD_IO_SEL<OUT>, caps:<IN,OUT>
pin 05: 1 CAM_GPIO<IN>, caps:<IN,OUT>
pin 06: 0 SD_PWR_ON<IN>, caps:<IN,OUT>
pin 07: 1 SD_OC_N<IN>, caps:<IN,OUT>
root@Fred_RasPi4B:~ # 


# gpioctl -f /dev/gpioc0 -lv
pin 00: 1 pin 0<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 01: 1 pin 1<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 02: 1 pin 2<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 03: 1 pin 3<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 04: 1 pin 4<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 05: 1 pin 5<PU>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 06: 1 pin 6<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 07: 1 pin 7<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 08: 1 pin 8<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 09: 0 pin 9<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 10: 0 pin 10<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 11: 0 pin 11<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 12: 0 pin 12<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 13: 0 pin 13<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 14: 1 pin 14<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 15: 1 pin 15<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 16: 0 pin 16<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 17: 0 pin 17<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 18: 0 pin 18<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 19: 0 pin 19<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 20: 0 pin 20<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 21: 0 pin 21<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 22: 1 pin 22<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 23: 0 pin 23<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 24: 0 pin 24<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 25: 0 pin 25<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 26: 0 pin 26<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 27: 0 pin 27<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 28: 1 pin 28<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 29: 0 pin 29<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 30: 1 pin 30<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 31: 1 pin 31<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 32: 0 pin 32<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 33: 0 pin 33<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 34: 1 pin 34<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 35: 1 pin 35<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 36: 1 pin 36<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 37: 1 pin 37<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 38: 1 pin 38<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 39: 1 pin 39<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 40: 0 pin 40<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 41: 0 pin 41<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 42: 0 pin 42<OUT>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 43: 1 pin 43<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 44: 1 pin 44<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 45: 1 pin 45<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 46: 0 pin 46<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 47: 0 pin 47<IN>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 48: 0 pin 48<>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 49: 0 pin 49<PU>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 50: 0 pin 50<PU>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 51: 0 pin 51<PU>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 52: 0 pin 52<PU>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>
pin 53: 0 pin 53<PU>, caps:<IN,OUT,PU,PD,INTRLL,INTRLH,INTRER,INTREF,INTREB>


 gpioctl -f /dev/gpioc0 -l
pin 00: 1 pin 0<IN>
pin 01: 1 pin 1<IN>
pin 02: 1 pin 2<IN>
pin 03: 1 pin 3<IN>
pin 04: 1 pin 4<>
pin 05: 1 pin 5<PU>
pin 06: 1 pin 6<IN>
pin 07: 1 pin 7<IN>
pin 08: 1 pin 8<IN>
pin 09: 0 pin 9<IN>
pin 10: 0 pin 10<IN>
pin 11: 0 pin 11<IN>
pin 12: 0 pin 12<IN>
pin 13: 0 pin 13<IN>
pin 14: 1 pin 14<>
pin 15: 1 pin 15<>
pin 16: 0 pin 16<IN>
pin 17: 0 pin 17<IN>
pin 18: 0 pin 18<IN>
pin 19: 0 pin 19<IN>
pin 20: 0 pin 20<IN>
pin 21: 0 pin 21<IN>
pin 22: 1 pin 22<>
pin 23: 0 pin 23<>
pin 24: 0 pin 24<>
pin 25: 0 pin 25<>
pin 26: 0 pin 26<>
pin 27: 0 pin 27<>
pin 28: 1 pin 28<>
pin 29: 0 pin 29<>
pin 30: 1 pin 30<IN>
pin 31: 1 pin 31<IN>
pin 32: 0 pin 32<IN>
pin 33: 0 pin 33<IN>
pin 34: 1 pin 34<IN>
pin 35: 1 pin 35<IN>
pin 36: 1 pin 36<IN>
pin 37: 1 pin 37<IN>
pin 38: 1 pin 38<IN>
pin 39: 1 pin 39<IN>
pin 40: 0 pin 40<>
pin 41: 0 pin 41<>
pin 42: 0 pin 42<OUT>
pin 43: 1 pin 43<IN>
pin 44: 1 pin 44<IN>
pin 45: 1 pin 45<IN>
pin 46: 0 pin 46<IN>
pin 47: 0 pin 47<IN>
pin 48: 0 pin 48<>
pin 49: 0 pin 49<PU>
pin 50: 0 pin 50<PU>
pin 51: 0 pin 51<PU>
pin 52: 0 pin 52<PU>
pin 53: 0 pin 53<PU>


Hey I found this blog post with an example of FreeBSD C source code for Raspberry Pi.

https://github.com/teverett/gpioexample.git   Github.com site of source code gpioexample

https://blog.khubla.com/freebsd/understanding-the-raspberry-pi-freebsd-gpio-device  Explanation FreeBSD GPIO on raspberry pi

Clone the github onto the Raspberry Pi 4B running FreeBSD 13.0-STABLE or 13.1-RELEASE or 14.0-CURRENT

git clone https://github.com/teverett/gpioexample.gi

gpioexample

FreeBSD GPIO Example. A simple example of programing the Raspberry Pi GPIO in C language using make on a Raspberry Pi 4B running operating system FreeBSD 14.0-CURRENT as of February 6, 2023. Below is the operating system details and the version number of the C compiler.


uname -aKmnopr
FreeBSD Fred_RasPi4B 14.0-CURRENT FreeBSD 14.0-CURRENT #6 main-n259952-7e2600ea7be2-dirty: Sun Jan 15 18:14:05 PST 2023     root@Fred_RasPi4B:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC-VCHIQ arm64 aarch64 1400077

https://blog.khubla.com/freebsd/understanding-the-raspberry-pi-freebsd-gpio-device

https://blog.khubla.com/hobbies


cc --version
FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)
Target: aarch64-unknown-freebsd14.0
Thread model: posix

InstalledDir: /usr/bin

make
cc -c gpioexample.c
cc -o gpioexample gpioexample.o


Create a RaspberryPi4B aarch64 executable binary file gpioexample  for you to run on FreeBSD operating system on the Raspberry Pi 4B.  


Modify binary file to be an executable binary file

chmod a+x gpioexample

Test run the executable binary file

./gpioexample

./gpioexample

GPIO has 53 pins
pin# description capabilties flags
0: pin 0  0x1f0063  0x1
1: pin 1  0x1f0063  0x1
2: pin 2  0x1f0063  0x1
3: pin 3  0x1f0063  0x1
4: pin 4  0x1f0063  0x0
5: pin 5  0x1f0063  0x20
6: pin 6  0x1f0063  0x1
7: pin 7  0x1f0063  0x1
8: pin 8  0x1f0063  0x1
9: pin 9  0x1f0063  0x1
10: pin 10  0x1f0063  0x1
11: pin 11  0x1f0063  0x1
12: pin 12  0x1f0063  0x1
13: pin 13  0x1f0063  0x1
14: pin 14  0x1f0063  0x0
15: pin 15  0x1f0063  0x0
16: pin 16  0x1f0063  0x1
17: pin 17  0x1f0063  0x1
18: pin 18  0x1f0063  0x1
19: pin 19  0x1f0063  0x1
20: pin 20  0x1f0063  0x1
21: pin 21  0x1f0063  0x1
22: pin 22  0x1f0063  0x0
23: pin 23  0x1f0063  0x0
24: pin 24  0x1f0063  0x0
25: pin 25  0x1f0063  0x0
26: pin 26  0x1f0063  0x0
27: pin 27  0x1f0063  0x0
28: pin 28  0x1f0063  0x0
29: pin 29  0x1f0063  0x0
30: pin 30  0x1f0063  0x1
31: pin 31  0x1f0063  0x1
32: pin 32  0x1f0063  0x1
33: pin 33  0x1f0063  0x1
34: pin 34  0x1f0063  0x1
35: pin 35  0x1f0063  0x1
36: pin 36  0x1f0063  0x1
37: pin 37  0x1f0063  0x1
38: pin 38  0x1f0063  0x1
39: pin 39  0x1f0063  0x1
40: pin 40  0x1f0063  0x0
41: pin 41  0x1f0063  0x0
42: pin 42  0x1f0063  0x2
43: pin 43  0x1f0063  0x1
44: pin 44  0x1f0063  0x1
45: pin 45  0x1f0063  0x1
46: pin 46  0x1f0063  0x1
47: pin 47  0x1f0063  0x1
48: pin 48  0x1f0063  0x0
49: pin 49  0x1f0063  0x20
50: pin 50  0x1f0063  0x20
51: pin 51  0x1f0063  0x20
52: pin 52  0x1f0063  0x20
53: pin 53  0x1f0063  0x20




Comments

Popular posts from this blog

HDMI Audio sound patches into GhostBSD source code /usr/ghost14/ghostbsd-src SOLVED Jan20 2024

How to install GhostBSD-Arm64 into a USB Flash Drive stick April 24, 2024 update edition.

January 19, 2024 Howto Download a Raspberry Pi 4B bootable image from http://ghostbsdarm64.hopto.org/packages/