Skip to content

STARLTE: the charger watched and guarded (sweetchg=2, default on), the fast-charge path (sweetafc=1, off) - #68

Merged
claudiusthebot merged 1 commit into
scion/xnu-12377from
agent/fastcharge/charger-guard
Nov 24, 2026
Merged

claudiusthebot merged 1 commit into
scion/xnu-12377from
agent/fastcharge/charger-guard

Conversation

@claudiusthebot

Copy link
Copy Markdown
Collaborator

The Galaxy S9's charger, watched and guarded under iOS 27. Goes with Scion-Project/scion-kernel#415 (CHARGING.md, the rules header's original and its host tests, the owner's test plan).

The bug (measured on phone 2, 24 Nov): this tree only read the gauge. S-Boot leaves the MAX77705 charger's watchdog on; nothing kicked it, so 69 s after the kernel started DETAILS_01 went 0x33 -> 0x3b (watchdog expired) and the phone stopped charging for the rest of the boot. iOS was also given a fixed 25 C battery temperature, with nothing to stop charging when hot or cold.

What this adds (bsd/dev/starlte_charger.c, every second, on starlte_muic.c's bus and lock):

  • sweetchg=1: read only. Charger, MUIC, gauge, battery and charger thermistors (CMGP ADC ch 4 and 3, the phone's table). SweetBattery now publishes the real battery temperature, charging/full from the charger's own CHG_DTLS, and adapter details (family from the BC 1.2 type, volts, amps).
  • sweetchg=2 (added to the kernel's default line): the guard. Volatile charger registers only, each read back: WDTCLR kicked every 10 s (re-armed on expiry, as Samsung's driver does), CNFG_00 bit 0 by Samsung's temperature bands / session timers / full and recharge, CNFG_09 and CNFG_02 to Samsung's limits for the type (SDP 475/550, CDP 1500/1500, DCP 1800/2100) or less. Faults, 45 C, float above 4350 mV or a differing read-back latch charging off until the cable goes. Never written: the float, the timers, every other register, the gauge, the PMIC, anything non-volatile.
  • sweetafc=1 (off by default): the AFC 9 V request on a DCP inside its band; 9 V taken only on result 0 with VBUS 7.5-10.5 V in both the answer and USBC_STATUS1; then 1650/2150 mA; dropped back the second any condition stops holding. starlte_muic.c leaves the D+/D- switch open on a DCP when this is on (Samsung's COM_OPEN for a TA).
  • sweetchg_drain=MIN: a test knob (input 100 mA, charging off for MIN minutes).
  • kern.hakios.chg_* sysctls (CTLFLAG_KERN, readable from the USB console).

bsd/dev/hakios.max77705_charge.h is a copy of scion-kernel's drivers/power/max77705/hakios.max77705_charge.h (identical), tested there (664810 checks).

Run on phone 2 (Mac mini USB-C port: BC_STATUS 0x82, a CDP), root as found, BOOT only:

  • k1 sweetchg=1 15:33-15:43: read only; the watchdog expiry above seen; battery 25.8-29.2 C (TWRP 25.6 C through Samsung's driver just before).
  • k3 sweetchg=2 sweetafc=1 sweetchg_drain=20 15:44-16:09: 14 kicks/2 min, DETAILS_01 never 0x3b; drain 100 -> 90 % on the battery; then CNFG_09 0x03 -> 0x3b and CNFG_00 0x14 -> 0x15, read back the same; fast charge (0x31) then CV (0x32); iOS showed the charging bolt; no 9 V request on the CDP.
  • k4 = this commit, default line + sweetafc=1 (phone 2's end state, 16:09-): guard from the default line, CDP, 1500/1500 mA, +373-419 mA at 92 % in CV, 30-31 C, 0 differing read-backs, 0 9 V requests; Wi-Fi up.

The 9 V handshake itself has not run: no fast charger on a computer port. scion-kernel's docs/ios27/CHARGING-TEST.md is the owner's test.

… the fast-charge path (sweetafc=1, off)

iOS 27 only read the S9's fuel gauge. S-Boot leaves the MAX77705 charger's watchdog on and nothing kicked it, so
the charger stopped about 70 s after every boot (DETAILS_01 0x33 -> 0x3b, measured on phone 2), and iOS was told a
fixed 25 C battery with nothing to stop charging when hot or cold.

bsd/dev/starlte_charger.c, every second, on starlte_muic.c's bus (its lock, now shared):
- sweetchg=1: read only. The charger, the MUIC, the gauge and the two thermistors (CMGP's ADC, channels 4 and 3,
  the phone's own table) read; SweetBattery gets the real battery temperature, "charging" and "full" from the
  charger's own state, and the adapter's details (type, volts, amps); the log says what the guard would do.
- sweetchg=2 (now in the kernel's default line): the guard. Volatile charger registers only, each write read
  back: the watchdog kicked every 10 s and re-armed if it expired; charging on or off by Samsung's temperature
  bands (off at 41 C until 39 C, at 5 C until 10 C; 700 mA at 15 C), session timers, full and recharge; the input
  limit and charge current set to Samsung's for the charger type (SDP 475/550, CDP 1500/1500, DCP 1800/2100) or
  less. A fault, 45 C, the float above 4350 mV or a read-back that differs latches charging off until the cable
  goes. The float voltage, the timers and every other register are never written; nothing non-volatile.
- sweetafc=1 (off by default): on a DCP inside its band (battery 15-39 C, charger under 44 C, under 98 %, no
  fault), the switch opened and Samsung's 9 V request sent; 9 V taken only on result 0 with VBUS 7.5-10.5 V in
  the answer and in USBC_STATUS1, then 1650/2150 mA; dropped back (500 mA, 5 V asked) the second any condition
  stops holding. Never on a computer port. Not run against a fast charger yet (phone 2 is on a computer).
- sweetchg_drain=MIN (a test): the first MIN minutes on the battery (input 100 mA, charging off).
- kern.hakios.chg_* for the console.

The rules are bsd/dev/hakios.max77705_charge.h, a copy of scion-kernel's
drivers/power/max77705/hakios.max77705_charge.h, which tools/max77705-charge-test.sh tests on a computer.
starlte_muic.c leaves the switch open on a DCP when the 9 V path is on. Facts and the owner's test plan:
scion-kernel docs/ios27/CHARGING.md and CHARGING-TEST.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant