My OTG port now works fine on 5.10 kernel with dynamic power, whereas on fresh install it did not.
Dynamic power turns the 5V OTG port on and off automatically as needed, while static (regulator-always-on) forces 5V power to stay on continuously even when nothing is plugged in.
Unlike my 4.4 kernel OTG fix script (and its companion script)which will safely run on many, many dtb's, from many OS's, whether they should have the script run on them or not, THIS IS NOT THAT.
This is a guaranteed fix for a single dtb, for a single board, for a single OS at the moment.
R36S-V21 2024-12-18 2642 (should also work on 2550, 2551, and 2552)
(d)ArkOS4Clone 20261126
dtb_selector -> GameConsole -> GameConsole R36S Panel 4 Type 1 -> Kernel 5.10 (rk3326-r36s-panel4-type1-linux.dtb)
If you decide to use it, BACKUP YOUR CURRENT DTB!
5.10 is in its infancy. The repo dtb files could change drastically and this script will be completely moot when they do.
My OTG did not work on a fresh install, selecting the proper dtb for my board. ("Type 2" says it fixes wifi, I don't know about 5.10, but in 4.4 I simply thought the WiFi fix wasn't quite optimal, so I again chose this route.)
This script creates an *.orig of your dtb, in the BOOT partition as an extra faisafe/fallback.
These are the changes it makes to the dtb (+/- = add/remove lines):
1. Allow battery power to OTG port
+ power_dc2otg = <0x00>;
2. Free up the Wi-Fi power pin (GPIO0_B7)
- status = "okay"; (on pwm0)
+ status = "disabled";
3. Fix OTG IRQ order, turn on USB OTG port, and link it to 5V power
- interrupts = <0x00 0x42 0x04 0x00 0x41 0x04 0x00 0x40 0x04>;
- interrupt-names = "otg-bvalid", "otg-id", "linestate";
- status = "disabled";
+ interrupts = <0x00 0x41 0x04 0x00 0x42 0x04 0x00 0x40 0x04>;
+ interrupt-names = "otg-id", "otg-bvalid", "linestate";
+ vbus-supply = <0x17b>;
+ status = "okay";
4. Lock USB port into Host mode
- dr_mode = "otg";
+ dr_mode = "host";
5. Stop gamepad driver from crashing without rumble
- pwms = <0xc1 0x00 0xbebc200 0x00>;
- pwm-names = "enable";
- rumble-boost-weak = <0x00>;
- rumble-boost-strong = <0x00>;
6. Create the dynamic 5V OTG power regulator on GPIO0_B7
+ vcc_host {
+ compatible = "regulator-fixed";
+ regulator-name = "vcc_host";
+ regulator-min-microvolt = <0x4c4b40>;
+ regulator-max-microvolt = <0x4c4b40>;
+ gpio = <0x61 0x0f 0x00>;
+ enable-active-high;
+ vin-supply = <0x69>;
+ phandle = <0x17b>;
+ };
And yes. I am testing. Not a lot. In fact, at this point, barely. I have a single board that I can test against, so whatever version of the script you see on this page will have always worked for me on my 2642 board before I post it here.
Save it in Unix LF format.
#!/bin/bash
# ==============================================================================
# R36S - Smart 1-Click Dynamic OTG Wi-Fi + Stick Fix (5.10 Kernel Only)
# ==============================================================================
# Drop into EASYROMS/tools/ and run from Options -> Tools on the R36S.
# ==============================================================================
trap 'rm -f /tmp/panel4_510_clean.dts /tmp/panel4_510_patched.dts /tmp/patched_510_out.dtb' EXIT
# Ensure output is visible on handheld screen (tty1) under 5.10 builds
if [ -w /dev/tty1 ]; then
exec >/dev/tty1 2>&1
fi
countdown() {
local LABEL="$1"
local SECS="${2:-10}"
echo ""
for ((i=SECS; i>0; i--)); do
printf "\r%s in %2d seconds... " "$LABEL" "$i"
sleep 1
done
echo ""
}
printf "\033c"
echo "=========================================="
echo " R36S [5.10] OTG Wi-Fi + Stick Fix"
echo "=========================================="
# 1. Verify Linux 5.10 kernel
KVER=$(uname -r)
if [[ "$KVER" != 5.10* ]]; then
echo "ERROR: Detected kernel $KVER (this patch is for 5.10 kernels only)."
echo "For 4.4 kernels, use Fix_2642_WiFi.sh instead."
countdown "Exiting" 10
exit 1
fi
# 2. Locate boot.ini
BOOT_INI=$(find /boot /mnt /media -maxdepth 3 -name "boot.ini" 2>/dev/null | head -n 1)
if [ -z "$BOOT_INI" ]; then
echo "ERROR: Could not find boot.ini on the boot partition!"
countdown "Exiting" 10
exit 1
fi
BOOT_DIR="$(dirname "$BOOT_INI")"
DTB_REL=$(tr -d '\r' < "$BOOT_INI" | grep -oE '[^ ]+\.dtb' | grep -v '\$' | head -n 1 | sed 's|^/||')
[ -z "$DTB_REL" ] && DTB_REL="rk3326-r36s-panel4-type1-linux.dtb"
BOOT_DTB="$BOOT_DIR/$DTB_REL"
DTB_NAME="$(basename "$DTB_REL")"
echo "Detected kernel: $KVER"
echo "Detected active DTB: $BOOT_DTB"
if [ ! -f "$BOOT_DTB" ] || ! command -v dtc >/dev/null 2>&1; then
echo "ERROR: $BOOT_DTB or 'dtc' not found!"
countdown "Exiting" 10
exit 1
fi
# 3. Decompile to /tmp for inspection & smart patching
RAW_DTS="/tmp/panel4_510_clean.dts"
PATCHED_DTS="/tmp/panel4_510_patched.dts"
OUT_DTB="/tmp/patched_510_out.dtb"
echo "[1/3] Decompiling & inspecting $DTB_NAME..."
dtc -I dtb -O dts -o "$RAW_DTS" "$BOOT_DTB" 2>/dev/null
# 4. Pre-flight hardware & board compatibility checks
GPIO0_PH=$(perl -0777 -ne 'if (/gpio0\@ff040000\s*\{[^}]*?phandle\s*=\s*<([^>]+)>/s) { $p=$1; $p=~s/\s+//g; print $p; }' "$RAW_DTS")
if grep -qiE 'G80|GR36|Variant|Y3506|2025-05-18|amux-channel-mapping|led-blue' "$RAW_DTS"; then
echo "ABORTED: Clone or SoySauce DTB detected."
echo "This script is for genuine R36S boards only."
countdown "Exiting" 10
exit 1
fi
if ! grep -q 'odroidgo3-joypad' "$RAW_DTS"; then
echo "ABORTED: Generic rg351mp / non-R36S joypad layout detected."
echo "Make sure you are using a genuine R36S DTB."
countdown "Exiting" 10
exit 1
fi
if ! grep -q 'gpio0@ff040000' "$RAW_DTS" || ! grep -q 'regulator-name = "vcc3v8_sys";' "$RAW_DTS" || ! grep -q 'dc_det_gpio' "$RAW_DTS"; then
echo "ABORTED: Incompatible PMIC or board layout (not an RK817 R36S DTB)."
countdown "Exiting" 10
exit 1
fi
if grep -q 'rumble-pins' "$RAW_DTS" || { [ -n "$GPIO0_PH" ] && grep -qE "${GPIO0_PH}\s+0x0f\b" "$RAW_DTS" && ! grep -qE 'regulator-name\s*=\s*"vcc[-_]host";' "$RAW_DTS"; }; then
echo "ABORTED: GPIO0_B7 is hogged by a conflicting driver (e.g. rumble or LED node)."
echo "Switch to a clean stock R36S DTB first, then run this script."
countdown "Exiting" 10
exit 1
fi
# 5. Smart idempotent dynamic 5.10 patch
echo "[2/3] Applying dynamic 5.10 OTG / GPIO0_B7 fixes..."
perl -0777 -pe '
my ($gpio0_blk) = /(gpio0\@ff040000\s*\{[^}]*\})/s;
my ($gpio0_ph) = ($gpio0_blk || "") =~ /phandle\s*=\s*<([^>]+)>/;
$gpio0_ph =~ s/\s+//g if $gpio0_ph;
my ($pwm0_blk) = /(pwm\@ff200000\s*\{[^}]*\})/s;
my ($pwm0_ph) = ($pwm0_blk || "") =~ /phandle\s*=\s*<([^>]+)>/;
$pwm0_ph =~ s/\s+//g if $pwm0_ph;
my ($bl_blk) = /(backlight\s*\{[^}]*\})/s;
my $bl_uses_pwm0 = ($pwm0_ph && $bl_blk && $bl_blk =~ /pwms\s*=\s*<\s*\Q$pwm0_ph\E\b/) ? 1 : 0;
my ($vccsys_blk) = /(\{[^{}]*regulator-name\s*=\s*"vcc3v8_sys";[^}]*\})/s;
my ($vccsys_ph) = ($vccsys_blk || "") =~ /phandle\s*=\s*<([^>]+)>/;
$vccsys_ph =~ s/\s+//g if $vccsys_ph;
if ($gpio0_ph && $vccsys_ph) {
# Step A: Disable PWM0 unless backlight uses PWM0 + strip optional rumble PWM from 5.10 joypad
unless ($bl_uses_pwm0) {
s/(pwm\@ff200000\s*\{[^}]*?)status\s*=\s*"okay";/$1status = "disabled";/s;
s/\bpwms\s*=\s*<[^>]+>;\s*pwm-names\s*=\s*"[^"]*";\s*rumble-boost-weak\s*=\s*<[^>]+>;\s*rumble-boost-strong\s*=\s*<[^>]+>;\s*//s;
}
# Step B: Create dynamic vcc_host OR update existing vcc-host/vcc_host node to GPIO0_B7 (0x0f)
if (/\{[^{}]*regulator-name\s*=\s*"vcc[-_]host";[^}]*\}/s) {
s/(?<!vcc_host:\s)\bvcc_host\s*\{/vcc_host: vcc_host {/g;
s!(\{[^{}]*regulator-name\s*=\s*"vcc[-_]host";[^}]*\})!
my $blk = $1;
if ($blk =~ m/gpio\s*=\s*<[^>]+>;/) {
$blk =~ s/gpio\s*=\s*<[^>]+>;/gpio = <$gpio0_ph 0x0f 0x00>;/;
} else {
$blk =~ s/(regulator-name\s*=\s*"vcc[-_]host";)/$1\n\t\tgpio = <$gpio0_ph 0x0f 0x00>;/;
}
$blk =~ s/(gpio\s*=\s*<[^>]+>;)/$1\n\t\tenable-active-high;/ unless $blk =~ m/enable-active-high/;
$blk;
!se;
} else {
s/(\{[^{}]*regulator-name\s*=\s*"vcc3v8_sys";[^}]*\};)/$1\n\n\tvcc_host: vcc_host {\n\t\tcompatible = "regulator-fixed";\n\t\tregulator-name = "vcc_host";\n\t\tregulator-min-microvolt = <0x4c4b40>;\n\t\tregulator-max-microvolt = <0x4c4b40>;\n\t\tgpio = <$gpio0_ph 0x0f 0x00>;\n\t\tenable-active-high;\n\t\tvin-supply = <$vccsys_ph>;\n\t};/s;
}
# Step C: Fix 5.10 usb2-phy otg-port IRQ order ("otg-id" first), enable, and link vbus-supply
s/(otg-port\s*\{[^}]*?)interrupts\s*=\s*<0x00 0x42 0x04 0x00 0x41 0x04 0x00 0x40 0x04>;\s*interrupt-names\s*=\s*"otg-bvalid",\s*"otg-id",\s*"linestate";/$1interrupts = <0x00 0x41 0x04 0x00 0x42 0x04 0x00 0x40 0x04>;\n\t\t\t\tinterrupt-names = "otg-id", "otg-bvalid", "linestate";/s;
s/(otg-port\s*\{[^}]*?)status\s*=\s*"disabled";/$1status = "okay";/s;
unless (/otg-port\s*\{[^}]*?vbus-supply\s*=/s) {
s/(otg-port\s*\{[^}]*?)(status\s*=\s*"okay";)/$1vbus-supply = <&vcc_host>;\n\t\t\t\t$2/s;
}
# Step D: Allow battery power to OTG
unless (/power_dc2otg\s*=/) {
s/(dc_det_gpio\s*=\s*<[^>]+>;)/power_dc2otg = <0x00>;\n\t\t\t\t$1/;
}
# Step E: Force usb@ff300000 (dwc2) into permanent host mode on 5.10
s/(usb\@ff300000\s*\{[^}]*?)dr_mode\s*=\s*"otg";/$1dr_mode = "host";/s;
}
' "$RAW_DTS" > "$PATCHED_DTS"
# 6. Check if any changes were actually needed
if cmp -s "$RAW_DTS" "$PATCHED_DTS"; then
echo ""
echo "ALREADY PATCHED: All 5.10 dynamic OTG/GPIO0_B7 fixes are already active in $DTB_NAME!"
echo "No changes were needed."
countdown "Exiting" 10
exit 0
fi
# 7. Verify all required end-states exist in the resulting DTS
if ! grep -q 'vbus-supply =' "$PATCHED_DTS" || \
! grep -q 'power_dc2otg = <0x00>;' "$PATCHED_DTS" || \
! grep -q 'dr_mode = "host";' "$PATCHED_DTS" || \
! GPIO0_PH="$GPIO0_PH" perl -0777 -ne 'exit(1) unless /\{[^{}]*regulator-name\s*=\s*"vcc[-_]host";[^{}]*gpio\s*=\s*<\s*\Q$ENV{GPIO0_PH}\E\s+0x0f\b/s' "$PATCHED_DTS" || \
! perl -0777 -ne 'exit(1) unless /otg-port\s*\{[^}]*?status\s*=\s*"okay";/s' "$PATCHED_DTS"; then
echo "ERROR: Patch verification failed! Original DTB untouched."
countdown "Exiting" 10
exit 1
fi
# 8. Save backup & compile
BACKUP_DTB="${BOOT_DTB}.orig"
if [ ! -f "$BACKUP_DTB" ]; then
sudo cp "$BOOT_DTB" "$BACKUP_DTB"
echo "Saved backup: $BACKUP_DTB"
fi
echo "[3/3] Compiling patched 5.10 DTB..."
DTC_ERR=$(dtc -I dts -O dtb -o "$OUT_DTB" "$PATCHED_DTS" 2>&1 >/dev/null | grep -i "error" || true)
if [ ! -s "$OUT_DTB" ] || [ -n "$DTC_ERR" ]; then
echo "ERROR: dtc compile failed!"
echo "$DTC_ERR"
countdown "Exiting" 10
exit 1
fi
sudo cp -f "$OUT_DTB" "$BOOT_DTB"
sync
echo ""
echo "SUCCESS! Applied dynamic 5.10 OTG fixes cleanly."
countdown "Rebooting" 10
sudo reboot
Apologies, but I won't have a lot of answers to questions or inquiries about this. Will it work on your board? Beats me! The 5.10 dtb was far different than the 4.4 one. Like way more different than I expected.