Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Mar 2022 12:57:26 +0800
From:      Archimedes Gaviola <archimedes.gaviola@gmail.com>
To:        Hans Petter Selasky <hps@selasky.org>
Cc:        freebsd-arm@freebsd.org
Subject:   Re: Raspberry Pi 3B USB Printing Issue
Message-ID:  <CAJFbk7G_SVcoH4pak4SvNp0EYsbU_i4LiNZ6HyEDrmxAPvviUg@mail.gmail.com>
In-Reply-To: <CAJFbk7EutGbB-LoHxN_mUZbSb70C8yjxfZBADvejuCLwTcD5FA@mail.gmail.com>
References:  <CAJFbk7EzSfPNbaGxiweKrivwNrKXCPVzA1b7_=0_bTvbs8oBow@mail.gmail.com> <7c67118e-f6ec-c87d-9a81-3ee6a5952f49@selasky.org> <CAJFbk7GYbLAFTJY077Nzh3CTBJM6bk8swr4AkgGMaukCxrfcHQ@mail.gmail.com> <60f98b10-dcdc-cdf4-3d7a-fe9fd4dff223@selasky.org> <CAJFbk7EAjrQG5Kj_upVKW72opOS%2B8d63VrMnQdLxcJjUcfsd=g@mail.gmail.com> <8226461b-5740-9c19-0575-2740bd952e16@selasky.org> <CAJFbk7GwjFA-=GrJG3KTCnqVfEPhRSY1g8xyws_nE8pAohErEg@mail.gmail.com> <dabb798c-435c-6dd3-ac9b-8db3fb02a43c@selasky.org> <CAJFbk7FFeNTKvbNMr41kkwwYtyamJybTzk3=DQB1Hg3z%2Bx2hgQ@mail.gmail.com> <CAJFbk7GZF4ahORzCUKaLZS4b=fCJQbEADPJmMYZjyaJwRR%2Bhbw@mail.gmail.com> <CAJFbk7Fxz24r73AzHGhZHHKYwyHLqn-HCpiCpsAi4D-E6oKtKg@mail.gmail.com> <7a77e3bd-1186-56a6-e60e-89e51c190a01@selasky.org> <CAJFbk7EutGbB-LoHxN_mUZbSb70C8yjxfZBADvejuCLwTcD5FA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000c7449305da3aa2b0
Content-Type: text/plain; charset="UTF-8"

On Mon, Mar 14, 2022 at 6:12 PM Archimedes Gaviola <
archimedes.gaviola@gmail.com> wrote:

>
>
> On Mon, Mar 14, 2022 at 5:31 PM Hans Petter Selasky <hps@selasky.org>
> wrote:
>
>> On 3/14/22 10:20, Archimedes Gaviola wrote:
>> > On Sun, Mar 13, 2022 at 11:25 PM Archimedes Gaviola <
>> > archimedes.gaviola@gmail.com> wrote:
>> >
>> >>
>> >>
>> >> On Sun, Mar 13, 2022 at 2:27 PM Archimedes Gaviola <
>> >> archimedes.gaviola@gmail.com> wrote:
>> >>
>> >>>
>> >>>
>> >>> On Sun, Mar 13, 2022 at 12:38 AM Hans Petter Selasky <hps@selasky.org
>> >
>> >>> wrote:
>> >>>
>> >>>> On 3/12/22 16:31, Archimedes Gaviola wrote:
>> >>>>>>
>> >>>>>> IOERROR usually means an electrical error. The RPI3B will use a
>> >>>>>> transaction translator for the FULL speed traffic, which is driven
>> by
>> >>>>>> software.
>> >>>>>
>> >>>>
>> >>>> Hi Archimedes,
>> >>>>
>> >>>>> Hi Hans,
>> >>>>>
>> >>>>> I'm curious about the transaction translator you've mentioned, any
>> >>>> idea why
>> >>>>> there's a need for translation and what is being translated?
>> >>>>
>> >>>> When the High Speed USB HUB was invented, there was a need to support
>> >>>> FULL and LOW speed USB transactions. Because FULL and LOW speed
>> >>>> transactions are slow and take up much bandwidth, a transactions
>> >>>> translator was invented which translates between High Speed USB and
>> >>>> FULL/LOW speed USB. That means the RPi 3B consists of a single USB
>> HIGH
>> >>>> speed port, followed by a USB HUB. These transactions are not
>> visible in
>> >>>> usbdump .
>> >>>>
>> >>>>   >Does this only
>> >>>>> happen when RPi 3B (acting as host controller) is transmitting data
>> to
>> >>>> the
>> >>>>> Epson printer? Are translation events visible in the usbdump? In
>> this
>> >>>> case
>> >>>>> there's a way to possibly track what's going on and how to identify
>> any
>> >>>>> info that is being translated?
>> >>>>
>> >>>> By turning on the HC debugging, you can possibly track via debug
>> >>>> messages what is going on. Maybe it is a timing issue, that the SW is
>> >>>> too slow serving the micro transactions.
>> >>>>
>> >>>> Any idea also if translation is being
>> >>>>> performed in RPi 4B?
>> >>>>
>> >>>> The later RPi's do the transaction translator bits in HW or via the
>> XHCI
>> >>>> block.
>> >>>>
>> >>>> As I have conducted several printing cases with my
>> >>>>> Epson printer without any issues with either of the 4 ports.
>> >>>>>
>> >>>>> Sorry for these questions as I am catching-up to the USB technology
>> >>>>> internal workings under the hood.
>> >>>>
>> >>>> You are welcome!
>> >>>>
>> >>>
>> >>>
>> >>> Thank you so much Hans for answering my questions, really appreciate
>> it!
>> >>> I have a much better understanding now.
>> >>>
>> >>> I came from testing with 13.0-RELEASE having the same RPi 3B hardware
>> and
>> >>> setup and it's very stable. I haven't encountered any IOERROR and
>> >>> incomplete printed outputs that were encountered with 14.0-CURRENT
>> >>> (February 24, 2022). By the way, I found in the repository here
>> >>> https://download.freebsd.org/snapshots/arm64/aarch64/ISO-IMAGES/14.0/
>> >>> that there were two latest snapshots released dated March 3 and March
>> 10,
>> >>> respectively. I need to take printing tests first, especially the
>> latest to
>> >>> check if it also manifests before I go back to the Feb. 24 snapshot
>> and do
>> >>> a thorough test with debugging. I'll provide updates for any
>> observations.
>> >>>
>> >>> Thanks,
>> >>> Archimedes
>> >>>
>> >>
>> >>
>> >> Hi Hans,
>> >>
>> >> Initial testing conducted with the latest 14.0-CURRENT (March 10, 2022
>> >> snapshot) seems to be stable. Another test will be performed tomorrow.
>> >>
>> >> Thanks,
>> >> Archimedes
>> >>
>> >
>> > Hi Hans,
>> >
>> > I still encountered the issue this morning with 14.0-CURRENT (March 10,
>> > 2022 snapshot). I just noticed when I left my RPi 3B idle for a long
>> period
>> > of time (2-3 hours and more) and started printing, then the issue
>> pops-up.
>> > Another concern I encountered was when I started enabling
>> > hw.usb.dwc_otg.debug but after 1-2 minutes my USB keyboard and network
>> > interface (remotely connected over SSH from my laptop) seemed to freeze
>> and
>> > I got disconnected.
>> >
>> > freebsd@generic:~ % uname -a
>> > FreeBSD generic 14.0-CURRENT FreeBSD 14.0-CURRENT #0
>> > main-n253697-f1d450ddee6: Thu Mar 10 09:32:38 UTC 2022
>> > root@releng1.nyi.freebsd.org:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC
>> > arm64
>> >
>> > root@generic:~ # sysctl -w hw.usb.dwc_otg.debug=1
>> > hw.usb.dwc_otg.debug: 0 -> 1
>> >
>> > See attached initial debug info (no printing testing yet).
>>
>
>
> Hi Hans,
>
>
>>
>> Hi,
>>
>> Nothing obvious there.
>>
>> Maybe you need to add a conditional to DPRINTF's in the fast path, to
>> only print for a certain device, to reduce the debug prints.
>>
>> How many USB devices are connected?
>>
>
> Only two devices, one is my USB keyboard and the other one is my Epson
> printer.
>
>
>>
>> One experiment you might try is to comment out:
>>
>> usbd_transfer_submit(xfer);
>>
>> in
>>
>> uhub_intr_callback()
>>
>> in
>>
>> /usr/src/sys/dev/usb/usb_hub.c
>>
>> It will save some USB resources, but also makes USB enumeration a bit
>> slower.
>
>
> This is noted, I'll try.
>
>
>> Maybe the chip is out of USB HW endpoints and is only polling
>> for RX data ...
>>
>
> This is noted as well, we'll probably see later what's going on. I'll get
> back to you once I recompile the kernel and perform the testing.
>
> Thanks,
> Archimedes
>


Hi Hans,

I did comment-out usbd_transfer_submit(xfer) and still the same behavior is
experienced when hw.usb.dwc_otg.debug is enabled. The system seems to
freeze as my USB keyboard is unresponsive and I cannot connect over the
Ethernet NIC with SSH. I can't print and capture.

freebsd@generic:/usr/src/sys/dev/usb % diff -Nur usb_hub.c.orig usb_hub.c
--- usb_hub.c.orig      2022-03-14 22:37:03.162678000 +0800
+++ usb_hub.c   2022-03-14 22:38:23.832660000 +0800
@@ -202,7 +202,7 @@

        case USB_ST_SETUP:
                usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
-               usbd_transfer_submit(xfer);
+               /* usbd_transfer_submit(xfer); */
                break;

Let me know our next step.

Thanks,
Archimedes

--000000000000c7449305da3aa2b0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Mon, Mar 14, 2022 at 6:12 PM Archi=
medes Gaviola &lt;<a href=3D"mailto:archimedes.gaviola@gmail.com">archimede=
s.gaviola@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quot=
e" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)=
;padding-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div cla=
ss=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Mon, Mar 14, 20=
22 at 5:31 PM Hans Petter Selasky &lt;<a href=3D"mailto:hps@selasky.org" ta=
rget=3D"_blank">hps@selasky.org</a>&gt; wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex">On 3/14/22 10:20, Archimedes Gaviola wrote=
:<br>
&gt; On Sun, Mar 13, 2022 at 11:25 PM Archimedes Gaviola &lt;<br>
&gt; <a href=3D"mailto:archimedes.gaviola@gmail.com" target=3D"_blank">arch=
imedes.gaviola@gmail.com</a>&gt; wrote:<br>
&gt; <br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Sun, Mar 13, 2022 at 2:27 PM Archimedes Gaviola &lt;<br>
&gt;&gt; <a href=3D"mailto:archimedes.gaviola@gmail.com" target=3D"_blank">=
archimedes.gaviola@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Sun, Mar 13, 2022 at 12:38 AM Hans Petter Selasky &lt;<a hr=
ef=3D"mailto:hps@selasky.org" target=3D"_blank">hps@selasky.org</a>&gt;<br>
&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On 3/12/22 16:31, Archimedes Gaviola wrote:<br>
&gt;&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;&gt; IOERROR usually means an electrical error. The RPI=
3B will use a<br>
&gt;&gt;&gt;&gt;&gt;&gt; transaction translator for the FULL speed traffic,=
 which is driven by<br>
&gt;&gt;&gt;&gt;&gt;&gt; software.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Hi Archimedes,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Hi Hans,<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I&#39;m curious about the transaction translator you&#=
39;ve mentioned, any<br>
&gt;&gt;&gt;&gt; idea why<br>
&gt;&gt;&gt;&gt;&gt; there&#39;s a need for translation and what is being t=
ranslated?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; When the High Speed USB HUB was invented, there was a need=
 to support<br>
&gt;&gt;&gt;&gt; FULL and LOW speed USB transactions. Because FULL and LOW =
speed<br>
&gt;&gt;&gt;&gt; transactions are slow and take up much bandwidth, a transa=
ctions<br>
&gt;&gt;&gt;&gt; translator was invented which translates between High Spee=
d USB and<br>
&gt;&gt;&gt;&gt; FULL/LOW speed USB. That means the RPi 3B consists of a si=
ngle USB HIGH<br>
&gt;&gt;&gt;&gt; speed port, followed by a USB HUB. These transactions are =
not visible in<br>
&gt;&gt;&gt;&gt; usbdump .<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;=C2=A0 =C2=A0&gt;Does this only<br>
&gt;&gt;&gt;&gt;&gt; happen when RPi 3B (acting as host controller) is tran=
smitting data to<br>
&gt;&gt;&gt;&gt; the<br>
&gt;&gt;&gt;&gt;&gt; Epson printer? Are translation events visible in the u=
sbdump? In this<br>
&gt;&gt;&gt;&gt; case<br>
&gt;&gt;&gt;&gt;&gt; there&#39;s a way to possibly track what&#39;s going o=
n and how to identify any<br>
&gt;&gt;&gt;&gt;&gt; info that is being translated?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; By turning on the HC debugging, you can possibly track via=
 debug<br>
&gt;&gt;&gt;&gt; messages what is going on. Maybe it is a timing issue, tha=
t the SW is<br>
&gt;&gt;&gt;&gt; too slow serving the micro transactions.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Any idea also if translation is being<br>
&gt;&gt;&gt;&gt;&gt; performed in RPi 4B?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; The later RPi&#39;s do the transaction translator bits in =
HW or via the XHCI<br>
&gt;&gt;&gt;&gt; block.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; As I have conducted several printing cases with my<br>
&gt;&gt;&gt;&gt;&gt; Epson printer without any issues with either of the 4 =
ports.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Sorry for these questions as I am catching-up to the U=
SB technology<br>
&gt;&gt;&gt;&gt;&gt; internal workings under the hood.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; You are welcome!<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Thank you so much Hans for answering my questions, really appr=
eciate it!<br>
&gt;&gt;&gt; I have a much better understanding now.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I came from testing with 13.0-RELEASE having the same RPi 3B h=
ardware and<br>
&gt;&gt;&gt; setup and it&#39;s very stable. I haven&#39;t encountered any =
IOERROR and<br>
&gt;&gt;&gt; incomplete printed outputs that were encountered with 14.0-CUR=
RENT<br>
&gt;&gt;&gt; (February 24, 2022). By the way, I found in the repository her=
e<br>
&gt;&gt;&gt; <a href=3D"https://download.freebsd.org/snapshots/arm64/aarch6=
4/ISO-IMAGES/14.0/" rel=3D"noreferrer" target=3D"_blank">https://download.f=
reebsd.org/snapshots/arm64/aarch64/ISO-IMAGES/14.0/</a><br>
&gt;&gt;&gt; that there were two latest snapshots released dated March 3 an=
d March 10,<br>
&gt;&gt;&gt; respectively. I need to take printing tests first, especially =
the latest to<br>
&gt;&gt;&gt; check if it also manifests before I go back to the Feb. 24 sna=
pshot and do<br>
&gt;&gt;&gt; a thorough test with debugging. I&#39;ll provide updates for a=
ny observations.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Thanks,<br>
&gt;&gt;&gt; Archimedes<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Hi Hans,<br>
&gt;&gt;<br>
&gt;&gt; Initial testing conducted with the latest 14.0-CURRENT (March 10, =
2022<br>
&gt;&gt; snapshot) seems to be stable. Another test will be performed tomor=
row.<br>
&gt;&gt;<br>
&gt;&gt; Thanks,<br>
&gt;&gt; Archimedes<br>
&gt;&gt;<br>
&gt; <br>
&gt; Hi Hans,<br>
&gt; <br>
&gt; I still encountered the issue this morning with 14.0-CURRENT (March 10=
,<br>
&gt; 2022 snapshot). I just noticed when I left my RPi 3B idle for a long p=
eriod<br>
&gt; of time (2-3 hours and more) and started printing, then the issue pops=
-up.<br>
&gt; Another concern I encountered was when I started enabling<br>
&gt; hw.usb.dwc_otg.debug but after 1-2 minutes my USB keyboard and network=
<br>
&gt; interface (remotely connected over SSH from my laptop) seemed to freez=
e and<br>
&gt; I got disconnected.<br>
&gt; <br>
&gt; freebsd@generic:~ % uname -a<br>
&gt; FreeBSD generic 14.0-CURRENT FreeBSD 14.0-CURRENT #0<br>
&gt; main-n253697-f1d450ddee6: Thu Mar 10 09:32:38 UTC 2022<br>
&gt; root@releng1.nyi.freebsd.org:/usr/obj/usr/src/arm64.aarch64/sys/GENERI=
C<br>
&gt; arm64<br>
&gt; <br>
&gt; root@generic:~ # sysctl -w hw.usb.dwc_otg.debug=3D1<br>
&gt; hw.usb.dwc_otg.debug: 0 -&gt; 1<br>
&gt; <br>
&gt; See attached initial debug info (no printing testing yet).<br></blockq=
uote><div><br></div><div><br></div><div>Hi Hans,</div><div>=C2=A0<br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Hi,<br>
<br>
Nothing obvious there.<br>
<br>
Maybe you need to add a conditional to DPRINTF&#39;s in the fast path, to <=
br>
only print for a certain device, to reduce the debug prints.<br>
<br>
How many USB devices are connected?<br></blockquote><div><br></div><div>Onl=
y two devices, one is my USB keyboard and the other one is my Epson printer=
.</div><div>=C2=A0<br></div><blockquote class=3D"gmail_quote" style=3D"marg=
in:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1e=
x">
<br>
One experiment you might try is to comment out:<br>
<br>
usbd_transfer_submit(xfer);<br>
<br>
in<br>
<br>
uhub_intr_callback()<br>
<br>
in<br>
<br>
/usr/src/sys/dev/usb/usb_hub.c<br>
<br>
It will save some USB resources, but also makes USB enumeration a bit <br>
slower. </blockquote><div><br></div><div>This is noted, I&#39;ll try.<br></=
div><div>=C2=A0<br></div><blockquote class=3D"gmail_quote" style=3D"margin:=
0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">=
Maybe the chip is out of USB HW endpoints and is only polling <br>
for RX data ...<br></blockquote><div><br></div><div>This is noted as well, =
we&#39;ll probably see later what&#39;s going on. I&#39;ll get back to you =
once I recompile the kernel and perform the testing.</div><div><br></div><d=
iv>Thanks,</div><div>Archimedes<br></div></div></div></blockquote><div><br>=
</div><div><br></div><div>Hi Hans,</div><div><br></div><div>I did comment-o=
ut=20
usbd_transfer_submit(xfer) and still the same behavior is experienced when =
hw.usb.dwc_otg.debug is enabled. The system seems to freeze as my USB keybo=
ard is unresponsive and I cannot connect over the Ethernet NIC with SSH. I =
can&#39;t print and capture.<br></div><div><br></div><div>freebsd@generic:/=
usr/src/sys/dev/usb % diff -Nur usb_hub.c.orig usb_hub.c<br>--- usb_hub.c.o=
rig =C2=A0 =C2=A0 =C2=A02022-03-14 22:37:03.162678000 +0800<br>+++ usb_hub.=
c =C2=A0 2022-03-14 22:38:23.832660000 +0800<br>@@ -202,7 +202,7 @@<br><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 case USB_ST_SETUP:<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_=
max_len(xfer));<br>- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 usbd_=
transfer_submit(xfer);<br>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 /* usbd_transfer_submit(xfer); */<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 break;</div><div><br></div><div>Let me know our next =
step.</div><div><br></div><div>Thanks,</div><div>Archimedes<br></div><div>=
=C2=A0</div></div></div>

--000000000000c7449305da3aa2b0--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJFbk7G_SVcoH4pak4SvNp0EYsbU_i4LiNZ6HyEDrmxAPvviUg>