Skip to content

Instantly share code, notes, and snippets.

@Fede-26
Last active September 24, 2024 15:13
Show Gist options
  • Save Fede-26/96df16410e0dd2ba9788457d0ac0e39b to your computer and use it in GitHub Desktop.
Save Fede-26/96df16410e0dd2ba9788457d0ac0e39b to your computer and use it in GitHub Desktop.
Build cdc-acm, usbserial and uvc USB kernel modules for MuOS on Anbernic RG35XX-H / Plus
#!/usr/bin/env sh
# Build cdc-acm USB and V4L2 kernel modules for Anbernic RG35XX-H / Plus
# Inspired by https://gist.github.com/mnml/12f75bbf16eac4def15ba72cf1b11926
echo "[##] Downloading kernel"
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.9.170.tar.gz
echo "[##] Unzipping kernel"
tar xzf linux-4.9.170.tar.gz
cd linux-4.9.170
echo "[##] Downloading config"
wget -O .config https://raw.githubusercontent.com/knulli-cfw/distribution/refs/heads/knulli-main/board/batocera/allwinner/h700/linux-sunxi64-legacy.config
sed -i 's/# CONFIG_USB_ACM is not set/CONFIG_USB_ACM=m/g' .config
sed -i 's/# CONFIG_USB_SERIAL is not set/CONFIG_USB_SERIAL=m/g' .config
sed -i 's/# CONFIG_USB_SERIAL_GENERIC is not set/CONFIG_USB_SERIAL_GENERIC=y/g' .config
sed -i 's/# CONFIG_USB_SERIAL_CH341 is not set/CONFIG_USB_SERIAL_CH341=m/g' .config
sed -i 's/^YYLTYPE yylloc;$/extern YYLTYPE yylloc;/g' scripts/dtc/dtc-lexer.lex.c_shipped
echo "[##] Making configs"
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- olddefconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules_prepare
echo "[##] Compiling cdc-acm.ko"
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- M=drivers/usb/class #cdc-acm.ko
echo "[##] Compiling usbserial.ko and others"
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- M=drivers/usb/serial #usbserial.ko and others
echo "[##] Compiling uvcvideo.ko"
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- M=drivers/media/usb/uvc #uvcvideo.ko
cd ..
mkdir built-modules
cp linux-4.9.170/drivers/usb/class/cdc-acm.ko built-modules/
cp linux-4.9.170/drivers/usb/serial/*.ko built-modules/
cp linux-4.9.170/drivers/media/usb/uvc/uvcvideo.ko built-modules/
echo "DONE!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment