Commit Graph

7026 Commits

Author SHA1 Message Date
Douglas Teles 2d04170214 RK3326: enable the in-tree MT7921U driver with its firmware
Common WiFi 6 dongles use the MediaTek MT7921U, which mainline has
supported since 5.18, but the kernel config never enabled the USB
glue and the firmware list did not ship the MT7961 blobs. Cheapest
gap found in the four-distro dongle driver census.
2026-07-08 17:44:08 -03:00
Douglas Teles 330c4199a6 packages: give quirks, sleep and system-utils a real version
Empty PKG_VERSION made gen-pacman-repo fall back to a garbage version
derived from the install dirname (quirks--quirks.-1) and broke the
package.mk lookup, so the PKG_REV bump was never honoured and pacman
could not see these packages as upgradable. Version them 2.1; vercmp
ranks it above the old garbage string, so 2.0 installs upgrade cleanly.
2026-07-07 21:59:07 -03:00
Douglas Teles 8b0f09c43e flash-sync: update only DTBs the image already ships
The per-image DTB set is curated by config.xml (the clone image carries
boards the original image deliberately leaves out), so the sync must
never add files to /flash/dtbs, only refresh the ones present. Caught
on the first hardware run: a clean sync on the original image added
three clone-only DTBs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 20:59:57 -03:00
Douglas Teles 6faa39c570 update: let kernel and DTB fixes flow through pacman via flash-sync
Until now anything living on the FAT boot partition (kernel Image and
the device trees) was reflash-only, breaking the promise that every
update can arrive either by rewriting the image or through pacman and
the ES update menu. Close the gap with three pieces:

- The linux package now ships the kernel image in the rootfs under
  /usr/share/bootloader/Image next to the device_trees it already
  installs, so a pacman upgrade of linux delivers both.
- archr-flash-sync copies Image to /flash/KERNEL (refreshing the
  KERNEL.md5 sidecar) and device_trees/*.dtb to /flash/dtbs, but only
  the files whose sha256 actually changed, each written as a verified
  .new temp in the same FAT directory and renamed over the original so
  the torn-write window is the rename alone. /flash/overlays (the
  user's panel overlay), extlinux, boot scripts and u-boot are never
  touched; u-boot/TPL live in raw sectors where a torn write bricks
  the card, so the bootloader intentionally stays image-flash only.
- An alpm PostTransaction hook (HookDir /etc/pacman.d/hooks) fires the
  sync whenever a transaction touches the bootloader payload.

gen-pacman-repo now prunes the .image build-plumbing directory from
packages, which would otherwise dump a duplicate raw kernel at /.image
on every update.

Hardware test pending: run archr-flash-sync by hand over SSH and check
the device still boots with the synced KERNEL and dtbs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 20:10:49 -03:00
Douglas Teles 56cd1626d6 packages: bump PKG_REV so today's fixes flow through pacman updates
These packages have empty or upstream-pinned PKG_VERSION, so without a
PKG_REV bump pacman never sees the new build as an update and the fixes
would only reach users through a reflash. Covers headphone_sense and
input.service (system-utils), the LED and audio quirks (quirks), the
s2idle defaults (sleep), the Soysauce SDL mapping (gamecontrollerdb)
and the rewritten udev swap rule (RTL8188EUS).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 19:46:39 -03:00
Douglas Teles f99aff1149 RK3326: route the Soysauce PMIC interrupt to GPIO0_A7
Live debugging showed the whole rk817 interrupt line dead on the
Soysauce (zero counts in /proc/interrupts for pwrkey, jack and charger
events across button presses). The vendor DTB wires pmic_int to
GPIO0_A7 while the shared r3xs.dtsi listens on GPIO0_B2, so every PMIC
interrupt was lost: power key, headphone detect, charger plug and the
suspend wake source. Override the interrupt and the pinctrl in the
soysauce DTS only; the other family members really use GPIO0_B2.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 19:29:51 -03:00
Douglas Teles 5f1f6182cf fake-suspend: cut the panel backlight even when DPMS handles the blank
The compositor path blanked the framebuffer but could leave the panel
backlight powered, so the "sleeping" console showed a black yet lit
screen and kept burning the display power budget. Turn the backlight
off through bl_power in both paths and restore it on wake.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 19:24:07 -03:00
Douglas Teles a0a45889f4 system-utils: enable input.service on RK3326
The whole power-button fake-suspend chain was dead code: input.service
(input_sense) is the only thing that turns KEY_POWER presses into
archr-fake-suspend calls, the R33S and RG351 dpad-volbright quirks even
restart it when active, but no package ever enabled it, so the power
key fell through to logind's kernel suspend, which locks up on px30.
Enable it for RK3326. Hardware test note: input_sense also reacts to
KEY_VOLUME events, so watch for double-stepping volume on the rocker;
if it doubles, the second handler needs to yield.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 19:23:05 -03:00
Douglas Teles 34b76db065 RK3326: default to fake-suspend, kernel suspend proven unwakeable
Hardware test on the Soysauce (2026-07-07) killed both kernel suspend
paths: SuspendState=mem hangs on entry and freeze (s2idle) enters but
never wakes, not even from an armed RTC alarm with every wakeup source
enabled (PMIC pwrkey, rk817 i2c and rtc0 all report enabled). Real
debugging needs UART on the pads.

Make the power button useful instead of a lockup: ship the RK3326
sleep.conf with AllowSuspend=no so logind's HandlePowerKey=suspend
becomes a no-op, and seed system.suspendmode=off through a platform
030-suspend_mode quirk so the archr-fake-suspend path (already wired
to the power key via input_sense) stops exiting early. The quirk also
serves the "default" choice of the ES SUSPEND MODE menu, and on boot
it repairs pacman-upgraded installs whose storage still carries the
old mem-first sleep.conf. Users can still opt in to real suspend
through the same menu (the suspendmode script rewrites the conf with
AllowSuspend=yes), and the sleep.sh state-preservation hooks stay in
place for the day s2idle works.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 19:20:16 -03:00
Douglas Teles 62edc065ad inputs: single source of truth for the built-in gamepad configs
Every platform pad needed three hand-maintained files (es_input.cfg,
the RetroArch autoconfig and gamecontrollerdb.txt) and nothing checked
they agreed; the Soysauce pad shipped without the SDL entry, so ports
saw no controller. Add projects/ArchR/inputs: one JSON definition per
pad plus gen-input-configs, which verifies the three artifacts against
the defs (wired as a fail-fast gate on the docker-% Makefile targets),
regenerates them on demand, imports legacy entries, and computes SDL
GUIDs the same way the runtime does, including the name-embedded form
SDL uses when vendor*product is zero.

The 17 platform pads were imported from the current artifacts and the
migration already caught two real inconsistencies. The GO-Super
gamecontrollerdb line carried a numeric-form GUID, but the pad reports
vendor 0 so SDL derives the name-embedded GUID at runtime (the form the
device-captured es_input block always had); the line is now fixed to
1900bb3e474f2d537570657220476100 and its RetroArch cfg canonicalized.
And retrogame_joypad legitimately ships different mappings per bus
(guide:b10 only on 0x19), now modeled explicitly as a per-GUID map.

Verification is semantic for es_input blocks and RetroArch cfgs (the
legacy files mix tabs and spaces) and byte-exact for gamecontrollerdb
lines, with GUIDs always recomputed from the identity fields.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 18:31:41 -03:00
Douglas Teles 205c5bccb3 sleep: default RK3326 to s2idle, preserve ALSA and governor state
Suspend on the R36S family hangs because the shipped sleep.conf orders
SuspendState as "mem standby freeze" and px30 mainline has no working
S3, so the kernel commits to a state it cannot leave. Ship
SuspendState=freeze on RK3326; the power button is the rk817 PMIC
pwrkey, which every board DTS already marks wakeup-source, and logind
already routes HandlePowerKey=suspend through systemd-sleep into this
hook.

Borrow the state discipline from the dArkOS sleep hooks: blank the
backlight before the kernel path runs, snapshot the full mixer state
with alsactl (the rk817 can lose its routing across s2idle and the
existing restore only re-set the master volume), and save/restore the
cpu/gpu/dmc governors. dwc2 reload on resume was already covered by
modules.bad.

Untested on hardware: needs a device check that s2idle enters (screen
and audio off), the pwrkey wakes it, and audio routing plus USB gadget
survive the round trip.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 18:28:53 -03:00
Douglas Teles 8aacf5c823 headphone_sense: sync the startup path with the real jack switch state
The boot-time probe read a legacy /sys/class/gpio number that mainline
kernels never expose, so the initial audio path was always the speaker
guess and a reboot with headphones plugged started routed wrong. Query
the actual EV_SW/SW_HEADPHONE_INSERT bit through evtest --query (exit
10 = bit set; on these boards the switch is inverted, value 0 means
inserted) with the legacy gpio node as fallback, make an empty "$2"
follow the detected state instead of forcing speakers, and bail out
before the event loop when the board has no jack input device at all
(evtest on an empty path just dies and burns service restarts).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 18:27:14 -03:00
Douglas Teles bd6fb8d0a9 gamecontrollerdb: add the Soysauce GO-Super Gamepad SDL mapping
SDL-based games and ports never recognized the Soysauce pad because
gamecontrollerdb.txt only knew r36s_Gamepad; RetroArch and ES have
their own configs, which is why "some games" needed manual input setup
(Reddit report on the 2.0 thread). GUID derived the same way SDL does:
bus 0x19 (host), crc16 of the device name (verified against the
r36s_Gamepad entry), vendor 0, product 0x1100, version 0x0100 from the
DTS; the button/axis layout matches the r36s entry, which is the same
physical layout the validated RetroArch config already uses.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 17:30:48 -03:00
Douglas Teles 0be7aab31b emulationstation: default power LED selection to on, matching boot
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 17:03:08 -03:00
Douglas Teles df92325273 RK3326: fix the shipped-but-broken v2.0 fixes for issues #19 and #35
Issue #19 (RTL8188EUS dongle can scan but never authenticates): the
udev swap rule shipped in v2.0 was structurally a no-op. It matched
the usb_device add event and echoed the device name ("1-1") into
rtl8xxxu's unbind node, but USB drivers bind to the interface
("1-1:1.0"), and at usb_device add time nothing is bound yet anyway;
the follow-up modprobe never rebinds an interface the in-tree driver
already claimed. Users confirmed the auth failure survived into the
release. Rewrite the rule to match the usb_interface event, where the
kernel has already finished its synchronous bind, and deterministically
move the interface: unbind from rtl8xxxu (no-op if it lost the probe
race) and write it into 8188eu's bind node via udev's own %k
substitution (no shell $$ escaping to get wrong).

Issue #35 (R36S Clone V20 speaker silent, headphones fine): the V20-era
clone boards route the speaker through the external amplifier exactly
like the Soysauce (the eeclone DTS already ships rk817-sound-amplified)
but the R36S Clone quirk never exported the playback mux paths nor the
jack input device. Reporters on the issue validated this exact config
by hand-editing the quirk. Also fix headphone_sense: every amixer cset
passed the control name unquoted, so names with spaces ("Playback Mux")
split into two arguments and the call failed; and the boot-time jack
probe read a legacy /sys/class/gpio node that mainline kernels don't
expose, now guarded with a speaker-path default.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 16:18:39 -03:00
Douglas Teles 4385a37cbf RK3326: fix Soysauce power LED polarity, surface DISABLE POWER LED
Live debugging on the Soysauce (USB SSH, watcher on the led sysfs while
the user drove the ES menu) showed the whole chain working but the LED
responding inverted: the blue power LED is wired active high, so the
GPIO_ACTIVE_LOW in the DTS made "off" light it and "on" darken it
(heartbeat looked normal because a blink is a blink upside down). Flip
the polarity and default the LED on so early boot keeps the stock look.
The led-red node was a phantom: the physical red LED belongs to the
charger IC and toggling GPIO0_A5 changes nothing, so drop it.

The DISABLE POWER LED switch in ES is gated on DEVICE_PWR_LED_CONTROL,
which sits in the 999-export allowlist but was never set by any quirk,
so the item was invisible on every device. Set it for the R36S family.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 15:42:40 -03:00
Douglas Teles 413b62304b RK3326: describe the R36S/R33S power LED so the ES menu can drive it
The power LED menu never worked on the R36S Original and Clone because
nothing consumes the old JELOS quirk vars on mainline: 002-disable-led
and battery_led_status poke BSP gpio numbers (gpio77) through the
legacy /sys/class/gpio interface that no longer exists, and the R36S
DTB did not describe the LED at all.

Describe the hardware in the DTS instead. The R36S Original has a
bicolor power LED behind a single line (GPIO2_B5, BSP gpio77): high is
red, low is the green side, high impedance lights both halves orange,
so there is no hardware off; exposed as red:status. The R33S has a mono
blue active-low LED on the same pin (the old quirk wrote 1 to disable
it), exposed as blue:status with true off. The Clone already had proper
LED nodes; its sysfs name is blue:power (color:function, no label).

Point DEVICE_POWER_LED at the right sysfs name per device so
batocera-gameforce (POWER LED COLOR and DISABLE POWER LED paths) finds
the LED, and drop the dead 002-disable-led quirks. On the Original,
"off" shows the stock steady green and "on" shows red; heartbeat pulses
between the two colors.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 23:58:41 -03:00
Douglas Teles 5c5dcd3c4a rkbin: retry the RK3326 TPL DDR frequency at 666MHz
The boot-loop investigation exonerated everything except the original
786MHz TPL: a full hardware bisect (no patches, 024 only, 0026 only,
both) booted every combination at 333MHz with byte-verified TPL
signatures inside the images, which means the earlier "666 and 333 also
fail" results came from flashing stale copies of the 786 image. 666MHz
therefore goes back in for a clean, checksum-verified hardware test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 23:28:12 -03:00
Douglas Teles a30e6ea7f5 emulationstation: fix clipped Internet Status, wire DISABLE POWER LED
Bump to the ES fork fix: the async INTERNET STATUS row now reserves the
cell for the widest value so NOT CONNECTED no longer clips, and the
DISABLE POWER LED switch actually drives the LED (it used to write a
conf key nothing consumed). 096-powerled honours powerled.disabled at
boot so the choice survives a restart.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 23:28:12 -03:00
Douglas Teles d652e2d7bd rkbin: drop the RK3326 TPL DDR frequency to 666MHz
786MHz failed the hardware boot test on the Soysauce: the screen lights
and the SoC resets in a loop before U-Boot, meaning the TPL DDR
training does not converge at that speed on these chips (dArkOS only
reaches 786 via the BSP dmc driver's runtime retraining, which is
gentler than a fixed cold init). 666MHz keeps twice the bandwidth of
the old 333MHz baseline; 528 (dArkOS's powersave floor) is the next
step down if any board still fails.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 20:48:07 -03:00
Douglas Teles 39e4a5ebcf rkbin: fix sed delimiter clashing with the alternation pipes
The frequency rewrite used | both as the sed delimiter and inside the
group alternation, so post_unpack failed and the previous build shipped
no images. Use # as the delimiter; verified against the generated
parameter dump (all five freq fields now rewrite to 786).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-01 23:02:56 -03:00
Douglas Teles 6794a56987 RK3326: gameplay priority and RetroArch tuning from the dArkOS analysis
- Launch emulators at nice -19 like dArkOS does; with the full-preempt
  kernel this keeps frame pacing stable when background work wakes up
  mid-frame.
- audio_latency 64 to 128, matching dArkOS on the same alsathread
  driver and hardware: the 64ms buffer underruns audibly on heavy
  cores, which users read as instability.
- fastforward_frameskip on: skip rendering during fast-forward and give
  the GPU time back to the core.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-01 22:59:19 -03:00
Douglas Teles d80eb6c482 RK3326: raise the TPL DDR frequency from 333MHz to 786MHz
The performance gap users report against dArkOS ("more FPS, more
stable") is dominated by memory bandwidth. Our TPL blob initialises
every DDR type at 333MHz (verified via ddrbin_tool -g: lp2/ddr3/lp3/
ddr4/lp4 all 333) and mainline has no px30 dmc driver, so the memory
never leaves 333MHz. dArkOS runs the BSP dmc_ondemand governor, which
scales the same boards up to the 786MHz ceiling of the vendor R36S DTB
dmc table (528/666/786, verified by decompiling their shipped DTB), and
even its powersave mode pins 528MHz: their WORST case has 60% more
memory bandwidth than our best.

Rewrite the frequency fields inside the TPL with Rockchip's ddrbin_tool
(the long-standing ArkOS "DDR fix") so DDR comes up at 786MHz from
boot, for both the standard and the UART5 clone TPL variants. Override
with RK3326_DDR_FREQ=666 if a board proves unstable.

MUST be boot-tested on hardware before any release: a board whose DDR
cannot run 786MHz will hang in the TPL before U-Boot even starts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-01 22:59:19 -03:00
Douglas Teles 235f113c25 fs-resize: gate resize2fs on fsck, fix sd* boot partition name, explain warnings
Analysis of a first-boot resize log (docs/resize.log):

- The two FAT warnings it records are expected and harmless. The 256MB
  boot partition ships the same out-of-spec FAT32 (16375 clusters, below
  the 65525 minimum) as ROCKNIX and the rest of the RK3326 ecosystem;
  vendor U-Boots are only tested against that layout, so reformatting it
  is exactly the change that has caused boot loops before. The
  boot-sector/backup difference is the kernel vfat dirty flag, written
  to the primary sector only while /flash is mounted read-write; the
  shipped image was verified to carry identical primary and backup
  sectors. The script now appends a NOTE to the log so the warnings stop
  being reported as failures.

Real defects fixed:

- resize2fs ran regardless of the e2fsck result; on unfixed corruption
  (exit above 2) growing the filesystem would compound the damage. The
  resize is now skipped in that case, leaving the grown partition for a
  later retry after a manual fsck.
- The boot-partition path was hardcoded as ${DISK}p1, which is wrong for
  /dev/sdX disks (sdXp1 does not exist), so the FAT serial
  randomization silently never ran there. Derive the partition name per
  device type alongside DISK.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-01 22:39:12 -03:00
Douglas Teles 1d892b9231 emulationstation: bump for the enumeration pre-warm
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-01 22:02:06 -03:00