# lcdyk0517/arkos4clone architecture

> Architecture diagram of the GitHub repository lcdyk0517/arkos4clone, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lcdyk0517/arkos4clone
- Repository: https://github.com/lcdyk0517/arkos4clone

## Overview

1. **Repository purpose**
   - This is a build-and-customization repository for **(d)ArkOS 4.4 kernel support on unsupported RK3326 handheld devices**.
   - The repo does not contain a single runtime application; it assembles a bootable SD-card image by combining a base ArkOS/dArkOS image with device-specific kernels, DTBs, firmware, modules, and launcher/game-emulator replacements.

2. **Top-level build pipeline**
   - The main entry points are shell scripts such as `build_image.sh`, `build_update_tar.sh`, `build_dtb_selector.sh`, `mount_arkos.sh`, and `grow_p2_plus.sh`.
   - These scripts orchestrate image unpacking/repacking, partition mounting, file replacement, DTB selection, and optional resize/update packaging.
   - The build outputs are image artifacts like `(d)ArkOS4Clone.img.xz`, intended for flashing to SD cards.

3. **Device selection and board-specific configuration**
   - The `consoles/` directory is the primary device configuration catalog.
   - Each device folder typically contains a `boot.ini` and one or more `.dtb` files, mapping that device to a specific display panel, touch/input layout, audio setup, and board variant.
   - This is the key hardware-compatibility boundary: selecting the wrong DTB changes how the kernel sees the board.

4. **Kernel boundary**
   - `consoles/kernel/original/Image` and `consoles/kernel/arkos4clone_fix/Image` provide alternative kernel images.
   - The README states the user chooses between **Original battery driver** and **arkos4clone_fix battery driver**, so kernel selection is a user-facing compatibility switch rather than an internal build-time detail.
   - The kernel itself is paired with the device DTB and is the core hardware abstraction layer.

5. **Binary firmware and module payload**
   - `replace_file/firmware/` contains a large firmware bundle for Wi-Fi, Bluetooth, GPU, audio, and assorted peripherals.
   - `replace_file/modules/4.4.189/` contains the kernel module tree and module metadata for the shipped 4.4.189 kernel.
   - These assets are copied into the image to make the kernel usable on the targeted handheld hardware without relying on the host system’s package manager.

6. **System overlay / replacement layer**
   - `replace_file/` is the main overlay directory used during image construction.
   - It contains replacement binaries, scripts, configs, emulator frontends, and system files that overwrite the base ArkOS/dArkOS contents.
   - This is where most of the functional customization lives: launcher configs, emulator patches, device scripts, service files, and bundled tools.

7. **Launcher, emulator, and frontend customization**
   - The repo ships customized packages or patched builds for tools such as `emulationstation`, `retroarch`, `retrorun`, `ppsspp`, `scummvm`, `onscripter`, `flycast`, `gametank`, `pymo`, and `drastic`.
   - Many of these are placed under `replace_file/<component>/` alongside patches or wrapper scripts, showing that the project modifies upstream emulator behavior to fit handheld controls, orientations, and device-specific quirks.
   - `mod_so/` contains modified libretro `.info` definitions and patches, indicating frontend/core metadata customization rather than emulator source changes alone.

8. **Device-specific shell scripts and runtime helpers**
   - Root-level `*.sh` launchers and helper scripts in `replace_file/` and `sh/` are used to switch modes, expand storage, remap ports, and launch per-system workflows.
   - `Jason3_Scripte/` and `bin/` contain additional helper utilities for Bluetooth, Wi‑Fi toggling, hotkey handling, LED control, ZRAM setup, and console detection.
   - These helpers bridge the hardware layer and the UI/launcher layer, turning raw device inputs into user-facing features.

9. **DTB selector toolchain**
   - `dtb_selector.go` is the source for the cross-platform `dtb_selector` utility, with built binaries checked in for Linux, macOS, and Windows.
   - The README describes it as the main post-flash configuration tool: it copies the chosen `boot.ini`, DTB, logo bitmap, and kernel image into the SD card’s boot partition.
   - This tool is the user-visible control point for selecting the correct hardware profile after flashing the image.

10. **Boot branding and display variants**
   - `consoles/logo/` and `consoles/logo-darkos/` store resolution-specific boot logos as `logo.bmp`.
   - The build process uses these assets to match the device’s screen resolution and rotation, so boot branding is part of the hardware compatibility layer, not just cosmetic content.

11. **Packaging of platform support assets**
   - `uboot/` contains bootloader-related binaries and flashing support files (`idbloader.img`, `trust.img`, `uboot.img`), indicating the repo also carries low-level boot assets for some device workflows.
   - `res/` and `resources/` contain UI/localization assets and metadata, supporting the themed launcher environment and multi-language presentation.

12. **CI/CD and release delivery**
   - GitHub Actions workflows in `.github/workflows/` automate image builds, release publishing, and update-only builds.
   - The repository’s delivery model is therefore: source overlays and binaries in Git, reproducible image assembly in CI, then published releases for end users to flash.

13. **Overall data flow**
   - The architectural flow is: choose a base ArkOS/dArkOS image → overlay repo files via build scripts → inject kernel/modules/firmware/device configs → package and compress the final SD image → flash it to a device → run `dtb_selector` to finalize the board-specific DTB/kernel/logo selection.
   - The important boundary is between the generic base OS and the per-device replacement set; almost everything in the repo exists to cross that boundary safely.

Main entry points: [`build_image.sh`](https://github.com/lcdyk0517/arkos4clone/blob/main/build_image.sh) (Build image), [`replace_file`](https://github.com/lcdyk0517/arkos4clone/tree/main/replace_file) (Overlay root), [`dtb_selector.go`](https://github.com/lcdyk0517/arkos4clone/blob/main/dtb_selector.go) (DTB selector), [`.github/workflows`](https://github.com/lcdyk0517/arkos4clone/blob/main/.github/workflows) (GitHub Actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_build["Build & package"]
  node_node_build_image["Build image<br/>shell pipeline<br/>[build_image.sh]"]
  node_node_build_update_tar["Update tar<br/>shell pipeline"]
  node_node_build_dtb_selector["DTB selector build<br/>go build"]
  node_node_mount_arkos["Mount image<br/>shell helper<br/>[mount_arkos.sh]"]
  node_node_grow_p2["Grow partition<br/>shell helper<br/>[grow_p2_plus.sh]"]
  node_node_dtb_selector_bin["DTB selector<br/>post-flash tool<br/>[dtb_selector.go]"]
end

subgraph group_group_hw["Hardware profiles"]
  node_node_consoles["Console configs<br/>device catalog"]
  node_node_kernel_orig["Original kernel<br/>kernel image"]
  node_node_kernel_fix["Fix kernel<br/>kernel image"]
  node_node_logos["Boot logos<br/>branding assets"]
  node_node_logo_darkos["DarkOS logos<br/>branding assets"]
end

subgraph group_group_overlay["System overlay"]
  node_node_replace_root["Overlay root<br/>system overlay"]
  node_node_helper_scripts["Helper scripts<br/>runtime helpers"]
end

subgraph group_group_apps["Launchers & emulators"]
  node_node_emu_custom["Emulator builds<br/>patched binaries"]
  node_node_drastic_kk["Drastic KK<br/>patched emulator"]
  node_node_mod_so["Core metadata<br/>libretro info"]
end

subgraph group_group_support["Support assets"]
  node_node_bin_utils["Device binaries<br/>device utilities"]
  node_node_firmware["Firmware bundle<br/>kernel firmware"]
  node_node_modules["Kernel modules<br/>4.4.189 modules<br/>[4.4.189]"]
  node_node_uboot[("U-Boot assets<br/>bootloader files")]
end

subgraph group_group_ci["Release automation"]
  node_node_ci["GitHub Actions<br/>release automation<br/>[workflows]"]
end

node_node_build_image -->|"mounts"| node_node_mount_arkos
node_node_build_image -->|"overlays"| node_node_replace_root
node_node_build_image -->|"selects profile"| node_node_consoles
node_node_build_image -->|"bundles"| node_node_kernel_orig
node_node_build_image -->|"bundles"| node_node_kernel_fix
node_node_build_image -->|"injects"| node_node_firmware
node_node_build_image -->|"injects"| node_node_modules
node_node_build_image -->|"includes"| node_node_uboot
node_node_build_image -->|"brands"| node_node_logos
node_node_build_image -->|"brands"| node_node_logo_darkos
node_node_build_image -->|"resizes"| node_node_grow_p2
node_node_build_update_tar -->|"packages"| node_node_replace_root
node_node_build_dtb_selector -->|"compiles"| node_node_dtb_selector_bin
node_node_dtb_selector_bin -->|"applies profile"| node_node_consoles
node_node_dtb_selector_bin -->|"writes kernel"| node_node_kernel_orig
node_node_dtb_selector_bin -->|"writes kernel"| node_node_kernel_fix
node_node_dtb_selector_bin -->|"writes logo"| node_node_logos
node_node_replace_root -->|"contains"| node_node_emu_custom
node_node_replace_root -->|"contains"| node_node_drastic_kk
node_node_replace_root -->|"contains"| node_node_helper_scripts
node_node_replace_root -->|"contains"| node_node_bin_utils
node_node_replace_root -->|"references"| node_node_mod_so
node_node_ci -->|"runs"| node_node_build_image
node_node_ci -->|"runs"| node_node_build_update_tar
node_node_ci -->|"publishes"| node_node_build_dtb_selector

click node_node_build_image "https://github.com/lcdyk0517/arkos4clone/blob/main/build_image.sh"
click node_node_build_update_tar "https://github.com/lcdyk0517/arkos4clone/blob/main/build_update_tar.sh"
click node_node_build_dtb_selector "https://github.com/lcdyk0517/arkos4clone/blob/main/build_dtb_selector.sh"
click node_node_mount_arkos "https://github.com/lcdyk0517/arkos4clone/blob/main/mount_arkos.sh"
click node_node_grow_p2 "https://github.com/lcdyk0517/arkos4clone/blob/main/grow_p2_plus.sh"
click node_node_consoles "https://github.com/lcdyk0517/arkos4clone/tree/main/consoles"
click node_node_kernel_orig "https://github.com/lcdyk0517/arkos4clone/tree/main/consoles/kernel/original/Image"
click node_node_kernel_fix "https://github.com/lcdyk0517/arkos4clone/tree/main/consoles/kernel/arkos4clone_fix/Image"
click node_node_logos "https://github.com/lcdyk0517/arkos4clone/tree/main/consoles/logo"
click node_node_logo_darkos "https://github.com/lcdyk0517/arkos4clone/tree/main/consoles/logo-darkos"
click node_node_replace_root "https://github.com/lcdyk0517/arkos4clone/tree/main/replace_file"
click node_node_emu_custom "https://github.com/lcdyk0517/arkos4clone/tree/main/replace_file/ppsspp"
click node_node_drastic_kk "https://github.com/lcdyk0517/arkos4clone/tree/main/replace_file/drastic-kk"
click node_node_mod_so "https://github.com/lcdyk0517/arkos4clone/tree/main/mod_so"
click node_node_helper_scripts "https://github.com/lcdyk0517/arkos4clone/tree/main/replace_file/tools"
click node_node_bin_utils "https://github.com/lcdyk0517/arkos4clone/tree/main/bin"
click node_node_firmware "https://github.com/lcdyk0517/arkos4clone/tree/main/replace_file/firmware"
click node_node_modules "https://github.com/lcdyk0517/arkos4clone/blob/main/replace_file/modules/4.4.189"
click node_node_uboot "https://github.com/lcdyk0517/arkos4clone/tree/main/uboot"
click node_node_dtb_selector_bin "https://github.com/lcdyk0517/arkos4clone/blob/main/dtb_selector.go"
click node_node_ci "https://github.com/lcdyk0517/arkos4clone/blob/main/.github/workflows"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_build_image,node_node_build_update_tar,node_node_build_dtb_selector,node_node_mount_arkos,node_node_grow_p2,node_node_dtb_selector_bin toneBlue
class node_node_consoles,node_node_kernel_orig,node_node_kernel_fix,node_node_logos,node_node_logo_darkos toneAmber
class node_node_replace_root,node_node_helper_scripts toneMint
class node_node_emu_custom,node_node_drastic_kk,node_node_mod_so toneRose
class node_node_bin_utils,node_node_firmware,node_node_modules,node_node_uboot toneIndigo
class node_node_ci toneTeal
```

## Components

### Build & package

Scripts and automation that assemble flashable images and update archives.

- [Build image](https://github.com/lcdyk0517/arkos4clone/blob/main/build_image.sh): shell pipeline · Main image assembly entry point that repacks and customizes the SD-card image. · `build_image.sh`
- [Update tar](https://github.com/lcdyk0517/arkos4clone/blob/main/build_update_tar.sh): shell pipeline · Builds update-only package artifacts for existing installs. · `build_update_tar.sh`
- [DTB selector build](https://github.com/lcdyk0517/arkos4clone/blob/main/build_dtb_selector.sh): go build · Compiles the post-flash hardware profile selector utility. · `build_dtb_selector.sh`
- [Mount image](https://github.com/lcdyk0517/arkos4clone/blob/main/mount_arkos.sh): shell helper · Mounts ArkOS partitions for overlay and inspection. · `mount_arkos.sh`
- [Grow partition](https://github.com/lcdyk0517/arkos4clone/blob/main/grow_p2_plus.sh): shell helper · Expands the second partition for larger storage use. · `grow_p2_plus.sh`
- [DTB selector](https://github.com/lcdyk0517/arkos4clone/blob/main/dtb_selector.go): post-flash tool · Cross-platform utility that copies the selected boot.ini, DTB, logo, and kernel into the boot partition. · `dtb_selector.go`

### Hardware profiles

Device-specific boot configuration, kernels, logos, and DTBs.

- [Console configs](https://github.com/lcdyk0517/arkos4clone/tree/main/consoles): device catalog · Per-device boot.ini and DTB selections that define the hardware compatibility boundary. · `consoles`
- [Original kernel](https://github.com/lcdyk0517/arkos4clone/tree/main/consoles/kernel/original/Image): kernel image · Default 4.4 kernel image with the original battery driver. · `consoles/kernel/original/Image`
- [Fix kernel](https://github.com/lcdyk0517/arkos4clone/tree/main/consoles/kernel/arkos4clone_fix/Image): kernel image · Alternate 4.4 kernel image with the arkos4clone_fix battery driver. · `consoles/kernel/arkos4clone_fix/Image`
- [Boot logos](https://github.com/lcdyk0517/arkos4clone/tree/main/consoles/logo): branding assets · Resolution-specific boot bitmaps used during startup. · `consoles/logo`
- [DarkOS logos](https://github.com/lcdyk0517/arkos4clone/tree/main/consoles/logo-darkos): branding assets · Alternate boot bitmaps for dArkOS-branded images. · `consoles/logo-darkos`

### System overlay

Replacement files copied into the base ArkOS/dArkOS image.

- [Overlay root](https://github.com/lcdyk0517/arkos4clone/tree/main/replace_file): system overlay · Primary replacement layer that overwrites the base OS contents. · `replace_file`
- [Helper scripts](https://github.com/lcdyk0517/arkos4clone/tree/main/replace_file/tools): runtime helpers · Shell helpers for mode switching, device detection, hotkeys, and console workflows. · `replace_file/tools`

### Launchers & emulators

Customized frontends, emulators, and per-system wrappers.

- [Emulator builds](https://github.com/lcdyk0517/arkos4clone/tree/main/replace_file/ppsspp): patched binaries · Customized packages for emulationstation, retroarch, retrorun, ppsspp, scummvm, flycast, drastic, and others. · `replace_file/ppsspp`
- [Drastic KK](https://github.com/lcdyk0517/arkos4clone/tree/main/replace_file/drastic-kk): patched emulator · Patched DraStic variant with device-specific resources, hotkeys, and rotation fixes. · `replace_file/drastic-kk`
- [Core metadata](https://github.com/lcdyk0517/arkos4clone/tree/main/mod_so): libretro info · Modified libretro .info definitions and patches for frontend/core compatibility. · `mod_so`

### Support assets

Low-level firmware, modules, and bootloader payloads.

- [Device binaries](https://github.com/lcdyk0517/arkos4clone/tree/main/bin): device utilities · Bundled helpers for Bluetooth, Wi‑Fi, LED, ZRAM, input mapping, and hardware services. · `bin`
- [Firmware bundle](https://github.com/lcdyk0517/arkos4clone/tree/main/replace_file/firmware): kernel firmware · Large firmware payload copied into the image for wireless, GPU, audio, and peripherals. · `replace_file/firmware`
- [Kernel modules](https://github.com/lcdyk0517/arkos4clone/blob/main/replace_file/modules/4.4.189): 4.4.189 modules · Shipped kernel module tree and metadata for the bundled kernel. · `replace_file/modules/4.4.189`
- [U-Boot assets](https://github.com/lcdyk0517/arkos4clone/tree/main/uboot): bootloader files · Low-level bootloader images and flashing support files. · `uboot`

### Release automation

GitHub Actions workflows for builds and publishing.

- [GitHub Actions](https://github.com/lcdyk0517/arkos4clone/blob/main/.github/workflows): release automation · Workflows that build images, create releases, and publish update-only artifacts. · `.github/workflows`

## Connections

- Build image → Mount image: mounts · Prepares base image partitions before overlaying files.
- Build image → Overlay root: overlays · Copies customized files into the base OS image.
- Build image → Console configs: selects profile · Uses device folders as the hardware profile catalog.
- Build image → Original kernel: bundles · Can package the original kernel image.
- Build image → Fix kernel: bundles · Can package the battery-driver-fixed kernel image.
- Build image → Firmware bundle: injects · Adds firmware needed for wireless, audio, and GPU support.
- Build image → Kernel modules: injects · Adds the matching 4.4.189 kernel modules.
- Build image → U-Boot assets: includes · Carries bootloader assets for supported flashing workflows.
- Build image → Boot logos: brands · Places boot logos matching device resolution and rotation.
- Build image → DarkOS logos: brands · Uses dArkOS-specific boot logos when needed.
- Build image → Grow partition: resizes · Optionally expands the data partition during image preparation.
- Update tar → Overlay root: packages · Reuses overlay content for update-only deliverables.
- DTB selector build → DTB selector: compiles · Builds the selector tool from source.
- DTB selector → Console configs: applies profile · Copies the selected boot.ini and DTB for a specific device.
- DTB selector → Original kernel: writes kernel · Can install the chosen kernel image into boot media.
- DTB selector → Fix kernel: writes kernel · Can install the chosen fixed kernel image into boot media.
- DTB selector → Boot logos: writes logo · Installs the matching boot bitmap for the selected profile.
- Overlay root → Emulator builds: contains · Holds customized emulator and frontend payloads.
- Overlay root → Drastic KK: contains · Includes the DraStic-specific replacement bundle.
- Overlay root → Helper scripts: contains · Includes scripts used at runtime for device workflows.
- Overlay root → Device binaries: contains · Ships helper binaries and services for device features.
- Overlay root → Core metadata: references · Uses modified libretro metadata and patches.
- GitHub Actions → Build image: runs · Automates full image builds in CI.
- GitHub Actions → Update tar: runs · Automates update-only artifact generation.
- GitHub Actions → DTB selector build: publishes · Builds and releases the selector utility binaries.
