From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by mx.groups.io with SMTP id smtpd.web11.36962.1623077898768659082 for ; Mon, 07 Jun 2021 07:58:19 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DP3qiE3S; spf=pass (domain: gmail.com, ip: 209.85.128.53, mailfrom: mariobalanica02@gmail.com) Received: by mail-wm1-f53.google.com with SMTP id l9so1248197wms.1 for ; Mon, 07 Jun 2021 07:58:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KC+VnYq9If5Xbq532FpsAbQ8TmBrtdgASpNj1Aar2rU=; b=DP3qiE3SRkgQES7sXRhHvyz7gioOBVwkJmmvUBLXUDQTkxiW65oTlzdV9TfgXHc1X9 Mt8W9AP2Bb6hckKy6bZfei54YTwfDzia9mLdIvcNs6iH7y2x/AQ7LbX1b53/OaG0e1Pq P0fEC/gXNEGzLcimsaVJnj5EhnFLNCOzE0EgWuZe006SeTsg80vXl7W+1orZ20zchSEd sdeGio3HF2EhSGl4qeQefOeYg3UzcsmSp2+wSlIP52b4ul03rmH3HkHqhwzxDU4ye0P6 SdjPwzreKBF4fXLD1PoiEd8rR71SBZ0eTPkvKYWSmN29iIViI2BloKb4l+RRJ8pSAD/b CNew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KC+VnYq9If5Xbq532FpsAbQ8TmBrtdgASpNj1Aar2rU=; b=V3N9hu8uIPWTajdi71KLcQIsC1erZdaE/qADmq4JVEZk0izNxQNZpDgDvmwGr7rY+8 QhhfUlOmogCxJQvmo4bDjAHJL35to+Yx1APsHZMEguaDetrzoLXTCvjychMaU9il9IXn G7C+j0sDldhOWWd3SN9waE453GudwOjsygTZHnxVVasuwQW8QmlbKpwveTPov3gkVhKp OHUZ7E3GMG0zIei1hcnuIVC9XX+4dBfGpsyttXBz25853Qd7XE5fLfRO6ZsCcY9oZtUr unNz3/iNADZ0PK3mUdIseyi46VImpIhJe6WwN8Vhm1v5qJGcataLgehdWT5hXEk1HHnn iTtA== X-Gm-Message-State: AOAM531TKgHDTeq9+9jMRPQkaf0EVL7+eykCzwh4lqBKEoPr++IXjdqf d4M3vnELKsMiQ7j2HpMXBwnd/bh7Glg2ZSw8Z4g= X-Google-Smtp-Source: ABdhPJw5FVgfCMX4ON4d4ittTwBaMHAPkkiFKeb6n3htbiQOCbPoMOiKyQCTiYEpV8LeEDYf1eAsYzJpc4AL+Wlzk78= X-Received: by 2002:a1c:df85:: with SMTP id w127mr17654952wmg.130.1623077897142; Mon, 07 Jun 2021 07:58:17 -0700 (PDT) MIME-Version: 1.0 References: <20210531082239.918-1-Sunny.Wang@arm.com> <20210531082239.918-3-Sunny.Wang@arm.com> In-Reply-To: From: =?UTF-8?B?TWFyaW8gQsSDbMSDbmljxIM=?= Date: Mon, 7 Jun 2021 17:58:05 +0300 Message-ID: Subject: Re: [edk2-devel] [PATCH v3 2/2] Platform/RaspberryPi: Enable Bluetooth and UART in Windows OS To: Sunny Wang Cc: "devel@edk2.groups.io" , Samer El-Haj-Mahmoud , Sami Mujawar , Jeremy Linton , Pete Batard , Ard Biesheuvel Content-Type: multipart/alternative; boundary="00000000000080827705c42e45bc" --00000000000080827705c42e45bc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable This version of MiniComm will work without vcredist (compiled with /MT): https://drive.google.com/file/d/1v04RHUEIqlhrg2TUU_d_G4Z6lbZ1l44g/view?usp= = =3Dsharing --Mario =C3=8En lun., 7 iun. 2021 la 11:31, Sunny Wang a scri= s: > Thanks for all the valuable comments, Mario. I learned a lot from your > comments. > > I just sent v4 for addressing your comments. > > > > By the way, for samples/MinComm at develop =C2=B7 ms-iot/samples (github= .com) > > > 1. I successfully build it. However, when I ran MinComm.exe on RPi4, = I > saw the =E2=80=9Cvcruntime140.dll was not found=E2=80=9D error messag= e, and couldn=E2=80=99t fix it > by installing the latest Microsoft Visual C++ Redistributable ( > vc_redist.arm64.exe ) > from > https://support.microsoft.com/en-us/topic/the-latest-supported-visual= -c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0. > > 2. Just a suggestion. I think it would be good to upload the > precompiled binary somewhere. > > > > > Best Regards, > > Sunny Wang > > *From:* devel@edk2.groups.io * On Behalf Of *Mari= o > Balanica via groups.io > *Sent:* Tuesday, June 1, 2021 12:36 AM > *To:* Sunny Wang > *Cc:* devel@edk2.groups.io; Samer El-Haj-Mahmoud < > Samer.El-Haj-Mahmoud@arm.com>; Sami Mujawar ; > Jeremy Linton ; Pete Batard ; Ard > Biesheuvel > *Subject:* Re: [edk2-devel] [PATCH v3 2/2] Platform/RaspberryPi: Enable > Bluetooth and UART in Windows OS > > > > edit: "GpioPinSet (31, 0);" should be "GpioPinSet (31, FALSE);" and mayb= e > add the "fake the CTS signal as we don't support HW flow control yet" > comment too. > > > > When this patch gets merged, I'll add my Bluetooth changes to raspberryp= i/windows-drivers: > Windows IOT drivers (github.com) > and submit another patc= h > here to enable hardware flow control. > > > > --Mario > > > > =C3=8En lun., 31 mai 2021 la 18:56, Mario B=C4=83l=C4=83nic=C4=83 > a scris: > > If there is no COM port for PL011 UART, how can I check PL011 UART=E2=80= = =99s > functionality? How can I use a telnet tool like PuTTY to send messages f= rom > RPi4 to my laptop? > > > > You can use: samples/MinComm at develop =C2=B7 ms-iot/samples (github.co= m) > (let me know if > you need a precompiled binary) > > > > As for why I mux both UARTs to the BT chip, I was trying to address your > comment =E2=80=9CThis always assumes that PL011 is used for Bluetooth=E2= = =80=9D. Apparently, > it didn=E2=80=99t address your comment. No matter whether I add =E2=80= =9CPinFunction > (Exclusive, PullDown, BCM_ALT5, "\\_SB.GDV0.GPI0", 0, ResourceConsumer, = , > ) { 32, 33 }=E2=80=9D or not, the Bluetooth has NOT worked when I config= ure PL011 > UART as the primary serial console. Bluetooth only works when I configur= e > Mini UART as the Primary serial console. I also confirmed that this prob= lem > also exists with RPi4 Release FW 1.26 + > edk2-platforms-raspberrypi-pl011-bth-noflow.diff in > https://github.com/worproject/RPi-Bluetooth-Testing/. Do you have any > idea to make the Bluetooth work with configuring PL011 UART as the prima= ry > serial console? > > > > Bluetooth doesn't really work with the mini UART driver at the moment. T= he > chip stalls after a few transfers, as far as I remember. Haven't looked > much into it. > > > > By the way, it is good to know the loading sequence. Do you know where I > can quickly find this information without using WinDbg? > > > > I'm not aware of any way to see the driver loading order without WinDbg. > Also, verbose mode must be enabled before boot: View Verbose Output - > Windows drivers | Microsoft Docs > > > > > You could also test if Bluetooth will break by uninstalling / > re-installing the mini UART driver while the system is running, then try= to > scan for nearby BT devices. > > > > 1. What is the connection between GPIO 128 and Bluetooth (BT_ON)? Why d= id > we add this line in the beginning? I just removed it by your request and > according to the change in worproject/RPi-Bluetooth-Testing/, but I=E2= =80=99m still > worried about if we did this for some other purposes. > > > > That is a leftover from the MS-IOT tables. It tries to toggle BT_ON from > the GPIO expander (I2C) through RPIQ (mailbox), but the driver has no > knowledge of it. And since the firmware blob turns on Bluetooth by defau= lt, > the line is completely useless. > > > > We may want to have something like this in the future, for power > management of the BT chip (will require some driver changes too). > > > > 2. Why do we need to configure GPIO 32 and 33? Is the Bluetooth using > GPIO 32 and 33? Or Is Windows OS checking GPIO 32 and 33 for Bluetooth? > Where can I find the information? > > > > Yes, the Bluetooth chip is available on pins 32, 33 (TX / RX). Also 30, = 31 > for hardware flow control (CTS / RTS). More info can be found in the BCM= 2711 > datasheet > (5.= 3. > Alternative Function Assignments) > > > > 3. As for your comment about GPIO 31, I was confused, so I didn=E2=80= =99t update > anything for addressing this comment. My understanding was that It is > intended to override the BCM_ALT2=E2=80=99s default setting from PullLow= to > PullNone to fack the CTS signal. If we change it to PullLow, it will be > used for HW flow control, which is unwanted, isn=E2=80=99t it? What did = you want me > to change? Could you directly paste the code change you wanted here for = my > reference? > > > > The BCM_ALT2 thing is a dirty hack. Pin 31 must be held LOW so that we c= an > talk to the BT chip without flow control. It seems this can't be describ= ed > with PinFunction, so I've relied on the default value of ALT2 for pin 31 > (which turns out to be always LOW). > > > > My proposal is to move the pin muxing stuff in ConfigDxe, like this: > > > > STATIC VOID > > ApplyVariables ( > > VOID > > ) > > { > > ... > > > > if (FanOnGpio) { > > DEBUG ((DEBUG_INFO, "Fan enabled on GPIO %d\n", FanOnGpio)); > > GpioPinFuncSet (FanOnGpio, GPIO_FSEL_OUTPUT); > > } > > > > /* > > * Bluetooth pin muxing > > */ > > GpioPinFuncSet (31, GPIO_FSEL_OUTPUT); > > GpioPinSet (31, 0); > > > > if ((PcdGet32 (PcdUartInUse) =3D=3D PL011_UART_IN_USE)) { > > GpioPinFuncSet (32, GPIO_FSEL_ALT3); > > GpioPinFuncSet (33, GPIO_FSEL_ALT3); > > } else { > > GpioPinFuncSet (32, GPIO_FSEL_ALT5); > > GpioPinFuncSet (33, GPIO_FSEL_ALT5); > > } > > } > > > > --Mario > > > > =C3=8En lun., 31 mai 2021 la 16:26, Sunny Wang a sc= ris: > > Hi Mario, > > > > Thanks for checking this. > > Yeah, the problem is NO COM port for PL011 UART in Windows IOT=E2=80=99s= device > manager, so I thought it doesn=E2=80=99t work. If there is no COM port f= or PL011 > UART, how can I check PL011 UART=E2=80=99s functionality? How can I use = a > telnet tool like PuTTY to send messages from RPi4 to my laptop? How to u= se > SerCx2? Is there a guideline for using PL011 UART on RPi4 with Windows I= oT? > > > > As for why I mux both UARTs to the BT chip, I was trying to address your > comment =E2=80=9CThis always assumes that PL011 is used for Bluetooth=E2= = =80=9D. Apparently, > it didn=E2=80=99t address your comment. No matter whether I add =E2=80= =9CPinFunction > (Exclusive, PullDown, BCM_ALT5, "\\_SB.GDV0.GPI0", 0, ResourceConsumer, = , > ) { 32, 33 }=E2=80=9D or not, the Bluetooth has NOT worked when I config= ure PL011 > UART as the primary serial console. Bluetooth only works when I configur= e > Mini UART as the Primary serial console. I also confirmed that this prob= lem > also exists with RPi4 Release FW 1.26 + > edk2-platforms-raspberrypi-pl011-bth-noflow.diff in > https://github.com/worproject/RPi-Bluetooth-Testing/. Do you have any > idea to make the Bluetooth work with configuring PL011 UART as the prima= ry > serial console? By the way, it is good to know the loading sequence. Do = you > know where I can quickly find this information without using WinDbg? > > > > > > Actually, the original code change (Patch 2/2) is the patch > (edk2-platforms-raspberrypi-pl011-bth-noflow.diff) on > https://github.com/worproject/RPi-Bluetooth-Testing/. I=E2=80=99m not fa= miliar > with Windows drivers=E2=80=99 behavior, so I had no idea about why we ne= ed to > change them and couldn=E2=80=99t find more information about the changes= = =E2=80=99 > background either. It looks like you know the details. Could you share w= ith > me more information about the background of these changes? At least, I h= ave > some questions below: > > 1. What is the connection between GPIO 128 and Bluetooth (BT_ON)? Why d= id > we add this line in the beginning? I just removed it by your request and > according to the change in worproject/RPi-Bluetooth-Testing/, but I=E2= =80=99m still > worried about if we did this for some other purposes. > > 2. Why do we need to configure GPIO 32 and 33? Is the Bluetooth using > GPIO 32 and 33? Or Is Windows OS checking GPIO 32 and 33 for Bluetooth? > Where can I find the information? > > 3. As for your comment about GPIO 31, I was confused, so I didn=E2=80= =99t update > anything for addressing this comment. My understanding was that It is > intended to override the BCM_ALT2=E2=80=99s default setting from PullLow= to > PullNone to fack the CTS signal. If we change it to PullLow, it will be > used for HW flow control, which is unwanted, isn=E2=80=99t it? What did = you want me > to change? Could you directly paste the code change you wanted here for = my > reference? > > > > Moreover, for the changes you want, could you also paste the code change= ? > > > Best Regards, > > Sunny Wang > > > > *From:* devel@edk2.groups.io *On Behalf Of *Mario > Balanica via groups.io > *Sent:* Monday, May 31, 2021 8:41 PM > *To:* Sunny Wang > *Cc:* devel@edk2.groups.io; Samer El-Haj-Mahmoud < > Samer.El-Haj-Mahmoud@arm.com>; Sami Mujawar ; > Jeremy Linton ; Pete Batard ; Ard > Biesheuvel > *Subject:* Re: [edk2-devel] [PATCH v3 2/2] Platform/RaspberryPi: Enable > Bluetooth and UART in Windows OS > > > > Hi Sunny, > > > > What issues are you seeing with the PL011 UART in Windows? Last time I > checked, it worked fine, and the fact that Bluetooth works also confirms > this. > > It won't show up as a COM port (like mini UART does) as it's built using > SerCx2. > > > > @@ -30,6 +30,12 @@ Device (URT0) > { > MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH, RMEM) > Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { > BCM2836_PL011_UART_INTERRUPT } > + > + PinFunction (Exclusive, PullDown, BCM_ALT3, "\\_SB.GDV0.GPI0", 0, > ResourceConsumer, , ) { 32, 33 } > + > > > > @@ -79,6 +85,11 @@ Device (URTM) > // from muxing the pins away. > > // PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.GPI0", 0, > ResourceConsumer, , ) { 14, 15 } > + PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.GDV0.GPI0", 0, > ResourceConsumer, , ) { 32, 33 } > + > > > > What is the reason for trying to mux both UARTs to the BT chip? If PL011 > is used for Bluetooth and the mini UART driver loads *after* it, wouldn'= t > it mux away the pins and break Bluetooth? > > > > > > > > > > =C3=8En lun., 31 mai 2021 la 11:23, Sunny Wang a sc= ris: > > This change is based on edk2-platforms-raspberrypi-pl011-bth-noflow.diff > in https://github.com/worproject/RPi-Bluetooth-Testing/ for enabling > Bluetooth and serial port (Mini UART) in Windows IOT. > > Note that PL011 UART still doesn't work with Windows 10 IOT with this > change, but PL011 UART works fine with VMware ESXi-Arm Fling v1.3. > Therefore, there should be no issue with PL011 UART related changes, > and we will still need a Windows expert to take a further look in the > future. Making PL011 UART work properly with Windows 10 IOT may require > additional changes to Windows driver or firmware's ACPI table. > > Testing Done: > - Successfully booted Windows Windows 10 IOT (20279.1) on SD (made by > WOR) with > the RPi-Windows-Drivers release ver 0.5 downloaded from > https://github.com/worproject/RPi-Windows-Drivers/releases > and checked that both Bluetooth and serial port (Mini UART) can > work fine. > - Successfully booted VMware ESXi-Arm Fling v1.3 with only serial > console connection (PL011 UART). > > Cc: Samer El-Haj-Mahmoud > Cc: Sami Mujawar > Cc: Jeremy Linton > Cc: Pete Batard > Cc: Ard Biesheuvel > Cc: Mario B=C4=83l=C4=83nic=C4=83 > Signed-off-by: Sunny Wang > --- > Platform/RaspberryPi/AcpiTables/Uart.asl | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) > > diff --git a/Platform/RaspberryPi/AcpiTables/Uart.asl > b/Platform/RaspberryPi/AcpiTables/Uart.asl > index bac9d791eb..cb99086d39 100644 > --- a/Platform/RaspberryPi/AcpiTables/Uart.asl > +++ b/Platform/RaspberryPi/AcpiTables/Uart.asl > @@ -30,6 +30,12 @@ Device (URT0) > { > MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH, RMEM) > Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { > BCM2836_PL011_UART_INTERRUPT } > + > + PinFunction (Exclusive, PullDown, BCM_ALT3, "\\_SB.GDV0.GPI0", 0, > ResourceConsumer, , ) { 32, 33 } > + > + // fake the CTS signal as we don't support HW flow control yet > + // BCM_ALT2 is set as output (low) by default > + PinFunction (Exclusive, PullNone, BCM_ALT2, "\\_SB.GDV0.GPI0", 0, > ResourceConsumer, , ) { 31 } > }) > Method (_CRS, 0x0, Serialized) > { > @@ -79,6 +85,11 @@ Device (URTM) > // from muxing the pins away. > > // PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.GPI0", 0, > ResourceConsumer, , ) { 14, 15 } > + PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.GDV0.GPI0", 0, > ResourceConsumer, , ) { 32, 33 } > + > + // fake the CTS signal as we don't support HW flow control yet > + // BCM_ALT2 is set as output (low) by default > + PinFunction (Exclusive, PullNone, BCM_ALT2, "\\_SB.GDV0.GPI0", 0, > ResourceConsumer, , ) { 31 } > }) > Method (_CRS, 0x0, Serialized) > { > @@ -143,10 +154,6 @@ Device(BTH0) > UAR0, // DescriptorName: creates name > // for offset of resource descriptor > ) // Vendor data > - // > - // RPIQ connection for BT_ON/OFF > - // > - GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\\_SB.GDV0.RPIQ", > 0, ResourceConsumer, , ) { 128 } > }) > > // > @@ -190,10 +197,6 @@ Device(BTH0) > UARM, // DescriptorName: creates name > // for offset of resource descriptor > ) // Vendor data > - // > - // RPIQ connection for BT_ON/OFF > - // > - GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\\_SB.GDV0.RPIQ", > 0, ResourceConsumer, , ) { 128 } > }) > > Method (_CRS, 0x0, Serialized) > -- > 2.31.0.windows.1 > > IMPORTANT NOTICE: The contents of this email and any attachments are > confidential and may also be privileged. If you are not the intended > recipient, please notify the sender immediately and do not disclose the > contents to any other person, use it for any purpose, or store or copy t= he > information in any medium. Thank you. > >=20 > IMPORTANT NOTICE: The contents of this email and any attachments are > confidential and may also be privileged. If you are not the intended > recipient, please notify the sender immediately and do not disclose the > contents to any other person, use it for any purpose, or store or copy t= he > information in any medium. Thank you. > --00000000000080827705c42e45bc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This version of MiniComm will work withou= t vcredist (compiled with /MT):=C2=A0https://drive.go= ogle.com/file/d/1v04RHUEIqlhrg2TUU_d_G4Z6lbZ1l44g/view?usp=3Dsharing

--Mario

=C3=8En lun., 7 iun. 2021 l= a 11:31, Sunny Wang <Sunny.Wang@ar= m.com> a scris:

Thanks for all= the valuable comments, Mario. I learned a lot from your comments.

I just sent v4= for addressing your comments.

=C2=A0<= u>

By the way, fo= r samples/MinComm at develop =C2=B7 ms-iot/samples (github.= com)

  1. I successfully build it. However, when I ran MinComm.exe on RPi4, I saw the =E2=80=9Cvcruntime140.d= ll was not found=E2=80=9D error message, and couldn=E2=80=99t fix it by ins= talling the latest Microsoft Visual C++ Redistributable (vc_redist.arm64.exe) from https://support.microsoft.com/en-us/top= ic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a21= 8cc0.
  2. Just= a suggestion. I think it would be good to upload the precompiled binary so= mewhere. =C2=A0

=C2=A0<= u>


Best Regards,<= /p>

Sunny Wang

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Mario Balanica via groups.io
Sent: Tuesday, June 1, 2021 12:36 AM
To: Sunny Wang <Sunny.Wang@arm.com>
Cc: devel= @edk2.groups.io; Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>; = Sami Mujawar <= Sami.Mujawar@arm.com>; Jeremy Linton <Jeremy.Linton@arm.com>; Pete Batard = <pete@akeo.ie>;= Ard Biesheuvel <ardb+tianocore@kernel.org>
Subject: Re: [edk2-devel] [PATCH v3 2/2] Platform/RaspberryPi: Enab= le Bluetooth and UART in Windows OS

=C2=A0

edit: "GpioPinSet (31, 0);" should be &qu= ot;GpioPinSet (31, FALSE);" and maybe add the "fake the CTS signa= l as we don't support HW flow control yet" comment too.<= /u>

=C2=A0

When this patch gets merged, I'll add my Blueto= oth changes to=C2=A0raspberrypi/windows-drivers: Windows IOT drivers (git= hub.com)=C2=A0and submit another patch here to enable hardware flow control.

=C2=A0

--Mario

=C2=A0

=C3=8En lun., 31 mai 2021 la 18:56, Mario B=C4=83l= =C4=83nic=C4=83 <mariobalanica02@gmail.com> a scris:

If there is no= COM port for PL011 UART, how can I check PL011 UART=E2=80=99s functionalit= y? How can I use a telnet=C2=A0tool like PuTTY to send messages from RPi4 t= o my laptop?=C2=A0

=C2=A0

You can use:=C2=A0samples/MinComm at deve= lop =C2=B7 ms-iot/samples (github.com)=C2=A0(let me know if you need a = precompiled binary)

=C2=A0

As for why I m= ux both UARTs to the BT chip, I was trying to address your comment =E2=80= =9CThis always assumes that PL011 is used for Bluetooth=E2=80=9D. Apparent= ly, it didn=E2=80=99t address your comment. No matter whether I add =E2=80= =9CPinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.GDV0.GPI0", 0, Re= sourceConsumer, , ) { 32, 33 }=E2=80=9D=C2=A0or not, the Bluetooth has NOT worked when I configure PL011 UART as = the primary serial console. Bluetooth only works when I configure Mini UART as the Primary serial console. I al= so confirmed that this problem also exists with RPi4 Release FW 1.26 + edk2= -platforms-raspberrypi-pl011-bth-noflow.diff in=C2=A0https://github= .com/worproject/RPi-Bluetooth-Testing/. Do you have any idea to make the Bluetooth work with configuring PL011 UA= RT as the primary serial console?

=C2=A0

Bluetooth doesn't really work with the mini UAR= T driver at the moment. The chip stalls after a few transfers, as far as I = remember. Haven't looked much into it.

=C2=A0

By the way, it= is good to know the loading sequence. Do you know where I can quickly find= this information without using WinDbg?

=C2=A0

I'm not aware of any way to see the driver load= ing order without WinDbg. Also, verbose mode must be enabled before boot:= =C2=A0View Verbose Output - Windows drivers | Microsoft Docs

=C2=A0

You could also test if Bluetooth will break by unin= stalling / re-installing the mini UART driver while the system is running, = then try to scan for nearby BT devices.

=C2=A0

1.=C2=A0 What = is the connection between GPIO 128 and Bluetooth (BT_ON)? Why did we add th= is line in the beginning? I just removed it by your request and according t= o the change in worproject/RPi-Bluetooth-Testing/, but I=E2=80=99m still worried about if we did this for some other purpose= s.=C2=A0=C2=A0

=C2=A0

That is a leftover from the MS-IOT tables. It tries= to toggle BT_ON from the GPIO expander (I2C) through RPIQ (mailbox), but t= he driver has no knowledge of it. And since the firmware blob turns on Blue= tooth by default, the line is completely useless.

=C2=A0

We may want to have something like this in the futu= re, for power management of the BT chip (will require some driver changes t= oo).

=C2=A0

2.=C2=A0 Why d= o we need to configure GPIO 32 and 33? Is the Bluetooth using GPIO 32 and 3= 3? Or Is Windows OS checking GPIO 32 and 33 for Bluetooth? Where can I find= the information?

=C2=A0

Yes, the Bluetooth chip is available on pins 32, 33= (TX / RX). Also 30, 31 for hardware flow control (CTS / RTS). More info ca= n be found in the BCM2711 datasheet=C2=A0(5.3. Alternative Function Assignments)<= u>

=C2=A0

3.=C2=A0 As fo= r your comment about GPIO 31, I was confused, so I didn=E2=80=99t update an= ything for addressing this comment. My understanding was that It is intende= d to override the BCM_ALT2=E2=80=99s default setting from PullLow to PullNone to fack the CTS signal. If we change it to PullLow, it will b= e used for HW flow control, which is unwanted, isn=E2=80=99t it? What did y= ou want me to change? Could you directly paste the code change you wanted h= ere for my reference?

=C2=A0

The BCM_ALT2 thing is a dirty hack. Pin 31 must be = held LOW so that we can talk to the BT chip without flow control. It seems = this can't be described with PinFunction, so I've relied on the def= ault value of ALT2 for pin 31 (which turns out to be always LOW).=C2=A0

=C2=A0

My proposal is to move the pin muxing stuff in Conf= igDxe, like this:

=C2=A0

STATIC VOID

ApplyVariables (

=C2=A0 VOID

=C2=A0 )

{

...

=C2=A0

=C2=A0 if (FanOnGpio) {

=C2=A0 =C2=A0 DEBUG ((DEBUG_INFO, "Fan enabled= on GPIO %d\n", FanOnGpio));

=C2=A0 =C2=A0 GpioPinFuncSet (FanOnGpio, GPIO_FSEL_= OUTPUT);

=C2=A0 }

=C2=A0

=C2=A0 /*

=C2=A0 =C2=A0* Bluetooth pin muxing

=C2=A0 =C2=A0*/=C2=A0 =C2=A0

=C2=A0 GpioPinFuncSet (31, GPIO_FSEL_OUTPUT);

=C2=A0 GpioPinSet (31, 0);

=C2=A0

=C2=A0 if ((PcdGet32 (PcdUartInUse) =3D=3D PL011_UA= RT_IN_USE)) {=C2=A0=C2=A0

=C2=A0 =C2=A0 GpioPinFuncSet (32, GPIO_FSEL_ALT3);<= u>

=C2=A0 =C2=A0 GpioPinFuncSet (33, GPIO_FSEL_ALT3);<= u>

=C2=A0 } else {

=C2=A0 =C2=A0 GpioPinFuncSet (32, GPIO_FSEL_ALT5);<= u>

=C2=A0 =C2=A0 GpioPinFuncSet (33, GPIO_FSEL_ALT5);<= u>

=C2=A0 }

}

=C2=A0

--Mario

=C2=A0

=C3=8En lun., 31 mai 2021 la 16:26, Sunny Wang <= Sunny.Wang@arm.com<= /a>> a scris:

Hi Mario,

=C2=A0<= u>

Thanks for che= cking this.

Yeah, the prob= lem is NO COM port for PL011 UART in Windows IOT=E2=80=99s device manager, = so I thought it doesn=E2=80=99t work. If there is no COM port for PL011 UAR= T, how can I check PL011 UART=E2=80=99s functionality? How can I use a telne= t=C2=A0tool like PuTTY to send messages from RPi4 to my laptop? How to use = SerCx2? Is there a guideline for using PL011 UART on RPi4 with Windows IoT?=

=C2=A0<= u>

As for why I m= ux both UARTs to the BT chip, I was trying to address your comment =E2=80= =9CThis always assumes that PL011 is used for Bluetooth=E2=80=9D. Apparent= ly, it didn=E2=80=99t address your comment. No matter whether I add =E2=80=9C= PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.GDV0.GPI0= ", 0, ResourceConsumer, , ) { 32, 33 }=E2=80=9D or not, the Bluetooth has NOT worked = when I configure PL011 UART as the primary serial console. Bluetooth only w= orks when I configure Mini UART as the Primary serial console. I also confi= rmed that this problem also exists with RPi4 Release FW 1.26 + edk2-platforms-raspberrypi-pl011-bth-noflow.diff in https://github.com/worproject/RPi-Bluetooth-Testing/. Do you have any = idea to make the Bluetooth work with configuring PL011 UART as the primary = serial console? By the way, it is good to know the loading sequence. Do you= know where I can quickly find this information without using WinDbg?

=C2=A0<= u>

=C2=A0<= u>

Actually, the = original code change (Patch 2/2) is the patch (edk2-platforms-raspberrypi-p= l011-bth-noflow.diff) on =C2=A0https://github.com/worproject/RPi-Bl= uetooth-Testing/. I=E2=80=99m not familiar with Windows drivers=E2=80=99 behavior, so I had= no idea about why we need to change them and couldn=E2=80=99t find more in= formation about the changes=E2=80=99 background either. It looks like you k= now the details. Could you share with me more information about the background of these changes? At least, I have some questions below:

1.=C2=A0 What = is the connection between GPIO 128 and Bluetooth (BT_ON)? Why did we add th= is line in the beginning? I just removed it by your request and according to the change in worproject/RPi-Bluetooth-Testing/, but I=E2=80=99m still= worried about if we did this for some other purposes. =C2=A0=

2.=C2=A0 Why d= o we need to configure GPIO 32 and 33? Is the Bluetooth using GPIO 32 and 3= 3? Or Is Windows OS checking GPIO 32 and 33 for Bluetooth? Where can I find the information?

3.=C2=A0 As fo= r your comment about GPIO 31, I was confused, so I didn=E2=80=99t update an= ything for addressing this comment. My understanding was that It is intende= d to override the BCM_ALT2=E2=80=99s default setting from PullLow to PullNo= ne to fack the CTS signal. If we change it to PullLow, it will be used for = HW flow control, which is unwanted, isn=E2=80=99t it? What did you want me = to change? Could you directly paste the code change you wanted here for my reference?

=C2=A0<= u>

Moreover, for = the changes you want, could you also paste the code change?


Best Regards,

Sunny Wang

=C2=A0

From: devel@edk2.group= s.io <deve= l@edk2.groups.io> On Behalf Of Mario Balanica via groups.io
Sent: Monday, May 31, 2021 8:41 PM
To: Sunny Wang <Sunny.Wang@arm.com>
Cc: devel= @edk2.groups.io; Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>; = Sami Mujawar <= Sami.Mujawar@arm.com>; Jeremy Linton <Jeremy.Linton@arm.com>; Pete Batard <pete@akeo.ie>; Ard Biesheuvel <ardb+tianocore@k= ernel.org>
Subject: Re: [edk2-devel] [PATCH v3 2/2] Platform/RaspberryPi: Enab= le Bluetooth and UART in Windows OS

=C2=A0

Hi Sunny,

=C2=A0

What issues are you seeing with the PL011 UART in W= indows? Last time I checked, it worked fine, and the fact that Bluetooth wo= rks also confirms this.

It won't show up as a COM port (like mini UART = does) as it's built using SerCx2.

=C2=A0

@@ -30,6 +30,12 @@ Device (URT0)
=C2=A0 =C2=A0{
=C2=A0 =C2=A0 =C2=A0MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH= , RMEM)
=C2=A0 =C2=A0 =C2=A0Interrupt (ResourceConsumer, Level, ActiveHigh, Exclus= ive) { BCM2836_PL011_UART_INTERRUPT }
+
+=C2=A0 =C2=A0 PinFunction (Exclusive, PullDown, BCM_ALT3, "\\_SB.= GDV0.GPI0", 0, ResourceConsumer, , ) { 32, 33 }
+

=C2=A0

@@ -79,6 +85,11 @@ Device (URTM)
=C2=A0 =C2=A0 =C2=A0// from muxing the pins away.

=C2=A0 =C2=A0 =C2=A0// PinFunction (Exclusive, PullDown, BCM_ALT5, "<= a>\\_SB.GPI0", 0, ResourceConsumer, , ) { 14, 15 }
+=C2=A0 =C2=A0 PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.= GDV0.GPI0", 0, ResourceConsumer, , ) { 32, 33 }
+

=C2=A0

What is the reason for trying to mux both UARTs to = the BT chip? If PL011 is used for Bluetooth and the mini UART driver loads after=C2=A0it, wouldn't it mux away the pins and break Bluetoot= h?

=C2=A0

=C2=A0

=C2=A0

=C2=A0

=C3=8En lun., 31 mai 2021 la 11:23, Sunny Wang <= Sunny.Wang@arm.com<= /a>> a scris:

This change is based o= n edk2-platforms-raspberrypi-pl011-bth-noflow.diff
in
https://github.com/worproject/RPi-Bluetooth-Testing/ for enabling
Bluetooth and serial port (Mini UART) in Windows IOT.

Note that PL011 UART still doesn't work with Windows 10 IOT with this<= br> change, but PL011 UART works fine with VMware ESXi-Arm Fling v1.3.
Therefore, there should be no issue with PL011 UART related changes,
and we will still need a Windows expert to take a further look in the
future. Making PL011 UART work properly with Windows 10 IOT may require additional changes to Windows driver or firmware's ACPI table.

Testing Done:
=C2=A0 - Successfully booted Windows Windows 10 IOT (20279.1) on SD (made = by WOR) with
=C2=A0 =C2=A0 the RPi-Windows-Drivers release ver 0.5 downloaded from
=C2=A0 =C2=A0 https://github.com/worproject/RPi-Windows-Drivers/releases
=C2=A0 =C2=A0 and checked that both Bluetooth and serial port (Mini UART) = can
=C2=A0 =C2=A0 work fine.
=C2=A0 - Successfully booted VMware ESXi-Arm Fling v1.3 with only serial =C2=A0 =C2=A0 console connection (PL011 UART).

Cc: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jeremy Linton <jeremy.linton@arm.com>
Cc: Pete Batard <pete= @akeo.ie>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Mario B=C4=83l=C4=83nic=C4=83 <mariobalanica02@gmail.com>
Signed-off-by: Sunny Wang <sunny.wang@arm.com>
---
=C2=A0Platform/RaspberryPi/AcpiTables/Uart.asl | 19 +++++++++++-------- =C2=A01 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/Platform/RaspberryPi/AcpiTables/Uart.asl b/Platform/Raspberry= Pi/AcpiTables/Uart.asl
index bac9d791eb..cb99086d39 100644
--- a/Platform/RaspberryPi/AcpiTables/Uart.asl
+++ b/Platform/RaspberryPi/AcpiTables/Uart.asl
@@ -30,6 +30,12 @@ Device (URT0)
=C2=A0 =C2=A0{
=C2=A0 =C2=A0 =C2=A0MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH= , RMEM)
=C2=A0 =C2=A0 =C2=A0Interrupt (ResourceConsumer, Level, ActiveHigh, Exclus= ive) { BCM2836_PL011_UART_INTERRUPT }
+
+=C2=A0 =C2=A0 PinFunction (Exclusive, PullDown, BCM_ALT3, "\\_SB.= GDV0.GPI0", 0, ResourceConsumer, , ) { 32, 33 }
+
+=C2=A0 =C2=A0 // fake the CTS signal as we don't support HW flow cont= rol yet
+=C2=A0 =C2=A0 // BCM_ALT2 is set as output (low) by default
+=C2=A0 =C2=A0 PinFunction (Exclusive, PullNone, BCM_ALT2, "\\_SB.= GDV0.GPI0", 0, ResourceConsumer, , ) { 31 }
=C2=A0 =C2=A0})
=C2=A0 =C2=A0Method (_CRS, 0x0, Serialized)
=C2=A0 =C2=A0{
@@ -79,6 +85,11 @@ Device (URTM)
=C2=A0 =C2=A0 =C2=A0// from muxing the pins away.

=C2=A0 =C2=A0 =C2=A0// PinFunction (Exclusive, PullDown, BCM_ALT5, "<= a>\\_SB.GPI0", 0, ResourceConsumer, , ) { 14, 15 }
+=C2=A0 =C2=A0 PinFunction (Exclusive, PullDown, BCM_ALT5, "\\_SB.= GDV0.GPI0", 0, ResourceConsumer, , ) { 32, 33 }
+
+=C2=A0 =C2=A0 // fake the CTS signal as we don't support HW flow cont= rol yet
+=C2=A0 =C2=A0 // BCM_ALT2 is set as output (low) by default
+=C2=A0 =C2=A0 PinFunction (Exclusive, PullNone, BCM_ALT2, "\\_SB.= GDV0.GPI0", 0, ResourceConsumer, , ) { 31 }
=C2=A0 =C2=A0})
=C2=A0 =C2=A0Method (_CRS, 0x0, Serialized)
=C2=A0 =C2=A0{
@@ -143,10 +154,6 @@ Device(BTH0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0UAR0,=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // Desc= riptorName: creates name
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0//=C2=A0 =C2=A0for offset of resource descriptor
=C2=A0 =C2=A0 =C2=A0)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 // Vendor data
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // RPIQ connection for BT_ON/OFF
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\= \_SB.GDV0.RPIQ", 0, ResourceConsumer, , ) { 128 }
=C2=A0 =C2=A0})

=C2=A0 =C2=A0//
@@ -190,10 +197,6 @@ Device(BTH0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0UARM,=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // Desc= riptorName: creates name
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0//=C2=A0 =C2=A0for offset of resource descriptor
=C2=A0 =C2=A0 =C2=A0)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 // Vendor data
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 // RPIQ connection for BT_ON/OFF
-=C2=A0 =C2=A0 //
-=C2=A0 =C2=A0 GpioIO (Shared, PullUp, 0, 0, IoRestrictionNone, "\= \_SB.GDV0.RPIQ", 0, ResourceConsumer, , ) { 128 }
=C2=A0 =C2=A0})

=C2=A0 =C2=A0Method (_CRS, 0x0, Serialized)
--
2.31.0.windows.1

IMPORTANT NOTICE: The contents of this email and an= y attachments are confidential and may also be privileged. If you are not t= he intended recipient, please notify the sender immediately and do not disc= lose the contents to any other person, use it for any purpose, or store or copy the information in any medium. T= hank you.

IMPORTANT NOTICE: The contents of this email and any attachments are confi= dential and may also be privileged. If you are not the intended recipient, = please notify the sender immediately and do not disclose the contents to an= y other person, use it for any purpose, or store or copy the information in any medium. Thank you.
--00000000000080827705c42e45bc--