rp2040-pd-sniffer

RP2040 USB-PD Sniffer and Sink

This project provides two firmwares for a Raspberry Pi Pico or any other RP2040-based board to interact with the USB Power Delivery (USB-PD) protocol.

  1. Sniffer: A passive USB-PD sniffer that listens to the communication on a USB-C CC (Configuration Channel) line, decodes the messages in real-time, and prints them to the USB serial console.
  2. Sink: An active device that can negotiate a specific power profile from a USB-PD power adapter. This example is configured to request a 15V / 3A profile.

Features

Building the Firmware

This project uses CMake and requires the ARM GCC toolchain.

Prerequisites

On a Debian-based system (like Ubuntu), you can install these with:

sudo apt-get update
sudo apt-get install -y git cmake gcc-arm-none-eabi

Build Steps

  1. Clone the repository:
    git clone https://github.com/your-username/rp2040-pd-sniffer.git
    cd rp2040-pd-sniffer
    
  2. Initialize the Submodules:
    git submodule update --init --recursive
    
  3. Run the Build:
    cmake -B build -S .
    cmake --build build --parallel
    
  4. Find the Firmware: If the build is successful, you will find the flashable .uf2 files inside the build directory:
    • build/sniffer.uf2
    • build/sink.uf2

Flashing and Usage

Sniffer

  1. Flash the Firmware: Flash sniffer.uf2 to your Pico.
  2. Monitor the Output: Open a serial monitor and connect to the Pico’s virtual COM port. You will see the decoded USB-PD messages.

Sink

  1. Flash the Firmware: Flash sink.uf2 to your Pico.
  2. Connect to Power Adapter: Connect the CC line of your circuit to a USB-PD power adapter.
  3. Monitor the Output: Open a serial monitor. The application will print a message if it finds and requests the 15V/3A profile.