From nobody Tue Jan 24 19:15:30 2023 X-Original-To: freebsd-arm@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P1cBF72KQz3bGxp for ; Tue, 24 Jan 2023 19:15:33 +0000 (UTC) (envelope-from 01070185e534f221-14f362b5-2b96-43f0-b0b0-f496ad9994fe-000000@eu-central-1.amazonses.com) Received: from b224-10.smtp-out.eu-central-1.amazonses.com (b224-10.smtp-out.eu-central-1.amazonses.com [69.169.224.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4P1cBD01SHz3ps2 for ; Tue, 24 Jan 2023 19:15:31 +0000 (UTC) (envelope-from 01070185e534f221-14f362b5-2b96-43f0-b0b0-f496ad9994fe-000000@eu-central-1.amazonses.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=cyclaero.com header.s=ez3m2wtglgbm5wj4q3hdyvc7qtjtqmlb header.b=kOVw2Qan; dkim=pass header.d=amazonses.com header.s=sokbgaaqhfgd6qjht2wmdajpuuanpimv header.b="eo/MgMk6"; spf=pass (mx1.freebsd.org: domain of 01070185e534f221-14f362b5-2b96-43f0-b0b0-f496ad9994fe-000000@eu-central-1.amazonses.com designates 69.169.224.10 as permitted sender) smtp.mailfrom=01070185e534f221-14f362b5-2b96-43f0-b0b0-f496ad9994fe-000000@eu-central-1.amazonses.com; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ez3m2wtglgbm5wj4q3hdyvc7qtjtqmlb; d=cyclaero.com; t=1674587730; h=From:Content-Type:Mime-Version:Subject:Date:References:To:In-Reply-To:Message-Id; bh=7Z7uc+qKlUNYqVFe02eqy/tMXSCC5S3XEJqn5jBp/4c=; b=kOVw2QanshBWntBRkaBYUTe2IzIDZaYSWPIIhC5Hmd3kmKQXcv5x+pYlOQxCelE+ ECfYLhe23S45UEB/2a7X2ZNI20yGLl+rJ2QI5+jDIEvLUdhifQwzF/Z55NyB1aI+g/p 4+BVzMgO+8EHMK7jQhs7/fvBnkWEHPRwVPFvIsN9EjFOoDbDXgWxE31OGuw6mimNGXy PdW2vJKCP6h3AD4wBmqD0JDcWenGTScTiTCE8sAAMtGOauwkLv1tnglbnd04Y3A0tcq tQvHobmPywMdQtPpuGfx5N34UfVMBdEFKyNYd+byECqGve5ZGRpzFSlnQi7Cyjy2oFz FFwHa//kdw== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=sokbgaaqhfgd6qjht2wmdajpuuanpimv; d=amazonses.com; t=1674587730; h=From:Content-Type:Mime-Version:Subject:Date:References:To:In-Reply-To:Message-Id:Feedback-ID; bh=7Z7uc+qKlUNYqVFe02eqy/tMXSCC5S3XEJqn5jBp/4c=; b=eo/MgMk6rmvj1bxu4C4hepMSx4d2bHKKzzjlgnYQuJuZOnm8a6PUJmi8GjMbHDnX oQWM8EdW8rRUSLKr7im+EZaRYzNE0bNLAzWclKqv45XWBPy9r7IO4pAV26Ra87idV4/ VPYJWzYG+fGiVddD3RNSOV4mTjN5AE/15crmD2C4= From: "Dr. Rolf Jansen" Content-Type: multipart/alternative; boundary="Apple-Mail=_A11E81C7-9742-46CA-9F56-79152AC5767A" List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.15\)) Subject: Re: GPIO inputs on Pis? Date: Tue, 24 Jan 2023 19:15:30 +0000 References: <0b235f83-7cb3-1d14-7c64-aee7c1c0c23d@denninger.net> <01070185e46b1a6e-ee34b885-1215-45c7-ac18-83320c02cac2-000000@eu-central-1.amazonses.com> <01070185e4732fd8-c0bede0b-d9df-4557-a174-cb237fa4bfaf-000000@eu-central-1.amazonses.com> To: freebsd-arm In-Reply-To: Message-ID: <01070185e534f221-14f362b5-2b96-43f0-b0b0-f496ad9994fe-000000@eu-central-1.amazonses.com> X-Mailer: Apple Mail (2.3445.104.15) Feedback-ID: 1.eu-central-1.i3TZMOZE/rJo3HQG0qvfyolMxXljeCj2Qj8Jp3rxK3c=:AmazonSES X-SES-Outgoing: 2023.01.24-69.169.224.10 X-Spamd-Result: default: False [1.91 / 15.00]; URI_COUNT_ODD(1.00)[27]; FROM_NAME_HAS_TITLE(1.00)[dr]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_SHORT(-1.00)[-0.999]; NEURAL_HAM_LONG(-0.97)[-0.974]; NEURAL_SPAM_MEDIUM(0.58)[0.583]; MV_CASE(0.50)[]; FORGED_SENDER(0.30)[freebsd-rj@cyclaero.com,01070185e534f221-14f362b5-2b96-43f0-b0b0-f496ad9994fe-000000@eu-central-1.amazonses.com]; R_DKIM_ALLOW(-0.20)[cyclaero.com:s=ez3m2wtglgbm5wj4q3hdyvc7qtjtqmlb,amazonses.com:s=sokbgaaqhfgd6qjht2wmdajpuuanpimv]; R_SPF_ALLOW(-0.20)[+ip4:69.169.224.0/20]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_IN_DNSWL_NONE(0.00)[69.169.224.10:from]; DMARC_NA(0.00)[cyclaero.com]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_NONE(0.00)[amazonses.com:dkim]; MLMMJ_DEST(0.00)[freebsd-arm@freebsd.org]; DKIM_TRACE(0.00)[cyclaero.com:+,amazonses.com:+]; TO_DN_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; ASN(0.00)[asn:16509, ipnet:69.169.224.0/23, country:US]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FROM_NEQ_ENVFROM(0.00)[freebsd-rj@cyclaero.com,01070185e534f221-14f362b5-2b96-43f0-b0b0-f496ad9994fe-000000@eu-central-1.amazonses.com]; RWL_MAILSPIKE_POSSIBLE(0.00)[69.169.224.10:from] X-Rspamd-Queue-Id: 4P1cBD01SHz3ps2 X-Spamd-Bar: + X-ThisMailContainsUnwantedMimeParts: N --Apple-Mail=_A11E81C7-9742-46CA-9F56-79152AC5767A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Am 24.01.2023 um 13:58 schrieb Karl Denninger >: >=20 > On 1/24/2023 10:43, Dr. Rolf Jansen wrote: >> I sent an old ink to the thread on the mailing list, which does not = work anymore. Here ist the new link: >>=20 >> = https://lists.freebsd.org/pipermail/freebsd-arm/2020-November/022738.html = >>=20 >>> Am 24.01.2023 um 12:35 schrieb Karl Denninger >: >>>=20 >>> Thank you -- will check it out. >>>=20 >>> On 1/24/2023 10:35, Dr. Rolf Jansen wrote: >>>>> Am 23.01.2023 um 11:41 schrieb Karl Denninger >: >>>>>=20 >>>>> Is there support somewhere in the 13.x for other than "read = current state" / "set current state"? >>>>>=20 >>>>> Specifically, there is evidence in the sys/gpio.h header file that = I can open up a file descriptor and then use select()/read() to grab the = contents of a ring buffer of some size (presumably interrupt-posted) of = events since last look, and determine if there's anything in there. = Provided you're reasonably fast this might be enough to, for example, = read an optical encoder that has a modest pulse rate. >>>>>=20 >>>>> I see apparent review code at https://reviews.freebsd.org/D27398 = from late 2020, but nothing else I = can find digging around; an example (assuming it is actually implemented = and works) would be helpful >>>>>=20 >>>> See >>>>=20 >>>> = https://forums.freebsd.org/threads/gpio-api-general-orange-pi-h3.83950/pos= t-556728 = >>>>=20 >>>> And the messages in that thread that follow the one linked above. >>>>=20 >>>> There is a respective thread on this mailing list as well: >>>>=20 >>>> Porting FreeBSD to ARM processors: User Space GPIO Interrupt = programming - GSoC-2018 = = --=20 >>> Karl Denninger >>> karl@denninger.net >>> The Market Ticker >>> [S/MIME encrypted email preferred] >>=20 > So the answer at this point appears to be "not in the codebase and no = indication on when/if it might be, but there are patches that are in = some state of development.=E2=80=9C >=20 No, at this point (13.1-RELEASE) everything is in the kernel, no patches = needed. Even the test tool made it into the source tree. It has only be = renamed from gpioc_intr_test.c to gpioevents.c. /usr/src/tools/test/gpioevents/gpioevents.c The documentation is missing. It is however easy to learn how things = work by examining the code of gpioevents.c. > Being able to read an encoder of some sort basically means being able = to know how many events occurred between "looks"; for most purposes you = don't need each event delivered exactly when it occurs, but missing some = of the counts entirely is not acceptable. Yes, and for this reason, this GPIO event code which was developed by = Christian Kr=C3=A4mer in the course of the GSoC-2018 and has been = submitted in 2020 by Ian Lepore to the freebsd tree is perfect. Ian tested it with a 10 MHz sqaure wave on an imx6 (ARMv7, 1GHz) and got = an event every 10 =C2=B5s. That means the max. speed without event = losses would be 100 kHz. I did not do exact measurements, however, my = impression is that my RPi4B can do it a tad faster than my BeagleBone = Black. With the RPi4, I needed to improve the debouncing of the encoder = and the buttons, because it saw hundreds of bounces which the BBB = didn=E2=80=99t. However, it may also be, that the internal GPIO circuits = of the BBB have a different damping characteristic. Anyway for my applications, 100 kHz way faster than what I need. On my GitHub repository I placed another example on using the GPIO = events for the RPi: https://github.com/cyclaero/shutdd See also the respective thread on this mailing list: https://lists.freebsd.org/archives/freebsd-arm/2022-July/001576.html = = --Apple-Mail=_A11E81C7-9742-46CA-9F56-79152AC5767A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Am = 24.01.2023 um 13:58 schrieb Karl Denninger <karl@denninger.net>:

On 1/24/2023 10:43, Dr. Rolf Jansen wrote:
I = sent an old ink to the thread on the mailing list, which does not work = anymore. Here ist the new link:


Am 24.01.2023 um 12:35 schrieb Karl = Denninger <karl@denninger.net>:

Thank you -- will check it out.

On 1/24/2023 10:35, Dr. Rolf Jansen wrote:
Am 23.01.2023 um 11:41 schrieb = Karl Denninger <karl@denninger.net>:

Is there support somewhere in the 13.x for other than "read = current state" / "set current state"?

Specifically, = there is evidence in the sys/gpio.h header file that I can open up a = file descriptor and then use select()/read() to grab the contents of a = ring buffer of some size (presumably interrupt-posted) of events since = last look, and determine if there's anything in there.  Provided = you're reasonably fast this might be enough to, for example, read an = optical encoder that has a modest pulse rate.

I see = apparent review code at https://reviews.freebsd.org/D27398 from late 2020, but nothing = else I can find digging around; an example (assuming it is actually = implemented and works) would be = helpful

See


And the messages in that thread that = follow the one linked above.

There is a respective thread on this = mailing list as well:

-- 
Karl = Denninger
karl@denninger.net
The Market Ticker
[S/MIME encrypted email = preferred]

So the answer at this = point appears to be "not in the codebase and no indication on when/if it = might be, but there are patches that are in some state of = development.=E2=80=9C

No, at this point = (13.1-RELEASE) everything is in the kernel, no patches needed. Even the = test tool made it into the source tree. It has only be renamed = from gpioc_intr_test.c to gpioevents.c.

/usr/src/tools/test/gpioevents/gpioevents.c

The documentation is missing. It is = however easy to learn how things work by examining the code of = gpioevents.c.

Being able to read an encoder of some sort basically means = being able to know how many events occurred between "looks"; for most = purposes you don't need each event delivered exactly when it occurs, but = missing some of the counts entirely is not = acceptable.

Yes, and for this reason, this GPIO = event code which was developed by Christian Kr=C3=A4mer in the = course of the GSoC-2018 and has been submitted in 2020 by Ian Lepore to = the freebsd tree is perfect.

Ian tested it with a 10 MHz sqaure = wave on an imx6 (ARMv7, 1GHz) and got an event every 10 =C2=B5s. = That means the max. speed without event losses would be 100 kHz. I did = not do exact measurements, however, my impression is that my RPi4B can = do it a tad faster than my BeagleBone Black. With the RPi4, I needed to = improve the debouncing of the encoder and the buttons, because it saw = hundreds of bounces which the BBB didn=E2=80=99t. However, it may also = be, that the internal GPIO circuits of the BBB have a different damping = characteristic.

Anyway for my applications, 100 kHz way faster than what I = need.

On my = GitHub repository I placed another example on using the GPIO events for = the RPi:

See also the respective thread on this = mailing list:

https://lists.freebsd.org/archives/freebsd-arm/2022-July/001576= .html
= --Apple-Mail=_A11E81C7-9742-46CA-9F56-79152AC5767A--