From nobody Wed Jul 13 23:19:57 2022 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 A69AF1D06FCE for ; Wed, 13 Jul 2022 23:20:11 +0000 (UTC) (envelope-from sl.lmysyibvge3tcobrhe3syibsg44tgmrqlu.6e6oohdr67d6k@qoruscant.com) Received: from mail-200160.simplelogin.co (mail-200160.simplelogin.co [176.119.200.160]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "protonmail.com", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LjtrV2mn2z3Xvv for ; Wed, 13 Jul 2022 23:20:10 +0000 (UTC) (envelope-from sl.lmysyibvge3tcobrhe3syibsg44tgmrqlu.6e6oohdr67d6k@qoruscant.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qoruscant.com; s=dkim; t=1657754402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VAk7DnVx0njscwZqfaLBlVjqykGy2XvuLbnwq100xxw=; b=DBWPtCTSri/MZjQg8+qVncPOfR5sJClo/WTUclVMxFWJEzKgOFK60hOYXMHCRM4uv5d80G vp/mW6mHDGUAuyRVm0btgPYeSu3azyL8wL7fN7t8EAATfBeWbBlgqZiT1mswdyohB8IVAl amtD/gMJLMAXcHe9Q/ZhTU2xIyhJ5cI= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: Startup-/Shutdown Button for the Raspberry Pi 4 Date: Wed, 13 Jul 2022 18:19:57 -0500 In-Reply-To: From: Jedi Tek'Unum To: "Dr. Rolf Jansen" Cc: freebsd-arm@freebsd.org Message-ID: <165775440275.8.4265153478134935826.51718197@qoruscant.com> References: X-SimpleLogin-Type: Reply X-SimpleLogin-EmailLog-ID: 51718197 X-SimpleLogin-Want-Signing: yes X-Rspamd-Queue-Id: 4LjtrV2mn2z3Xvv X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=qoruscant.com header.s=dkim header.b=DBWPtCTS; dmarc=pass (policy=quarantine) header.from=qoruscant.com; spf=pass (mx1.freebsd.org: domain of sl.lmysyibvge3tcobrhe3syibsg44tgmrqlu.6e6oohdr67d6k@qoruscant.com designates 176.119.200.160 as permitted sender) smtp.mailfrom=sl.lmysyibvge3tcobrhe3syibsg44tgmrqlu.6e6oohdr67d6k@qoruscant.com X-Spamd-Result: default: False [-1.70 / 15.00]; MISSING_MIME_VERSION(2.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.998]; DMARC_POLICY_ALLOW(-0.50)[qoruscant.com,quarantine]; FORGED_SENDER(0.30)[freebsd-arm-list-2022-fea3@qoruscant.com,sl.lmysyibvge3tcobrhe3syibsg44tgmrqlu.6e6oohdr67d6k@qoruscant.com]; R_SPF_ALLOW(-0.20)[+ip4:176.119.200.160/29]; R_DKIM_ALLOW(-0.20)[qoruscant.com:s=dkim]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_ZERO(0.00)[0]; ASN(0.00)[asn:62371, ipnet:176.119.200.0/24, country:CH]; MLMMJ_DEST(0.00)[freebsd-arm]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_TRACE(0.00)[qoruscant.com:+]; FROM_NEQ_ENVFROM(0.00)[freebsd-arm-list-2022-fea3@qoruscant.com,sl.lmysyibvge3tcobrhe3syibsg44tgmrqlu.6e6oohdr67d6k@qoruscant.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N 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 > On Jul 12, 2022, at 8:17 PM, Dr. Rolf Jansen - freebsd-rj at cyclaero.com= wrote: >=20 > =EF=BB=BFOne week ago I started with exploring the Raspberry Pi 4 B, whic= h might be a substitute for the aging BeagleBone Blacks for my future proje= cts. >=20 > I very much like the built-in power button facility of the BBB, and unfor= tunately the RPi 4 has nothing comparable - the one button to rule it all. >=20 > I read a lot of howtos and blog posts (mostly for Linux) and nothing was = really worth to give it even a try, compared to live without the button. We= ll, this is not becoming an elaborated question, but here I am going to ela= borate my solution for FreeBSD. >=20 > 1. I Prepared a momentary push button for connecting it to the RPi: > ___=20 > | / > |/ > / > / > +-o o--------+ > | | | > | [R] 100 =CE=A9 | > | | | > o o o > Pin 5 Pin 6 Pin 13 > (SCL 1) (GND) (GPIO 27) Ok, I=E2=80=99ll bite. I=E2=80=99m not understanding this. I imagine that the resistor is a current limit for the gpio pin and not the= pullup. Regardless of how it is wired, why use SCL1 which is pulsing? And how can a= ny of this cause a boot? Is this =E2=80=9Cmagic=E2=80=9D dependent on some quirk(s) of RPi? Will it = work with others, like Rock64? > 2. I created a shutdown daemon in C for FreeBSD, lurking for push button > events on a GPIO port: https://github.com/cyclaero/shutdd >=20 > clang -g0 -O3 -fsigned-char -Wno-empty-body -Wno-parentheses shutdd.c -= lgpio -s -o /usr/local/bin/shutdd >=20 > shutdd [-p file] [-f] [-n] [-b] [-g] [-h] =20 > -p file the path to the pid file [default: /var/run/shutdd.pid] =20 > -f foreground mode, don't fork off as a daemon. =20 > -n no console, don't fork off as a daemon. =20 > -b GPIO bank id [default: 0]. =20 > -g GPIO line id [default: 27]. =20 > -h shows these usage instructions. =20 >=20 > echo "/usr/local/bin/shutdd" >> /etc/rc.local=20 >=20 > Restart and ready for testing the RPi's Power Button. >=20 > shutdd does not poll the state of the GPIO port, but instead utilizes Fre= eBSD's user space interface for GPIO interrupts for lurking on state change= s of the GPIO line - default GPIO.0.27. Therefore, no significant load is i= mposed on the CPU's. >=20 > After 2 hs of operation, in output of ps -ax: > ... > 550 - Is 0:00.03 /usr/local/bin/shutdd > ... >=20 > - No CPU load !!! >=20 > - Pressing the power button does the same as shutdown -p now >=20 > - Pressing the power button when the RPi is down but still connected to t= he 5 V power supply lets it starting up. >=20 > BTW, I left the RTC DS3231 on I2C 1. That means, the RTC and the power bu= tton share the same pins for SCL 1 and GND. >=20 >=20 >=20