From nobody Sat May 13 02:58:14 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 4QJ9Lf6yRBz4Bmgl for ; Sat, 13 May 2023 02:58:34 +0000 (UTC) (envelope-from bscott@bunyatech.com.au) Received: from vmse03.mailcluster.com.au (vmse03.mailcluster.com.au [IPv6:2401:fc00:0:14::11]) (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 did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4QJ9Lb0mx7z4CgB for ; Sat, 13 May 2023 02:58:30 +0000 (UTC) (envelope-from bscott@bunyatech.com.au) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bunyatech.com.au header.s=default header.b=hu7ZLChR; spf=pass (mx1.freebsd.org: domain of bscott@bunyatech.com.au designates 2401:fc00:0:14::11 as permitted sender) smtp.mailfrom=bscott@bunyatech.com.au; dmarc=none Received: from vmcp43.digitalpacific.com.au ([101.0.119.58]) by vmse03.mailcluster.com.au with esmtps (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1pxfSb-0006Vf-GV for freebsd-arm@freebsd.org; Sat, 13 May 2023 12:58:23 +1000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=bunyatech.com.au; s=default; h=In-Reply-To:From:References:To:Subject: MIME-Version:Date:Message-ID:Content-Type:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=P2NYVYXlN5fHbgesSxr0vCF7Y4eTXtoMnDJS902/24s=; b=hu7ZLChRrzDcuMndHFn+4hcpGq jvmKRZ8xhTf6t61Dps0kxR2NgXRuV+0sJ6byWMr8G92akyQncCn5fMJgN/aYH5hM2dJk1t9945wDX PSGFboUmmvxUJf0bT6fF8PVjLM4/AdB3t8+HcY81Aj76Xj5uBHV9cpG+ng5/MLj60h9w+Ds6BSwlu z/MzDlVfJa2SnXjoU3xQ/+HTwoAMAY6c6F3hS0/hW7n3O0gbn6/0JDmMa9eV+21ULX7nJGhMmlusW 06Fyw8os71JubKo1B0A+EbbLRzc3xDvjoqm7zM2j5cbtm/97ghCB8GlE4elBtrGchq1YfJ55A/y4b pepHE5NA==; Received: from ppp221-139.static.internode.on.net ([150.101.221.139]:45397 helo=[10.0.1.197]) by vmcp43.digitalpacific.com.au with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1pxfSZ-009LMp-1H for freebsd-arm@freebsd.org; Sat, 13 May 2023 12:58:15 +1000 Content-Type: multipart/alternative; boundary="------------tgznBgeoe1oP6togsuOi0lFv" Message-ID: Date: Sat, 13 May 2023 12:58:14 +1000 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 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: Raspberry Pi POE+ hat overlay To: freebsd-arm@freebsd.org References: <77CD0716-3BC8-47EB-8743-F2BD9CA43D31@yahoo.com> <432A1A16-9FE5-4339-AB38-8F3E03A5D4EF@yahoo.com> From: Brian Scott In-Reply-To: <432A1A16-9FE5-4339-AB38-8F3E03A5D4EF@yahoo.com> X-Authenticated-User: bscott@bunyatech.com.au X-Authenticator: dovecot_plain X-Originating-IP: 101.0.119.58 X-SpamExperts-Domain: digipac-sh-outbound4.mailcluster.com.au X-SpamExperts-Username: 101.0.119.58 X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.01) X-Recommended-Action: accept X-Filter-ID: Pt3MvcO5N4iKaDQ5O6lkdGlMVN6RH8bjRMzItlySaT9g/w5wPCocGuxcdDqJPMg5PUtbdvnXkggZ 3YnVId/Y5jcf0yeVQAvfjHznO7+bT5wOvGg18h18lTsuUGH1KgAagLCWYuPCxwJEfxKP87A95+fH zJ6mVE7ewsipSVIfs4biUsQ8K1YIB5+wMA+S19kBABHVTw1lV42ob3hDgXVUNfMYOaf2k/5ge9xY pFnK4mEZANNbnYFKmAzb4T8ZHiCK+gaXrHkgRC7/tI3CjXmVyopDDA7s27T1ptzB417+I1gp8Gnm YnDDwZLHsvD3pj+LvuKTBmuOVTCmQ/b22sw+yoj/3DdQ0wDV188+gffZv/QAKQlQdTfwbSciar+2 JCMst0dEunmtVTQWqR0MJGYnYGBIZS4rRgm1GD0QN7Psq7kMoOLjGsRz/MUE6aIZoCcUNXR4aVG4 tVHU1Zldyy+zfdeiXSYiLTYFU2inszSuEYHdlUkt/DWy8vGLtXVYC5E2Ixfs2qKc0fhF4YMd0lwH wOXyY7DGIntSiB4r6Kj1fsj0vv0lYcA3KUCZ1xbWKiooCEhtIlNufemFbU3yy1ZWIMOHTNjJsV8U ZvUGC4qEZBLXzXmHaN80JC+nfH561Te/6BtpbmdpMLvM58ZB4GVvZfvg7iEFLP+SSY+Av5+AiC64 m+k59xMAqz9bfz2u3IufXgzJJmjXk7fyp6dRgNba53gXfHH8ghB3TJhRhCEqvojF4DEPUxAkEvKE S3Dwga/K50QJEfuYSa1oqImpgX99qcen5bW2mj7gpl+Nel82aV6t85jdQ1W7xM52M4KvSDibnd+2 AEC7XXwrqk2mM9pO7yAC7PGX5cs6w1Q8AODFgbv5QexkYW9lGrw8C7YdqgAuV5Om7ryjiSwbRKL6 mPH7a1z1pRXWhjh9fdbl44I0Df0hM4dsD4bDwITFGCwK76hQ6vxPb3kvW+FOj8dHBAEnPnyse24r Z04BTGPuKCWPMdaEOqqgRFGeEt6xotIlx57hKeDIpVo9Y8swg9vllynHi7u2NJscbLjsBWgbQir3 s7IISG0iU2596YVtTfLLVlYg24YpMwV2Qj6zr+H1W4fdfycpg/800vALz8mnE6wA706qGokY7okO g7HJIt1nJKmB0MxOKVrDfQzDgqFDumjx9w03a6SLNhJ6Q12/4jZa7jE= X-Report-Abuse-To: spam@vmse01.mailcluster.com.au X-Spamd-Result: default: False [-3.50 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-0.999]; NEURAL_HAM_SHORT(-1.00)[-0.999]; R_DKIM_ALLOW(-0.20)[bunyatech.com.au:s=default]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; RCVD_IN_DNSWL_NONE(0.00)[2401:fc00:0:14::11:from]; DKIM_TRACE(0.00)[bunyatech.com.au:+]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; BLOCKLISTDE_FAIL(0.00)[2401:fc00:0:14::11:server fail,150.101.221.139:server fail,101.0.119.58:server fail]; ASN(0.00)[asn:55803, ipnet:2401:fc00::/32, country:AU]; MLMMJ_DEST(0.00)[freebsd-arm@freebsd.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; HAS_XOIP(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DMARC_NA(0.00)[bunyatech.com.au]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MID_RHS_MATCH_FROM(0.00)[] X-Rspamd-Queue-Id: 4QJ9Lb0mx7z4CgB X-Spamd-Bar: --- X-ThisMailContainsUnwantedMimeParts: N This is a multi-part message in MIME format. --------------tgznBgeoe1oP6togsuOi0lFv Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit > [Note: The copy I got in E-mail does not show your message as having > been sent to the list. Not knowing why, I am just directly replying > instead of putting your content on the list. If you do send to the > list, feel free to include any of my content additions.] [Apologies, finally got covid and my brain is running on fumes in the tank and feels like somebody has snuck a basketball in with it.] On May 12, 2023, at 18:13, Brian Scott wrote: > On 13/5/2023 3:41 am, Mark Millard wrote: >> On May 12, 2023, at 10:19, Mark Millard wrote: >> >>> On May 12, 2023, at 10:11, Mark Millard wrote: >>> >>>> On May 12, 2023, at 09:38, Doug Rabson wrote: >>>> >>>>> On Fri, 12 May 2023 at 17:27, Mark Millard wrote: >>>>> On May 12, 2023, at 08:43, Doug Rabson wrote: >>>>> >>>>>> I have a pi4 with the official POE+ hat which I want to run FreeBSD on. One thing I noticed is that the fan doesn't run in FreeBSD so I decided to try and write a little driver for it. First step seems to be to load the corresponding devicetree overlay by adding something like this to /boot/msdos/config.txt: >>>>>> >>>>>> dtoverlay=rpi-poe-plus >>>>>> dtparam=poe_fan_temp0=45000,dtparam=poe_fan_temp0_hyst=3000 >>>>>> dtparam=poe_fan_temp1=50000,dtparam=poe_fan_temp1_hyst=3000 >>>>>> dtparam=poe_fan_temp2=62000,dtparam=poe_fan_temp2_hyst=4000 >>>>>> dtparam=poe_fan_temp3=70000,dtparam=poe_fan_temp3_hyst=5000 >>>>>> >>>>>> Unfortunately this is where I'm stuck - the overlay is not present in the final DTB given to the kernel so there isn't anything to hook a driver to. Are dtoverlays supposed to work on FreeBSD? >>>>> The RPi* firwmare version that FreeBSD has in ports and uses >>>>> in making snapshots and other images does not have that overlay: >>>>> >>>>> # ls -Tld /usr/local/share/rpi-firmware/overlays/rpi* >>>>> -rw-r--r-- 1 root wheel 489 Mar 3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-backlight.dtbo >>>>> -rw-r--r-- 1 root wheel 4081 Mar 3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-cirrus-wm5102.dtbo >>>>> -rw-r--r-- 1 root wheel 643 Mar 3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-dac.dtbo >>>>> -rw-r--r-- 1 root wheel 2574 Mar 3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-display.dtbo >>>>> -rw-r--r-- 1 root wheel 842 Mar 3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-ft5406.dtbo >>>>> -rw-r--r-- 1 root wheel 2937 Mar 3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-poe.dtbo >>>>> -rw-r--r-- 1 root wheel 771 Mar 3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-proto.dtbo >>>>> -rw-r--r-- 1 root wheel 893 Mar 3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-sense.dtbo >>>>> -rw-r--r-- 1 root wheel 567 Mar 3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-tv.dtbo >>>>> -rw-r--r-- 1 root wheel 1226 Mar 3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpivid-v4l2.dtbo >>>>> >>>>> You do not mention establishing a copy of overlays/rpi-poe-plus.dtbo . >>>>> >>>>> I copied the file from a rasbian install I had for another project. Perhaps I should find the corresponding source for it and build it with the device tree source from FreeBSD. >>>>> >>>>> You also do not mention what version of FreeBSD you are using >>>>> on the RPi4B. The output of the command: > I had a quick look at this a few months ago but seemed too hard for me. > > I now have the fan directly connected to the 5V lines and running full time. Not a bad idea in the Australian summer for a box that was sitting outside. I've even installed a second fan to keep the temperatures around 60C. All of that is my problems not yours. > > I just checked and I do have the overlay enabled (dtoverlay=rpi-poe) on a "13.2-STABLE stable/13-n255298-7dea7445ba44" system (built a week ago). > I'll note that recent enough stable/13 (going back a ways but not all the > way back to releng/13.2 being branched) has the kernel fix that avoids > crashing for more modern RPi* firmware, allowing potential experiments with > such. > > releng/14.0 should be the first RELEASE to have the fix. Later releng/13.3 > would be created and pick up the fix. Excellent. 14.0 also has the ds3231 etc fix. > The overlay is from the rpi-firmware port (rpi-firmware-1.20210303.g20210303). I see that I am not using the 'plus' version (my hat is a +) but also that my rpi-firmware package is quite ancient compared to those Mark was quoting. > 1.20210527/boot/overlays/rpi-poe-plus.dtbo > 1.20210727/boot/overlays/rpi-poe-plus.dtbo > 1.20210805/boot/overlays/rpi-poe-plus.dtbo > > are all from 2021 (May-27, Jul-27, Aug-05). They are the > first 3 officially tagged releases after the 1.20210303 > (2021-Mar-03) RPi* firmware that FreeBSD bundles in > RPi* snapshots and releases as things are. > > (The 2021-Jul-27 and 2021-Aug-05 being so close in time > suggests that 1.20210727 was a bad release.) > > For releng/13.2 , 1.20210805 may be the best option that > officially has an overlays/rpi-poe-plus.dtbo . I'll try updating (after a backup). I thought I had recently, see initial comment. > In devinfo -v I see: > > unknown pnpinfo name=rpi-poe-fan@0 compat=raspberrypi,rpi-poe-fan > > I can't find my old emails quickly but seem to recall a lack of documentation at the time for the chip in the POE+ device. There were a bunch of mystery registers tucked in after the storage area that were in an area that vendors could use for their own purposes. I.e. nothing documented. > > Good luck! > > Brian >>>>> I'm running 13.2-RELEASE-p0 >>>> That limits the range of firmware you can experiment with >>>> but the following tagged vintages should be compatible and >>>> also have an overlays/rpi-poe-plus.dtbo present: >>>> >>>> 1.20210527/boot/overlays/rpi-poe-plus.dtbo >>>> 1.20210727/boot/overlays/rpi-poe-plus.dtbo >>>> 1.20210805/boot/overlays/rpi-poe-plus.dtbo >>>> >>>> So extracting a consistent/full set of firmware and trying >>>> it is a possibility. >>>> >>>> The first 3 tags links on: >>>> >>>> https://github.com/raspberrypi/linux/tags?after=1.20210831 >> That was likely a wasteful reference for me to supply. Trying >> again: >> >> https://github.com/raspberrypi/firmware/tags?after=1.20210831 >> >> likely avoids ending up with a full set of linux materials >> to go along with the firmware (smaller download with a smaller >> expansion). >> >>>> are for the above 3 firmware versions. >>>> >>>> Anything newer will lead to a FreeBSD kernel crash for >>>> 13.2-RELEASE-p0 due to mishandling the .dtb file that >>>> would be used. >>>> >>>> As an example of what is in . . ./boot/ from one of those 3: >>>> >>>> # ls -Tld firmware-1.20210805/boot/* >>>> -rw-rw-r-- 1 root wheel 18693 Aug 5 04:11:18 2021 firmware-1.20210805/boot/COPYING.linux >>>> -rw-rw-r-- 1 root wheel 1594 Aug 5 04:11:18 2021 firmware-1.20210805/boot/LICENCE.broadcom >>>> -rw-rw-r-- 1 root wheel 26401 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2708-rpi-b-plus.dtb >>>> -rw-rw-r-- 1 root wheel 25749 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2708-rpi-b-rev1.dtb >>>> -rw-rw-r-- 1 root wheel 26138 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2708-rpi-b.dtb >>>> -rw-rw-r-- 1 root wheel 26060 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2708-rpi-cm.dtb >>>> -rw-rw-r-- 1 root wheel 27076 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2708-rpi-zero-w.dtb >>>> -rw-rw-r-- 1 root wheel 25883 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2708-rpi-zero.dtb >>>> -rw-rw-r-- 1 root wheel 27276 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2709-rpi-2-b.dtb >>>> -rw-rw-r-- 1 root wheel 27425 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2710-rpi-2-b.dtb >>>> -rw-rw-r-- 1 root wheel 29542 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2710-rpi-3-b-plus.dtb >>>> -rw-rw-r-- 1 root wheel 28923 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2710-rpi-3-b.dtb >>>> -rw-rw-r-- 1 root wheel 27421 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2710-rpi-cm3.dtb >>>> -rw-rw-r-- 1 root wheel 49825 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2711-rpi-4-b.dtb >>>> -rw-rw-r-- 1 root wheel 49821 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2711-rpi-400.dtb >>>> -rw-rw-r-- 1 root wheel 50499 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bcm2711-rpi-cm4.dtb >>>> -rw-rw-r-- 1 root wheel 52456 Aug 5 04:11:18 2021 firmware-1.20210805/boot/bootcode.bin >>>> -rw-rw-r-- 1 root wheel 7278 Aug 5 04:11:18 2021 firmware-1.20210805/boot/fixup.dat >>>> -rw-rw-r-- 1 root wheel 5407 Aug 5 04:11:18 2021 firmware-1.20210805/boot/fixup4.dat >>>> -rw-rw-r-- 1 root wheel 3211 Aug 5 04:11:18 2021 firmware-1.20210805/boot/fixup4cd.dat >>>> -rw-rw-r-- 1 root wheel 8416 Aug 5 04:11:18 2021 firmware-1.20210805/boot/fixup4db.dat >>>> -rw-rw-r-- 1 root wheel 8418 Aug 5 04:11:18 2021 firmware-1.20210805/boot/fixup4x.dat >>>> -rw-rw-r-- 1 root wheel 3211 Aug 5 04:11:18 2021 firmware-1.20210805/boot/fixup_cd.dat >>>> -rw-rw-r-- 1 root wheel 10262 Aug 5 04:11:18 2021 firmware-1.20210805/boot/fixup_db.dat >>>> -rw-rw-r-- 1 root wheel 10262 Aug 5 04:11:18 2021 firmware-1.20210805/boot/fixup_x.dat >>>> drwxrwxr-x 2 root wheel 236 Aug 5 04:11:18 2021 firmware-1.20210805/boot/overlays >>>> -rw-rw-r-- 1 root wheel 2959904 Aug 5 04:11:18 2021 firmware-1.20210805/boot/start.elf >>>> -rw-rw-r-- 1 root wheel 2235712 Aug 5 04:11:18 2021 firmware-1.20210805/boot/start4.elf >>>> -rw-rw-r-- 1 root wheel 799964 Aug 5 04:11:18 2021 firmware-1.20210805/boot/start4cd.elf >>>> -rw-rw-r-- 1 root wheel 3731528 Aug 5 04:11:18 2021 firmware-1.20210805/boot/start4db.elf >>>> -rw-rw-r-- 1 root wheel 2987720 Aug 5 04:11:18 2021 firmware-1.20210805/boot/start4x.elf >>>> -rw-rw-r-- 1 root wheel 799964 Aug 5 04:11:18 2021 firmware-1.20210805/boot/start_cd.elf >>>> -rw-rw-r-- 1 root wheel 4803496 Aug 5 04:11:18 2021 firmware-1.20210805/boot/start_db.elf >>>> -rw-rw-r-- 1 root wheel 3711432 Aug 5 04:11:18 2021 firmware-1.20210805/boot/start_x.elf >>> Note the lack of config.txt , armstub8-gic.bin , and >>> armstub8.bin . >>> >>>> (I'll not list the overlays/* .) >>>> >>>> I've no clue to the consequences of mixing and matching >>>> materials from different vintages of the firmware. It >>>> does appear that: >>>> >>>> 1.20210727/boot/overlays/rpi-poe-plus.dtbo >>>> 1.20210805/boot/overlays/rpi-poe-plus.dtbo >>>> >>>> (the newer 2 of th3 3) are the same by content but that: >>>> >>>> 1.20210527/boot/overlays/rpi-poe-plus.dtbo >>>> >>>> is distinct in its older content. >>> Be warned that the sys-utils/rpi-firmware port installs a >>> couple of files that are not based on >>> https://github.com/raspberrypi/ materials: >>> >>> # ls -Tld /boot/efi/armstub8* >>> -rwxr-xr-x 1 root wheel 5888 Apr 20 19:25:22 2022 /boot/efi/armstub8-gic.bin >>> -rwxr-xr-x 1 root wheel 5888 Apr 20 19:25:22 2022 /boot/efi/armstub8.bin (I was only showing the file naming. I used a more modern context to do that, which may have been confusing. Ignore the dates for those 2 files and that I used a mount point for where they are placed for live use.) >>> Be sure to keep those 2 files in place (for at least >>> armstub8-gic.bin ). A similar point goes for your >>> config.txt . === Mark Millard marklmi at yahoo.com --------------tgznBgeoe1oP6togsuOi0lFv Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit
[Note: The copy I got in E-mail does not show your message as having
been sent to the list. Not knowing why, I am just directly replying
instead of putting your content on the list. If you do send to the
list, feel free to include any of my content additions.]
[Apologies, finally got covid and my brain is running on fumes in the tank and feels like somebody has snuck a basketball in with it.] On May 12, 2023, at 18:13, Brian Scott <bscott@bunyatech.com.au> wrote:
On 13/5/2023 3:41 am, Mark Millard wrote:
On May 12, 2023, at 10:19, Mark Millard <marklmi@yahoo.com> wrote:

On May 12, 2023, at 10:11, Mark Millard <marklmi@yahoo.com> wrote:

On May 12, 2023, at 09:38, Doug Rabson <dfr@rabson.org> wrote:

On Fri, 12 May 2023 at 17:27, Mark Millard <marklmi@yahoo.com> wrote:
On May 12, 2023, at 08:43, Doug Rabson <dfr@rabson.org> wrote:

I have a pi4 with the official POE+ hat which I want to run FreeBSD on. One thing I noticed is that the fan doesn't run in FreeBSD so I decided to try and write a little driver for it. First step seems to be to load the corresponding devicetree overlay by adding something like this to /boot/msdos/config.txt:

dtoverlay=rpi-poe-plus
dtparam=poe_fan_temp0=45000,dtparam=poe_fan_temp0_hyst=3000
dtparam=poe_fan_temp1=50000,dtparam=poe_fan_temp1_hyst=3000
dtparam=poe_fan_temp2=62000,dtparam=poe_fan_temp2_hyst=4000
dtparam=poe_fan_temp3=70000,dtparam=poe_fan_temp3_hyst=5000

Unfortunately this is where I'm stuck - the overlay is not present in the final DTB given to the kernel so there isn't anything to hook a driver to. Are dtoverlays supposed to work on FreeBSD?
The RPi* firwmare version that FreeBSD has in ports and uses
in making snapshots and other images does not have that overlay:

# ls -Tld /usr/local/share/rpi-firmware/overlays/rpi*
-rw-r--r--  1 root  wheel   489 Mar  3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-backlight.dtbo
-rw-r--r--  1 root  wheel  4081 Mar  3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-cirrus-wm5102.dtbo
-rw-r--r--  1 root  wheel   643 Mar  3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-dac.dtbo
-rw-r--r--  1 root  wheel  2574 Mar  3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-display.dtbo
-rw-r--r--  1 root  wheel   842 Mar  3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-ft5406.dtbo
-rw-r--r--  1 root  wheel  2937 Mar  3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-poe.dtbo
-rw-r--r--  1 root  wheel   771 Mar  3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-proto.dtbo
-rw-r--r--  1 root  wheel   893 Mar  3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-sense.dtbo
-rw-r--r--  1 root  wheel   567 Mar  3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpi-tv.dtbo
-rw-r--r--  1 root  wheel  1226 Mar  3 05:29:57 2021 /usr/local/share/rpi-firmware/overlays/rpivid-v4l2.dtbo

You do not mention establishing a copy of overlays/rpi-poe-plus.dtbo .

I copied the file from a rasbian install I had for another project. Perhaps I should find the corresponding source for it and build it with the device tree source from FreeBSD.

You also do not mention what version of FreeBSD you are using
on the RPi4B. The output of the command:
I had a quick look at this a few months ago but seemed too hard for me.

I now have the fan directly connected to the 5V lines and running full time. Not a bad idea in the Australian summer for a box that was sitting outside. I've even installed a second fan to keep the temperatures around 60C. All of that is my problems not yours.

I just checked and I do have the overlay enabled (dtoverlay=rpi-poe) on a "13.2-STABLE stable/13-n255298-7dea7445ba44" system (built a week ago).
I'll note that recent enough stable/13 (going back a ways but not all the
way back to releng/13.2 being branched) has the kernel fix that avoids
crashing for more modern RPi* firmware, allowing potential experiments with
such.

releng/14.0 should be the first RELEASE to have the fix. Later releng/13.3
would be created and pick up the fix.
Excellent. 14.0 also has the ds3231 etc fix.
The overlay is from the rpi-firmware port (rpi-firmware-1.20210303.g20210303). I see that I am not using the 'plus' version (my hat is a +) but also that my rpi-firmware package is quite ancient compared to those Mark was quoting.
1.20210527/boot/overlays/rpi-poe-plus.dtbo
1.20210727/boot/overlays/rpi-poe-plus.dtbo
1.20210805/boot/overlays/rpi-poe-plus.dtbo

are all from 2021 (May-27, Jul-27, Aug-05). They are the
first 3 officially tagged releases after the 1.20210303
(2021-Mar-03) RPi* firmware that FreeBSD bundles in
RPi* snapshots and releases as things are.

(The 2021-Jul-27 and 2021-Aug-05 being so close in time
suggests that 1.20210727 was a bad release.)

For releng/13.2 , 1.20210805 may be the best option that
officially has an overlays/rpi-poe-plus.dtbo .
I'll try updating (after a backup). I thought I had recently, see initial comment.
In devinfo -v I see:

unknown pnpinfo name=rpi-poe-fan@0 compat=raspberrypi,rpi-poe-fan

I can't find my old emails quickly but seem to recall a lack of documentation at the time for the chip in the POE+ device. There were a bunch of mystery registers tucked in after the storage area that were in an area that vendors could use for their own purposes. I.e. nothing documented.

Good luck!

Brian
I'm running 13.2-RELEASE-p0
That limits the range of firmware you can experiment with
but the following tagged vintages should be compatible and
also have an overlays/rpi-poe-plus.dtbo present:

1.20210527/boot/overlays/rpi-poe-plus.dtbo
1.20210727/boot/overlays/rpi-poe-plus.dtbo
1.20210805/boot/overlays/rpi-poe-plus.dtbo

So extracting a consistent/full set of firmware and trying
it is a possibility.

The first 3 tags links on:

https://github.com/raspberrypi/linux/tags?after=1.20210831
That was likely a wasteful reference for me to supply. Trying
again:

https://github.com/raspberrypi/firmware/tags?after=1.20210831

likely avoids ending up with a full set of linux materials
to go along with the firmware (smaller download with a smaller
expansion).

are for the above 3 firmware versions.

Anything newer will lead to a FreeBSD kernel crash for
13.2-RELEASE-p0 due to mishandling the .dtb file that
would be used.

As an example of what is in . . ./boot/ from one of those 3:

# ls -Tld firmware-1.20210805/boot/*
-rw-rw-r--  1 root  wheel    18693 Aug  5 04:11:18 2021 firmware-1.20210805/boot/COPYING.linux
-rw-rw-r--  1 root  wheel     1594 Aug  5 04:11:18 2021 firmware-1.20210805/boot/LICENCE.broadcom
-rw-rw-r--  1 root  wheel    26401 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2708-rpi-b-plus.dtb
-rw-rw-r--  1 root  wheel    25749 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2708-rpi-b-rev1.dtb
-rw-rw-r--  1 root  wheel    26138 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2708-rpi-b.dtb
-rw-rw-r--  1 root  wheel    26060 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2708-rpi-cm.dtb
-rw-rw-r--  1 root  wheel    27076 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2708-rpi-zero-w.dtb
-rw-rw-r--  1 root  wheel    25883 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2708-rpi-zero.dtb
-rw-rw-r--  1 root  wheel    27276 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2709-rpi-2-b.dtb
-rw-rw-r--  1 root  wheel    27425 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2710-rpi-2-b.dtb
-rw-rw-r--  1 root  wheel    29542 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2710-rpi-3-b-plus.dtb
-rw-rw-r--  1 root  wheel    28923 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2710-rpi-3-b.dtb
-rw-rw-r--  1 root  wheel    27421 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2710-rpi-cm3.dtb
-rw-rw-r--  1 root  wheel    49825 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2711-rpi-4-b.dtb
-rw-rw-r--  1 root  wheel    49821 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2711-rpi-400.dtb
-rw-rw-r--  1 root  wheel    50499 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bcm2711-rpi-cm4.dtb
-rw-rw-r--  1 root  wheel    52456 Aug  5 04:11:18 2021 firmware-1.20210805/boot/bootcode.bin
-rw-rw-r--  1 root  wheel     7278 Aug  5 04:11:18 2021 firmware-1.20210805/boot/fixup.dat
-rw-rw-r--  1 root  wheel     5407 Aug  5 04:11:18 2021 firmware-1.20210805/boot/fixup4.dat
-rw-rw-r--  1 root  wheel     3211 Aug  5 04:11:18 2021 firmware-1.20210805/boot/fixup4cd.dat
-rw-rw-r--  1 root  wheel     8416 Aug  5 04:11:18 2021 firmware-1.20210805/boot/fixup4db.dat
-rw-rw-r--  1 root  wheel     8418 Aug  5 04:11:18 2021 firmware-1.20210805/boot/fixup4x.dat
-rw-rw-r--  1 root  wheel     3211 Aug  5 04:11:18 2021 firmware-1.20210805/boot/fixup_cd.dat
-rw-rw-r--  1 root  wheel    10262 Aug  5 04:11:18 2021 firmware-1.20210805/boot/fixup_db.dat
-rw-rw-r--  1 root  wheel    10262 Aug  5 04:11:18 2021 firmware-1.20210805/boot/fixup_x.dat
drwxrwxr-x  2 root  wheel      236 Aug  5 04:11:18 2021 firmware-1.20210805/boot/overlays
-rw-rw-r--  1 root  wheel  2959904 Aug  5 04:11:18 2021 firmware-1.20210805/boot/start.elf
-rw-rw-r--  1 root  wheel  2235712 Aug  5 04:11:18 2021 firmware-1.20210805/boot/start4.elf
-rw-rw-r--  1 root  wheel   799964 Aug  5 04:11:18 2021 firmware-1.20210805/boot/start4cd.elf
-rw-rw-r--  1 root  wheel  3731528 Aug  5 04:11:18 2021 firmware-1.20210805/boot/start4db.elf
-rw-rw-r--  1 root  wheel  2987720 Aug  5 04:11:18 2021 firmware-1.20210805/boot/start4x.elf
-rw-rw-r--  1 root  wheel   799964 Aug  5 04:11:18 2021 firmware-1.20210805/boot/start_cd.elf
-rw-rw-r--  1 root  wheel  4803496 Aug  5 04:11:18 2021 firmware-1.20210805/boot/start_db.elf
-rw-rw-r--  1 root  wheel  3711432 Aug  5 04:11:18 2021 firmware-1.20210805/boot/start_x.elf
Note the lack of config.txt , armstub8-gic.bin , and
armstub8.bin .

(I'll not list the overlays/* .)

I've no clue to the consequences of mixing and matching
materials from different vintages of the firmware. It
does appear that:

1.20210727/boot/overlays/rpi-poe-plus.dtbo
1.20210805/boot/overlays/rpi-poe-plus.dtbo

(the newer 2 of th3 3) are the same by content but that:

1.20210527/boot/overlays/rpi-poe-plus.dtbo

is distinct in its older content.
Be warned that the sys-utils/rpi-firmware port installs a
couple of files that are not based on
https://github.com/raspberrypi/ materials:

# ls -Tld /boot/efi/armstub8*
-rwxr-xr-x  1 root  wheel  5888 Apr 20 19:25:22 2022 /boot/efi/armstub8-gic.bin
-rwxr-xr-x  1 root  wheel  5888 Apr 20 19:25:22 2022 /boot/efi/armstub8.bin
(I was only showing the file naming. I used a more modern
context to do that, which may have been confusing. Ignore
the dates for those 2 files and that I used a mount point
for where they are placed for live use.)

Be sure to keep those 2 files in place (for at least
armstub8-gic.bin ). A similar point goes for your
config.txt .

      
===
Mark Millard
marklmi at yahoo.com

--------------tgznBgeoe1oP6togsuOi0lFv--