Skip to content

microSD on the Galaxy S9, read only (sdcard=, off by default): Jesvi-iOS's dw-mshc driver + IOMedia moved to the 9810 - #422

Merged
claudiusthebot merged 3 commits into
mainfrom
sdcard-s9
Nov 27, 2026
Merged

claudiusthebot merged 3 commits into
mainfrom
sdcard-s9

Conversation

@claudiusthebot

Copy link
Copy Markdown
Collaborator

What

A read-only microSD driver for the Galaxy S9 on iOS 16.5. It is off by default (sdcard=) and not yet run on a phone.

It is Jesvi-iOS's S20 microSD driver and IOMedia (jesvi-eulah, APSL-2.0), moved to the Exynos 9810's dwmmc2. The PR has two commits:

  1. 452fc93 (author: jesvi-eulah) brings in redwood_sdcard.c @ b35cfdc and RedwoodSDMedia.cpp @ 0b6bce9 unchanged, renamed to drivers/storage/sd/hakios.exynos_sd.c and hakios.sdmedia.cpp. Because they are unchanged, the second commit's adaptation reads as a diff.
  2. facc7f3 (Claudius) makes the S9 adaptation:
    • Controller: dwmmc2 at 0x11500000 (from Samsung's DT and Scion's XNU-MICROSD.md).
    • Card detect: GPA1-5 (0x14050044 bit 5, low means a card is in).
    • Clock gates checked before the controller is read: CMU top 0x1a242070, FSYS1 0x11402030 and 0x11402034. If the FSYS1 gates are not forced on, the controller is not touched, because reading a gated IP can hang the bus.
    • Used only if the slot is left initialised, as S-Boot leaves it on the S20: VERID x270a, HCON data width 2 (the 64-bit FIFO), PWREN, CLKENA, and CTYPE 4-bit.
    • Read only: the CMD24 path is removed, write() returns EROFS, DKIOCISWRITABLE is 0, and the IOMedia has Writable = no.
    • Wiring: sysctls under kern.hakios.sdcard*; driver EXYNOS_SD in drivers/storage/conf and drivers/map, started after UFS, with a stub when it isn't built.

Boot args

  • sdcard=0 (the default): nothing.
  • sdcard=1: a look, nothing written. Logs the card-detect pin and the gates, and the controller registers only if the gates are on.
  • sdcard=2: forces the three card clock gates on and reads them back. Then, with a card in and the slot initialised, reads the MBR 6 s after start and publishes /dev/disk9, rdisk9, disk9s1, rdisk9s1 and an external IOBlockStorageDevice "SD Card" → IOMedia disk9 → IOMedia disk9s1, all read only.

Never written: the card, the PMIC, the pins, the clock dividers.

Compared with Scion's XNU-MICROSD.md

That design (for the iOS 26/27 forks) brings the card up itself: S2MPS18 LDO31/LDO2 through ACPM, then CMD0/8/ACMD41/2/3/9/7/ACMD6. This driver does not. It is the smaller step: it uses a slot that something earlier already initialised. sdcard=1 answers in one boot whether anything does that on the S9 (S-Boot, or Scion's loader if it read the card). If nothing does, the next PR ports section 2.3 of the design for this kernel. The comparison table is in docs/devices/starlte-microsd.md.

Files: iOS 16.5's external-drive path needs Apple's lifs.kext, which Scion does not load. On Jesvi-iOS that is done by redwood_kextload.c (d838091) plus a userfsd start-up wrapper (6139189). Until that is ported, the card appears as /dev/disk9s1 and in the IORegistry, but not in Files.

The checks run locally all pass: hakios-config-test, boot-args-test/--check, drivers-check, arch-check, hakios-device check, docs-gen --check, docs-check, provenance. The kernel build itself is left to CI (xnu-linux; EXYNOS_SD is built by default, inert without sdcard=).

Test plan (S9, iOS 16.5 image from this branch, FAT32 or exFAT card)

  1. Boot with sdcard=1. Look for sdcard: sdcard=1: card detect GPA1 DAT 0x.. (a card); gates top 0x.., FSYS1 ACLK 0x.. SDCLKIN 0x.., followed by one of:
    • the controller's clocks are not on …: not touched;
    • the dwmmc2: VERID … RESP0 … line and slot initialised;
    • not as a loader leaves an initialised card.
      Send the lines. Then boot again without a card: the log should say no card.
  2. Only if step 1 said slot initialised, boot with sdcard=2. After about 6 s the log should show sdcard: ready: disk9 … disk9s1 type 0x.. … (read only); IOKit published. Then check:
    • dd if=/dev/rdisk9s1 bs=512 count=1 | xxd | head shows the FAT/exFAT boot sector;
    • ioreg -l | grep -A3 'SD Card' shows the device;
    • dd of=/dev/rdisk9s1 fails with EROFS.
  3. Stop and send the log on a hang after the dwmmc2: line, or if sdcard_errors keeps growing.

Revert: boot without sdcard=. Nothing is written to the card. The forced clock gates are volatile.

Credits: Jesvi-iOS is added to NOTICE, with its licences (APSL-2.0 for its kernel files, MIT for the rest) and the source SHAs.

Not merging: the owner merges after a phone test.

🤖 Generated with Claude Code

jesvi-eulah and others added 2 commits November 26, 2026 19:12
… (APSL-2.0)

Taken unchanged from Jesvi-iOS (github.com/jesvi-eulah/Jesvi-iOS, iOS 16.5 on the Galaxy S20, by jesvi-eulah), with the
Scion owner's approval of 26 November 2026, under the Apple Public Source License 2.0 that covers its xnu/files/:

  xnu/files/bsd/dev/redwood_sdcard.c        at b35cfdc ("Enable microSD writes and harden startup")
                                            -> drivers/storage/sd/hakios.exynos_sd.c
  xnu/files/iokit/Kernel/RedwoodSDMedia.cpp at 0b6bce9 ("Add opt-in microSD partition writes"; first in d838091)
                                            -> drivers/storage/sd/hakios.sdmedia.cpp

Only the file names change here, so the next commit's adaptation to the Galaxy S9 (Exynos 9810, dwmmc2 at
0x11500000) shows as a diff. Not built by this commit (not yet in drivers/map or drivers/storage/conf).
…iOS's driver moved to the 9810's dwmmc2

The previous commit brought in Jesvi-iOS's S20 microSD driver and its IOMedia unchanged (jesvi-eulah: redwood_sdcard.c
at b35cfdc, RedwoodSDMedia.cpp at 0b6bce9, APSL-2.0). This one moves them to the S9 and makes them read only:

- the controller: dwmmc2 at 0x11500000 (Samsung's DT, Scion's XNU-MICROSD.md), still the 64-bit FIFO and S-Boot-style
  use of a slot left initialised; required now: VERID x270a, HCON data width 2, PWREN, CLKENA, CTYPE 4-bit;
- before the controller is read, the card-detect pin (GPA1-5, 0x14050044 bit 5) and the three clock gates (CMU top
  0x1a242070, FSYS1 0x11402030/0x11402034) are read; with the FSYS1 gates not forced on the controller is not touched
  (sdcard=1 writes nothing at all; sdcard=2 forces the gates on, read back, as XNU-MICROSD.md 2.3 step 2);
- read only: the CMD24 path removed, write() EROFS, DKIOCISWRITABLE 0, the IOMedia Writable no;
- boot-arg sdcard= (0 by default, 1 a look, 2 the card), sysctls under kern.hakios, names hakios_*;
- driver EXYNOS_SD in drivers/storage/conf, drivers/map, started from hakios_input_init after UFS, a stub.

docs/devices/starlte-microsd.md compares it with Jesvi's and with XNU-MICROSD.md and has the test plan. Not run on a
phone: whether anything leaves the S9's card initialised is what sdcard=1 answers first. Files needs lifs.kext, which
Scion does not load yet (Jesvi-iOS d838091, 6139189). Credited in NOTICE.
@claudiusthebot

Copy link
Copy Markdown
Collaborator Author

CI: GitHub Actions is disabled on this repository, so I ran this repo's own workflows (check, xnu-linux) in a temporary private repo. It held one squashed snapshot commit of this branch's tree (facc7f3), no history, and has since been deleted.

  • check: green.
  • xnu-linux: the bcm2837 kernel linked; each SoC table linked; starlte_defconfig: linked (35 drivers). That is one more than main's 34, which is EXYNOS_SD. No error: / undefined symbols.
    Still not run on a phone.

@claudiusthebot

Copy link
Copy Markdown
Collaborator Author

Phone regression of current main, phone 2 (Galaxy S9, iOS 27.2.1), 28 Nov 2026 — PASS.

Built: scion-kernel main adbb15d6 (this PR and #398 #408 #416 #418 #419 #420 #421 #422 all in) + Scion-Project/xnu scion/xnu-12377 head f2f59dd (xnu#70), with the recipe of the previous phone runs (gpupass-1124 kbuild.sh, rc 0; kernel f36b080a), image = that kernel + the same loader and the boot line phone 2 already runs (no new boot-args): BOOT 0edca00b…, flash read back. Root: phone 2's own as found, nothing written to USERDATA.

boot SpringBoard Wi-Fi assoc BT (BlueTool / 0xfe3b) panic idle all-CPU (of 800) crashes big core
M1b 21 s after flash +8 s up / answered none 16 % chronod 1 42.1 C
M1c 21 s after flash +8 s up / answered none 17 % locationd 2, chronod 1 43.0 C

Home screen drawn on both (icons, widgets, dock, Wi-Fi + charging). Crash set = the earlier baselines' (locationd, chronod); no new crash loop. The S9's charger guard as before (sweetchg=2 sweetafc=1: the guard).

#421 (max77705_chg=) and #422 (sdcard=) are iOS 16.5 kernel drivers, off by default, and not in this iOS 27 kernel; #421 was not enabled (live charging tests need Dylan beside the phone); #422 not run on phone 2: no microSD card in it.

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