Please comment if you think I can improve my question (like rephrase, add other tags) . I'm really at a loss at the moment.
There are many online instructions explaining how to make a raspberry pi zero behave like a USB keyboard / mouse / etc.
A few years ago I used my pi as a USB keyboard by just following instructions, that I found on the net everything was working fine.
Example: https://randomnerdtutorials.com/raspberry-pi-zero-usb-keyboard-hid/
I installed a new OS (Raspbian GNU/Linux 11 (bullseye)), which has a more recent kernel (6.1.21+) and all the instructions that I find don't work anymore. Whenever I perform the final command
ls /sys/class/udc > UDC
I get an error message:
ls: write error: Device or resource busy
Summary of what I tried.
- add "dtoverlay=dwc2" to /boot/config.txt
- add dwc2 and libcomposite to /etc/modules
- add
modules-load=dwc2,g_ether
at the end of/boot/cmdline.txt
I created a script that shall be called after bootup to setup your usb device:
Example version:
#!/bin/bash
cd /sys/kernel/config/usb_gadget/
mkdir -p isticktoit
cd isticktoit
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB2
mkdir -p strings/0x409
echo "fedcba9876543210" > strings/0x409/serialnumber
echo "Tobias Girstmair" > strings/0x409/manufacturer
echo "iSticktoit.net USB Device" > strings/0x409/product
mkdir -p configs/c.1/strings/0x409
echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration
echo 250 > configs/c.1/MaxPower
# Add functions here
mkdir -p functions/hid.usb0
echo 1 > functions/hid.usb0/protocol
echo 1 > functions/hid.usb0/subclass
echo 8 > functions/hid.usb0/report_length
echo -ne \\x05\\x01\\x09\\x06\\xa1\\x01\\x05\\x07\\x19\\xe0\\x29\\xe7\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02\\x95\\x01\\x75\\x08\\x81\\x03\\x95\\x05\\x75\\x01\\x05\\x08\\x19\\x01\\x29\\x05\\x91\\x02\\x95\\x01\\x75\\x03\\x91\\x03\\x95\\x06\\x75\\x08\\x15\\x00\\x25\\x65\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0 > functions/hid.usb0/report_desc
ln -s functions/hid.usb0 configs/c.1/
# End functions
ls /sys/class/udc > UDC
If my web searches are correct it seems that some things changed in newer kernels and therefore the old instructions don't work anymore. However I didn't find any article guiding me to a solution.
Does anyone have a raspberry pi zero W with a halfways recent distribution, that can act as a USB keyboard / mouse and have Wifi enabled at the same time?
I don't insist on Raspian.
In fact all that I want is a device, that can simulate mouse movements / clicks and be controlled via Wifi. in fact the major use case is even more simple.
I just want to be able to wake up a laptop, that is in standby mode and that doesn't have a working wake on lan feature. Send a command over Wwifi to the pizero and let it do a keyboard press / mouse click to wake it up would be all I really need.
/boot/cmdline.txt
or/boot/config.txt
or output oflsmod
? please tell me what could help and I'll add it to my question