Mastodon Politics, Power, and Science: Kindle Paperwhite 2 (PW2) USB Audio Implementation Plan

Monday, March 9, 2026

Kindle Paperwhite 2 (PW2) USB Audio Implementation Plan

 

I. Hardware Requirements

  • Audio Output: Generic USB DAC (USB Audio Class 1 compatible).
  • Power Supply: External 5V DC source (Battery or regulated wall power).
  • Wiring: USB "Y-cable" configuration or custom solder job.
  • Logic: Common Ground (GND) between Kindle and 5V source.

II. Hardware Implementation (The Power/Ground Hack)

  1. VCC (5V): Connect the external 5V source directly to the DAC's VCC pin. Do not connect this to the Kindle's VCC pin.
  2. GND (Ground): Solder a common ground connecting the Kindle’s USB GND (Pin 5), the external 5V source GND, and the DAC’s GND.
  3. Data (D+/D-): Connect Kindle Pin 2 (D-) and Pin 3 (D+) directly to the DAC’s data pads.
  4. ID Pin (Host Mode): To trigger Host Mode, bridge Kindle Pin 4 (ID) to GND (Pin 5) using a 10kΩ resistor. If the trace is missing on the PW2 board, Host Mode must be forced via the musb registers in software.

III. Software Implementation (The Driver Stack)

  1. Environment: Set up a Linux VM with an arm-linux-gnueabi toolchain.
  2. Kernel Modules:
    • Download the Kindle PW2 GPL source (e.g., version 5.4.x).
    • Configure the kernel to build modules (m) for:
      • CONFIG_SND_USB_AUDIO
      • CONFIG_SND_PCM
      • CONFIG_SND_HWDEP
      • CONFIG_SND
    • make modules and extract the .ko files.
  3. ALSA User-land:
    • Cross-compile alsa-lib and alsa-utils.
    • The primary binary needed is aplay for raw playback or amixer for volume control.
  4. Media Player: Cross-compile mpg123 or mplayer for MP3/FLAC decoding.

IV. KUAL Integration (The GUI)

Create a new extension directory: /extensions/usbaudio/.
  1. Initialization Script (bin/load_audio.sh):
    #!/bin/sh
    mntroot rw
    # Load the audio stack
    insmod /mnt/us/usbaudio/modules/snd.ko
    insmod /mnt/us/usbaudio/modules/snd-pcm.ko
    insmod /mnt/us/usbaudio/modules/snd-usb-audio.ko
    # Force Host Mode on the Freescale/NXP USB Controller
    echo "host" > /sys/devices/platform/fsl-usb2-otg/mode
    # Feedback to Screen
    if [ -e /dev/snd/pcmC0D0p ]; then
        eips 0 0 "USB Audio: READY"
    else
        eips 0 0 "USB Audio: FAILED"
    fi
    
  2. KUAL Menu (menu.json):
    {
      "items": [
        {"name": "Enable USB Audio", "priority": 1, "action": "bin/load_audio.sh"},
        {"name": "Play Music", "priority": 2, "action": "bin/play.sh"}
      ]
    }
    
  3. Playback Script (bin/play.sh):
    #!/bin/sh
    # Pipe files from user storage to the DAC
    /mnt/us/usbaudio/bin/mpg123 -a hw:0,0 /mnt/us/music/*.mp3
    

V. Execution Flow

  1. Connect the powered DAC to the Kindle.
  2. Launch KUAL from the Kindle home screen.
  3. Select "Enable USB Audio" (Triggers the insmod and Host Mode flip).
  4. Verify device detection via SSH using lsusb and cat /proc/asound/cards.
  5. Select "Play Music" via KUAL to initiate the binary playback.

No comments:

Post a Comment

Made Progress on the r36s handheld.

 I got it last year and loaded a game on it and couldn't get it to not pop up the menu every few seconds because that menu had been mapp...