Skip to content

Instantly share code, notes, and snippets.

@ecliptik
Last active September 1, 2024 18:20
Show Gist options
  • Save ecliptik/caed560a14c9804137be9e01bb997f79 to your computer and use it in GitHub Desktop.
Save ecliptik/caed560a14c9804137be9e01bb997f79 to your computer and use it in GitHub Desktop.
usb4vc Bookworm

usb4vc on Bookworm

Pre Requisites

Notes

32-bit Raspbian armhf is required, running on 64-bit Raspbian will start usb4vc, but give errors in the debug log,

Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/usb4vc/rpi_app/usb4vc_usb_scan.py", line 788, in raw_input_event_worker
    event_code = data[3] * 256 + data[2]
                 ~~~~^^^
IndexError: list index out of range

python3-rpi.gpio packages will give an error in the debug log,

RuntimeError: Failed to add edge detection

Switching to python3-rpi-lgpio fixes this.

Everything in /home/pi comes from the official usb4vc release (https://github.com/dekuNukem/USB4VC/releases/tag/0.3.3), which was copied over.

Todo

  • Run as user other than pi, maybe usb4vc?
  • Add/test xpadneo from upstream git instead of on usb4vc image
  • Add how to install usb4vc from git and not from sdcard image
  • Does the pi/usb4vc user need sudo? Even a shell?

Update and Install Packages

sudo apt update
sudo apt upgrade
sudo apt install i2c-tools git stm32flash dfu-util evtest dkms raspberrypi-kernel-headers python3 python3-pip python3-pil libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libudev-dev libevdev-dev x2gothinclient-usbmount cmake python3-rpi-lgpio

RaspberryPi and System Configuration

Add user pi (should change to something like usb4vc, but need to look at script more) and add to sudo group

sudo adduserpi
sudo usermod -G sudo pi

Run sudo raspi-config and enable the following under Interface Options

  • SPI
  • I2C
  • Hardware Serial
  • Do not enable login shell over serial

Remove CTRL+ALT+DELETE reboot

sudo rm /lib/systemd/system/ctrl-alt-del.target
sudo ln -s /dev/null /lib/systemd/system/ctrl-alt-del.target
sudo systemctl daemon-reload

Add startup script to to /etc/rc.local

cd /home/pi/usb4vc/rpi_app; python3 keep_alive.py 2>&1 | tee -a /home/pi/usb4vc/usb4vc_debug_log.txt &

Update /boot/firmware/config.txt to include,

disable_splash=1
boot_delay=0
gpu_freq=250
gpu_freq_min=250

Add quiet to /boot/firmware/cmdline.txt after rootwait

Configure USB

Edit /lib/systemd/system/systemd-udevd.service set PrivateMounts=no

Setup bluetooth

echo 'options bluetooth disable_ertm=Y' | sudo tee -a /etc/modprobe.d/bluetooth.conf

Python Setup

Python

sudo mv /usr/lib/python3.11/EXTERNALLY-MANAGED /usr/lib/python3.11/EXTERNALLY-MANAGED.old
sudo -H pip3 install luma.oled
sudo su -
pip3 install evdev

Setup usb4vc

Run commands as pi in /home/pi (need to update to a usb4vc user at some point)

sudo su -
tar -xvzf pi.tar.gz
chown -R pi:pi /home/pi/

3rd Party Utilities

Run commands as pi in /home/pi (need to update to a usb4vc user at some point)

xpadneo

cd /home/pi/xpadneo
sudo ./install.sh

dkms-hid-nintendo

git clone --depth=1 https://github.com/nicman23/dkms-hid-nintendo
cd dkms-hid-nintendo
sudo dkms add .
sudo dkms build nintendo -v 3.2
sudo dkms install nintendo -v 3.2

joycond

git clone --depth=1 https://github.com/DanielOgorchock/joycond.git
cd joycond
cmake .
sudo make install
sudo systemctl enable --now joycond

Reboot

If everything went through without error, reboot and check for functionality.

Debug logs are in /home/pi/usb4vc/usb4vc_debug_log.txt

Debug Log Output

lsb_release -a && uname -a && ps aux | grep usb4vc && cat /home/pi/usb4vc/usb4vc_debug_log.txt

No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 12 (bookworm)
Release:	12
Codename:	bookworm

Linux fatmac 6.6.31+rpt-rpi-v7 #1 SMP Raspbian 1:6.6.31-1+rpt1 (2024-05-29) armv7l GNU/Linux

root       770  0.0  0.1   6660  1536 ?        S    22:08   0:00 tee -a /home/pi/usb4vc/usb4vc_debug_log.txt
root      1026  0.0  0.1   2144  1280 ?        S    22:09   0:00 sh -c cd /home/pi/usb4vc/rpi_app; python3 -u usb4vc_main.py
root      1027 23.8  3.1 133324 29568 ?        Sl   22:09   6:11 python3 -u usb4vc_main.py

Version: luma.oled 3.13.0 (luma.core 2.4.2)
Display: ssd1306
Interface: spi
Dimensions: 128 x 32
------------------------------------------------------------
ensure_dir /home/pi/usb4vc/rpi_app
ensure_dir /home/pi/usb4vc/config
ensure_dir /home/pi/usb4vc/firmware
ensure_dir /home/pi/usb4vc/temp
current_model Raspberry Pi 3 Model B Rev 1.2
stored_model Raspberry Pi 3 Model B Rev 1.2
@@@@@@@@@@@@ writing usbhid.mousepoll to /boot/cmdline.txt @@@@@@@@@@@@
PB INFO: [205, 0, 128, 3, 0, 0, 1, 0, 131, 134, 9, 10, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
{'rpi_app_ver': [0, 3, 1], 3: {'keyboard_protocol_index': 2, 'mouse_protocol_index': 1, 'mouse_sensitivity_index': 2, 'gamepad_protocol_index': 0, 'joystick_curve_index': 0}}
usb_device_scan_worker started
ui_worker started
set_protocol: ['0xde', '0x0', '0x2', '0xb', '0x8a', '0x3', '0x89', '0x6', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0']
raw_input_event_worker started
new status: ['0xcd', '0x0', '0x80', '0x3', '0x0', '0x0', '0x1', '0x0', '0x3', '0x6', '0x89', '0x8a', '0xb', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0']
opened device: 0x4d4d 0x458 MythosMann TG4x
opened device: 0x4d4d 0x458 MythosMann TG4x Mouse
opened device: 0x4d4d 0x458 MythosMann TG4x System Control
opened device: 0x4d4d 0x458 MythosMann TG4x Consumer Control
opened device: 0x5ac 0x24f Meetion Wireless
opened device: 0x5ac 0x24f Meetion Wireless
opened device: 0x0 0x0 vc4-hdmi
opened device: 0x0 0x0 vc4-hdmi HDMI Jack
sleeping!
waking up!
sleeping!
waking up!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment