Leave the SD slot empty when there is no SD image

Without --sd (and no sd.img in the working directory) the emulator still
presented a card: a blank one, which SDMMC1 initialised at SDR104 and
FatFs then found no volume on. A console with nothing in the slot shows
the payload no card at all.

Now the slot starts empty when there is no image: card detect (PZ1)
reads no card and every SDMMC1 command times out, which the existing
[sd] inserted = 0 path already modelled. The config window's SD toggle
can still insert a blank card at runtime.

hwtest, which CI runs without --sd, now reports sd_initialize failing
and the SD as not ready instead of an unformatted 32 GiB card; its
verdict goes from 35 to 34 passes with no failures, and every CI
expectation still holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
This commit is contained in:
Claude committed 2026-09-26 10:23:58 +00:00
1 parent 33d16976fe
commit f31175f19a
3 files changed
+16 -3

No files matched your search

+5 -1
View File
@@ -181,7 +181,11 @@ SDR104 like the real slot:
their defaults, not the voltage.
- CMD19 tunes the SDR104 sampling point through the same tuning circuit as
the eMMC. hwtest reports a 199.68 MHz card clock.
- The CSD is an SD CSD 2.0 (SD 5.3.3): the image's size (32 GiB with none)
- With no image (`--sd`, or `sd.img` in the working directory) the slot is
empty: card detect (PZ1) reads no card and every SDMMC1 command times
out, as on a console with no card in. The config window can still insert
a blank card.
- The CSD is an SD CSD 2.0 (SD 5.3.3): the image's size (32 GiB for a blank card)
and command classes that include class 8, so bdk reads the SD status.
That (ACMD13) reports the bus width ACMD6 set and a Class 10, U1, V10
card with 4 MB AUs; the SCR sets SD_SPEC3.
+3 -2
View File
@@ -36,7 +36,8 @@ slow or destructive.
- Read real eMMC (embedded MMC) dumps (`BOOT0`, multi-part `rawnand.bin.NN`)
and decrypt them with XTS-AES-128 (XEX-based Tweaked-codebook with ciphertext
stealing) against keys from `prod.keys`.
- Serve a real FAT32 SD image to the payload (`--sd sd.img`).
- Serve a real FAT32 SD image to the payload (`--sd sd.img`). Without one the
SD slot is empty.
## Quick start
@@ -270,7 +271,7 @@ needed.
| Flag | Argument | Purpose |
| --------------------- | ------------- | --------------------------------------------------------- |
| `--sd` | `sd.img` | Back the SD card (SDMMC1) with this raw FAT32 image. |
| `--sd` | `sd.img` | Back the SD card (SDMMC1) with this raw FAT32 image. Without it (and with no `sd.img` in the working directory) the slot is empty. |
| `--boot0` | `BOOT0` | eMMC BOOT0 partition file (SDMMC4). |
| `--rawnand` | `rawnand.bin` | eMMC GPP partition prefix (auto-detects `.00`, `.01`, …). |
| `--prod-keys` | `prod.keys` | Override BIS keys from a Lockpick-style key file. |
+8
View File
@@ -412,6 +412,14 @@ int main(int argc, char *argv[]) {
if (state.sd_fd < 0) perror("[emu] Failed to open SD image");
else printf("[emu] SD image opened: %s\n", sd_path);
}
// No image, no card: the slot starts empty, so card detect (PZ1) reads
// empty and SDMMC1 commands time out, as on a console with no card in.
// This used to present a blank card that FatFs then found no volume on.
// The config window's SD toggle can still insert a blank card.
if (state.sd_fd < 0 && state.sd_inserted.load()) {
state.sd_inserted = false;
printf("[emu] No SD image: the SD slot is empty\n");
}
if (boot0_path) {
state.emmc_boot0_fd = open(boot0_path, O_RDWR | O_BINARY);
if (state.emmc_boot0_fd < 0) perror("[emu] Failed to open BOOT0 image");