Date: Sat, 11 Mar 2017 12:17:58 -0700 From: Ian Lepore <ian@freebsd.org> To: Shawn Webb <shawn.webb@hardenedbsd.org> Cc: freebsd-arm@freebsd.org Subject: Re: Odd-looking serial console prompt on RPI2 Message-ID: <1489259878.40576.62.camel@freebsd.org> In-Reply-To: <20170311180947.ro5obisuaemvudkp@mutt-hbsd> References: <20170302000334.GA99403@www.zefox.net> <1488419304.60166.26.camel@freebsd.org> <20170302020116.GA98466@bluezbox.com> <1488420309.60166.32.camel@freebsd.org> <CA%2B7sy7Bv=-2mx2MJP18ZnbNp2yO2hKukw=KALn711txaxsk=rg@mail.gmail.com> <1488664965.69705.24.camel@freebsd.org> <20170307190937.r7n45xj67tnhevv4@mutt-hbsd> <20170307192918.2garie2ow6lzekg7@mutt-hbsd> <20170311174940.bze4k7ndjdemmu4l@mutt-hbsd> <1489255444.40576.57.camel@freebsd.org> <20170311180947.ro5obisuaemvudkp@mutt-hbsd>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-q+0yLMX7JzA43d2N+dSS Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit On Sat, 2017-03-11 at 13:09 -0500, Shawn Webb wrote: > On Sat, Mar 11, 2017 at 11:04:04AM -0700, Ian Lepore wrote: > > > > On Sat, 2017-03-11 at 12:49 -0500, Shawn Webb wrote: > > > > > > On Tue, Mar 07, 2017 at 02:29:18PM -0500, Shawn Webb wrote: > > > > > > > > > > > > On Tue, Mar 07, 2017 at 02:09:37PM -0500, Shawn Webb wrote: > > > > > > > > > > > > > > > On Sat, Mar 04, 2017 at 03:02:45PM -0700, Ian Lepore wrote: > > > > > > > > > > > > > > > > > > The bugs should be fixed as of r314682. ?It looks like the > > > > > > bugs > > > > > > have > > > > > > long been in the pl011 driver, but were masked by having a > > > > > > fifo > > > > > > depth > > > > > > of 1 byte -- it all sorta worked by accident previously. > > > > > Thanks for the fix! But it looks to be only partial. When I > > > > > connect to > > > > > the serial console via either cu or screen, I don't get > > > > > corrupted > > > > > text, > > > > > but no keypresses are registered. Hitting enter at the login > > > > > prompt does > > > > > absolutely nothing. I'm at the latest commit of > > > > > hardened/current/master > > > > > on HardenedBSD for both the RPI3 and my laptop. > > > > > > > > > > I'm using this serial cable from Adafruit: > > > > > https://www.adafruit.com/product/954 > > > > It looks like I had a bad cable. Sorry for the line noise. > > > > Switching to > > > > a different cable worked. > > > Looks like the problem is back, but manifest in a different way. > > > Screenshot: > > > > > > https://goo.gl/photos/XYx6v1jCTVCGrnhd6 > > > > > > Thanks, > > > > > I wonder if rpi3 needs the same smaller-fifo fix as a 32-bit rpi. > > ?Just > > to test that theory, can you see if the attached patch fixes > > problem? > > ?If it does, I'll figure out how to detect rpi3 at runtime and set > > the > > sizes properly. > > > > -- Ian > > > > Index: sys/dev/uart/uart_dev_pl011.c > > =================================================================== > > --- sys/dev/uart/uart_dev_pl011.c (revision 314917) > > +++ sys/dev/uart/uart_dev_pl011.c (working copy) > > @@ -464,7 +464,7 @@ uart_pl011_bus_probe(struct uart_softc *sc) > > is_bcm2835 = ofw_bus_is_compatible(sc->sc_dev, > > "brcm,bcm2835-pl011") || > > ofw_bus_is_compatible(sc->sc_dev, "broadcom,bcm2835- > > uart"); > > #else > > - is_bcm2835 = false; > > + is_bcm2835 = true; > > #endif > > hwrev = __uart_getreg(&sc->sc_bas, UART_PIDREG_2) >> 4; > > if (hwrev <= 2 || is_bcm2835) { > Sure. I'll report back either tonight or tomorrow. > > Thanks, > Actually, I think a proper solution will be something like the attached patch. After some spelunking on the web I think the rpi3 fifos are the smaller size because the fdt data contains the linux-style workaround (which overrides the primecell periphid value with fdt data). This patch looks for that in addition to looking for the rpi compatible strings (still required to handle old-style freebsd fdt data). -- Ian --=-q+0yLMX7JzA43d2N+dSS Content-Disposition: inline; filename="uart_pl011_fifosizes_rpi.diff" Content-Type: text/x-patch; name="uart_pl011_fifosizes_rpi.diff"; charset="us-ascii" Content-Transfer-Encoding: 7bit Index: sys/dev/uart/uart_dev_pl011.c =================================================================== --- sys/dev/uart/uart_dev_pl011.c (revision 314917) +++ sys/dev/uart/uart_dev_pl011.c (working copy) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <dev/uart/uart_cpu.h> #ifdef FDT #include <dev/uart/uart_cpu_fdt.h> +#include <dev/ofw/ofw_bus.h> #endif #include <dev/uart/uart_bus.h> #include "uart_if.h" @@ -449,25 +450,36 @@ static int uart_pl011_bus_probe(struct uart_softc *sc) { uint8_t hwrev; - bool is_bcm2835; +#ifdef FDT + pcell_t node; + uint32_t periphid; - device_set_desc(sc->sc_dev, "PrimeCell UART (PL011)"); - /* * The FIFO sizes vary depending on hardware; rev 2 and below have 16 - * byte FIFOs, rev 3 and up are 32 byte. We get a bit of drama, as - * always, with the bcm2835 (rpi), which claims to be rev 3, but has 16 - * byte FIFOs. We check for both the old freebsd-historic and the - * proper bindings-defined compatible strings for bcm2835. + * byte FIFOs, rev 3 and up are 32 byte. The hardware rev is in the + * primecell periphid register, but we get a bit of drama, as always, + * with the bcm2835 (rpi), which claims to be rev 3, but has 16 byte + * FIFOs. We check for both the old freebsd-historic and the proper + * bindings-defined compatible strings for bcm2835, and also check the + * workaround the linux drivers use for rpi3, which is to override the + * primecell periphid register value with a property. */ -#ifdef FDT - is_bcm2835 = ofw_bus_is_compatible(sc->sc_dev, "brcm,bcm2835-pl011") || - ofw_bus_is_compatible(sc->sc_dev, "broadcom,bcm2835-uart"); + if (ofw_bus_is_compatible(sc->sc_dev, "brcm,bcm2835-pl011") || + ofw_bus_is_compatible(sc->sc_dev, "broadcom,bcm2835-uart")) { + hwrev = 2; + } else { + node = ofw_bus_get_node(sc->sc_dev); + if (OF_getencprop(node, "arm,primecell-periphid", &periphid, + sizeof(periphid)) > 0) { + hwrev = (periphid >> 20) & 0x0f; + } else { + hwrev = __uart_getreg(&sc->sc_bas, UART_PIDREG_2) >> 4; + } + } #else - is_bcm2835 = false; + hwrev = __uart_getreg(&sc->sc_bas, UART_PIDREG_2) >> 4; #endif - hwrev = __uart_getreg(&sc->sc_bas, UART_PIDREG_2) >> 4; - if (hwrev <= 2 || is_bcm2835) { + if (hwrev <= 2) { sc->sc_rxfifosz = FIFO_RX_SIZE_R2; sc->sc_txfifosz = FIFO_TX_SIZE_R2; } else { @@ -475,6 +487,8 @@ uart_pl011_bus_probe(struct uart_softc *sc) sc->sc_txfifosz = FIFO_TX_SIZE_R3; } + device_set_desc(sc->sc_dev, "PrimeCell UART (PL011)"); + return (0); } --=-q+0yLMX7JzA43d2N+dSS--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1489259878.40576.62.camel>