oyama / pico-w-usb-failures

This repository investigates issues with initiating communication when the battery-powered Raspberry Pi Pico W is connected to a host PC via USB Type-C.
0 stars 0 forks source link
raspberry-pi-pico

Battery-Powered Raspberry Pi Pico W and USB Type-C Connection Issue

This repository investigates a specific issue that occurs when the battery-powered Raspberry Pi Pico W is connected to a host PC via a USB Type-C connection. Specifically, the following connection sequence fails to initiate USB communication:

  1. Supply power to Pico W's VSYS.
  2. Connect the USB cable to the micro USB connector of the Pico W.
  3. Connect the USB cable to the Type-C connector of the host PC.

This phenomenon does not occur if the cable is connected in the reverse order from the host PC to the Pico W, or when using a USB Type-A connection. And interestingly, it does not occur with the standard Raspberry Pi Pico either.

Investigation Methodology

To understand and diagnose this issue, the following methods were employed:

Identical tests were also carried out on six Pico Ws to rule out the possibility of the problem being a problem with a particular individual Pico W. The monitoring results matched the USB communication state, but the behavior of the Pico W when connected to the host PC was not as expected. Further behavior is detailed below.

Build and Install Instructions

The pico-sdk^4 build environment is required to build the firmware used for this monitoring, see Getting started with Raspberry Pi Pico[^5] to prepare the toolchain for your platform.

Build for Pico

mkdir build; cd build
PICO_SDK_FETCH_FROM_GIT=1 cmake -DPICO_BOARD=pico ..
make

Build for Pico W

mkdir build; cd build
PICO_SDK_FETCH_FROM_GIT=1 cmake -DPICO_BOARD=pico_w ..
make

The above examples specify the environment variable PICO_SDK_FETCH_FROM_GIT to download the pico-sdk from GitHub. If you want to specify a locally deployed pico-sdk, you should set it with the PICO_SDK_PATH environment variable. Once built, the firmware picow-usb-failures.uf2 will be generated. Simply drag and drop it onto your device to install.

Circuit Diagram

circut_diagram

Results

The firmware in this repository monitors the USB connection status of Pico and Pico W and continuously reports the USB connection status to the UART and onboard LEDs every second. To observe the UART output under battery power, use the Raspberry Pi Debug Probe[^6] to monitor the UART. For the Pico, when connected to the host PC, the status changes as follows:

Waiting for USB connection
BOARD=pico, TinyUSB not ready, USB_SIE_STATUS=0x00000015 disconnect, VBUS low
BOARD=pico, TinyUSB not ready, USB_SIE_STATUS=0x00000015 disconnect, VBUS low
BOARD=pico, TinyUSB not ready, USB_SIE_STATUS=0x00000015 disconnect, VBUS low
BOARD=pico, TinyUSB ready, USB_SIE_STATUS=0x40050005 connect, VBUS high
BOARD=pico, TinyUSB ready, USB_SIE_STATUS=0x40050005 connect, VBUS high
BOARD=pico, TinyUSB ready, USB_SIE_STATUS=0x40050005 connect, VBUS high

However, for the Pico W, even when the host PC's type-C cable is connected, the status does not change:

Waiting for USB connection
BOARD=pico_w, TinyUSB not ready, USB_SIE_STATUS=0x40050015 disconnect, VBUS low
BOARD=pico_w, TinyUSB not ready, USB_SIE_STATUS=0x40050015 disconnect, VBUS low
BOARD=pico_w, TinyUSB not ready, USB_SIE_STATUS=0x40050015 disconnect, VBUS low
BOARD=pico_w, TinyUSB not ready, USB_SIE_STATUS=0x40050015 disconnect, VBUS low
BOARD=pico_w, TinyUSB not ready, USB_SIE_STATUS=0x40050015 disconnect, VBUS low
BOARD=pico_w, TinyUSB not ready, USB_SIE_STATUS=0x40050015 disconnect, VBUS low

The USB connection status recognized by the devices matches the device recognition status on the host PC side.

Actual voltage of VBUS

A multimeter was used to measure the change in voltage on VBUS(pin 40) and GND(pin 38) of Pico and Pico W. Power is supplied to VSYS under all conditions.

Device Voltage with USB Disconnected Voltage after connecting to device first, then host Voltage after connecting to host first, then device
Pico 0.42 V 5.17 V 5.17 V
Pico W 1.36 V 0.97..1.09 V (unstable) 5.16 V

Under the conditions in question, the host PC does not supply VBUS power to the Pico W when the cable is connected. Furthermore, the VBUS on the Pico W showed a voltage of 1.36 V when no cable was connected. This exceeds the vSafe0V (0-0.8V) defined by USB Power Delivery[^7].

Conclusion

The VBUS of the Pico W during battery operation exceeds vSafe0V (0-0.8V). It is therefore suspected that the USB controller of the host PC accepting the connection has deactivated the VBUS supply for safety reasons. micro USB and Type-C cable circuits for mixed use are defined in USB Type-C Spec[^8] as Legacy Cable Assemblies which is defined as. The circuits and states expected when connecting devices using these cables are then explicitly stated. A device with a VBUS in excess of vSafe0V, as in this Issue, connecting to a host PC with Type-C would have unintended consequences for the user.

It would be desirable if Pico W could address this issue by changing the circuitry or firmware, and it would be useful to mention this issue in the Pico W datasheet. I have already reported this issue to pico-feedback^9. Fortunately, there are two measures that end-users can adopt now.

Software solution

This problem can be avoided by setting WL_GPIO 2 to Low.

     cyw43_arch_init();
+    cyw43_arch_gpio_put(2, 0);

This method shows the expected behaviour, but with the limitation that the use case where you want to get the VBUS status via GPIOs will not work.

Hardware solution

This problem can be avoided by pull-down the VBUS.

Pico W USB Pull-down

Pull-down resistor R1 works as expected at around 1 kOhm. Considering the USB suspend requirements, around 10 kOhm may be appropriate, but this has not been tested.

Limitation

These investigations and solutions are limited to using Pico W as a USB device; using Pico W as a USB host has not been investigated.

Acknowledgements

I would like to express my gratitude to the Raspberry Pi Pico forum[^10] for their invaluable advice and insights, which greatly assisted in the development of the solutions documented in this README. Your contributions have been instrumental in making these improvements possible.

References

[^1]: Raspberry Pi Pico Datasheet [^2]: Raspberry Pi Pico W Datasheet [^3]: RP2040 Datasheet

[^5]: Getting started with Raspberry Pi Pico [^6]: Raspberry Pi Debug Probe [^7]: Universal Serial Bus Power Delivery Specification [^8]: USB Type-C® Cable and Connector Specification

[^10]: Raspberry Pi Pico forum