- Download and install Rasperry Pi Imager application from here.
- Insert MicroSD card into your computer SD card reader.
- Select RASPBERRY PI OS LITE (64-BIT) Bullseye and newly inserted MicroSD card in Rasperry Pi Imager application.
- Configure required Raspberry Pi settings by clicking gear icon (SSH, hostname, etc.).
- Click Write and wait until completion.
- Safely eject MicroSD card from the SD card reader and insert into Raspberry Pi.
- Boot the Raspberry Pi.
- Create file at path:
/etc/udev/rules.d/100-usb-proxy.rules- Enter following text into file and save it:
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="*", ATTR{idProduct}=="*", MODE="0666", NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}", RUN+="/bin/chmod 0666 %c"- Restart udev with following command:
udevadm control --reload-rules && udevadm triggerBased on the following original instructions.
- Log in into Raspberry Pi via SSH.
- Install required dependencies:
sudo apt update && sudo apt install git bc bison flex libssl-dev libncurses5-dev -y && sudo wget https://raw.githubusercontent.com/RPi-Distro/rpi-source/master/rpi-source -O /usr/local/bin/rpi-source && sudo chmod +x /usr/local/bin/rpi-source && /usr/local/bin/rpi-source -q --tag-update && rpi-source- Clone original Git repository.
git clone https://github.com/xairy/raw-gadget.git- Clone original Git repository.
cd raw-gadget/raw_gadget && make- Following error may happen:
raw_gadget.c:548:8: error: implicit declaration of function ‘usb_gadget_probe_driver’;Rename all entries of usb_gadget_probe_driver() to usb_gadget_register_driver() and rebuild.
- Install newly build kernel module:
./insmod.sh- Verify that kernel module somewhat started to work:
ls -l /dev/
# "/dev/raw-gadget" shall appear in the list.- Edit insmod.sh to following for easier automatic startup:
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
script_dir="$( dirname -- "$BASH_SOURCE"; )";
set -eux
sudo modprobe udc_core
sudo insmod $script_dir/raw_gadgetBased on the following original instructions.
- Log in into Raspberry Pi via SSH.
- Install required dependencies:
sudo apt install libusb-1.0-0-dev libjsoncpp-dev -y && wget https://github.com/WiringPi/WiringPi/releases/download/2.61-1/wiringpi-2.61-1-arm64.deb && sudo apt install ./wiringpi-2.61-1-arm64.deb- Enabled raw-gadget kernel module access:
echo "dtoverlay=dwc2" | sudo tee -a /boot/config.txt && echo "dwc2" | sudo tee -a /etc/modules && sudo reboot- Verify that access to raw-gadget kernel module has appeared:
ls /sys/class/udc/
# Should echo "fe980000.usb".
cat /sys/class/udc/fe980000.usb/uevent
# Should echo "USB_UDC_NAME=fe980000.usb".- Clone original Git repository.
git clone https://github.com/morwy/usb-proxy-rpi-gpio.git- Clone original Git repository.
cd usb-proxy-rpi-gpio && make- Test newly built application.
./usb-proxy --device=fe980000.usb --driver=fe980000.usb --vendor_id=044f --product_id=b66e- Create a bash script start.sh for easier future startup:
#!/bin/bash
script_dir="$( dirname -- "$BASH_SOURCE"; )";
sudo $script_dir/usb-proxy --device=fe980000.usb --driver=fe980000.usb --vendor_id=044f --product_id=b66e --enable_injection --injection_file=$script_dir/injection-rpi-gpio.json &- Create a new text file with 0644 permissions:
sudo nano /lib/systemd/system/usbproxy.service && sudo chmod 644 /lib/systemd/system/usbproxy.service- Add following text to the file:
[Unit]
Description=Starting raw-gadget and usb-proxy at boot
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=true
# Load raw-gadget kernel module at first and then start usb-proxy.
ExecStart=/home/pi/raw-gadget/raw_gadget/insmod.sh
ExecStart=/home/pi/usb-proxy-rpi-gpio/start.sh
ExecReload=sudo rmmod raw_gadget
ExecReload=pkill -f "usb-proxy"
ExecReload=/home/pi/raw-gadget/raw_gadget/insmod.sh
ExecReload=/home/pi/usb-proxy-rpi-gpio/start.sh
# In case of stop or failure unload raw-gadget kernel module and kill usb-proxy.
ExecStopPost=sudo rmmod raw_gadget
ExecStopPost=pkill -f "usb-proxy"
[Install]
WantedBy=multi-user.target- Restart systemd service:
sudo systemctl daemon-reload- Enable autostart of newly created service:
sudo systemctl enable usbproxy.service- Reboot Raspberry Pi:
sudo reboot now- Verify that new service started and worked well:
sudo systemctl status usbproxy.service