diff --git a/cli/sidecart.py b/cli/sidecart.py index 4f564b7..1fceaef 100644 --- a/cli/sidecart.py +++ b/cli/sidecart.py @@ -38,7 +38,8 @@ 5 server returned 400 / 422 / other 4xx 6 server returned 503 (busy or SD unmounted) 7 server returned 5xx other than 503 - 8 network / DNS error (couldn't reach the host) + 8 network error: couldn't reach the host, or it dropped the + connection (a reboot, a panic or a SELECT press all look like this) Examples: python3 cli/sidecart.py ping @@ -57,6 +58,7 @@ import http.client import json import os +import socket import sys import urllib.error import urllib.parse @@ -67,6 +69,30 @@ USER_AGENT = "sidecart-cli/0.1" REQUEST_TIMEOUT_S = 10 +# The device dropping a connection is a normal thing to survive -- it reboots +# on a watchdog, a panic or a SELECT press, and the HTTP server closes idle +# connections on purpose. urllib only wraps some of that in URLError; the rest +# escapes as a bare OSError and used to reach the user as a traceback +# (EPIC-15 STORY-03). IncompleteRead is in here because a chunked body cut +# short raises it rather than an OSError. +CONNECTION_DROPPED = ( + ConnectionResetError, + ConnectionAbortedError, + BrokenPipeError, + http.client.RemoteDisconnected, + http.client.IncompleteRead, + socket.timeout, + TimeoutError, +) + + +def _dropped(operation: str, exc: BaseException) -> int: + """Report a dropped connection as one line and the network exit code.""" + detail = str(exc) or exc.__class__.__name__ + print(f"error: {operation}: connection dropped by the device ({detail})", + file=sys.stderr) + return EXIT_NETWORK + # Granular exit-code map (see docs/epics/02-http-api.md "CLI / Exit code # map"). Lets shell scripts branch on category. EXIT_OK = 0 @@ -143,6 +169,12 @@ def request_json(method: str, url: str, *, body: bytes | None = None, with urllib.request.urlopen(req, timeout=timeout) as resp: raw = resp.read() status = resp.status + except CONNECTION_DROPPED as exc: + # Re-raised as URLError so the callers' existing handling applies; + # the reason carries what actually happened. + detail = str(exc) or exc.__class__.__name__ + raise urllib.error.URLError( + f"connection dropped by the device ({detail})") from exc except urllib.error.HTTPError as exc: # Server returned >= 400 — read its body so we can render the # error envelope, then close the response handle to silence @@ -408,6 +440,8 @@ def cmd_get(args: argparse.Namespace) -> int: req = urllib.request.Request(url, headers=headers, method="GET") try: resp = urllib.request.urlopen(req, timeout=REQUEST_TIMEOUT_S) + except CONNECTION_DROPPED as exc: + return _dropped(f"downloading {url}", exc) except urllib.error.HTTPError as exc: try: raw = exc.read() if exc.fp is not None else b"" @@ -464,6 +498,13 @@ def cmd_get(args: argparse.Namespace) -> int: # Newline after the progress line. sys.stderr.write("\n") sys.stderr.flush() + except CONNECTION_DROPPED as exc: + # Mid-transfer: the partial file is left in place so --resume can pick + # it up, which is the whole reason that option exists. + if not args.quiet: + sys.stderr.write("\n") + sys.stderr.flush() + return _dropped(f"downloading {url}", exc) finally: resp.close() @@ -843,6 +884,8 @@ def cmd_debug_tail(args: argparse.Namespace) -> int: try: # No timeout — we deliberately want to block forever. resp = urllib.request.urlopen(req, timeout=None) + except CONNECTION_DROPPED as exc: + return _dropped(f"tailing {url}", exc) except urllib.error.HTTPError as exc: # Non-200 from the server — render the error envelope if any. try: @@ -875,6 +918,10 @@ def cmd_debug_tail(args: argparse.Namespace) -> int: out.flush() except KeyboardInterrupt: return EXIT_OK + except CONNECTION_DROPPED as exc: + # A tail is long-lived by design, so the device rebooting under it is + # the expected way for this to end, not an anomaly. + return _dropped(f"tailing {url}", exc) finally: resp.close() return EXIT_OK diff --git a/cli/test_sidecart.py b/cli/test_sidecart.py index 5d3880e..a7b192d 100644 --- a/cli/test_sidecart.py +++ b/cli/test_sidecart.py @@ -16,6 +16,8 @@ import io import json import os +import socket +import struct import sys import tempfile import threading @@ -1714,3 +1716,96 @@ def test_known_codes(self) -> None: if __name__ == "__main__": unittest.main() + + +class _ResettingServer: + """A server that accepts a connection and then drops it mid-response. + + Covers what the device does when it reboots under a command: a watchdog, + a panic or a SELECT press all cut the socket without a reply, and urllib + surfaces that as ConnectionResetError or RemoteDisconnected rather than + URLError (EPIC-15 STORY-03). + """ + + def __init__(self, mode: str = "immediate") -> None: + self.mode = mode + self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + self.sock.bind(("127.0.0.1", 0)) + self.sock.listen(4) + self.port = self.sock.getsockname()[1] + self.host = f"127.0.0.1:{self.port}" + self.thread = threading.Thread(target=self._serve, daemon=True) + self.running = True + self.thread.start() + + def _serve(self) -> None: + while self.running: + try: + conn, _addr = self.sock.accept() + except OSError: + return + try: + conn.recv(65536) + if self.mode == "partial": + # Headers promising a body, then the socket dies: this is + # what a reboot mid-download looks like. + conn.sendall( + b"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n" + b"Content-Length: 1000\r\n\r\n" + b"x" * 10) + # Reset rather than a clean close, so the client sees ECONNRESET. + conn.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, + struct.pack("ii", 1, 0)) + except OSError: + pass + finally: + with contextlib.suppress(OSError): + conn.close() + + def close(self) -> None: + self.running = False + with contextlib.suppress(OSError): + self.sock.close() + self.thread.join(timeout=2) + + +class DroppedConnectionTests(unittest.TestCase): + """A device that drops the connection must never print a traceback.""" + + def _assert_clean_network_error(self, code: int, out: str, err: str) -> None: + self.assertEqual(code, sidecart.EXIT_NETWORK) + self.assertNotIn("Traceback", err) + self.assertNotIn("Traceback", out) + # Exactly one line, and it is an error line. + lines = [ln for ln in err.strip().splitlines() if ln.strip()] + self.assertEqual(len(lines), 1, f"expected one line, got: {lines!r}") + self.assertTrue(lines[0].startswith("error:"), lines[0]) + + def test_reset_before_reply(self) -> None: + server = _ResettingServer("immediate") + self.addCleanup(server.close) + code, out, err = _run_cli(["--host", server.host, "ping"]) + self._assert_clean_network_error(code, out, err) + + def test_reset_on_json_command(self) -> None: + server = _ResettingServer("immediate") + self.addCleanup(server.close) + code, out, err = _run_cli( + ["--host", server.host, "gemdrive", "ls", "/"]) + self._assert_clean_network_error(code, out, err) + + def test_reset_mid_download(self) -> None: + server = _ResettingServer("partial") + self.addCleanup(server.close) + with tempfile.TemporaryDirectory() as tmp: + dest = os.path.join(tmp, "out.bin") + code, out, err = _run_cli( + ["--host", server.host, "-q", "gemdrive", "get", "/A.BIN", + dest]) + self._assert_clean_network_error(code, out, err) + + def test_reset_on_health(self) -> None: + server = _ResettingServer("immediate") + self.addCleanup(server.close) + code, out, err = _run_cli(["--host", server.host, "health"]) + self._assert_clean_network_error(code, out, err) diff --git a/docs/api.md b/docs/api.md index 1b1c845..b835ff6 100644 --- a/docs/api.md +++ b/docs/api.md @@ -89,7 +89,7 @@ python3 cli/sidecart.py gemdrive rm SWITCHER.TOS | `416 Range Not Satisfiable` | Range outside file bounds. Carries `Content-Range: bytes */`. | | `422 Unprocessable Entity` | Malformed JSON body, missing required field, listing-on-file, rename-into-own-descendant. | | `500 Internal Server Error` | FatFs disk error. | -| `503 Service Unavailable` | Body-stream lock held, SD not mounted, Runner busy with another command, or `insufficient_memory`: FatFs could not allocate its working buffer, so the operation can be retried when memory frees up. Always carries `Retry-After: 1`. | +| `503 Service Unavailable` | Body-stream lock held (`busy`), no usable SD card (`no_sd_card`), Runner busy with another command (`busy`), or `insufficient_memory`: FatFs could not allocate its working buffer, so the operation can be retried when memory frees up. Always carries `Retry-After: 1`. | | `504 Gateway Timeout` | Synchronous Runner endpoint exceeded its server-side spin-wait deadline (`gateway_timeout`). Per-endpoint deadlines: `runner load` 10 s; `runner unload` 5 s; `runner meminfo`, `runner adv/meminfo`, and each `runner adv/load` chunk 1 s. | ## Error code vocabulary @@ -99,11 +99,18 @@ Clients can switch on `code` reliably. All defined symbols: `bad_request`, `bad_path`, `bad_query`, `name_too_long`, `not_found`, `is_directory`, `is_file`, `conflict`, `length_required`, `payload_too_large`, `range_invalid`, `bad_json`, `unprocessable`, -`unsupported_media`, `method_not_allowed`, `busy`, `disk_error`, +`unsupported_media`, `method_not_allowed`, `busy`, `no_sd_card`, `disk_error`, `insufficient_memory`, `internal_error`, `runner_inactive`, `gateway_timeout`, `no_snapshot`, `wrong_hook`, `ram_overflow`, `pexec_failed`, `mfree_failed`, `program_already_loaded`, `no_program_loaded`. +`no_sd_card` — there is no usable SD card mounted. **Every** endpoint that +needs the card answers this the same way: `volume`, listings, downloads, +uploads, folder operations, `runner load` and `runner run`. It is not a fault +to recover from by hand: the firmware retries the mount every two seconds, so +inserting a working card clears it within a few seconds with no reset, and the +setup menu shows `SD: NO CARD` meanwhile and refuses `[G]` and `[U]`. + Runner-specific codes (see *Runner mode* below): - `runner_inactive` — the user didn't pick `[U]` at boot. - `busy` — another foreground Runner command is in flight. Every @@ -235,7 +242,7 @@ python3 cli/sidecart.py health `UNKNOWN` (the SD card mounted but FatFs reported a filesystem type the firmware doesn't have a string for). -**Errors:** `503 busy` if the SD card is not mounted. +**Errors:** `503 no_sd_card` if no usable SD card is mounted. **`curl`**: ```sh diff --git a/rp/src/emul.c b/rp/src/emul.c index afdfe84..139e3f6 100644 --- a/rp/src/emul.c +++ b/rp/src/emul.c @@ -632,6 +632,13 @@ static void drawSetupInfoLine(const char *message) { // Set when [G] or [U] was refused because no HELLO arrived since the RP // booted (see emul_canLaunch). Cleared when HELLO lands. static bool launchNeedsStReset = false; +// Set when [G] or [U] was refused because no usable SD card is mounted +// (EPIC-15 STORY-02). Cleared as soon as a card appears; the retry loop in +// sdcard_pollRemount is what makes that happen without a reset. +static bool launchNeedsSdCard = false; +// Tracks the card state the menu was last drawn with, so the line is redrawn +// when it changes rather than on every pass. +static bool lastDrawnSdMounted = false; // True while the countdown itself is launching, so a refusal can restart the // countdown once HELLO lands instead of leaving it stopped. static bool countdownLaunching = false; @@ -646,6 +653,8 @@ static void drawHaltedInfoLine(void) { drawSetupInfoLine( settingsSaveFailed ? "Saving the settings failed: the change was not stored." + : launchNeedsSdCard + ? "Insert a working microSD card: GEMDRIVE needs one." : launchNeedsStReset ? "Reset the Atari ST first: no HELLO since RP boot." : "Countdown stopped. Press [G], [U] or [X] to continue."); @@ -803,6 +812,14 @@ static uint32_t emul_devhooksApp(uint16_t commandId, const uint16_t *payload, DPRINTF("devhooks: slow connect returned %d\n", (int)rc); return 1; } + case DEVHOOKS_APP_GEMDRIVE_STALL: { + uint16_t chunks = (payloadSize >= 2u) ? payload[0] : 1u; + uint16_t ds = (payloadSize >= 4u) ? payload[1] : 0u; + gemdrive_setWriteStall(chunks, ds); + DPRINTF("devhooks: stalling the next %u write chunk(s) by %u ds\n", + (unsigned)chunks, (unsigned)ds); + return 1; + } case DEVHOOKS_APP_COUNTDOWN_STOP: haltCountdown = true; return 1; @@ -1312,7 +1329,13 @@ static void menu(void) { // Folder + drive read straight from aconfig, like source/md-drives. vt52Cursor(2, 0); - term_printString("GEMDRIVE\n"); + // The card's state goes on the header line, not a row of its own: the + // section dividers are at fixed pixel rows and the status icons are + // right-aligned per header row, so an extra line shifts every section below + // into them (EPIC-15 STORY-02). Kept short to clear the drive icon on the + // right. + term_printString(sdcard_isMounted() ? "GEMDRIVE SD: mounted\n" + : "GEMDRIVE SD: NO CARD\n"); SettingsConfigEntry *gemDriveFolder = settings_find_entry(aconfig_getContext(), ACONFIG_PARAM_GEMDRIVE_FOLDER); @@ -1514,6 +1537,17 @@ static void showCounter(int cdown) { // run's shared variables survived in uncleared RAM. static bool emul_canLaunch(void) { haltCountdown = true; + // Without a card there is nothing to emulate a drive from, and both modes + // would come up broken. Refuse and say so; sdcard_pollRemount keeps trying, + // so inserting one clears this within a couple of seconds (EPIC-15 STORY-02). + if (!sdcard_isMounted()) { + DPRINTF("Launch refused: no SD card mounted\n"); + launchNeedsSdCard = true; + restartCountdownOnHello = countdownLaunching; + menu(); + display_refresh(); + return false; + } if (gemdrive_getPhystop(NULL, NULL)) return true; DPRINTF("Launch refused: no HELLO from the ST since the RP booted\n"); launchNeedsStReset = true; @@ -2186,6 +2220,31 @@ void emul_start() { // press (≥ SELECT_LONG_RESET ms) fires reset_deviceAndEraseFlash. select_checkPushReset(); + // Bring a reinserted SD card back without a reset (EPIC-15 STORY-01). + // Cheap while the card is mounted. + sdcard_pollRemount(); + + // Follow the card's state on the menu, and lift the launch block as soon + // as a usable card appears (EPIC-15 STORY-02). + bool sdMountedNow = sdcard_isMounted(); + if (sdMountedNow != lastDrawnSdMounted) { + lastDrawnSdMounted = sdMountedNow; + if (sdMountedNow && launchNeedsSdCard) { + launchNeedsSdCard = false; + if (restartCountdownOnHello) { + restartCountdownOnHello = false; + (void)term_consumeAnyKeyPressed(); + countdown = BOOT_COUNTDOWN_SECONDS; + lastCountdownTick = get_absolute_time(); + haltCountdown = false; + } + } + if (menuScreenActive) { + menu(); + display_refresh(); + } + } + // Heap sampling, the debug summary and debug test hooks. health_tick(); devhooks_poll(); diff --git a/rp/src/gemdrive.c b/rp/src/gemdrive.c index 066bb53..185f2ad 100644 --- a/rp/src/gemdrive.c +++ b/rp/src/gemdrive.c @@ -18,6 +18,7 @@ #include #include +#include "sdcard.h" #include "aconfig.h" #include "chandler.h" #include "debug.h" @@ -48,6 +49,13 @@ static char dpathStr[GEMDRIVE_DEFAULT_PATH_LEN] = "\\"; typedef struct { bool inUse; FIL fp; + // Last write chunk accepted on this handle (EPIC-15 STORY-05). The m68k + // bumps its sequence once per chunk and re-sends the same one on every + // retry, so a repeat means the ST never heard the answer -- not that there + // is more data. Writing it again is what duplicated a chunk and lost the + // tail of the file. + uint32_t lastWriteSeq; + uint32_t lastWriteBytes; } GemFileSlot; static GemFileSlot fileTable[GEMDRIVE_MAX_OPEN_FILES]; @@ -254,6 +262,8 @@ static int __not_in_flash_func(allocFileSlot)(void) { if (!fileTable[i].inUse) { fileTable[i].inUse = true; memset(&fileTable[i].fp, 0, sizeof(FIL)); + fileTable[i].lastWriteSeq = 0; + fileTable[i].lastWriteBytes = 0; return i; } } @@ -453,6 +463,7 @@ static void __not_in_flash_func(handleDfreeCall)(void) { uint32_t bytesPerSector = 0, sectorsPerCluster = 0; FRESULT res = f_getfree("", &freeClusters, &fs); + sdcard_noteResult(res); if (res != FR_OK || fs == NULL) { status = (uint32_t)-1; DPRINTF("GEMDRIVE Dfree: f_getfree failed (%d)\n", (int)res); @@ -529,6 +540,7 @@ static void __not_in_flash_func(handleDsetpathCall)(uint16_t *payload) { FILINFO info; FRESULT res = f_stat(sdPath, &info); + sdcard_noteResult(res); if (res != FR_OK || !(info.fattrib & AM_DIR)) { DPRINTF("GEMDRIVE Dsetpath: '%s' not a directory (fr=%d, attr=0x%X)\n", sdPath, (int)res, (unsigned)info.fattrib); @@ -649,6 +661,7 @@ static void __not_in_flash_func(handleDcreateCall)(uint16_t *payload) { char sdPath[GEMDRIVE_DEFAULT_PATH_LEN + 64] = {0}; getLocalFullPathname(atari, sdPath, sizeof(sdPath)); FRESULT res = f_mkdir(sdPath); + sdcard_noteResult(res); uint16_t status = (res == FR_OK) ? 0 : (res == FR_NOT_ENOUGH_CORE) ? (uint16_t)-39 // ENSMEM : (res == FR_NO_PATH) ? (uint16_t)-34 // EPTHNF @@ -666,6 +679,7 @@ static void __not_in_flash_func(handleDdeleteCall)(uint16_t *payload) { char sdPath[GEMDRIVE_DEFAULT_PATH_LEN + 64] = {0}; getLocalFullPathname(atari, sdPath, sizeof(sdPath)); FRESULT res = f_unlink(sdPath); + sdcard_noteResult(res); uint16_t status; if (res == FR_OK) { status = 0; @@ -699,6 +713,7 @@ static void __not_in_flash_func(handleFcreateCall)(uint16_t *payload) { } FRESULT res = f_open(&fileTable[slotIdx].fp, sdPath, FA_READ | FA_WRITE | FA_CREATE_ALWAYS); + sdcard_noteResult(res); if (res != FR_OK) { DPRINTF("GEMDRIVE Fcreate: '%s' -> fr=%d\n", sdPath, (int)res); releaseFileSlot(slotIdx); @@ -736,6 +751,7 @@ static void __not_in_flash_func(handleFdeleteCall)(uint16_t *payload) { char sdPath[GEMDRIVE_DEFAULT_PATH_LEN + 64] = {0}; getLocalFullPathname(atari, sdPath, sizeof(sdPath)); FRESULT res = f_unlink(sdPath); + sdcard_noteResult(res); uint32_t status; if (res == FR_OK || res == FR_NO_FILE) { status = 0; // source treats FR_NO_FILE as success @@ -765,6 +781,7 @@ static void __not_in_flash_func(handleFattribCall)(uint16_t *payload) { FILINFO info; FRESULT res = f_stat(sdPath, &info); + sdcard_noteResult(res); if (res != FR_OK) { writeAppFreeLong(GEMDRIVE_FATTRIB_STATUS_OFFSET, (uint32_t)-33); return; @@ -805,6 +822,7 @@ static void __not_in_flash_func(handleFrenameCall)(uint16_t *payload) { getLocalFullPathname(dstAtari, dstSd, sizeof(dstSd)); FRESULT res = f_rename(srcSd, dstSd); + sdcard_noteResult(res); uint32_t status; if (res == FR_OK) { status = 0; @@ -856,12 +874,43 @@ static void __not_in_flash_func(handleFdatetimeCall)(uint16_t *payload) { writeAppFreeLong(GEMDRIVE_FDATETIME_STATUS_OFFSET, 0); } +#if defined(_DEBUG) && (_DEBUG != 0) +// Debug-only fault injection for EPIC-15 STORY-05: stall after committing a +// chunk so the ST's synchronous wait times out and it re-sends that chunk. +static volatile uint16_t gemdriveWriteStallChunks = 0; +static volatile uint16_t gemdriveWriteStallDs = 20; // 100 ms units + +void gemdrive_setWriteStall(uint16_t chunks, uint16_t deciseconds) { + gemdriveWriteStallChunks = chunks; + if (deciseconds > 0) { + gemdriveWriteStallDs = deciseconds; + } +} + +static void gemdrive_stallIfRequested(void) { + if (gemdriveWriteStallChunks == 0) { + return; + } + gemdriveWriteStallChunks--; + DPRINTF("GEMDRIVE Fwrite: stalling this answer on purpose\n"); + // Long enough to outlast the ST's COMMAND_TIMEOUT, short enough that the + // watchdog never fires -- fed on the way through. + for (uint16_t i = 0; i < gemdriveWriteStallDs; i++) { + health_feed(); + sleep_ms(100); + } + health_feed(); +} +#endif + static void __not_in_flash_func(handleWriteBuffCall)(uint16_t *payload) { uint16_t handle = TPROTO_GET_PAYLOAD_PARAM16(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); uint32_t bytes = TPROTO_GET_PAYLOAD_PARAM32(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); - TPROTO_NEXT32_PAYLOAD_PTR(payload); // skip d5 + // d5 carries the chunk sequence number (EPIC-15 STORY-05). + uint32_t seq = TPROTO_GET_PAYLOAD_PARAM32(payload); + TPROTO_NEXT32_PAYLOAD_PTR(payload); if (bytes > GEMDRIVE_WRITE_BUFFER_SIZE) bytes = GEMDRIVE_WRITE_BUFFER_SIZE; @@ -871,6 +920,16 @@ static void __not_in_flash_func(handleWriteBuffCall)(uint16_t *payload) { return; } + // The same chunk again: the write already happened, only the answer was + // lost. Report what it wrote and do not touch the file -- appending it a + // second time is exactly the corruption this guards against. + if (seq != 0 && seq == slot->lastWriteSeq) { + DPRINTF("GEMDRIVE Fwrite: repeat of chunk %lu, answering %lu again\n", + (unsigned long)seq, (unsigned long)slot->lastWriteBytes); + writeAppFreeLong(GEMDRIVE_WRITE_BYTES_OFFSET, slot->lastWriteBytes); + return; + } + // Swap the chunk where it already sits, in the parser's payload buffer: a // 1 KB copy on the stack for every chunk (EPIC-12 STORY-03). uint8_t *tmp = (uint8_t *)payload; @@ -887,6 +946,7 @@ static void __not_in_flash_func(handleWriteBuffCall)(uint16_t *payload) { uint32_t writeStartUs = (uint32_t)time_us_32(); #endif FRESULT res = f_write(&slot->fp, tmp, (UINT)bytes, &bw); + sdcard_noteResult(res); #if defined(_DEBUG) && (_DEBUG != 0) uint32_t writeUs = (uint32_t)time_us_32() - writeStartUs; if (writeUs > GEMDRIVE_SLOW_WRITE_US) { @@ -895,6 +955,15 @@ static void __not_in_flash_func(handleWriteBuffCall)(uint16_t *payload) { } #endif health_feed(); + if (res == FR_OK) { + // Remember it before answering: if this answer is the one that gets lost, + // the retry has to find it here. + slot->lastWriteSeq = seq; + slot->lastWriteBytes = (uint32_t)bw; + } +#if defined(_DEBUG) && (_DEBUG != 0) + gemdrive_stallIfRequested(); +#endif if (res != FR_OK) { // Zero tells the ST the write failed; its loop returns EIO rather than // retrying a chunk this side may already have written. @@ -974,6 +1043,7 @@ static void __not_in_flash_func(handleFopenCall)(uint16_t *payload) { } FRESULT res = f_open(&fileTable[slotIdx].fp, sdPath, faMode); + sdcard_noteResult(res); if (res != FR_OK) { DPRINTF("GEMDRIVE Fopen: '%s' (mode=%lu) failed (%d)\n", sdPath, (unsigned long)mode, (int)res); @@ -999,6 +1069,7 @@ static void __not_in_flash_func(handleFcloseCall)(uint16_t *payload) { return; } FRESULT res = f_close(&slot->fp); + sdcard_noteResult(res); releaseFileSlot(handle - GEMDRIVE_FIRST_FD); writeAppFreeLong(GEMDRIVE_FCLOSE_STATUS_OFFSET, (res == FR_OK) ? 0 : (uint32_t)-37); @@ -1033,6 +1104,7 @@ static void __not_in_flash_func(handleFseekCall)(uint16_t *payload) { return; } FRESULT res = f_lseek(&slot->fp, newPos); + sdcard_noteResult(res); if (res != FR_OK) { writeAppFreeLong(GEMDRIVE_FSEEK_STATUS_OFFSET, (uint32_t)-64); return; @@ -1062,6 +1134,7 @@ static void __not_in_flash_func(handleReadBuffCall)(uint16_t *payload) { uint8_t *dst = (uint8_t *)(appFreeAddress() + GEMDRIVE_READ_BUFFER_OFFSET); UINT bytesRead = 0; FRESULT res = f_read(&slot->fp, dst, (UINT)bytesThisChunk, &bytesRead); + sdcard_noteResult(res); if (res != FR_OK) { writeAppFreeLong(GEMDRIVE_READ_BYTES_OFFSET, (uint32_t)-93); // EIO_READ return; @@ -1257,6 +1330,7 @@ static void __not_in_flash_func(handleFsfirstCall)(uint16_t *payload) { // gives us only the first hit and garbage after that. FILINFO info; FRESULT res = f_findfirst(&slot->dir, &info, sdDir, slot->pattern); + sdcard_noteResult(res); if (res == FR_OK) { slot->hasDir = true; } @@ -1291,6 +1365,7 @@ static void __not_in_flash_func(handleFsnextCall)(uint16_t *payload) { } FILINFO info; FRESULT res = f_findnext(&slot->dir, &info); + sdcard_noteResult(res); if (res == FR_OK && info.fname[0]) { res = advancePastFiltered(&slot->dir, &info, slot->attribs); } diff --git a/rp/src/http_server.c b/rp/src/http_server.c index 58c450e..6ef5861 100644 --- a/rp/src/http_server.c +++ b/rp/src/http_server.c @@ -28,6 +28,7 @@ #include "pico/cyw43_arch.h" #include "pico/time.h" #include "runner.h" +#include "sdcard.h" #include "select.h" #include "settings.h" #include "usbcdc.h" @@ -226,6 +227,7 @@ static void write_error(http_conn_t *c, int status, const char *reason, const char *code_symbol, const char *message); static void write_fs_error(http_conn_t *c, FRESULT fr, const char *message); static void write_405(http_conn_t *c, const char *allow); +static void write_no_card(http_conn_t *c); static err_t srv_accept_cb(void *arg, struct tcp_pcb *newpcb, err_t err); static err_t __not_in_flash_func(srv_recv_cb)(void *arg, struct tcp_pcb *pcb, struct pbuf *p, @@ -1307,8 +1309,7 @@ static void handle_volume(http_conn_t *c) { FRESULT res = f_getfree("", &free_clusters, &fs); if (res != FR_OK || fs == NULL) { DPRINTF("http_server: /volume f_getfree failed (%d)\n", (int)res); - write_error(c, 503, "Service Unavailable", "busy", - "SD filesystem unavailable"); + write_fs_error(c, res, "f_getfree failed"); return; } uint64_t bytes_per_sector = @@ -4358,6 +4359,23 @@ static bool strip_rename_action(char *rel) { static void route(http_conn_t *c) { health_setPhase(HEALTH_PHASE_HTTP_REQUEST); + // Everything under /gemdrive needs the card, and so does loading a program + // from it. One check here is what keeps the answer identical across volume, + // listings, downloads, uploads, folder operations and the Runner + // (EPIC-15 STORY-02). + static const char gemdrive_prefix[] = "/api/v1/gemdrive"; + static const char runner_load_prefix[] = "/api/v1/runner/load"; + static const char runner_run_prefix[] = "/api/v1/runner/run"; + if (!sdcard_isMounted() && + (strncmp(c->path, gemdrive_prefix, sizeof(gemdrive_prefix) - 1) == 0 || + strncmp(c->path, runner_load_prefix, sizeof(runner_load_prefix) - 1) == + 0 || + strncmp(c->path, runner_run_prefix, sizeof(runner_run_prefix) - 1) == + 0)) { + write_no_card(c); + return; + } + // HEAD is treated as GET for matching purposes (the dispatcher // suppresses the body during write). uint8_t method_bit = @@ -4645,7 +4663,25 @@ static void write_error(http_conn_t *c, int status, const char *reason, // A FatFs call failed. With the malloc panic off (EPIC-11 STORY-01) FatFs can // report FR_NOT_ENOUGH_CORE instead of the device dying, so report that apart // from a disk fault: the caller can retry when memory frees up. +// Every SD endpoint answers a missing card the same way (EPIC-15 STORY-02). +// Before this, /volume said 503 "busy" while a listing said 500 "disk_error" +// for the same missing card, and a listing could even answer 200 with an empty +// directory from FatFs's cache. +static void write_no_card(http_conn_t *c) { + write_error(c, 503, "Service Unavailable", "no_sd_card", + "No SD card mounted"); +} + static void write_fs_error(http_conn_t *c, FRESULT fr, const char *message) { + // A disk error may mean the card is gone; let the SD layer start retrying + // the mount (EPIC-15 STORY-01). + sdcard_noteResult(fr); + // If that is what happened, say so rather than reporting a disk fault: the + // card being out is a different thing from the card being broken. + if (!sdcard_isMounted()) { + write_no_card(c); + return; + } if (fr == FR_NOT_ENOUGH_CORE) { write_error(c, 503, "Service Unavailable", "insufficient_memory", message); return; diff --git a/rp/src/include/emul.h b/rp/src/include/emul.h index 20369e4..c1b84ca 100644 --- a/rp/src/include/emul.h +++ b/rp/src/include/emul.h @@ -58,6 +58,11 @@ void emul_start(); // times out after NETWORK_CONNECT_TIMEOUT. Used to check that SELECT, the ST // and the terminal stay alive for the whole attempt (EPIC-14 STORY-04). #define DEVHOOKS_APP_WIFI_SLOW_CONNECT 8 +// Debug builds only. Makes the next N GEMDRIVE write chunks stall after the +// data is committed but before the ST is answered, which is exactly the shape +// of the failure in EPIC-15 STORY-05: the write happened, the answer was lost, +// and the ST re-sends the chunk. Payload word 0 = how many chunks to stall. +#define DEVHOOKS_APP_GEMDRIVE_STALL 9 /** * @brief Whether the user picked Runner mode at boot ([U] in the diff --git a/rp/src/include/gemdrive.h b/rp/src/include/gemdrive.h index 6638db2..b96b08c 100644 --- a/rp/src/include/gemdrive.h +++ b/rp/src/include/gemdrive.h @@ -101,6 +101,16 @@ #define GEMDRIVE_WRITE_BYTES_OFFSET 0x10F0 // 4 bytes (bytes written) #define GEMDRIVE_WRITE_BUFFER_OFFSET 0x10F4 // 1024 bytes #define GEMDRIVE_WRITE_BUFFER_SIZE 1024 + +#if defined(_DEBUG) && (_DEBUG != 0) +/** + * @brief Debug-only: stall the answer to the next `chunks` write chunks. + * + * The data is committed first, so this reproduces a lost answer rather than a + * lost write (EPIC-15 STORY-05). + */ +void gemdrive_setWriteStall(uint16_t chunks, uint16_t deciseconds); +#endif // Report a write that took longer than this (debug builds only): the ST waits // about 300 ms for its answer before retrying the chunk. #define GEMDRIVE_SLOW_WRITE_US 20000 diff --git a/rp/src/include/sdcard.h b/rp/src/include/sdcard.h index 7020f41..4544ba3 100644 --- a/rp/src/include/sdcard.h +++ b/rp/src/include/sdcard.h @@ -21,6 +21,13 @@ typedef enum { SDCARD_CREATE_FOLDER_ERROR = -3 } sdcard_status_t; +// How long to wait between remount attempts while no card is mounted. +#define SDCARD_REMOUNT_RETRY_MS 2000u +// How often to ask the card whether it is still there, by reading one sector. +#define SDCARD_PRESENCE_POLL_MS 2000u +// Longest GEMDRIVE folder name kept for a later remount. +#define SDCARD_FOLDER_NAME_MAX 128 + #define SDCARD_KILOBAUD 1000 // Bounds enforced by sdcard_setSpiSpeedSettings() so a malformed @@ -137,6 +144,25 @@ void sdcard_getInfo(FATFS *fsPtr, uint32_t *totalSizeMb, uint32_t *freeSpaceMb); */ bool sdcard_isMounted(void); +/** + * @brief Tell the SD layer what a FatFs call returned. + * + * Results that mean the medium stopped answering mark the card unmounted, so + * sdcard_pollRemount() starts trying to bring it back. Everything else is + * ignored. + */ +void sdcard_noteResult(FRESULT fres); + +/** + * @brief Retry the mount while no card is mounted. Call from the main loop. + */ +void sdcard_pollRemount(void); + +/** + * @brief How many times a card has been remounted since boot. + */ +uint32_t sdcard_getRemountRecoveries(void); + /** * @brief Retrieves total and free SD card space from the mounted filesystem. * diff --git a/rp/src/include/target_firmware.h b/rp/src/include/target_firmware.h index f1f4e4b..dd049ae 100644 --- a/rp/src/include/target_firmware.h +++ b/rp/src/include/target_firmware.h @@ -1,5 +1,5 @@ const uint16_t target_firmware[] __attribute__((aligned(4))) = { - 0xABCD, 0xEF42, 0x0000, 0x0000, 0x08FA, 0x001E, 0x0000, 0x0000, 0x92BB, 0x5D30, 0x0000, 0x06C4, 0x5445, 0x524D, 0x0000, 0x6100, + 0xABCD, 0xEF42, 0x0000, 0x0000, 0x08FA, 0x001E, 0x0000, 0x0000, 0x6EF8, 0x5D31, 0x0000, 0x06C4, 0x5445, 0x524D, 0x0000, 0x6100, 0x05A4, 0x3F3C, 0x0002, 0x4E4E, 0x548F, 0x2440, 0x45EA, 0xF000, 0x264A, 0x2C3C, 0x0000, 0x057A, 0x43F9, 0x00FA, 0x004A, 0xE44E, 0x5346, 0x24D9, 0x51CE, 0xFFFC, 0x4ED3, 0x2C40, 0x0038, 0x0008, 0x0484, 0x3F3C, 0x0004, 0x4E4E, 0x548F, 0xB07C, 0x0002, 0x6700, 0x0128, 0x3F3C, 0x0025, 0x4E4E, 0x548F, 0x204E, 0x227C, 0x00FA, 0xE0C0, 0x203C, 0x0000, 0x0F9F, 0x3219, 0xE159, 0x3401, 0x4842, @@ -63,164 +63,164 @@ const uint16_t target_firmware[] __attribute__((aligned(4))) = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x6000, 0x0006, 0x6000, 0x0072, 0x48E7, 0xFFFE, 0x41FA, 0x00D6, 0x2F08, 0x3F3C, 0x0021, 0x3F3C, 0x0005, 0x4E4D, 0x508F, 0x43FA, - 0x00C0, 0x2280, 0x2600, 0x2809, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7208, 0x303C, 0x0401, 0x6100, 0x1156, 0x4CDF, 0x00FE, 0x4A40, + 0x6000, 0x0006, 0x6000, 0x0072, 0x48E7, 0xFFFE, 0x41FA, 0x00DA, 0x2F08, 0x3F3C, 0x0021, 0x3F3C, 0x0005, 0x4E4D, 0x508F, 0x43FA, + 0x00C0, 0x2280, 0x2600, 0x2809, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7208, 0x303C, 0x0401, 0x6100, 0x1164, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4A78, 0x04A6, 0x660E, 0x21FC, 0x0000, 0x0001, 0x04C2, 0x31FC, 0x0001, 0x04A6, 0x2039, 0x00FA, 0x2840, 0x7201, 0xE1A9, 0x83B8, 0x04C2, 0xB07C, 0x0002, 0x6604, 0x31C0, 0x0446, 0x4CDF, 0x7FFF, 0x4E75, 0x48E7, 0xFFF0, 0x41FA, 0x0034, - 0x2F08, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2638, 0x0436, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0452, 0x6100, 0x10F0, + 0x2F08, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2638, 0x0436, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0452, 0x6100, 0x10FE, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4CDF, 0x0FFF, 0x4E75, 0x1B45, 0x5374, 0x6172, 0x7469, 0x6E67, 0x2044, 0x6576, 0x4F70, 0x7320, 0x4D69, 0x6372, 0x6F66, 0x6972, 0x6D77, 0x6172, 0x652E, 0x2E2E, 0x0D0A, 0x0000, 0x5842, 0x5241, 0x5344, 0x4744, - 0x0000, 0x0000, 0x4AB9, 0x00FA, 0x2848, 0x6706, 0x2F3A, 0xFFF2, 0x4E75, 0x0817, 0x0005, 0x6704, 0x204F, 0x6004, 0x4E68, 0x5D88, - 0x4A78, 0x059E, 0x6702, 0x5448, 0x48E7, 0x7F3E, 0x3628, 0x0006, 0xC6BC, 0x0000, 0xFFFF, 0xB67C, 0x0057, 0x6200, 0x000E, 0xD643, - 0xD643, 0x43FA, 0x0010, 0x4EF1, 0x3000, 0x4CDF, 0x7CFE, 0x2F3A, 0xFFB0, 0x4E75, 0x6000, 0xFFF4, 0x6000, 0xFFF0, 0x6000, 0xFFEC, - 0x6000, 0xFFE8, 0x6000, 0xFFE4, 0x6000, 0xFFE0, 0x6000, 0xFFDC, 0x6000, 0xFFD8, 0x6000, 0xFFD4, 0x6000, 0xFFD0, 0x6000, 0xFFCC, - 0x6000, 0xFFC8, 0x6000, 0xFFC4, 0x6000, 0xFFC0, 0x6000, 0xFFBC, 0x6000, 0xFFB8, 0x6000, 0xFFB4, 0x6000, 0xFFB0, 0x6000, 0xFFAC, - 0x6000, 0xFFA8, 0x6000, 0xFFA4, 0x6000, 0xFFA0, 0x6000, 0xFF9C, 0x6000, 0xFF98, 0x6000, 0xFF94, 0x6000, 0xFF90, 0x6000, 0x097C, - 0x6000, 0xFF88, 0x6000, 0xFF84, 0x6000, 0xFF80, 0x6000, 0xFF7C, 0x6000, 0xFF78, 0x6000, 0xFF74, 0x6000, 0xFF70, 0x6000, 0xFF6C, - 0x6000, 0xFF68, 0x6000, 0xFF64, 0x6000, 0xFF60, 0x6000, 0xFF5C, 0x6000, 0xFF58, 0x6000, 0xFF54, 0x6000, 0xFF50, 0x6000, 0xFF4C, - 0x6000, 0xFF48, 0x6000, 0xFF44, 0x6000, 0xFF40, 0x6000, 0xFF3C, 0x6000, 0xFF38, 0x6000, 0xFF34, 0x6000, 0xFF30, 0x6000, 0xFF2C, - 0x6000, 0xFF28, 0x6000, 0xFF24, 0x6000, 0xFF20, 0x6000, 0x0086, 0x6000, 0xFF18, 0x6000, 0xFF14, 0x6000, 0x0174, 0x6000, 0x0212, - 0x6000, 0x06BC, 0x6000, 0x02AC, 0x6000, 0x0740, 0x6000, 0x07E0, 0x6000, 0x085C, 0x6000, 0x0630, 0x6000, 0x033E, 0x6000, 0x0810, - 0x6000, 0x03D8, 0x6000, 0xFEE4, 0x6000, 0xFEE0, 0x6000, 0xFEDC, 0x6000, 0x00E4, 0x6000, 0xFED4, 0x6000, 0xFED0, 0x6000, 0xFECC, - 0x6000, 0x0936, 0x6000, 0xFEC4, 0x6000, 0xFEC0, 0x6000, 0x0C24, 0x6000, 0x0D06, 0x6000, 0xFEB4, 0x6000, 0xFEB0, 0x6000, 0xFEAC, - 0x6000, 0xFEA8, 0x6000, 0xFEA4, 0x6000, 0xFEA0, 0x6000, 0x0514, 0x6000, 0x0430, 0x4283, 0x2828, 0x0008, 0x3628, 0x000C, 0x4A43, - 0x664A, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0EDC, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, - 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0EB4, 0x4CDF, 0x00FE, - 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x261F, 0x5283, 0x5383, 0xB6B9, 0x00FA, 0x2840, 0x6600, 0xFE34, 0x3E3C, 0x0005, 0x48E7, 0x7F00, - 0x7202, 0x303C, 0x0436, 0x6100, 0x0E86, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2039, 0x00FA, 0x2B80, 0x4A80, 0x6610, - 0x4BF9, 0x00FA, 0x2B84, 0x2844, 0x28DD, 0x28DD, 0x28DD, 0x28DD, 0x4CDF, 0x7CFE, 0x4E73, 0x4283, 0x2868, 0x0008, 0x3628, 0x000C, - 0x4A43, 0x670C, 0x5383, 0xB6B9, 0x00FA, 0x2840, 0x6600, 0xFDDC, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7202, 0x303C, 0x0447, 0x6100, - 0x0E2E, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x303C, 0x007F, 0x4BF9, 0x00FA, 0x2B00, 0x4A15, 0x6706, 0x18DD, 0x51C8, - 0xFFF8, 0x18BC, 0x0000, 0x7000, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, - 0x2847, 0x6600, 0xFD86, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0DD6, 0x4CDF, 0x00FE, 0x4A40, - 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, - 0x0DAE, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xFD2C, - 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x0439, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0E58, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, - 0xFFE4, 0x3039, 0x00FA, 0x3BD8, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, - 0x00FA, 0x2847, 0x6600, 0xFCE4, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0D34, 0x4CDF, 0x00FE, - 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, - 0x6100, 0x0D0C, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, - 0xFC8A, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x043A, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0DB6, 0x4CDF, 0x107E, 0x4A40, 0x6704, - 0x51CE, 0xFFE4, 0x3039, 0x00FA, 0x3BDC, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x3628, 0x000C, 0x0C2C, 0x003A, 0x0001, - 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xFC3E, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, - 0x0C8E, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, - 0x7200, 0x303C, 0x0404, 0x6100, 0x0C66, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, - 0x00FA, 0x2840, 0x6600, 0xFBE4, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x043C, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0D10, 0x4CDF, - 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x3039, 0x00FA, 0x3BE0, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x0C2C, 0x003A, - 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xFB9C, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, - 0x6100, 0x0BEC, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, - 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0BC4, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, - 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xFB42, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x0441, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0C6E, - 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x3039, 0x00FA, 0x3BE4, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x3628, - 0x000C, 0x3828, 0x000E, 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xFAF2, 0x6058, 0x3E3C, 0x0005, - 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0B42, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, - 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0B1A, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, - 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xFA98, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x0443, - 0x2C3C, 0x0000, 0x0080, 0x6100, 0x0BC4, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x2039, 0x00FA, 0x3BE8, 0x4CDF, 0x7CFE, - 0x4E73, 0x2868, 0x0008, 0x3828, 0x000C, 0x3628, 0x000E, 0x2A2C, 0x0000, 0x2C2C, 0x0004, 0xC6BC, 0x0000, 0xFFFF, 0xC8BC, 0x0000, - 0xFFFF, 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xFA36, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, - 0x7200, 0x303C, 0x0403, 0x6100, 0x0A86, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, - 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0A5E, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, - 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF9DC, 0x2F0C, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7210, 0x303C, 0x0457, - 0x6100, 0x0A2C, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x285F, 0x4DF9, 0x00FA, 0x4124, 0x196E, 0x0002, 0x0000, 0x196E, - 0x0003, 0x0001, 0x4DF9, 0x00FA, 0x4120, 0x196E, 0x0002, 0x0002, 0x196E, 0x0003, 0x0003, 0x2039, 0x00FA, 0x4128, 0x4CDF, 0x7CFE, - 0x4E73, 0x2A68, 0x000A, 0x2C68, 0x000E, 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xF96E, 0x6058, - 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x09BE, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, - 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0996, 0x4CDF, 0x00FE, 0x4A40, - 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF914, 0x4FEF, 0xFF00, 0x284F, 0x363C, - 0x007F, 0x18DD, 0x51CB, 0xFFFC, 0x363C, 0x007F, 0x18DE, 0x51CB, 0xFFFC, 0x284F, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x0456, - 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0A24, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x4FEF, 0x0100, 0x2039, 0x00FA, 0x3BEC, - 0x4CDF, 0x7CFE, 0x4E73, 0x3628, 0x0008, 0x2828, 0x000A, 0x2868, 0x000E, 0xB679, 0x00FA, 0x284E, 0x6D00, 0xF8B0, 0x4A84, 0x6608, - 0x7000, 0x4CDF, 0x7CFE, 0x4E73, 0x4286, 0x2A04, 0xBABC, 0x0000, 0x0400, 0x6F06, 0x2A3C, 0x0000, 0x0400, 0x3E3C, 0x0005, 0x48E7, - 0x7F08, 0x303C, 0x0488, 0x2C05, 0x6100, 0x09C2, 0x4CDF, 0x10FE, 0x4A40, 0x670C, 0x51CF, 0xFFE8, 0x70A4, 0x4CDF, 0x7CFE, 0x4E73, - 0x2439, 0x00FA, 0x3BF0, 0x4A82, 0x6FEE, 0xD9C2, 0xDC82, 0x9882, 0x6704, 0x6A00, 0xFFB6, 0x2006, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, - 0x0008, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x089C, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, - 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0874, 0x4CDF, 0x00FE, - 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF7F2, 0x3C3C, 0x0005, 0x48E7, - 0x7E08, 0x303C, 0x043B, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x091E, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x3039, 0x00FA, - 0x2B90, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x3628, 0x000C, 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, - 0x2847, 0x6600, 0xF7A6, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x07F6, 0x4CDF, 0x00FE, 0x4A40, - 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, - 0x07CE, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF74C, - 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x043D, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0878, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, - 0xFFE4, 0x2039, 0x00FA, 0x2B94, 0x4CDF, 0x7CFE, 0x4E73, 0x3628, 0x0008, 0xC6BC, 0x0000, 0xFFFF, 0xB679, 0x00FA, 0x284E, 0x6D00, - 0xF70A, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7202, 0x303C, 0x043E, 0x6100, 0x075C, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, - 0x3039, 0x00FA, 0x2B98, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2828, 0x0008, 0x3628, 0x000C, 0x3A28, 0x000E, 0xB679, 0x00FA, 0x284E, - 0x6D00, 0xF6C8, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x720C, 0x303C, 0x0442, 0x6100, 0x071A, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, - 0xFFE8, 0x2039, 0x00FA, 0x2B9C, 0x4CDF, 0x7CFE, 0x4E73, 0x3628, 0x0008, 0x2828, 0x000A, 0x2868, 0x000E, 0xB679, 0x00FA, 0x284E, - 0x6D00, 0xF688, 0x6100, 0x0008, 0x4CDF, 0x7CFE, 0x4E73, 0x2A04, 0x7C00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x720C, 0x303C, 0x0481, - 0x6100, 0x06CC, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4A40, 0x6704, 0x70A3, 0x4E75, 0x2039, 0x00FA, 0x2BA0, 0x6B2C, - 0x4A80, 0x6726, 0x48E7, 0x8300, 0x2E00, 0x5387, 0x4BF9, 0x00FA, 0x2BA4, 0x18DD, 0x51CF, 0xFFFC, 0x4CDF, 0x00C1, 0xDC80, 0xB0BC, - 0x0000, 0x1000, 0x6604, 0x9A80, 0x6EA8, 0x2006, 0x4E75, 0x4A85, 0x6706, 0x421D, 0x5385, 0x66FA, 0x4E75, 0x2628, 0x0008, 0x3E3C, - 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0660, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, - 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0638, 0x4CDF, 0x00FE, 0x4A40, 0x6704, - 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF5B6, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, - 0x303C, 0x041A, 0x6100, 0x0608, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x6000, 0xF594, 0x2608, 0x2848, 0x0C2C, 0x003A, - 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xF57C, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, - 0x6100, 0x05CC, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, - 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x05A4, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, - 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF522, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x044B, 0x2C3C, 0x0000, 0x0020, 0x6100, 0x064E, - 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x0C79, 0x0000, 0x00FA, 0x3FF4, 0x670C, 0x0C79, 0x0003, 0x00FA, 0x3FF4, 0x6600, - 0xF4EA, 0x2879, 0x00FA, 0x3FFC, 0x4243, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x043D, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x060E, - 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x2039, 0x00FA, 0x2B94, 0x6B00, 0x01E4, 0x3600, 0x283C, 0x0000, 0x001C, 0x4FEF, - 0xFFE0, 0x284F, 0x6100, 0xFE28, 0x284F, 0xB0BC, 0x0000, 0x001C, 0x6600, 0x01CC, 0x0C6C, 0x601A, 0x0000, 0x6600, 0x01C2, 0x3C3C, - 0x0005, 0x48E7, 0x7E08, 0x303C, 0x0484, 0x2C3C, 0x0000, 0x001C, 0x6100, 0x05BA, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, - 0x4FEF, 0x0020, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x04BA, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, - 0xFFE8, 0x2F39, 0x00FA, 0x4004, 0x2F39, 0x00FA, 0x4000, 0x42A7, 0x3F3C, 0x0005, 0x3F3C, 0x004B, 0x4E41, 0x4FEF, 0x0010, 0x2840, - 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x047E, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4BF9, - 0x00FA, 0x400C, 0x262D, 0x0002, 0x282D, 0x0006, 0x2A2D, 0x000A, 0x2C2D, 0x000E, 0x2E0C, 0xDEBC, 0x0000, 0x0100, 0x2947, 0x0008, - 0x2943, 0x000C, 0xDE83, 0x2947, 0x0010, 0x2944, 0x0014, 0xDE84, 0x2947, 0x0018, 0x2945, 0x001C, 0x3C3C, 0x0005, 0x48E7, 0x7E08, - 0x303C, 0x0483, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0500, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x4BF9, 0x00FA, 0x400C, - 0x49F9, 0x00FA, 0x4034, 0x286C, 0x0008, 0x282D, 0x0002, 0xD8AD, 0x0006, 0xD8AD, 0x000E, 0xD8BC, 0x0000, 0xFFFF, 0x2639, 0x00FA, - 0x2B94, 0x6100, 0xFD0A, 0x2639, 0x00FA, 0x2B94, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7202, 0x303C, 0x043E, 0x6100, 0x03D2, 0x4CDF, - 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3039, 0x00FA, 0x2B98, 0x48C0, 0x6B00, 0x0084, 0x4BF9, 0x00FA, 0x4034, 0x2A6D, 0x0008, - 0x220D, 0x2C4D, 0x49F9, 0x00FA, 0x400C, 0xDBEC, 0x0002, 0xDBEC, 0x0006, 0xDBEC, 0x000E, 0x4A95, 0x671A, 0x7000, 0xDDDD, 0xD396, - 0x101D, 0x6710, 0xB03C, 0x0001, 0x6606, 0xDCFC, 0x00FE, 0x60F0, 0xDCC0, 0x60EA, 0x2879, 0x00FA, 0x4034, 0x2A6C, 0x0018, 0x2A2C, - 0x001C, 0x6100, 0xFCEA, 0x0C79, 0x0003, 0x00FA, 0x3FF4, 0x6700, 0x0022, 0x2079, 0x00FA, 0x3FF8, 0x317C, 0x0006, 0x0008, 0x42A8, - 0x000A, 0x2179, 0x00FA, 0x4034, 0x000E, 0x42A8, 0x0012, 0x6000, 0xF2DA, 0x2039, 0x00FA, 0x4034, 0x4CDF, 0x7CFE, 0x4E73, 0x4FEF, - 0x0020, 0x2639, 0x00FA, 0x2B94, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7202, 0x303C, 0x043E, 0x6100, 0x0316, 0x4CDF, 0x00FE, 0x4A40, - 0x6704, 0x51CF, 0xFFE8, 0x3039, 0x00FA, 0x2B98, 0x48C0, 0x6000, 0xFFC8, 0x2868, 0x0008, 0x3828, 0x000C, 0x0C2C, 0x003A, 0x0001, - 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xF27E, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, - 0x02CE, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, - 0x7200, 0x303C, 0x0404, 0x6100, 0x02A6, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, - 0x00FA, 0x2840, 0x6600, 0xF224, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0276, 0x4CDF, 0x00FE, 0x4A40, - 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x002F, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, - 0x024E, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2617, 0x2A0C, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x044E, 0x2C3C, - 0x0000, 0x00C0, 0x6100, 0x0306, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x6000, 0x007E, 0x3E3C, 0x0005, 0x48E7, 0x7F00, - 0x7200, 0x303C, 0x0403, 0x6100, 0x0206, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x002F, 0x4E41, 0x548F, 0x2F00, - 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x01DE, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2057, - 0x2028, 0x000C, 0xB0B9, 0x00FA, 0x2840, 0x6622, 0x2617, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x044F, 0x6100, 0x01B0, - 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x6006, 0x201F, 0x6000, 0xF138, 0x2A5F, 0x3039, 0x00FA, 0x3BA4, 0x4A40, 0x6662, - 0x49F9, 0x00FA, 0x3BA8, 0x742B, 0x1ADC, 0x51CA, 0xFFFC, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0170, - 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2039, 0x00FA, 0x2840, 0x3F00, 0x3F3C, 0x000E, 0x4E41, 0x588F, 0x3E3C, 0x0005, - 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0142, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x7000, 0x4CDF, 0x7CFE, - 0x4E73, 0x2F00, 0x260D, 0x742B, 0x421D, 0x51CA, 0xFFFC, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x048B, 0x6100, 0x0110, - 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x00F2, 0x4CDF, - 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2039, 0x00FA, 0x2840, 0x3F00, 0x3F3C, 0x000E, 0x4E41, 0x588F, 0x3E3C, 0x0005, 0x48E7, - 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x00C4, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0x48C0, 0x4CDF, 0x7CFE, - 0x4E73, 0x2038, 0x05A0, 0x6700, 0x001A, 0x2040, 0x2018, 0x6700, 0x0012, 0xB0BC, 0x5F4D, 0x4348, 0x6704, 0x5848, 0x60EE, 0x2818, - 0x6002, 0x4284, 0x2F04, 0x263C, 0x0000, 0x0000, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7208, 0x303C, 0x0001, 0x6100, 0x0072, 0x4CDF, - 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4A40, 0x6604, 0x201F, 0x4E75, 0x281F, 0x60CE, 0x3F3C, 0x0030, 0x4E41, 0x548F, 0xC0BC, - 0x0000, 0xFFFF, 0x0C78, 0x00FC, 0x0004, 0x6608, 0x3239, 0x00FC, 0x0002, 0x6006, 0x3239, 0x00E0, 0x0002, 0xC2BC, 0x0000, 0xFFFF, - 0x4841, 0x8081, 0x263C, 0x0000, 0x0001, 0x2800, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7208, 0x303C, 0x0001, 0x6100, 0x0012, 0x4CDF, - 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4A40, 0x4E75, 0x2439, 0x00FA, 0x2808, 0x5841, 0x43F9, 0x00FA, 0x2804, 0x207C, 0x00FB, - 0x0000, 0xD1FC, 0x0000, 0x8000, 0x3E3C, 0xABCD, 0x4A30, 0x7000, 0x4287, 0xDE40, 0x4A30, 0x0000, 0xDE41, 0x4A30, 0x1000, 0x4A41, - 0x6700, 0x0088, 0xDE42, 0x4A30, 0x2000, 0xB27C, 0x0002, 0x6700, 0x007A, 0x4842, 0xDE42, 0x4A30, 0x2000, 0xB27C, 0x0004, 0x6700, - 0x006A, 0xDE43, 0x4A30, 0x3000, 0xB27C, 0x0006, 0x6700, 0x005C, 0x4843, 0xDE43, 0x4A30, 0x3000, 0xB27C, 0x0008, 0x6700, 0x004C, - 0xDE44, 0x4A30, 0x4000, 0xB27C, 0x000A, 0x6700, 0x003E, 0x4844, 0xDE44, 0x4A30, 0x4000, 0xB27C, 0x000C, 0x672E, 0xDE45, 0x4A30, - 0x5000, 0xB27C, 0x000E, 0x6722, 0x4845, 0xDE45, 0x4A30, 0x5000, 0xB27C, 0x0010, 0x6714, 0xDE46, 0x4A30, 0x6000, 0xB27C, 0x0012, - 0x6708, 0x4846, 0xDE46, 0x4A30, 0x6000, 0x4A30, 0x7000, 0x4842, 0x2E3C, 0x0006, 0xFFFF, 0x7000, 0xB491, 0x6608, 0xB4B9, 0x00FA, - 0x2808, 0x6606, 0x5387, 0x66F0, 0x5380, 0x4E75, 0x2439, 0x00FA, 0x2808, 0xCCBC, 0x0000, 0xFFFF, 0x7210, 0xD286, 0x5281, 0xE289, - 0xE389, 0x43F9, 0x00FA, 0x2804, 0x207C, 0x00FB, 0x0000, 0xD1FC, 0x0000, 0x8000, 0x3E3C, 0xABCD, 0x4A30, 0x7000, 0x4287, 0xDE40, - 0x4A30, 0x0000, 0xDE41, 0x4A30, 0x1000, 0xDE42, 0x4A30, 0x2000, 0x4842, 0xDE42, 0x4A30, 0x2000, 0xDE43, 0x4A30, 0x3000, 0x4843, - 0xDE43, 0x4A30, 0x3000, 0xDE44, 0x4A30, 0x4000, 0x4844, 0xDE44, 0x4A30, 0x4000, 0xDE45, 0x4A30, 0x5000, 0x4845, 0xDE45, 0x4A30, - 0x5000, 0x2A06, 0x2C07, 0x4287, 0x0805, 0x0000, 0x662E, 0x5285, 0xE24D, 0x5345, 0x280C, 0x0804, 0x0000, 0x6712, 0x161C, 0xE14B, - 0x161C, 0x4A30, 0x3000, 0xDE43, 0x51CD, 0xFFF2, 0x605E, 0x381C, 0xDE44, 0x4A30, 0x4000, 0x51CD, 0xFFF6, 0x6050, 0x5285, 0xE24D, - 0x280C, 0x0804, 0x0000, 0x6726, 0x5345, 0x6712, 0x5345, 0x161C, 0xE14B, 0x161C, 0x4A30, 0x3000, 0xDE43, 0x51CD, 0xFFF2, 0x181C, - 0xE14C, 0xC87C, 0xFF00, 0xDE44, 0x4A30, 0x4000, 0x601E, 0x5345, 0x670E, 0x5345, 0x381C, 0xDE44, 0x4A30, 0x4000, 0x51CD, 0xFFF6, - 0x381C, 0xC87C, 0xFF00, 0xDE44, 0x4A30, 0x4000, 0xDC47, 0x4A30, 0x6000, 0x4842, 0x2C3C, 0x0006, 0xFFFF, 0x7000, 0xB491, 0x6608, - 0xB4B9, 0x00FA, 0x2808, 0x6606, 0x5386, 0x66F0, 0x5380, 0x4E75, 0xDEAD, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x4AB9, 0x00FA, 0x2848, 0x6706, 0x2F3A, 0xFFEE, 0x4E75, 0x0817, 0x0005, 0x6704, 0x204F, 0x6004, + 0x4E68, 0x5D88, 0x4A78, 0x059E, 0x6702, 0x5448, 0x48E7, 0x7F3E, 0x3628, 0x0006, 0xC6BC, 0x0000, 0xFFFF, 0xB67C, 0x0057, 0x6200, + 0x000E, 0xD643, 0xD643, 0x43FA, 0x0010, 0x4EF1, 0x3000, 0x4CDF, 0x7CFE, 0x2F3A, 0xFFAC, 0x4E75, 0x6000, 0xFFF4, 0x6000, 0xFFF0, + 0x6000, 0xFFEC, 0x6000, 0xFFE8, 0x6000, 0xFFE4, 0x6000, 0xFFE0, 0x6000, 0xFFDC, 0x6000, 0xFFD8, 0x6000, 0xFFD4, 0x6000, 0xFFD0, + 0x6000, 0xFFCC, 0x6000, 0xFFC8, 0x6000, 0xFFC4, 0x6000, 0xFFC0, 0x6000, 0xFFBC, 0x6000, 0xFFB8, 0x6000, 0xFFB4, 0x6000, 0xFFB0, + 0x6000, 0xFFAC, 0x6000, 0xFFA8, 0x6000, 0xFFA4, 0x6000, 0xFFA0, 0x6000, 0xFF9C, 0x6000, 0xFF98, 0x6000, 0xFF94, 0x6000, 0xFF90, + 0x6000, 0x0986, 0x6000, 0xFF88, 0x6000, 0xFF84, 0x6000, 0xFF80, 0x6000, 0xFF7C, 0x6000, 0xFF78, 0x6000, 0xFF74, 0x6000, 0xFF70, + 0x6000, 0xFF6C, 0x6000, 0xFF68, 0x6000, 0xFF64, 0x6000, 0xFF60, 0x6000, 0xFF5C, 0x6000, 0xFF58, 0x6000, 0xFF54, 0x6000, 0xFF50, + 0x6000, 0xFF4C, 0x6000, 0xFF48, 0x6000, 0xFF44, 0x6000, 0xFF40, 0x6000, 0xFF3C, 0x6000, 0xFF38, 0x6000, 0xFF34, 0x6000, 0xFF30, + 0x6000, 0xFF2C, 0x6000, 0xFF28, 0x6000, 0xFF24, 0x6000, 0xFF20, 0x6000, 0x0086, 0x6000, 0xFF18, 0x6000, 0xFF14, 0x6000, 0x0174, + 0x6000, 0x0212, 0x6000, 0x06C6, 0x6000, 0x02AC, 0x6000, 0x074A, 0x6000, 0x07EA, 0x6000, 0x0866, 0x6000, 0x0630, 0x6000, 0x033E, + 0x6000, 0x081A, 0x6000, 0x03D8, 0x6000, 0xFEE4, 0x6000, 0xFEE0, 0x6000, 0xFEDC, 0x6000, 0x00E4, 0x6000, 0xFED4, 0x6000, 0xFED0, + 0x6000, 0xFECC, 0x6000, 0x0940, 0x6000, 0xFEC4, 0x6000, 0xFEC0, 0x6000, 0x0C2E, 0x6000, 0x0D10, 0x6000, 0xFEB4, 0x6000, 0xFEB0, + 0x6000, 0xFEAC, 0x6000, 0xFEA8, 0x6000, 0xFEA4, 0x6000, 0xFEA0, 0x6000, 0x0514, 0x6000, 0x0430, 0x4283, 0x2828, 0x0008, 0x3628, + 0x000C, 0x4A43, 0x664A, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0EE6, 0x4CDF, 0x00FE, 0x4A40, 0x6704, + 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0EBE, + 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x261F, 0x5283, 0x5383, 0xB6B9, 0x00FA, 0x2840, 0x6600, 0xFE34, 0x3E3C, 0x0005, + 0x48E7, 0x7F00, 0x7202, 0x303C, 0x0436, 0x6100, 0x0E90, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2039, 0x00FA, 0x2B80, + 0x4A80, 0x6610, 0x4BF9, 0x00FA, 0x2B84, 0x2844, 0x28DD, 0x28DD, 0x28DD, 0x28DD, 0x4CDF, 0x7CFE, 0x4E73, 0x4283, 0x2868, 0x0008, + 0x3628, 0x000C, 0x4A43, 0x670C, 0x5383, 0xB6B9, 0x00FA, 0x2840, 0x6600, 0xFDDC, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7202, 0x303C, + 0x0447, 0x6100, 0x0E38, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x303C, 0x007F, 0x4BF9, 0x00FA, 0x2B00, 0x4A15, 0x6706, + 0x18DD, 0x51C8, 0xFFF8, 0x18BC, 0x0000, 0x7000, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, + 0xB039, 0x00FA, 0x2847, 0x6600, 0xFD86, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0DE0, 0x4CDF, + 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, + 0x0404, 0x6100, 0x0DB8, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, + 0x6600, 0xFD2C, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x0439, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0E62, 0x4CDF, 0x107E, 0x4A40, + 0x6704, 0x51CE, 0xFFE4, 0x3039, 0x00FA, 0x3BD8, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x0C2C, 0x003A, 0x0001, 0x660E, + 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xFCE4, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0D3E, + 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, + 0x303C, 0x0404, 0x6100, 0x0D16, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, + 0x2840, 0x6600, 0xFC8A, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x043A, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0DC0, 0x4CDF, 0x107E, + 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x3039, 0x00FA, 0x3BDC, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x3628, 0x000C, 0x0C2C, + 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xFC3E, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, + 0x0403, 0x6100, 0x0C98, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, + 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0C70, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, + 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xFBE4, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x043C, 0x2C3C, 0x0000, 0x0100, 0x6100, + 0x0D1A, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x3039, 0x00FA, 0x3BE0, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, + 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xFB9C, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, + 0x303C, 0x0403, 0x6100, 0x0BF6, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, + 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0BCE, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, + 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xFB42, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x0441, 0x2C3C, 0x0000, 0x0100, + 0x6100, 0x0C78, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x3039, 0x00FA, 0x3BE4, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, + 0x0008, 0x3628, 0x000C, 0x3828, 0x000E, 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xFAF2, 0x6058, + 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0B4C, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, + 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0B24, 0x4CDF, 0x00FE, 0x4A40, + 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xFA98, 0x3C3C, 0x0005, 0x48E7, 0x7E08, + 0x303C, 0x0443, 0x2C3C, 0x0000, 0x0080, 0x6100, 0x0BCE, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x2039, 0x00FA, 0x3BE8, + 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x3828, 0x000C, 0x3628, 0x000E, 0x2A2C, 0x0000, 0x2C2C, 0x0004, 0xC6BC, 0x0000, 0xFFFF, + 0xC8BC, 0x0000, 0xFFFF, 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xFA36, 0x6058, 0x3E3C, 0x0005, + 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0A90, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, + 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0A68, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, + 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF9DC, 0x2F0C, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7210, + 0x303C, 0x0457, 0x6100, 0x0A36, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x285F, 0x4DF9, 0x00FA, 0x4124, 0x196E, 0x0002, + 0x0000, 0x196E, 0x0003, 0x0001, 0x4DF9, 0x00FA, 0x4120, 0x196E, 0x0002, 0x0002, 0x196E, 0x0003, 0x0003, 0x2039, 0x00FA, 0x4128, + 0x4CDF, 0x7CFE, 0x4E73, 0x2A68, 0x000A, 0x2C68, 0x000E, 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, + 0xF96E, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x09C8, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, + 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x09A0, 0x4CDF, + 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF914, 0x4FEF, 0xFF00, + 0x284F, 0x363C, 0x007F, 0x18DD, 0x51CB, 0xFFFC, 0x363C, 0x007F, 0x18DE, 0x51CB, 0xFFFC, 0x284F, 0x3C3C, 0x0005, 0x48E7, 0x7E08, + 0x303C, 0x0456, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0A2E, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x4FEF, 0x0100, 0x2039, + 0x00FA, 0x3BEC, 0x4CDF, 0x7CFE, 0x4E73, 0x3628, 0x0008, 0x2828, 0x000A, 0x2868, 0x000E, 0xB679, 0x00FA, 0x284E, 0x6D00, 0xF8B0, + 0x4A84, 0x6608, 0x7000, 0x4CDF, 0x7CFE, 0x4E73, 0x4286, 0x2A04, 0xBABC, 0x0000, 0x0400, 0x6F06, 0x2A3C, 0x0000, 0x0400, 0x43FA, + 0xF844, 0x5291, 0x2211, 0x3E3C, 0x0005, 0x48E7, 0x7F08, 0x303C, 0x0488, 0x2C05, 0x2A01, 0x6100, 0x09C2, 0x4CDF, 0x10FE, 0x4A40, + 0x670C, 0x51CF, 0xFFE6, 0x70A4, 0x4CDF, 0x7CFE, 0x4E73, 0x2439, 0x00FA, 0x3BF0, 0x4A82, 0x6FEE, 0xD9C2, 0xDC82, 0x9882, 0x6704, + 0x6A00, 0xFFAC, 0x2006, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, + 0x089C, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, + 0x7200, 0x303C, 0x0404, 0x6100, 0x0874, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, + 0x00FA, 0x2840, 0x6600, 0xF7E8, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x043B, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x091E, 0x4CDF, + 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x3039, 0x00FA, 0x2B90, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x3628, 0x000C, + 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xF79C, 0x6058, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, + 0x303C, 0x0403, 0x6100, 0x07F6, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, + 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x07CE, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, + 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF742, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x043D, 0x2C3C, 0x0000, 0x0100, + 0x6100, 0x0878, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x2039, 0x00FA, 0x2B94, 0x4CDF, 0x7CFE, 0x4E73, 0x3628, 0x0008, + 0xC6BC, 0x0000, 0xFFFF, 0xB679, 0x00FA, 0x284E, 0x6D00, 0xF700, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7202, 0x303C, 0x043E, 0x6100, + 0x075C, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3039, 0x00FA, 0x2B98, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2828, 0x0008, + 0x3628, 0x000C, 0x3A28, 0x000E, 0xB679, 0x00FA, 0x284E, 0x6D00, 0xF6BE, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x720C, 0x303C, 0x0442, + 0x6100, 0x071A, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2039, 0x00FA, 0x2B9C, 0x4CDF, 0x7CFE, 0x4E73, 0x3628, 0x0008, + 0x2828, 0x000A, 0x2868, 0x000E, 0xB679, 0x00FA, 0x284E, 0x6D00, 0xF67E, 0x6100, 0x0008, 0x4CDF, 0x7CFE, 0x4E73, 0x2A04, 0x7C00, + 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x720C, 0x303C, 0x0481, 0x6100, 0x06CC, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4A40, + 0x6704, 0x70A3, 0x4E75, 0x2039, 0x00FA, 0x2BA0, 0x6B2C, 0x4A80, 0x6726, 0x48E7, 0x8300, 0x2E00, 0x5387, 0x4BF9, 0x00FA, 0x2BA4, + 0x18DD, 0x51CF, 0xFFFC, 0x4CDF, 0x00C1, 0xDC80, 0xB0BC, 0x0000, 0x1000, 0x6604, 0x9A80, 0x6EA8, 0x2006, 0x4E75, 0x4A85, 0x6706, + 0x421D, 0x5385, 0x66FA, 0x4E75, 0x2628, 0x0008, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0660, 0x4CDF, + 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, + 0x0404, 0x6100, 0x0638, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, + 0x6600, 0xF5AC, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x041A, 0x6100, 0x0608, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, + 0xFFE8, 0x6000, 0xF58A, 0x2608, 0x2848, 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xF572, 0x6058, + 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x05CC, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, + 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x05A4, 0x4CDF, 0x00FE, 0x4A40, + 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF518, 0x3C3C, 0x0005, 0x48E7, 0x7E08, + 0x303C, 0x044B, 0x2C3C, 0x0000, 0x0020, 0x6100, 0x064E, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x0C79, 0x0000, 0x00FA, + 0x3FF4, 0x670C, 0x0C79, 0x0003, 0x00FA, 0x3FF4, 0x6600, 0xF4E0, 0x2879, 0x00FA, 0x3FFC, 0x4243, 0x3C3C, 0x0005, 0x48E7, 0x7E08, + 0x303C, 0x043D, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x060E, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x2039, 0x00FA, 0x2B94, + 0x6B00, 0x01E4, 0x3600, 0x283C, 0x0000, 0x001C, 0x4FEF, 0xFFE0, 0x284F, 0x6100, 0xFE28, 0x284F, 0xB0BC, 0x0000, 0x001C, 0x6600, + 0x01CC, 0x0C6C, 0x601A, 0x0000, 0x6600, 0x01C2, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x0484, 0x2C3C, 0x0000, 0x001C, 0x6100, + 0x05BA, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x4FEF, 0x0020, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, + 0x6100, 0x04BA, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2F39, 0x00FA, 0x4004, 0x2F39, 0x00FA, 0x4000, 0x42A7, 0x3F3C, + 0x0005, 0x3F3C, 0x004B, 0x4E41, 0x4FEF, 0x0010, 0x2840, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x047E, + 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4BF9, 0x00FA, 0x400C, 0x262D, 0x0002, 0x282D, 0x0006, 0x2A2D, 0x000A, 0x2C2D, + 0x000E, 0x2E0C, 0xDEBC, 0x0000, 0x0100, 0x2947, 0x0008, 0x2943, 0x000C, 0xDE83, 0x2947, 0x0010, 0x2944, 0x0014, 0xDE84, 0x2947, + 0x0018, 0x2945, 0x001C, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x0483, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0500, 0x4CDF, 0x107E, + 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x4BF9, 0x00FA, 0x400C, 0x49F9, 0x00FA, 0x4034, 0x286C, 0x0008, 0x282D, 0x0002, 0xD8AD, 0x0006, + 0xD8AD, 0x000E, 0xD8BC, 0x0000, 0xFFFF, 0x2639, 0x00FA, 0x2B94, 0x6100, 0xFD0A, 0x2639, 0x00FA, 0x2B94, 0x3E3C, 0x0005, 0x48E7, + 0x7F00, 0x7202, 0x303C, 0x043E, 0x6100, 0x03D2, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3039, 0x00FA, 0x2B98, 0x48C0, + 0x6B00, 0x0084, 0x4BF9, 0x00FA, 0x4034, 0x2A6D, 0x0008, 0x220D, 0x2C4D, 0x49F9, 0x00FA, 0x400C, 0xDBEC, 0x0002, 0xDBEC, 0x0006, + 0xDBEC, 0x000E, 0x4A95, 0x671A, 0x7000, 0xDDDD, 0xD396, 0x101D, 0x6710, 0xB03C, 0x0001, 0x6606, 0xDCFC, 0x00FE, 0x60F0, 0xDCC0, + 0x60EA, 0x2879, 0x00FA, 0x4034, 0x2A6C, 0x0018, 0x2A2C, 0x001C, 0x6100, 0xFCEA, 0x0C79, 0x0003, 0x00FA, 0x3FF4, 0x6700, 0x0022, + 0x2079, 0x00FA, 0x3FF8, 0x317C, 0x0006, 0x0008, 0x42A8, 0x000A, 0x2179, 0x00FA, 0x4034, 0x000E, 0x42A8, 0x0012, 0x6000, 0xF2D0, + 0x2039, 0x00FA, 0x4034, 0x4CDF, 0x7CFE, 0x4E73, 0x4FEF, 0x0020, 0x2639, 0x00FA, 0x2B94, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7202, + 0x303C, 0x043E, 0x6100, 0x0316, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3039, 0x00FA, 0x2B98, 0x48C0, 0x6000, 0xFFC8, + 0x2868, 0x0008, 0x3828, 0x000C, 0x0C2C, 0x003A, 0x0001, 0x660E, 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xF274, 0x6058, 0x3E3C, + 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x02CE, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, + 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x02A6, 0x4CDF, 0x00FE, 0x4A40, 0x6704, + 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF21A, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, + 0x303C, 0x0403, 0x6100, 0x0276, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x002F, 0x4E41, 0x548F, 0x2F00, 0x3E3C, + 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x024E, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2617, 0x2A0C, + 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x044E, 0x2C3C, 0x0000, 0x00C0, 0x6100, 0x0306, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, + 0xFFE4, 0x6000, 0x007E, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0206, 0x4CDF, 0x00FE, 0x4A40, 0x6704, + 0x51CF, 0xFFE8, 0x3F3C, 0x002F, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x01DE, + 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2057, 0x2028, 0x000C, 0xB0B9, 0x00FA, 0x2840, 0x6622, 0x2617, 0x3E3C, 0x0005, + 0x48E7, 0x7F00, 0x7204, 0x303C, 0x044F, 0x6100, 0x01B0, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x6006, 0x201F, 0x6000, + 0xF12E, 0x2A5F, 0x3039, 0x00FA, 0x3BA4, 0x4A40, 0x6662, 0x49F9, 0x00FA, 0x3BA8, 0x742B, 0x1ADC, 0x51CA, 0xFFFC, 0x3E3C, 0x0005, + 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0170, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2039, 0x00FA, 0x2840, + 0x3F00, 0x3F3C, 0x000E, 0x4E41, 0x588F, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0142, 0x4CDF, 0x00FE, + 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x7000, 0x4CDF, 0x7CFE, 0x4E73, 0x2F00, 0x260D, 0x742B, 0x421D, 0x51CA, 0xFFFC, 0x3E3C, 0x0005, + 0x48E7, 0x7F00, 0x7204, 0x303C, 0x048B, 0x6100, 0x0110, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3E3C, 0x0005, 0x48E7, + 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x00F2, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2039, 0x00FA, 0x2840, 0x3F00, + 0x3F3C, 0x000E, 0x4E41, 0x588F, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x00C4, 0x4CDF, 0x00FE, 0x4A40, + 0x6704, 0x51CF, 0xFFE8, 0x201F, 0x48C0, 0x4CDF, 0x7CFE, 0x4E73, 0x2038, 0x05A0, 0x6700, 0x001A, 0x2040, 0x2018, 0x6700, 0x0012, + 0xB0BC, 0x5F4D, 0x4348, 0x6704, 0x5848, 0x60EE, 0x2818, 0x6002, 0x4284, 0x2F04, 0x263C, 0x0000, 0x0000, 0x3E3C, 0x0005, 0x48E7, + 0x7F00, 0x7208, 0x303C, 0x0001, 0x6100, 0x0072, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4A40, 0x6604, 0x201F, 0x4E75, + 0x281F, 0x60CE, 0x3F3C, 0x0030, 0x4E41, 0x548F, 0xC0BC, 0x0000, 0xFFFF, 0x0C78, 0x00FC, 0x0004, 0x6608, 0x3239, 0x00FC, 0x0002, + 0x6006, 0x3239, 0x00E0, 0x0002, 0xC2BC, 0x0000, 0xFFFF, 0x4841, 0x8081, 0x263C, 0x0000, 0x0001, 0x2800, 0x3E3C, 0x0005, 0x48E7, + 0x7F00, 0x7208, 0x303C, 0x0001, 0x6100, 0x0012, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4A40, 0x4E75, 0x2439, 0x00FA, + 0x2808, 0x5841, 0x43F9, 0x00FA, 0x2804, 0x207C, 0x00FB, 0x0000, 0xD1FC, 0x0000, 0x8000, 0x3E3C, 0xABCD, 0x4A30, 0x7000, 0x4287, + 0xDE40, 0x4A30, 0x0000, 0xDE41, 0x4A30, 0x1000, 0x4A41, 0x6700, 0x0088, 0xDE42, 0x4A30, 0x2000, 0xB27C, 0x0002, 0x6700, 0x007A, + 0x4842, 0xDE42, 0x4A30, 0x2000, 0xB27C, 0x0004, 0x6700, 0x006A, 0xDE43, 0x4A30, 0x3000, 0xB27C, 0x0006, 0x6700, 0x005C, 0x4843, + 0xDE43, 0x4A30, 0x3000, 0xB27C, 0x0008, 0x6700, 0x004C, 0xDE44, 0x4A30, 0x4000, 0xB27C, 0x000A, 0x6700, 0x003E, 0x4844, 0xDE44, + 0x4A30, 0x4000, 0xB27C, 0x000C, 0x672E, 0xDE45, 0x4A30, 0x5000, 0xB27C, 0x000E, 0x6722, 0x4845, 0xDE45, 0x4A30, 0x5000, 0xB27C, + 0x0010, 0x6714, 0xDE46, 0x4A30, 0x6000, 0xB27C, 0x0012, 0x6708, 0x4846, 0xDE46, 0x4A30, 0x6000, 0x4A30, 0x7000, 0x4842, 0x2E3C, + 0x0006, 0xFFFF, 0x7000, 0xB491, 0x6608, 0xB4B9, 0x00FA, 0x2808, 0x6606, 0x5387, 0x66F0, 0x5380, 0x4E75, 0x2439, 0x00FA, 0x2808, + 0xCCBC, 0x0000, 0xFFFF, 0x7210, 0xD286, 0x5281, 0xE289, 0xE389, 0x43F9, 0x00FA, 0x2804, 0x207C, 0x00FB, 0x0000, 0xD1FC, 0x0000, + 0x8000, 0x3E3C, 0xABCD, 0x4A30, 0x7000, 0x4287, 0xDE40, 0x4A30, 0x0000, 0xDE41, 0x4A30, 0x1000, 0xDE42, 0x4A30, 0x2000, 0x4842, + 0xDE42, 0x4A30, 0x2000, 0xDE43, 0x4A30, 0x3000, 0x4843, 0xDE43, 0x4A30, 0x3000, 0xDE44, 0x4A30, 0x4000, 0x4844, 0xDE44, 0x4A30, + 0x4000, 0xDE45, 0x4A30, 0x5000, 0x4845, 0xDE45, 0x4A30, 0x5000, 0x2A06, 0x2C07, 0x4287, 0x0805, 0x0000, 0x662E, 0x5285, 0xE24D, + 0x5345, 0x280C, 0x0804, 0x0000, 0x6712, 0x161C, 0xE14B, 0x161C, 0x4A30, 0x3000, 0xDE43, 0x51CD, 0xFFF2, 0x605E, 0x381C, 0xDE44, + 0x4A30, 0x4000, 0x51CD, 0xFFF6, 0x6050, 0x5285, 0xE24D, 0x280C, 0x0804, 0x0000, 0x6726, 0x5345, 0x6712, 0x5345, 0x161C, 0xE14B, + 0x161C, 0x4A30, 0x3000, 0xDE43, 0x51CD, 0xFFF2, 0x181C, 0xE14C, 0xC87C, 0xFF00, 0xDE44, 0x4A30, 0x4000, 0x601E, 0x5345, 0x670E, + 0x5345, 0x381C, 0xDE44, 0x4A30, 0x4000, 0x51CD, 0xFFF6, 0x381C, 0xC87C, 0xFF00, 0xDE44, 0x4A30, 0x4000, 0xDC47, 0x4A30, 0x6000, + 0x4842, 0x2C3C, 0x0006, 0xFFFF, 0x7000, 0xB491, 0x6608, 0xB4B9, 0x00FA, 0x2808, 0x6606, 0x5386, 0x66F0, 0x5380, 0x4E75, 0xDEAD, + 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2039, 0x00FA, 0x2838, 0xD0BC, 0x0000, 0x1800, 0x2240, 0x207C, 0x00FA, 0x1C00, 0x223C, 0x0000, 0x0C00, 0xE489, 0x5381, 0x22D8, diff --git a/rp/src/sdcard.c b/rp/src/sdcard.c index 8c09e30..9fb0a9c 100644 --- a/rp/src/sdcard.c +++ b/rp/src/sdcard.c @@ -1,5 +1,8 @@ #include "sdcard.h" +#include "health.h" +#include "diskio.h" + #include #include #include @@ -7,6 +10,22 @@ static FATFS *mountedFsPtr = NULL; static bool sdMounted = false; +// Remount state (EPIC-15 STORY-01). The card is mounted once at boot, so a card +// pulled and put back stayed dead until a reset: FatFs keeps the volume +// registered, and with card-detect disabled on this board nothing ever marks +// the drive uninitialised, so mount_volume() sees a mounted volume and never +// asks the driver to re-initialise the card. +// +// Unregistering the volume is what breaks that: with fs_type cleared, the next +// f_mount() runs disk_initialize(), which calls the card's own init +// unconditionally (fatfs-sdk src/glue.c), and a freshly inserted card comes up. +static FATFS *bootFsPtr = NULL; +static char bootFolder[SDCARD_FOLDER_NAME_MAX] = ""; +static absolute_time_t nextRemountAt; +static bool remountScheduled = false; +static uint32_t remountAttempts = 0; +static uint32_t remountRecoveries = 0; + // qsort comparator: directories first, then alphabetic case-insensitive. static int dirFirstCmp(const void *a, const void *b) { const DirEntry *e1 = (const DirEntry *)a; @@ -97,6 +116,12 @@ sdcard_status_t sdcard_initFilesystem(FATFS *fsPtr, const char *folderName) { return SDCARD_INIT_ERROR; } + // Remember what to mount with before trying, not after succeeding: a device + // booted with no card has to keep retrying too, and that is the case where + // the retry matters most. + bootFsPtr = fsPtr; + snprintf(bootFolder, sizeof(bootFolder), "%s", folderName); + // Check the status of the sd card sdcard_status_t sdcardOk = sdcardInit(); if (sdcardOk != SDCARD_INIT_OK) { @@ -204,6 +229,113 @@ void sdcard_getInfo(FATFS *fsPtr, uint32_t *totalSizeMb, bool sdcard_isMounted(void) { return sdMounted && (mountedFsPtr != NULL); } +uint32_t sdcard_getRemountRecoveries(void) { return remountRecoveries; } + +// Whether the card is still there cannot be inferred from FatFs results: with +// the card physically out, `volume` still answered 200 from the cached FAT and +// a listing answered 200 with an empty directory, because FatFs serves what it +// has cached and never reports a disk error. Card-detect is disabled on this +// board, so disk_status() cannot tell us either. +// +// The only honest question is a real one: read a sector off the card. Sector 0 +// is always there, the read bypasses FatFs's cache, and a card that has been +// pulled cannot answer it. +static absolute_time_t nextPresenceCheckAt; +static bool presenceCheckStarted = false; +static uint8_t presenceBuf[512]; + +static void sdcard_pollPresence(void) { + absolute_time_t now = get_absolute_time(); + if (!presenceCheckStarted) { + presenceCheckStarted = true; + nextPresenceCheckAt = delayed_by_ms(now, SDCARD_PRESENCE_POLL_MS); + return; + } + if (absolute_time_diff_us(now, nextPresenceCheckAt) > 0) { + return; + } + nextPresenceCheckAt = delayed_by_ms(now, SDCARD_PRESENCE_POLL_MS); + + DRESULT dres = disk_read(0, presenceBuf, 0, 1); + if (dres == RES_OK) { + return; + } + DPRINTF("SD card: sector read failed (%d) -- card gone\n", (int)dres); + sdMounted = false; + mountedFsPtr = NULL; + remountScheduled = true; + nextRemountAt = now; +} + +void sdcard_noteResult(FRESULT fres) { + if (!sdMounted) { + return; + } + // Only the results that mean "the medium is not answering". A missing file or + // a full lock table says nothing about the card. + if (fres == FR_DISK_ERR || fres == FR_NOT_READY || fres == FR_INVALID_DRIVE || + fres == FR_NO_FILESYSTEM) { + DPRINTF("SD card: marking unmounted after FatFs error %d\n", (int)fres); + sdMounted = false; + mountedFsPtr = NULL; + remountScheduled = true; + nextRemountAt = get_absolute_time(); // try at the next poll + } +} + +// Called from the main loop. Cheap when the card is mounted; when it is not, +// retries a full remount every SDCARD_REMOUNT_RETRY_MS. +void sdcard_pollRemount(void) { + if (sdcard_isMounted()) { + sdcard_pollPresence(); + return; + } + if (bootFsPtr == NULL || bootFolder[0] == '\0') { + return; + } + if (!remountScheduled) { + remountScheduled = true; + nextRemountAt = get_absolute_time(); + } + if (absolute_time_diff_us(get_absolute_time(), nextRemountAt) > 0) { + return; + } + + // A remount talks to the card over SPI and can take a moment, and a card that + // is half-inserted can take longer still. + health_feed(); + health_setPhase(HEALTH_PHASE_BOOT); + remountAttempts++; + // Two things have to be undone before a reinserted card will come up. + // + // First the driver: sd_card_spi_init() returns immediately unless STA_NOINIT + // is set ("Check if we're not already initialized before proceeding", + // sd_card_spi.c), and with card-detect disabled nothing ever sets it when a + // card is pulled. So the driver would keep believing the old card is still + // initialised and skip the whole init sequence, leaving FatFs to fail on the + // first sector read. deinit() sets STA_NOINIT and forgets the card type. + // + // Then FatFs: while the volume stays registered, mount_volume() will not ask + // the driver to initialise anything at all. + sd_card_t *sdCard = sd_get_by_num(0); + if (sdCard != NULL && sdCard->deinit != NULL) { + sdCard->deinit(sdCard); + } + f_mount(NULL, "0:", 0); + sdcard_status_t rc = sdcard_initFilesystem(bootFsPtr, bootFolder); + health_feed(); + if (rc == SDCARD_INIT_OK) { + remountRecoveries++; + presenceCheckStarted = false; + DPRINTF("SD card: remounted after %lu attempt(s)\n", + (unsigned long)remountAttempts); + remountAttempts = 0; + remountScheduled = false; + return; + } + nextRemountAt = delayed_by_ms(get_absolute_time(), SDCARD_REMOUNT_RETRY_MS); +} + bool sdcard_getMountedInfo(uint32_t *totalSizeMb, uint32_t *freeSpaceMb) { if ((totalSizeMb == NULL) || (freeSpaceMb == NULL)) { return false; diff --git a/target/atarist/src/gemdrive.s b/target/atarist/src/gemdrive.s index be19a15..29d257b 100644 --- a/target/atarist/src/gemdrive.s +++ b/target/atarist/src/gemdrive.s @@ -349,6 +349,20 @@ old_handler: dc.l 0 even +; ==================================================================== +; write_seq — chunk sequence number for .Fwrite (EPIC-15 STORY-05). +; +; Bumped once per chunk, never per retry, and never reset: every retry +; of a chunk carries the number the first attempt carried, and no two +; distinct chunks ever share one. That is what lets the RP tell "you +; did not hear my answer, here is the same data again" from "here is +; the next chunk", which it could not do from the data alone -- a +; retried chunk and a new one look identical on the wire. + cnop 0,4 +write_seq: + dc.l 0 + even + ; ==================================================================== ; gemdrive_trap — full trap #1 dispatcher ; @@ -705,11 +719,18 @@ gemdrive_trap: ble.s .fwrite_chunk_size_ok move.l #BUFFER_WRITE_SIZE, d5 .fwrite_chunk_size_ok: + ; One new sequence number per chunk. a1/d1 are scratch under the + ; GEMDOS calling convention, and d1 is inside the movem below, so + ; it survives every retry of this chunk. + lea write_seq(pc), a1 + addq.l #1, (a1) + move.l (a1), d1 move.w #CMD_RETRIES_COUNT, d7 .fwrite_retry: movem.l d1-d7/a4, -(sp) move.w #CMD_WRITE_BUFF_CALL, d0 - move.l d5, d6 + move.l d5, d6 ; payload size = chunk size + move.l d1, d5 ; d5 = sequence (RP reads it here) bsr send_sync_write_command_to_sidecart movem.l (sp)+, d1-d7/a4 tst.w d0