Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4686

Advanced users • USB MIDI device on Raspberry Pi can't make it work!

$
0
0
I'm on:
Linux hp-protob 6.6.74+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.74-1+rpt1 (2025-01-27) aarch64

and I have the Pi5 powered using the 40 pin connector, and the USBC port connected to a Mac


I have looked at several threads and tutorials but so far it seems I cannot get the Raspberry 5 in device/peripheral mode on the USBC connector.

I followed the instructions in here, which seems to get some success:
viewtopic.php?p=2243257

I got the service going and it creates the files as expected in
/sys/kernel/config/usb_gadget/midi_gadget/

but when I look here:

ls /sys/class/udc

I get nothing.


I have /boot/firmware/config.txt

Code:

[cm4]# Enable host mode on the 2711 built-in XHCI USB controller.# This line should be removed if the legacy DWC2 controller is required# (e.g. for USB device mode) or if USB support is not required.# otg_mode=1[cm5]# dtoverlay=dwc2,dr_mode=hostdtoverlay=dwc2,dr_mode=peripheral
and /boot/firmware/cmdline.txt

Code:

console=serial0,115200 console=tty1 root=PARTUUID=1299cf8a-02 rootfstype=ext4 fsck.repair=yes rootwait modules-load=dwc2 cfg80211.ieee80211_regdom=GB

/usr/local/bin/setup_usb_midi.sh

Code:

#!/bin/bash# Check if the script is run as rootif [[ $EUID -ne 0 ]]; then   echo "This script must be run as root"   exit 1fi# Load USB gadget modulesmodprobe libcomposite# Create the gadget directorymkdir -p /sys/kernel/config/usb_gadget/midi_gadgetcd /sys/kernel/config/usb_gadget/midi_gadget# Set USB device attributesecho 0x1d6b > idVendor  # Linux Foundationecho 0x0104 > idProduct # Multifunction Composite Gadget# echo 0x0100 > bcdDevice # v1.0.0# echo 0x0200 > bcdUSB    # USB2# Set device description stringsmkdir -p strings/0x409echo "001" > strings/0x409/serialnumberecho "manufacturer" > strings/0x409/manufacturerecho "product" > strings/0x409/product# Create configurationmkdir -p configs/c.1/strings/0x409echo "Config 1: MIDI" > configs/c.1/strings/0x409/configurationecho 250 > configs/c.1/MaxPower# Create MIDI functionmkdir -p functions/midi.usb0# echo "0" > functions/midi.usb0/in_jack_id# echo "1" > functions/midi.usb0/out_jack_id# Bind the configuration to the functionln -s functions/midi.usb0 configs/c.1# Enable the USB gadgetUDC=$(ls /sys/class/udc | head -n 1)echo "$UDC" > UDC
and /etc/systemd/system/usb_midi.service

Code:

[Unit]Description=USB MIDI GadgetAfter=multi-user.target[Service]Type=oneshotRemainAfterExit=trueExecStart=/usr/bin/sudo /usr/local/bin/setup_usb_midi.sh[Install]WantedBy=multi-user.target


any suggestions?

Statistics: Posted by ultramarineblue — Thu Feb 06, 2025 1:32 am — Replies 1 — Views 26



Viewing all articles
Browse latest Browse all 4686

Trending Articles