r/R36S • • 1d ago

News [RELEASE] (d)ArkOS4Clone 20261126 - Dolphin, ARMSX2, Azahar, Kodi

Post image
147 Upvotes

Following the recent 5.10 kernel and Vulkan update, it's time to show the new features this brings.

ArkOS4Clone 20261126 Release Notes https://github.com/lcdyk0517/arkos4clone/releases/tag/20261126

  1. Fixed a memory leak in SDL3 when using screen rotation, which could eventually cause OOM (Out of Memory).
  2. Fixed Vulkan issues on rotated-screen devices in PPSSPP, PPSSPP2021, Flycast, and Flycast2022, where Vulkan either failed to work or displayed the image with incorrect rotation.
  3. Added defensive safeguards to the 5.10 codec audio driver to reduce the maximum volume and prevent excessive audio output from potentially overdriving some low-quality speakers.
  4. Adjusted the build flags for the PSP and Dreamcast emulators to achieve a slight performance improvement.
  5. Fixed a bug where all core options in the ARMN64 and ARMGBA cores were displayed in Chinese.
  6. Added the standalone Dolphin emulator (5.10 kernel only).

    • Press SELECT + START to exit a game.
    • Place GameCube ROMs in the gc directory and Wii ROMs in the wii directory.
    • Thanks to jokubasver.
  7. Fixed an incorrect screen rotation issue in RetroArch on rotated-screen devices.
  8. Removed the PortMaster dependency. Users who need PortMaster should update it manually.
  9. Updated the rk817_codec driver in both the 5.10 and 4.4 kernels.

    • Thanks to jokubasver.
  10. Added the malisx2 0.6.1 driver.
  11. Added Kodi, accessible from the ArkOS4Clone menu under EmulationStation.
  • RK3326 supports hardware video decoding for H.264, HEVC (H.265), MPEG-1, MPEG-2, MPEG-4, and VP8.
  1. Added the 3DS emulator core (5.10 kernel only).
  • Game decryption is not available by default.
  • To enable on-device game decryption, compile lcdyk0517/3dsdec and place the resulting executable in /usr/local/bin.
  • Place boot9.bin in /roms/bios.
  • Place 3DS games in /roms/3ds.
  1. Added a PS2 emulator.
  • Vulkan is supported on both the 4.4.189 and 5.10.252 kernels.
  • Place BIOS files in /roms/bios.
  • Place games in /roms/ps2.
  • Press SELECT + X to open the emulator menu. Configure the controls and settings as needed.

r/R36S • • Jun 22 '26 Bravo

Guide R36S Buying Guide 2026: Vendor Overview and Protection Against Clone Hardware

Post image
195 Upvotes

Due to its low price point, the R36S remains a highly popular handheld in the entry-level retro emulation market. However, the commercial success of the device has led to numerous modified replicas (clones) and optical imitations (fakes) entering the market.

These devices often deviate significantly from the hardware and software specifications of the original. The primary issue is their incompatibility with official Custom Firmware (CFW) such as dArkOSRE, ArkOS (which is no longer maintained) or ArkOS4Clones. Modifications made to these counterfeit devices frequently cause total system failures (e.g frozen black screen and a flashing red light) when attempting a standard software update.

The following guide provides a data-driven overview of vendors and technical differences to help avoid purchasing the wrong device.

1. Where to Buy: Trusted vs. Non-Trusted Sellers

Purchasing an authentic R36S depends heavily on choosing the right store. Unscrupulous vendors frequently copy the logos and storefront designs of established, community-trusted sellers like BOYHOM to build false trust on marketplace platforms, using these familiar branding elements to mask the sale of counterfeit or cloned hardware.

Recommended Sellers

The following sellers offer genuine products without counterfeits and have a proven track record of shipping the original hardware revision of the R36S, which is fully compatible with official community firmware:

PlatformStore NameNotes
AliExpress001 Ali Choice StoreGenerally trusted distribution source and consistently supplies authentic hardware.
AliExpressFactory Game Direct StoreGenerally trusted distribution source and consistently supplies authentic hardware.
AliExpressBOYHOM StoreGenerally trusted distribution source and consistently supplies authentic hardware (though community notes advise double-checking)⚠️.

⚠️ Not clearly verified, as it is possible that the buyers purchased from a seller who advertises using the BOYHOM logo.

Alternatives recommended by the Community

While marketplace listings change frequently, these specific sellers have been flagged by community members as having successfully delivered authentic, dual-RAM hardware configurations:

PlatformStore NameCommunity Note
TemuWUDS GamesConfirmed by community members to ship authentic panels.
Amazon (US)Xiaoyu USA branchConfirmed by community members to ship authentic panels.
Amazon (UK)Blidinner StoreConfirmed by community members to ship authentic panels.

The continuously updated list of verified sellers can be viewed directly on the wiki: 👉 Handhelds Wiki - R36S Buying Guide: Sellers

Non-Trusted Sellers (Clones & Fakes Reported)

Key report logs indicate hardware discrepancies, system locks, or non-standard motherboard shipments from buyers for the following sellers. Purchasing from them is not recommended:

PlatformStore NameIdentified Clone or Fake Type
AliExpressUncharted GAME StoreDistributes the G80CA clone
AliExpressSUPER FUN GAME StoreDistributes the G80D / G80C mainboard variants.
Amazon (US)Micro Center (Retail locations)Physical inventory spot-checks discovered batches of G80CA clones on shelves (likely via fraudulent customer returns).

The complete blacklist, including specific user reports, is hosted on the wiki: 👉 Handhelds Wiki - R36S Clones: Untrusted Sellers

2. Technical Analysis: Clones vs. Fakes

The community methodically distinguishes between three categories of hardware found on the market: Genuine R36S units (full CFW support), EmuELEC Clones (limited, highly segmented firmware support), and Fakes (zero community firmware support due to weak or non-standard architectures).

Category 1: EmuELEC Clones

These devices are nearly identical in appearance to the original R36S and usually employ the same System-on-Chip (Rockchip RK3326). However, cost-cutting measures heavily compromise the primary configuration:

  • Software Restrictions: Instead of native ArkOS, some of these units run often a modified version of EmuELEC 4.7, the FN button is broken or mapped incorrectly to the Y button and other Software related issues.
  • Reduced Memory Configuration: While the original features 1 GB of RAM, clones frequently pack only 512 MB of RAM. This can be visually verified on transparent shells by the absence of a second RAM chip on the motherboard. This causes heavy performance degradation on demanding systems like Sega Dreamcast.
  • Motherboard Fragmentation: The community faces significant fragmentation from variations like the G80C/G80CA boards and the R36S-V20 boards. Flashing a standard ArkOS image onto these devices results in a black screen. On certain V20 clones, flashing improper firmware can overvolt the audio hardware, permanently damaging the internal speaker.
  • Physical Differences: Clones regularly use lower-quality display panels with reduced brightness, louder and looser shoulder buttons, and unaligned font prints (such as a crooked/italic "X" button).

Category 2: Fakes (Imitations)

These models merely copy the physical shell design of the R36S, while the internal electronics have been entirely replaced with unrelated, obsolete hardware.

  • Inferior Processors: Instead of the RK3326, older or less capable hardware is used, such as the underpowered Rockchip RK3128 or cheap MediaTek mobile chipsets.
  • Impaired Emulation Performance: Due to the weak SOC architectures, PlayStation 1 emulation is plagued by heavy graphical glitches, while systems like Dreamcast or PSP are entirely unplayable.
  • No Community Support: There is no custom firmware available for models like the GA36, Gaminja Batocera, or R36HD / GB350 variants.

Identification Steps to Verify Your Device

  1. Boot Behavior Without Storage Media: An original R36S will not boot past a blank state without SD cards inserted. If the device displays an active error message ("We can't find any systems!") or a graphical logo without an SD card, it is an EmuELEC clone variant.
  2. Checking System Information: You can check the available memory via RetroArch -> Main Menu -> Information -> System. A listed total memory value around 497 MB indicates a downgraded 512 MB clone model.
  3. File System Layout: True R36S configurations utilize an EASYROMS partition layout. Counterfeit or clone units often expose an EMUELEC or EEROMS structure on their storage media.
  4. Inspecting the internal hardware: Look at the revision code printed directly on the mainboard and compare your board code against the documented hardware variants on the Handhelds Wiki Clones Page.

Additional technical documentation, pictures, and mainboard analyses of individual revisions can be found in the corresponding wiki entries: 👉 Handhelds Wiki - R36S Clones Overview

Summary

To avoid technical complications, button remapping failures, and software incompatibilities, it is highly recommended to purchase exclusively from verified vendors like the BOYHOM, 001 Ali Choice Store or Factory Game Direct Store. A minor price advantage from unlisted sellers usually comes with an increased risk of receiving clone hardware.

Acknowledgements: Special thanks to u/manster, u/Electrical-Pace4092, and everyone else who contributes to writing the Handhelds Wiki and helping others in r/R36S. Your ongoing work tracking clone variants and verifying hardware keeps the (reddit) community safe from counterfeit devices.

Disclaimer: Every effort was made to present all information accurately when creating this buyer's guide. Given how quickly marketplace storefronts alter stock and how frequently clone variations mutate, new edge cases appear regularly. If there are any errors or outdated listings found, please point them out in the comments below so they can be immediately updated and corrected.


r/R36S • • 3h ago

Lounge GTA VI Port on R36S running very well

Post image
173 Upvotes

Jason and Lucia with a yellow skin glitch, but it's playable.


r/R36S • • 1h ago

Showcase I finally received my 2gb model from AliBaba

Thumbnail
gallery
29 Upvotes

Got this and promised to let u/datkenny know how it turned out. Looking like a legit 2gb model to me, 4 cpu cores. It came with a 64gb card loaded with ArkOs even though i requested one with no card, so I saved about $5 there and got a free card anyway. Used a new 64gb card and loaded darkosen with no issue, after selecting my model with the .bat file. Pics included! Will post a link in the comments to the seller


r/R36S • • 5h ago

Showcase Testing the new Azahar core (3ds) in DarkOs4clone

49 Upvotes

I have a genuine R36s v22 board, but today I downloaded DarkOS4clone just to test the 3DS emulation and I'm surprised, I didn't expect to see this console almost playable via emulation. I didn't configure practically anything in the emulator. Lighter games are probably playable.


r/R36S • • 3h ago

Port Shadow of Collosus

23 Upvotes

This game is awesome.

My only complaint is the sky animation, looks choppy.


r/R36S • • 1h ago

Question: Device Problem PS202 ANDROID 4.4.2

Thumbnail
gallery
8 Upvotes

Ya le puse Baxy y un tal VamanOS... pero no siento que sea suficiente y hay alguna forma de quitarle ese andorid y ponerle otra cosa... :(

Tengo problemas con VamanOS con juegos de n64 y snes van mal... solo con emulador por medio de un apk en baxy me los corre decente pero... todos los juegos que van decentes tienen un delay sutil poco se le nota, pero yo si lo noto y lo compare con un original... y el original va muy bien a comparacion del mio

Hay alguna forma de hackearla y quitarle andorid y ponerle un OS para el procesador que lleva...

PS202_6GEN1_MB_V11


r/R36S • • 1h ago

Showcase Don't talk to me or my son again (A10mini short review)

Post image
7 Upvotes

A10mini can be considered as a clone R36S in a miyoo mini housing. Same RK3326 chipset. It cost me about €65 IIRC

Im running an older version of Arkos on the R36S and a more recent version of DArkos on the A10mini. They seem almost like the same software.

the A10mini tends to heat up more quickly because it's so small. It also has a smaller battery. I also have a heatsink on the R36S. These things add up and make a difference in performance.

The A10mini feels more premium at first glance. The plastic feels nicer. However, the R36S generally has better buttons. My least favourite button on the A10mini is the dpad. It does have a likeable soft squish, but it is inaccurate which ruins everything and ends up kinda shit.

A10mini also has a weird screen. It has quirky viewing angles. It looks darker when viewed straight on, but brighter when you tilt it at an angle. It's not really a problem at all, the screen is sharp and the colors are great. But it's noticeable and can at times be a bit distracting.

I do appreciate it has built-in WiFi.

So it's more expensive than the R36S, and it's generally kinda worse! Do I still recommend it? It depends!

Obviously the portability makes it worth it. Further than that, its minimalist design ends up benefitting 8-bit and a lot of 16-bit games. The R36S feels much better for PSX and ports of pc games.

Don't get the A10mini if it's your first handheld. Get the R36S instead. But the more you love your R36S, the more the A10mini has to offer for you.


r/R36S • • 5h ago

Showcase Two days into owning my new R36H Pro Max, already modding it :D

Post image
10 Upvotes

Just got done installing hall effect analog sticks and Rumble motor, works great in the emulators that support it. If you guys need the item link please let me know, I'll fire the link over!


r/R36S • • 2h ago

Question: Chill Do I have a good one?

Post image
5 Upvotes

r/R36S • • 13h ago

Showcase 3DS On The New (d)ArkOS4Clones Is Pretty Impressive!

37 Upvotes

I was honestly not expecting much with the new 3DS emulator included in the latest versions of arkos4clones and darkos4clones, but OOT 3D seems to run incredibly well (at least at the start of the game)!

Tested this on an original non-clone panel 4 device with "ArkOS4Clone-20261126" at the stock clock speeds (no overclock here!).

##--Rough guide to getting this working--##

you need to put your legally obtained "boot9.bin" into the bios folder on the easyroms partition, and then just put all of your decrypted 3ds games into the 3ds folder and run them from the 3ds system menu on the main emulation station homescreen as normal

As for the games...I was only really able to get .cci files working, so maybe stick with them to begin with. game loading times are pretty fast too...maybe around 8-10 seconds, at least in my initial tests

in OOT 3D i was hitting pretty close to 60fps on average inside kokiri village, but it did dip to around 40fps or so when sarah? runs up to you as you leave your house. it returned close to 60fps after that little cutscene though

##--In Game Hotkeys--##

fn + r1 = FF

fn + r2 = save state (this takes like 20 secs or so to actually work though)

fn + l2 = load state (this takes like 20 secs or so to actually work though)

fn + x = RA menu!

fn + y = onscreen fps toggle

fn + b = change screen layout

I have a quick 1min vid showing performance and screen layouts here if anyone is interested - 3DS On The New (d)ArkOS4Clones Is Pretty Impressive! (Quick Preview)


r/R36S • • 7h ago

Showcase TreeFrogUI CatOS theme

Thumbnail
gallery
10 Upvotes

r/R36S • • 6h ago

Discussion Don't make my mistakes, trying to fix the screen

Thumbnail
gallery
7 Upvotes

Yesterday night I wanted to play my handheld as always, but found that screen shows vertical stripes and all picture is faded, later it stopped showing picture at all, although backlight was working and I heard music, so only display was broken.

Today I disassembled it, thinking that display ribbon is detached or has bad contact. There were no visual damage on ribbon or PCB. After different manipulations it still didn't work.

I decided to try to take screen off, to test it further outside the frame, I thought front panel is just a glass, but it appeared to be part of screen itself, so I completely broken it.

I found that new screens cost around half of new handheld, so it is much better to buy new one. I am afraid to buy new one with risk of damaged screen again. Now I am thinking how to use this E-waste headless Linux board, maybe use for my homelab.

Thanks all community for support of such a great and affordable handheld. I was really impressed by Portmaster, I fully completed Undertale, played GTA Vice City, Stardew Valley, Freedom Planet. For the first time I touched gems like Spider-Man from PS1, Metal Gear Solid, first Pokemon for Gameboy and Sonic from Sega Mega Drive.

I probably will start saving money for more powerful handheld, maybe Retroid Pocket 6, to try more modern games from PSP, PS2 and PC.


r/R36S • • 17h ago

Showcase [RELEASE] yabasanshiro-pirry — Optimized Sega Saturn Emulator for R36S / RK3326 v1.6.4 ArkOS + dArkOS

48 Upvotes

Here i'am again ;) with some more fixes for my saturn emu, have fun playing good old sega saturn on your loved R36S

yabasanshiro-pirry 1.6.4

Game fixes

  • Die Hard Trilogy — no longer hangs on a black screen at start-up; runs without the RAM expansion cartridge automatically (issue #7)
  • Dragon Ball Z: Shinbutouden — characters are no longer see-through (background no longer shows through them)
  • The Need for Speed — no more slowdowns when braking
  • The Need for Speed — no more stripes along the road and walls

General

  • SH-2: polling the sound mailbox is no longer skipped as an idle loop
  • VDP2: MSB color calculation for sprites in destination alpha mode
  • VDP1: distorted flat-shaded sprites are subdivided bilinearly
  • VDP1: a command list that loops without END keeps VDP1 busy, and an empty list signals draw end right at VBlank-OUT, as on real hardware
  • Cartridge: per-game cartridge list (from Mednafen's game database): Die Hard Trilogy without expansion cartridge, Real Bout Garou Densetsu and Samurai Spirits Amakusa Kourin with the 1 MB cartridge; all other games keep the 4 MB cartridge

Release Repo: https://github.com/pirrypirrypirry/yabasanshiro-pirry-release

dArkOS: https://github.com/pirrypirrypirry/yabasanshiro-pirry-release/releases/tag/v1.6.4_dArkOS

ArkOS: https://github.com/pirrypirrypirry/yabasanshiro-pirry-release/releases/tag/v1.6.4_ArkOS


r/R36S • • 11h ago

Showcase The azahar emulator on darkos4clones is INSANE (g80ca 1.2)

17 Upvotes

Azahar is a 3ds emulator btw. Mario is running 60 fps, smash bros at 30(some frame drops) but DAMN DUDE, some people are also saying that OOT runs amazing TOO! THANKS to the developer of arkos4clones, it unbelievable


r/R36S • • 1h ago

Question: Device Problem Got this strange graphic bug on Pokemon Stadium, can anyone help?

Post image
2 Upvotes

I just got the device and didn't change any options yet.
It's running dArkOSRE (03082026), I got a branded SD Card (Intenso 128GB SDXC U1 class 10) and I am running a single SD setup.
I also tried sveral different game files (EU version, EU (Rev 1), German version; .z64, .v64), all resulted in this weird starting screen.
Stadium 2 is running normal so far.


r/R36S • • 2h ago

Question: Device Problem Çalışmıyor

2 Upvotes

Merhaba,

Bir and çalışmamaya başladı, şarj olmuyor vs kapkaranlık

Bir tavsiyeniz var mı?


r/R36S • • 3h ago

Port O Port do PES 6 reinicia ao inicializar o primeiro jogo da Master liga.

Post image
2 Upvotes

r/R36S • • 10h ago

Question: Device Problem Hola amigos que opinan de esta placa es de una r40s ultra, saben que sistema le puede quedar?

Post image
6 Upvotes

r/R36S • • 2h ago

Question: Device Problem Помогите разобраться с прошивкой

1 Upvotes

Здраствуйте возможно уже кто то спрашивал о таком , но я толком не нашел , купил влешку smartby на 64 чтоб залить на неё систему , через руфус всё прошло хорошо , разделы появились , экран панель 4 выбрал ( так как она и стоит ) , вставляю в консоль ( пробывал и аркос и даркосре) , появляется логотип прошивки и когда по идее должна ( открыться консоль и закончить установку ) как я понял консоль зависает... ( акркос каким то чудом догрузила до надписи arcos2.0 с бегающими точками и на них виснет , 30 минут ждал этого после включения ) , а даркосре виснет сразу после показа логотипа... ( ждал каждую по часу , но так ни ода не запустилась),клон стоковой тоже делал ( не запускается) со стоковой флешкой всё запускается за минуту +- . Есть кто сталкивался с таким ?

r36s v30 Буду благодарен за ответ. Новую флешку заказал (netac на 64) приедет 4 декабря.


r/R36S • • 7h ago

Question: Device Problem Stardew Valley not loading (dArkOSen latest)

2 Upvotes

I have PortMaster installed, and games like Balatro work great, but Stardew doesn't seem to work at all. I have the port working on other devices and used those exact files but it blinks the loading screen then returns to ES.

I even tried completely redoing the port with new files but it isn't working, no matter what I do. Is there anything I can do?


r/R36S • • 15h ago

Device Problem: SOLVED 5.10 OTG Fix

8 Upvotes

My OTG port now works fine on 5.10 kernel with dynamic power, whereas on fresh install it did not have power at all.

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 absolutely 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.


r/R36S • • 5h ago

Suggestion Anyone Who Was Able To Get An R36S In India?

1 Upvotes

Been searching for this everywhere, i've already given up on local shops as none of them have anything other than a ps2 or a psp in the name of retro. I looked into hgworld but people say they often deliver false models of the R36S. Is there anyone from India who managed to get one for a fair price? Thanks in advance and have a great day


r/R36S • • 6h ago

Question: Chill SD card Tips

Post image
0 Upvotes

I just did some research and ordered three R36Ss for me and my friends for Christmas, and I wanted to get the SD cards now before they show up. Does anyone know if these work for both the ROMs and the firmware in both slots? On the spreadsheet, it lists the Elite Class 10 and the Premier X Class 10 as compatible, but not the Elite-X Class 10. I really just want the cheapest possible option to run the firmware and ROMs off of, so any suggestions would be super helpful!