Skip to content

Instantly share code, notes, and snippets.

@moritzmhmk
Last active July 30, 2017 17:11
Show Gist options
  • Save moritzmhmk/7e83dda02c9b530460fe538dd1975fed to your computer and use it in GitHub Desktop.
Save moritzmhmk/7e83dda02c9b530460fe538dd1975fed to your computer and use it in GitHub Desktop.
CEC Pi zero

Faking HDMI Port

echo "pa 30 00" | cec-client

sets physical address to 3.0.0.0 - which is HDMI Port 3 - receiving remote control signals from different hdmi port

Use Pi zero as "Pulse8 CEC Adapter"

Enable USB Serial

/boot/config.txt add dtoverlay=dwc2 /boot/cmdline.txt add modules-load=dwc2 (not dwc2,g_serial - see below)

Fake the VendorID and ProductID

To fake the VendorID and ProductID to match those of the usb adapter one cant use the default "g_serial" module.

Alternative method found here

#!/bin/bash -e

modprobe libcomposite

cd /sys/kernel/config/usb_gadget/
mkdir g && cd g

echo 0x2548 > idVendor  # pulse-8
echo 0x1001 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB    # USB 2.0

mkdir -p strings/0x409
echo "deadbeef00115599" > strings/0x409/serialnumber
echo "irq5 labs"        > strings/0x409/manufacturer
echo "Pi Zero Gadget"   > strings/0x409/product

mkdir -p functions/acm.usb0    # serial
# mkdir -p functions/rndis.usb0  # network

mkdir -p configs/c.1
echo 250 > configs/c.1/MaxPower
# ln -s functions/rndis.usb0 configs/c.1/
ln -s functions/acm.usb0   configs/c.1/

udevadm settle -t 5 || :
ls /sys/class/udc/ > UDC

Check that it is working

use cat /dev/ttyGS0 (or xxd /dev/ttyGS0 for hex output) to show received messages.

send messages by calling echo "foo" > /dev/ttyGS0 (or echo -n -e '\x66\x6f\x6f' > /dev/ttyGS0 for hex input)

Install a cec-client on the host

for macOS use Couch Slouch

check communication with above commands

Respond to received messages

pulse8 protocol

To be continued ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment