[prev in list] [next in list] [prev in thread] [next in thread]
List: freebsd-arm
Subject: Re: Raspberry Pi 3B Over-current USB
From: Archimedes Gaviola <archimedes.gaviola () gmail ! com>
Date: 2022-05-07 14:35:57
Message-ID: CAJFbk7Hs7qmfS3TYWuk_=FpgBoY3hBj766RBsGwUL1+=3__qPw () mail ! gmail ! com
[Download RAW message or body]
On Sat, May 7, 2022 at 8:46 PM Archimedes Gaviola <
archimedes.gaviola@gmail.com> wrote:
>
>
> On Sat, May 7, 2022 at 5:20 PM Hans Petter Selasky <hps@selasky.org>
> wrote:
>
>> On 5/6/22 16:03, Archimedes Gaviola wrote:
>> > On Tue, Apr 12, 2022 at 5:16 PM Archimedes Gaviola <
>> > archimedes.gaviola@gmail.com> wrote:
>> >
>> >>
>> >>
>> >> On Mon, Apr 11, 2022 at 9:59 PM Hans Petter Selasky <hps@selasky.org>
>> >> wrote:
>> >>
>> >>> On 4/11/22 15:59, Archimedes Gaviola wrote:
>> >>>> Hi Hans,
>> >>>>
>> >>>> Noted on the self-powered hub, thanks for the suggestion, I will try.
>> >>>>
>> >>>> Just wanted to share the observation from the testing I've conducted
>> >>> with
>> >>>> my Raspberry Pi 4B with the same 14.0-CURRENT to check if
>> overcurrent is
>> >>>> also experienced and it did, there was overcurrent and each ports'
>> power
>> >>>> shut-off during the situation but it was able to recover back. I
>> >>> initiated
>> >>>> the command 'usbconfig reset' and each port gloriously came back
>> alive
>> >>> one
>> >>>> by one and loaded my USB keyboard and Prolific uplcom(4) drivers into
>> >>>> functional and operational states. My measuring device is showing the
>> >>> same
>> >>>> amount of current 460mA while the voltage stayed at 5.05 from a
>> >>> baseline of
>> >>>> 5.15 voltshttps://filebin.net/10vy575q6h2yl8og. Unlike my RPi 3B,
>> >>> voltage
>> >>>> dropped to 4.93 from a baseline of 5.19 volts. So, the difference I
>> >>>> observed is when the voltage dropped below 5, the system will not
>> give a
>> >>>> chance to make the ports come back alive as a sort of protection
>> >>> mechanism.
>> >>>> Sharing to you the logs below (with hw.usb.uhub.debug=1).
>> >>>
>> >>> FreeBSD does not actively check and use "bMaxPower" .
>> >>>
>> >>
>> >> Hi Hans,
>> >>
>> >> It's okay, just tried your recommendation on a self-powered USB hub, my
>> >> Prolific device is now working. Thanks a lot!
>> >>
>> >> Archimedes
>> >>
>> >
>> > Hi Hans,
>> >
>> > I got my Prolific PL2303 USB-serial device working in RPi 3B without the
>> > self-powered USB hub. I've extended the code
>> /usr/src/sys/dev/usb/usb_hub.c
>> > in the uhub_explore() routine specific to handling overcurrent
>> condition.
>> > Below are the added lines of code.
>> >
>> > freebsd@generic:~ % diff -Nur /usr/src/sys/dev/usb/usb_hub.c.orig
>> > /usr/src/sys/dev/usb/usb_hub.c
>> > --- /usr/src/sys/dev/usb/usb_hub.c.orig 2022-04-29 10:52:44.787344000
>> +0000
>> > +++ /usr/src/sys/dev/usb/usb_hub.c 2022-05-03 07:29:45.159470000
>> +0000
>> > @@ -1045,6 +1045,25 @@
>> > udev, NULL, portno,
>> UHF_C_PORT_OVER_CURRENT);
>> > if (err != USB_ERR_NORMAL_COMPLETION)
>> > retval = err;
>> > +
>> > + /* Turn on hub port power if current get
>> > normalized. */
>> > + DPRINTF("Turn on power on port %d.\n", portno);
>> > + err = usbd_req_set_port_feature(
>> > + udev, NULL, portno, UHF_PORT_POWER);
>> > + if (err != USB_ERR_NORMAL_COMPLETION)
>> > + retval = err;
>>
>> You need a sleep here, to wait for power to come back on.
>>
>> > +
>> > + /* Re-validate if overcurrent still exists. */
>> > + err = uhub_read_port_status(sc, portno);
>> > + if (err != USB_ERR_NORMAL_COMPLETION)
>> > + retval = err;
>> > + if (sc->sc_st.port_change &
>> > UPS_C_OVERCURRENT_INDICATOR) {
>> > + DPRINTF("Overcurrent condition on port
>> > %u.\n", portno);
>> > + err = usbd_req_clear_port_feature(
>> > + udev, NULL, portno,
>> > UHF_C_PORT_OVER_CURRENT);
>> > + if (err != USB_ERR_NORMAL_COMPLETION)
>> > + retval = err;
>> > + }
>> > }
>> >
>>
>> Can you upload the patch to https://reviews.freebsd.org and add
>> "hselasky" as reviewer?
>>
>
> Thank you Hans for the feedback! Just created an account and once approved
> and activated then I'll upload it. Meanwhile, for the sleep you've
> mentioned what particular function should be used? I tried these two,
> sleep(3) and usleep(3) but seems to encounter errors during compilation.
>
Hi Hans,
Submitted, please see https://reviews.freebsd.org/D35146.
Thanks,
Archimedes
[Attachment #3 (text/html)]
<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" \
class="gmail_attr">On Sat, May 7, 2022 at 8:46 PM Archimedes Gaviola <<a \
href="mailto:archimedes.gaviola@gmail.com">archimedes.gaviola@gmail.com</a>> \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div \
dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On \
Sat, May 7, 2022 at 5:20 PM Hans Petter Selasky <<a href="mailto:hps@selasky.org" \
target="_blank">hps@selasky.org</a>> wrote:<br></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">On 5/6/22 16:03, Archimedes Gaviola wrote:<br> \
> On Tue, Apr 12, 2022 at 5:16 PM Archimedes Gaviola <<br> > <a \
href="mailto:archimedes.gaviola@gmail.com" \
target="_blank">archimedes.gaviola@gmail.com</a>> wrote:<br> > <br>
>><br>
>><br>
>> On Mon, Apr 11, 2022 at 9:59 PM Hans Petter Selasky <<a \
href="mailto:hps@selasky.org" target="_blank">hps@selasky.org</a>><br> >> \
wrote:<br> >><br>
>>> On 4/11/22 15:59, Archimedes Gaviola wrote:<br>
>>>> Hi Hans,<br>
>>>><br>
>>>> Noted on the self-powered hub, thanks for the suggestion, I will \
try.<br> >>>><br>
>>>> Just wanted to share the observation from the testing I've \
conducted<br> >>> with<br>
>>>> my Raspberry Pi 4B with the same 14.0-CURRENT to check if \
overcurrent is<br> >>>> also experienced and it did, there was \
overcurrent and each ports' power<br> >>>> shut-off during the \
situation but it was able to recover back. I<br> >>> initiated<br>
>>>> the command 'usbconfig reset' and each port gloriously came \
back alive<br> >>> one<br>
>>>> by one and loaded my USB keyboard and Prolific uplcom(4) drivers \
into<br> >>>> functional and operational states. My measuring device is \
showing the<br> >>> same<br>
>>>> amount of current 460mA while the voltage stayed at 5.05 from a<br>
>>> baseline of<br>
>>>> 5.15 voltshttps://<a href="http://filebin.net/10vy575q6h2yl8og" \
rel="noreferrer" target="_blank">filebin.net/10vy575q6h2yl8og</a>. Unlike my RPi \
3B,<br> >>> voltage<br>
>>>> dropped to 4.93 from a baseline of 5.19 volts. So, the difference \
I<br> >>>> observed is when the voltage dropped below 5, the system will \
not give a<br> >>>> chance to make the ports come back alive as a sort of \
protection<br> >>> mechanism.<br>
>>>> Sharing to you the logs below (with hw.usb.uhub.debug=1).<br>
>>><br>
>>> FreeBSD does not actively check and use "bMaxPower" .<br>
>>><br>
>><br>
>> Hi Hans,<br>
>><br>
>> It's okay, just tried your recommendation on a self-powered USB hub, \
my<br> >> Prolific device is now working. Thanks a lot!<br>
>><br>
>> Archimedes<br>
>><br>
> <br>
> Hi Hans,<br>
> <br>
> I got my Prolific PL2303 USB-serial device working in RPi 3B without the<br>
> self-powered USB hub. I've extended the code \
/usr/src/sys/dev/usb/usb_hub.c<br> > in the uhub_explore() routine specific to \
handling overcurrent condition.<br> > Below are the added lines of code.<br>
> <br>
> freebsd@generic:~ % diff -Nur /usr/src/sys/dev/usb/usb_hub.c.orig<br>
> /usr/src/sys/dev/usb/usb_hub.c<br>
> --- /usr/src/sys/dev/usb/usb_hub.c.orig 2022-04-29 10:52:44.787344000 +0000<br>
> +++ /usr/src/sys/dev/usb/usb_hub.c 2022-05-03 07:29:45.159470000 \
+0000<br> > @@ -1045,6 +1045,25 @@<br>
> udev, NULL, portno, \
UHF_C_PORT_OVER_CURRENT);<br> > if (err != \
USB_ERR_NORMAL_COMPLETION)<br> > \
retval = err;<br> > +<br>
> + /* Turn on hub port power if current get<br>
> normalized. */<br>
> + DPRINTF("Turn on power on port \
%d.\n", portno);<br> > + err = \
usbd_req_set_port_feature(<br> > + udev, \
NULL, portno, UHF_PORT_POWER);<br> > + if (err \
!= USB_ERR_NORMAL_COMPLETION)<br> > + \
retval = err;<br> <br>
You need a sleep here, to wait for power to come back on.<br>
<br>
> +<br>
> + /* Re-validate if overcurrent still exists. \
*/<br> > + err = uhub_read_port_status(sc, \
portno);<br> > + if (err != \
USB_ERR_NORMAL_COMPLETION)<br> > + \
retval = err;<br> > + if \
(sc->sc_st.port_change &<br> > UPS_C_OVERCURRENT_INDICATOR) {<br>
> + DPRINTF("Overcurrent \
condition on port<br> > %u.\n", portno);<br>
> + err = \
usbd_req_clear_port_feature(<br> > + \
udev, NULL, portno,<br> > UHF_C_PORT_OVER_CURRENT);<br>
> + if (err != \
USB_ERR_NORMAL_COMPLETION)<br> > + \
retval = err;<br> > + }<br>
> }<br>
> <br>
<br>
Can you upload the patch to <a href="https://reviews.freebsd.org" rel="noreferrer" \
target="_blank">https://reviews.freebsd.org</a> and add <br> "hselasky" as \
reviewer?<br></blockquote><div><br></div></div><div class="gmail_quote">Thank you \
Hans for the feedback! Just created an account and once approved and activated then \
I'll upload it. Meanwhile, for the sleep you've mentioned what particular \
function should be used? I tried these two, sleep(3) and usleep(3) but seems to \
encounter errors during \
compilation.<br></div></div></blockquote><div><br></div><div>Hi \
Hans,</div><div><br></div><div> Submitted, please see <a \
href="https://reviews.freebsd.org/D35146">https://reviews.freebsd.org/D35146</a>.</div><div><br></div><div>Thanks,</div><div>Archimedes<br></div></div></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic