From owner-freebsd-arm@freebsd.org Wed Aug 28 21:41:07 2019 Return-Path: Delivered-To: freebsd-arm@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5CA05E70B9 for ; Wed, 28 Aug 2019 21:41:07 +0000 (UTC) (envelope-from crowston@protonmail.com) Received: from mail4.protonmail.ch (mail4.protonmail.ch [185.70.40.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "protonmail.com", Issuer "SwissSign Server Gold CA 2014 - G22" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46JfLp2nbnz3Ggk for ; Wed, 28 Aug 2019 21:41:06 +0000 (UTC) (envelope-from crowston@protonmail.com) Date: Wed, 28 Aug 2019 21:40:57 +0000 To: "freebsd-arm@freebsd.org" From: Robert Crowston Cc: Mark Linimon , T W , Nick Wolff Reply-To: Robert Crowston Subject: Re: raspberry pi 4 Message-ID: In-Reply-To: References: <20190709161243.GC4904@mon.zyxst.net> <34BA723D-D603-4A09-9850-A88E644F0950@kronometrix.org> <20190812092026.GA1842@lonesome.com> Feedback-ID: 2OVbcR1yHYpdkD8cgQllkFwcuMVZg_LiVMMPvptooFDfHD_03MuQO4ZaF626jWHZYFEhNR2cmIbZ53j4QGWMBQ==:Ext:ProtonMail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch X-Rspamd-Queue-Id: 46JfLp2nbnz3Ggk X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.09 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; HAS_REPLYTO(0.00)[crowston@protonmail.com]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:185.70.40.0/24]; FREEMAIL_FROM(0.00)[protonmail.com]; DKIM_TRACE(0.00)[protonmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[protonmail.com,quarantine]; NEURAL_HAM_SHORT(-0.99)[-0.994,0]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; IP_SCORE(0.00)[ip: (-9.86), ipnet: 185.70.40.0/24(-4.90), asn: 19905(-3.92), country: US(-0.05)]; RCVD_IN_DNSWL_LOW(-0.10)[27.40.70.185.list.dnswl.org : 127.0.5.1]; ASN(0.00)[asn:19905, ipnet:185.70.40.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[protonmail.com:s=default]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; FREEMAIL_REPLYTO(0.00)[protonmail.com]; FREEMAIL_ENVFROM(0.00)[protonmail.com]; IP_SCORE_FREEMAIL(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[] X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Aug 2019 21:41:07 -0000 Alright, I hoped to have time to make this pretty but I didn't, so here is = what I have: You'll need an SD card with a ~ 50 MB FAT partition and plenty of space for= a UFS partition. You'll want the aarch64 gcc build tools. I did experiment with clang but it= was too much of a diversion. For multiprocessor support, you need this (note, I just updated Oleksandr T= ymoshenko's original work, no original thought was required): https://github.com/gonzoua/rpi3-psci-monitor/compare/master...RobCrowston:r= pi4 Compiling that will produce armstub8.bin. Put it on the SD card. Then you need to build u-boot. Again, just building on the work of others w= ith some small tweaks: https://github.com/RobCrowston/u-boot/tree/rpi4-freebsd Copy the built u-boot.bin onto the FAT partition. And copy the dt.dtb file = emitted to broadcom/bcm2711-rpi-4-b.dtb. Then you need to create a config.txt. Mine looks like this: arm_control=3D0x200 armstub=3Darmstub8.bin arm_64bit=3D1 enable_gic=3D1 device_tree_address=3D0x4000 enable_jtag_gpio=3D1 enable_uart=3D1 kernel=3Du-boot.bin Some of those lines may be redundant; e.g., you probably don't need jtag en= abled. Enabling uart here lets you interact with the boot sequence on your = serial line but has a weird side effect after boot (discussed below). Finally you need to grab the remaining files from the official rpi4 reposit= ory and place them on the SD card. Note they are not BSD licensed. bcm2711-rpi-4-b.dtb bootcode.bin fixup4.dat start4.elf I think(?) this is the minimum set to boot but you can always take the rest= if that's not enough. If you don't get the rainbow screen on the HDMI out,= you're missing something. Note that it seems you do need the official bcm2711-rpi-4-b.dtb in the root= of the partition, not the one compiled by u-boot, which you should put in = broadcom/. The pi4 seems to be pretty sensitive about wanting the original = dtb during pre-boot. FreeBSD will look into broadcom/bcm2711-rpi-4-b.dtb to= find the dtb it uses during boot, so after u-boot runs it will use the dtb= file you compiled. For the kernel sources, the only serious change I had to make was to the SD= card driver. I also had to comment out some code to make various things wo= rk, in particular I disabled DMA in the SD card driver for reasons unknown = and I removed the HTTP boot loader because u-boot passes a bad pointer to s= ome http-related functions which causes a segfault on boot. My kernel source is here: https://github.com/RobCrowston/freebsd/tree/rpi4-= sdhci I use the FreeBSD crochet tool against this source, to produce the UFS part= ition and the EFI/ directory for the FAT partition. If you set enable_uart=3D1 in config.txt and you boot with -D, there is a w= eird condition where immediately after /sbin/init runs, the serial speed on= the client needs to be doubled from 115200 to 230400. I assume that's some= thing to do with both freebsd and the firmware trying to do serial emulatio= n at the same time. I haven't had time to investigate. Caveats: most hardware still not working, including USB, PCI-E, and etherne= t. RAM detection is incorrect on my 2 GB Pi. Witness complains about lock r= eversals in the sd driver. Basically, we are some distance from tier 1. Robert Crowston. =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me= ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 On Monday, 12 August 2019 20:58, Nick Wolff wrote: > Robert, > > Definitely excited to see any patches or if you have a github branch that= even better. > > Thanks, > > Nick Wolff > > On Mon, Aug 12, 2019 at 5:20 AM Mark Linimon wrote= : > > > On Sun, Aug 11, 2019 at 10:14:33AM +0000, Robert Crowston via freebsd-a= rm wrote: > > > I don't know.=C2=A0 This is just a hobby.=C2=A0 I am not part of the = FreeBSD > > > Foundation. > > > > You don't have to be a member of the Foundation (or even employed there= ) > > to contribute to FreeBSD :-)=C2=A0 The Foundation exists to hold the co= pyrights, > > perform advoacy, own equipment, and so forth. > > > > Everything else is done by individual participants -- a few are funded = by > > the companies they work for, but the vast majority are individual volun= teer > > contributors. > > > > So if there are patches or documentation that can help move Rpi4 suppor= t > > along, please feel free to share them. > > > > mcl > > _______________________________________________ > > freebsd-arm@freebsd.org mailing list > > https://lists.freebsd.org/mailman/listinfo/freebsd-arm > > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org"