This is a script to build a custom raspberry pi kernel, including a kernel patch to fix dwc2 wakeup issue. I haven't tested, but probably works for Pi4 or Pi5.
Also, the directory raspi_scripts
contains utilities to setup HID keyboard, RNDIS or ECM. Using a python library by @Danny-Dasilva (https://github.com/Danny-Dasilva/Py_Keyboard)
Patch reference: https://github.com/pikvm/packages/blob/master/packages/linux-rpi-pikvm/1003-remote-wakeup.patch raspberrypi/linux#3977 http://www.dt8.jp/cgi-bin/adiary/adiary.cgi/0583
- (if you are using selinux, run this script to allow write access from docker)
sudo sh selinux.sh
sh download.sh
sh docker.sh
- (inside docker)
cd /rpizero-linux-build
- (inside docker)
sh clean.sh
- (inside docker)
sh build.sh
- (inside docker)
exit
- Create a file named
names.sh
and set the contents as follows.MYHOSTNAME=<hostname of rpi zero including .local, or the ip address of it> MYUSERNAME=<username of rpi zero> MY_KERNEL_SUFFIX=wakeup MY_KERNEL_NAME=kernel-$MY_KERNEL_SUFFIX
sh pack.sh
sh packsend.sh
make sure you have SSH access to the rpi zero and it is connected to the local network. Alternatively, you can just copy generated files atinstall/
to the SD card. First, copyboot/firmware
into/
of the EFI partition (usually the first partition). Second, copylib/modules
intolib/modules
of the root partition (usually the second partition). Beware of file ownership. All files should be owned byroot
.- ssh into the rpizero and edit
/boot/firmware/config.txt
. Add following lines to the boot configuration. Alternatively, you can edit the SD. The file is at/config.txt
in the EFI partition. If anything wrong happens (eg. the system doesn't start), please edit SD directly and delete these lines to revert all changes made to the system.[all] dtoverlay=dwc2 kernel=kernel-wakeup.img
- ssh into the rpizero and reboot
-
raspi_scripts/
: scripts to be run inside raspberry pietc/rc.local
: rc file to enable HID mouse and keyboard on startuphome/someusername
: scripts to control USB devicekeyboard2.py
: control HID keyboard via command line
Example1 :p CONTROL ALT DEL
Example2 :p ALT F4
Example3 :p DOWN_ARROW
Example4 :w sometext12345
root/
: scripts to enable HID/Ether feature on startupgeth.sh
: Enable an old driver for ethernet over USB using RNDIS. On windows, you have to install a special driver to connect to the rpi zero. Go to https://www.catalog.update.microsoft.com/Search.aspx?q=USB%20RNDIS%20Gadget, and download the driver file named "Acer Incorporated. - Other hardware - USB Ethernet/RNDIS Gadget". On linux, it works without any configration.hid-and-eth.sh
: enable both HID and Ethernet-over-USB at the same time using a new driver. Unfortunately, there is no signed Windows driver for it.hid-double.sh
: enable both HID keyboard and Mouse.hid.sh
: enable only HID keyboard.remove.sh
: unloads all drivers so that you can use any of these scripts again. very unstable, so it is better to restart the rpi zero instead.
-
host_scripts/
: scripts to be run from the remote computer that will control raspberry piqt.py
: Use PyQt5 to synchronize keyboard input and mouse movement
USAGE: Alt+G to toggle mouse grabbing. After switching mouse grabbing on, just type text or moving mouse. Note that on MacOS, CTRL is interpreted as COMMAND/WINDOWS key, and COMMAND/WINDOWS is interpreted as CTRL key.mouse.py
: Use Xlib to synchronize mouse movement