From 0a45000209f6a09de63dfdd651665d657c0423a4 Mon Sep 17 00:00:00 2001 From: Diego Parrilla Date: Wed, 16 Sep 2026 17:17:59 +0200 Subject: [PATCH 01/12] Run the handlers from flash again (EPIC-12 STORY-01) Every http_server handler, and most of emul.c, gemdrive.c, runner.c, term.c and select.c, was marked __not_in_flash_func, so 47 KB of code and data sat in RAM and the release heap was 35,472 bytes. RAM placement only matters for code that runs while flash is unavailable: the settings write itself, the per-tick command path, and there are no application interrupt handlers (C-09). The handlers run from flash now. The five functions of the download data path (srv_recv_cb, srv_sent_cb, stream_download_drive, stream_send_chunk, send_buffered) stay in RAM: without them a 256 KB download slowed from 0.65 s to 0.72 s, and keeping them costs 4.8 KB. Release: code and data in RAM 47,496 -> 20,824 bytes, heap 35,472 -> 60,048 (+24,576). Debug heap 23,132 -> about 55,900 before the download path was put back. Measured on hardware, medians of three runs of a 256 KB round trip: upload 3.03 s before and 3.04 s after (SD-bound), download 0.65 s and 0.64 s, listing 43-48 ms both. flash.sh keys its build folder on the source path too, so building two checkouts that are both called rp/src no longer reuses one CMake cache. The stale comment in emul.c that credited the RAM move is corrected. --- rp/src/emul.c | 29 ++++---- rp/src/gemdrive.c | 2 +- rp/src/http_server.c | 162 +++++++++++++++++++++---------------------- rp/src/runner.c | 2 +- rp/src/select.c | 2 +- rp/src/term.c | 4 +- tools/dev/flash.sh | 6 +- 7 files changed, 106 insertions(+), 101 deletions(-) diff --git a/rp/src/emul.c b/rp/src/emul.c index 5ed3879..3c16350 100644 --- a/rp/src/emul.c +++ b/rp/src/emul.c @@ -538,7 +538,7 @@ static absolute_time_t lastCountdownTick; // Polling tick used as the network poll callback so command handling stays // alive during multi-second WiFi operations. -static void __not_in_flash_func(emul_pollTick)(void) { +static void emul_pollTick(void) { health_feed(); chandler_loop(); usbcdc_drain(); @@ -553,7 +553,7 @@ static bool resetDeviceAtBoot = true; // Returns the last n chars of str, prefixed with ".." if truncated. // Caller frees. NULL on bad input. -static char *__not_in_flash_func(right)(const char *str, int n) { +static char *right(const char *str, int n) { if (str == NULL || n < 0) return NULL; int len = (int)strlen(str); if (n == 0) return strdup(""); @@ -568,7 +568,7 @@ static char *__not_in_flash_func(right)(const char *str, int n) { } // "C".."Z" only; identical predicate to source's GEMDRIVE drive validator. -static bool __not_in_flash_func(isValidDrive)(const char *drive) { +static bool isValidDrive(const char *drive) { if (drive == NULL || drive[0] == '\0') { return false; } @@ -597,7 +597,7 @@ static void showTitle(void) { "DevOps Microfirmware - " RELEASE_VERSION "\n\x1Bq"); } -static void __not_in_flash_func(showCounter)(int cdown); +static void showCounter(int cdown); // Bottom-of-OLED info strip rendered with the smaller squeezed font — // this is the "second font size" referenced by the source. Inverts a 1px @@ -1006,7 +1006,7 @@ static DirNavigation *navState = &navStateStorage; // Filter: directories only — we list folders, never files. Hidden dotfiles // are skipped. Mirrors the spirit of source's floppiesFilter for our case. -static bool __not_in_flash_func(foldersOnlyFilter)(const char *name, +static bool foldersOnlyFilter(const char *name, BYTE attr) { if (name[0] == '.') { return false; @@ -1015,7 +1015,7 @@ static bool __not_in_flash_func(foldersOnlyFilter)(const char *name, } // Remove last path component (".." navigation). -static void __not_in_flash_func(pathUp)(void) { +static void pathUp(void) { char temp[MAX_FILENAME_LENGTH + 1]; char *segments[MAX_ENTRIES_DIR]; int sp = 0; @@ -1078,7 +1078,7 @@ static void drawPage(uint16_t top_offset) { term_printString("SPACE to confirm selection. ESC to exit"); } -static enum navStatus __not_in_flash_func(navigate_directory)( +static enum navStatus navigate_directory( bool first_time, bool dirs_only, char key, EntryFilterFn filter_fn, char top_folder[MAX_FILENAME_LENGTH + 1]) { enum navStatus status = NAV_DIR_ERROR; @@ -1188,7 +1188,7 @@ static enum navStatus __not_in_flash_func(navigate_directory)( // Builds the menu — single GEMDRIVE block + bottom navigation strip. // Layout follows the source's menu(): vt52Cursor positions, the F[o]lder/ // [D]rive labels, and the bottom "[G]EMDRIVE / [X] Return to Booster" line. -static void __not_in_flash_func(menu)(void) { +static void menu(void) { term_setCommandLevel(TERM_COMMAND_LEVEL_SINGLE_KEY); menuScreenActive = true; @@ -1373,7 +1373,7 @@ static void __not_in_flash_func(menu)(void) { refreshSetupInfoLine(); } -static void __not_in_flash_func(showCounter)(int cdown) { +static void showCounter(int cdown) { if (cdown > 0) { // animated progress bar on the bottom strip // instead of plain text. Visual + textual at once. @@ -1462,7 +1462,7 @@ void cmdBooster(const char *arg) { // the currently configured folder; subsequent keystrokes (arrows / RETURN // / SPACE) come back through TERM_COMMAND_LEVEL_COMMAND_SINGLE_KEY_REENTRY // and drive navigate_directory. -void __not_in_flash_func(cmdGemdriveFolder)(const char *arg) { +void cmdGemdriveFolder(const char *arg) { haltCountdown = true; enum navStatus status = NAV_DIR_ERROR; switch (term_getCommandLevel()) { @@ -1962,10 +1962,11 @@ void emul_start() { // Earlier builds deferred this to firmware launch because of // an ST-side crash; that turned out to be RAM pressure (the // per-conn pool was 47 KB of BSS, pushing the heap into the - // ROM-in-RAM region). After shrinking the pool to ~5 KB and - // moving every http_server function to RAM via - // __not_in_flash_func, running the server during the menu - // is safe. Idempotent — safe even if Wi-Fi connect timed out. + // ROM-in-RAM region). Shrinking the pool to ~5 KB fixed it; + // the handlers were also moved to RAM at the time, which only + // added pressure and is undone in EPIC-12 STORY-01 (the + // download data path stays in RAM for speed). Idempotent — + // safe even if Wi-Fi connect timed out. http_server_init(); } } else { diff --git a/rp/src/gemdrive.c b/rp/src/gemdrive.c index 2f03c6f..ad73979 100644 --- a/rp/src/gemdrive.c +++ b/rp/src/gemdrive.c @@ -1282,7 +1282,7 @@ static void handleDtaReleaseCall(uint16_t *payload) { // Dispatcher // --------------------------------------------------------------------------- -void __not_in_flash_func(gemdrive_command_cb)(TransmissionProtocol *protocol, +void gemdrive_command_cb(TransmissionProtocol *protocol, uint16_t *payload) { if ((protocol->command_id & 0xFF00u) == GEMDRIVE_APP) { health_setPhase(HEALTH_PHASE_GEMDRIVE); diff --git a/rp/src/http_server.c b/rp/src/http_server.c index bb473d8..101df52 100644 --- a/rp/src/http_server.c +++ b/rp/src/http_server.c @@ -190,7 +190,7 @@ static void conn_close(http_conn_t *c); static void parse_and_dispatch(http_conn_t *c); static void route(http_conn_t *c); -static void send_buffered(http_conn_t *c); +static void __not_in_flash_func(send_buffered)(http_conn_t *c); static void write_response(http_conn_t *c, int status, const char *reason, const char *content_type, const char *body, @@ -205,19 +205,19 @@ 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 err_t srv_accept_cb(void *arg, struct tcp_pcb *newpcb, err_t err); -static err_t srv_recv_cb(void *arg, struct tcp_pcb *pcb, struct pbuf *p, +static err_t __not_in_flash_func(srv_recv_cb)(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); -static err_t srv_sent_cb(void *arg, struct tcp_pcb *pcb, u16_t len); +static err_t __not_in_flash_func(srv_sent_cb)(void *arg, struct tcp_pcb *pcb, u16_t len); static err_t srv_poll_cb(void *arg, struct tcp_pcb *pcb); static void srv_err_cb(void *arg, err_t err); // Streaming-handler forward decls; bodies live alongside the // download / listing / upload route handlers further down. static void stream_listing_drive(http_conn_t *c); -static void stream_download_drive(http_conn_t *c); +static void __not_in_flash_func(stream_download_drive)(http_conn_t *c); static void stream_debug_drive(http_conn_t *c); // Chunked-encoding helpers (definitions further down). -static err_t stream_send_chunk(http_conn_t *c, const char *body, +static err_t __not_in_flash_func(stream_send_chunk)(http_conn_t *c, const char *body, size_t body_len); static err_t stream_send_terminator(http_conn_t *c); static bool handle_file_upload_init(http_conn_t *c, const char *body_start, @@ -232,7 +232,7 @@ static void adv_load_finish_ok(http_conn_t *c); // --- Public API --- -void __not_in_flash_func(http_server_init)(void) { +void http_server_init(void) { DPRINTF("http_server: init entered (g_listen_pcb=%p)\n", (void *)g_listen_pcb); if (g_listen_pcb != NULL) { @@ -266,7 +266,7 @@ void __not_in_flash_func(http_server_init)(void) { DPRINTF("http_server: listening on :%d\n", HTTP_SERVER_PORT); } -void __not_in_flash_func(http_server_deinit)(void) { +void http_server_deinit(void) { if (g_listen_pcb != NULL) { tcp_close(g_listen_pcb); g_listen_pcb = NULL; @@ -280,7 +280,7 @@ void __not_in_flash_func(http_server_deinit)(void) { // --- Connection lifecycle --- -static http_conn_t *__not_in_flash_func(conn_alloc)(void) { +static http_conn_t *conn_alloc(void) { for (int i = 0; i < HTTP_SERVER_MAX_CONNECTIONS; i++) { if (g_conns[i].state == HC_FREE) { memset(&g_conns[i], 0, sizeof(g_conns[i])); @@ -291,12 +291,12 @@ static http_conn_t *__not_in_flash_func(conn_alloc)(void) { return NULL; } -static void __not_in_flash_func(conn_free)(http_conn_t *c) { +static void conn_free(http_conn_t *c) { c->pcb = NULL; c->state = HC_FREE; } -static void __not_in_flash_func(conn_close)(http_conn_t *c) { +static void conn_close(http_conn_t *c) { if (c->stream_dir_open) { f_closedir(&c->stream_dir); c->stream_dir_open = false; @@ -338,7 +338,7 @@ static void __not_in_flash_func(conn_close)(http_conn_t *c) { // --- TCP callbacks --- -static err_t __not_in_flash_func(srv_accept_cb)(void *arg, struct tcp_pcb *newpcb, err_t err) { +static err_t srv_accept_cb(void *arg, struct tcp_pcb *newpcb, err_t err) { (void)arg; if (err != ERR_OK || newpcb == NULL) { return ERR_VAL; @@ -491,7 +491,7 @@ static err_t __not_in_flash_func(srv_sent_cb)(void *arg, struct tcp_pcb *pcb, u1 return ERR_OK; } -static err_t __not_in_flash_func(srv_poll_cb)(void *arg, struct tcp_pcb *pcb) { +static err_t srv_poll_cb(void *arg, struct tcp_pcb *pcb) { (void)pcb; http_conn_t *c = (http_conn_t *)arg; if (c == NULL) { @@ -509,7 +509,7 @@ static err_t __not_in_flash_func(srv_poll_cb)(void *arg, struct tcp_pcb *pcb) { return ERR_OK; } -static void __not_in_flash_func(srv_err_cb)(void *arg, err_t err) { +static void srv_err_cb(void *arg, err_t err) { (void)err; http_conn_t *c = (http_conn_t *)arg; if (c != NULL) { @@ -521,7 +521,7 @@ static void __not_in_flash_func(srv_err_cb)(void *arg, err_t err) { // --- Request parsing --- -static int __not_in_flash_func(strncasecmp_n)(const char *a, const char *b, size_t n) { +static int strncasecmp_n(const char *a, const char *b, size_t n) { for (size_t i = 0; i < n; i++) { char ca = a[i]; char cb = b[i]; @@ -541,7 +541,7 @@ static int __not_in_flash_func(strncasecmp_n)(const char *a, const char *b, size return 0; } -static hc_method_t __not_in_flash_func(parse_method)(const char *s, size_t n) { +static hc_method_t parse_method(const char *s, size_t n) { if (n == 3 && memcmp(s, "GET", 3) == 0) return HM_GET; if (n == 4 && memcmp(s, "HEAD", 4) == 0) return HM_HEAD; if (n == 4 && memcmp(s, "POST", 4) == 0) return HM_POST; @@ -550,7 +550,7 @@ static hc_method_t __not_in_flash_func(parse_method)(const char *s, size_t n) { return HM_UNKNOWN; } -static void __not_in_flash_func(parse_and_dispatch)(http_conn_t *c) { +static void parse_and_dispatch(http_conn_t *c) { // Request line char *eol = strstr(c->hdr, "\r\n"); if (eol == NULL) { @@ -768,7 +768,7 @@ static void __not_in_flash_func(parse_and_dispatch)(http_conn_t *c) { // --- URL decoding + query parsing --- -static int __not_in_flash_func(hex_digit)(int c) { +static int hex_digit(int c) { if (c >= '0' && c <= '9') return c - '0'; if (c >= 'a' && c <= 'f') return c - 'a' + 10; if (c >= 'A' && c <= 'F') return c - 'A' + 10; @@ -779,7 +779,7 @@ static int __not_in_flash_func(hex_digit)(int c) { // (we don't accept form-encoded query strings as space-encoded). // Returns false on bad encoding, NUL byte in result, or buffer // overflow. -static bool __not_in_flash_func(url_decode)(const char *src, char *dst, size_t dst_cap) { +static bool url_decode(const char *src, char *dst, size_t dst_cap) { size_t out = 0; while (*src != '\0') { if (out + 1 >= dst_cap) return false; @@ -805,7 +805,7 @@ static bool __not_in_flash_func(url_decode)(const char *src, char *dst, size_t d // Find `key` in a URL-encoded query string `?a=1&b=2&...`. Writes the // URL-decoded value into `out`. Returns true on hit (even when value // is empty), false if key not present or buffer would overflow. -static bool __not_in_flash_func(query_get)(const char *query, const char *key, char *out, +static bool query_get(const char *query, const char *key, char *out, size_t out_cap) { size_t key_len = strlen(key); const char *p = query; @@ -834,7 +834,7 @@ static bool __not_in_flash_func(query_get)(const char *query, const char *key, c // Reads gconfig PARAM_HOSTNAME (used for the API's mDNS name); we // don't actually need it here but the GEMDRIVE_FOLDER lookup is the // real prize. -static const char *__not_in_flash_func(get_gemdrive_folder)(void) { +static const char *get_gemdrive_folder(void) { SettingsConfigEntry *entry = settings_find_entry(aconfig_getContext(), ACONFIG_PARAM_GEMDRIVE_FOLDER); if (entry == NULL || entry->value[0] == '\0') return "/devops"; @@ -851,7 +851,7 @@ typedef enum { NORM_TOO_LONG, } norm_status_t; -static norm_status_t __not_in_flash_func(normalize_rel)(const char *rel, char *out, +static norm_status_t normalize_rel(const char *rel, char *out, size_t out_cap) { if (out_cap < 2) return NORM_TOO_LONG; out[0] = '/'; @@ -913,7 +913,7 @@ static norm_status_t __not_in_flash_func(normalize_rel)(const char *rel, char *o // Build absolute on-disk path: GEMDRIVE_FOLDER + normalised rel. // rel can be NULL/empty (treated as "/"). -static norm_status_t __not_in_flash_func(resolve_jail)(const char *rel, char *out, +static norm_status_t resolve_jail(const char *rel, char *out, size_t out_cap) { char norm[HTTP_PATH_BUF_BYTES]; norm_status_t s = normalize_rel(rel, norm, sizeof(norm)); @@ -945,7 +945,7 @@ static norm_status_t __not_in_flash_func(resolve_jail)(const char *rel, char *ou // historically rejected ('+', ',', ';', '=', '[', ']'). Lower-case // letters are allowed at validation time and case-folded by FatFs; // our jail returns the canonical uppercase form to clients. -static bool __not_in_flash_func(fat_illegal_char)(unsigned char ch) { +static bool fat_illegal_char(unsigned char ch) { if (ch < 0x20) return true; if (ch >= 0x80) return true; static const char banned[] = "\"*/:<>?\\|+,;=[]"; @@ -964,7 +964,7 @@ static bool __not_in_flash_func(fat_illegal_char)(unsigned char ch) { // `norm` is the leading-slash form produced by normalize_rel (e.g. // "/foo/bar.txt"). This function only inspects the segment after the // last '/'. -static norm_status_t __not_in_flash_func(validate_8_3_last)(const char *norm) { +static norm_status_t validate_8_3_last(const char *norm) { const char *last_slash = strrchr(norm, '/'); const char *seg = (last_slash != NULL) ? last_slash + 1 : norm; size_t seg_len = strlen(seg); @@ -1012,14 +1012,14 @@ typedef enum { JSON_KEY_MISSING, // syntactically valid but key absent / not a string } json_status_t; -static const char *__not_in_flash_func(skip_ws)(const char *p, const char *end) { +static const char *skip_ws(const char *p, const char *end) { while (p < end && (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n')) { p++; } return p; } -static json_status_t __not_in_flash_func(json_extract_string)(const char *body, size_t body_len, +static json_status_t json_extract_string(const char *body, size_t body_len, const char *key, char *out, size_t out_cap) { const char *p = body; @@ -1128,7 +1128,7 @@ static json_status_t __not_in_flash_func(json_extract_string)(const char *body, // FAT date+time → ISO-8601 "YYYY-MM-DDTHH:MM:SS". Returns false if // the date field is zero (FatFs uses 0 for "no date set") so the // caller can emit `null`. -static bool __not_in_flash_func(fat_to_iso8601)(WORD fdate, WORD ftime, char *out, +static bool fat_to_iso8601(WORD fdate, WORD ftime, char *out, size_t out_cap) { if (fdate == 0) return false; unsigned year = 1980u + ((fdate >> 9) & 0x7F); @@ -1144,7 +1144,7 @@ static bool __not_in_flash_func(fat_to_iso8601)(WORD fdate, WORD ftime, char *ou // --- Route handlers --- -static void __not_in_flash_func(handle_ping)(http_conn_t *c) { +static void handle_ping(http_conn_t *c) { uint64_t uptime_us = (uint64_t)absolute_time_diff_us(g_boot_time, get_absolute_time()); uint64_t uptime_s = uptime_us / 1000000ULL; @@ -1156,7 +1156,7 @@ static void __not_in_flash_func(handle_ping)(http_conn_t *c) { write_response(c, 200, "OK", "application/json", body, (size_t)n); } -static const char *__not_in_flash_func(fat_type_name)(BYTE fs_type) { +static const char *fat_type_name(BYTE fs_type) { switch (fs_type) { case FS_FAT12: return "FAT12"; case FS_FAT16: return "FAT16"; @@ -1166,7 +1166,7 @@ static const char *__not_in_flash_func(fat_type_name)(BYTE fs_type) { } } -static void __not_in_flash_func(handle_volume)(http_conn_t *c) { +static void handle_volume(http_conn_t *c) { FATFS *fs = NULL; DWORD free_clusters = 0; FRESULT res = f_getfree("", &free_clusters, &fs); @@ -1224,7 +1224,7 @@ static const char *runner_last_command_str(runner_last_command_t cmd) { // // busy / cwd / exit-code fields are populated as RUNNER_EXECUTE / CD // commands land. -static void __not_in_flash_func(handle_runner_status)(http_conn_t *c) { +static void handle_runner_status(http_conn_t *c) { bool active = emul_isRunnerActive(); bool busy = emul_isRunnerBusy(); const char *last_cmd = runner_last_command_str(emul_getRunnerLastCommand()); @@ -1344,7 +1344,7 @@ static bool finfo_is_dir(const FILINFO *info); // into `out`. Absolute paths and paths with no cwd in effect are // copied verbatim. Returns true on success, false if the resolved // string would overflow `out_cap`. -static bool __not_in_flash_func(runner_resolve_relative)(const char *input, +static bool runner_resolve_relative(const char *input, char *out, size_t out_cap) { if (input == NULL || out == NULL || out_cap == 0) return false; @@ -1376,7 +1376,7 @@ static bool __not_in_flash_func(runner_resolve_relative)(const char *input, // Runner sub-region writers. m68k can only READ the cartridge area; // the RP populates path / cmdline buffers in APP_FREE so the m68k // Runner can dereference them directly when it runs Pexec. -static uint32_t __not_in_flash_func(runner_app_free_address)(void) { +static uint32_t runner_app_free_address(void) { return (uint32_t)&__rom_in_ram_start__ + CHANDLER_APP_FREE_OFFSET; } @@ -1386,7 +1386,7 @@ static uint32_t __not_in_flash_func(runner_app_free_address)(void) { // for byte reads. We pre-swap each pair so the m68k's byte reads // land in the right order. Same idea as writeAppFreeBytesSwapped in // gemdrive.c. -static void __not_in_flash_func(runner_memcpy_swapped)(uint8_t *dst, +static void runner_memcpy_swapped(uint8_t *dst, const char *src, size_t n) { for (size_t i = 0; i < n; i++) { @@ -1394,7 +1394,7 @@ static void __not_in_flash_func(runner_memcpy_swapped)(uint8_t *dst, } } -static void __not_in_flash_func(runner_write_path)(const char *path) { +static void runner_write_path(const char *path) { uint8_t *dst = (uint8_t *)(runner_app_free_address() + RUNNER_PATH_OFFSET); size_t n = strlen(path); if (n >= RUNNER_PATH_LEN - 1) n = RUNNER_PATH_LEN - 2; @@ -1408,7 +1408,7 @@ static void __not_in_flash_func(runner_write_path)(const char *path) { // TOS Pexec cmdline format: , no NUL. The // length byte is BYTE 0; the m68k passes a pointer to this buffer // straight to GEMDOS Pexec. Same byte-pair swap as the path. -static void __not_in_flash_func(runner_write_cmdline)(const char *cmdline) { +static void runner_write_cmdline(const char *cmdline) { uint8_t *dst = (uint8_t *)(runner_app_free_address() + RUNNER_CMDLINE_OFFSET); size_t n = strlen(cmdline); @@ -1431,7 +1431,7 @@ static void __not_in_flash_func(runner_write_cmdline)(const char *cmdline) { // the Runner busy, fires RUNNER_CMD_EXECUTE on the cartridge // sentinel. The m68k's Pexec result is reported asynchronously via // the chandler RUNNER_CMD_DONE_EXECUTE callback (runner.c). -static void __not_in_flash_func(handle_runner_run)(http_conn_t *c) { +static void handle_runner_run(http_conn_t *c) { if (!emul_isRunnerActive()) { write_error(c, 409, "Conflict", "runner_inactive", "Runner mode is not active; boot via [U] first"); @@ -1573,7 +1573,7 @@ static void __not_in_flash_func(handle_runner_run)(http_conn_t *c) { // under 1 s for normal-sized TOS programs; uses the same 10 s // outer timeout as a generous worst-case. #define RUNNER_LOAD_TIMEOUT_US 10000000 -static void __not_in_flash_func(handle_runner_load)(http_conn_t *c) { +static void handle_runner_load(http_conn_t *c) { if (!emul_isRunnerActive()) { write_error(c, 409, "Conflict", "runner_inactive", "Runner mode is not active; boot via [U] first"); @@ -1741,7 +1741,7 @@ static void __not_in_flash_func(handle_runner_load)(http_conn_t *c) { // soon as RUNNER_CMD_EXEC is on the sentinel. The exit code // arrives asynchronously via DONE_EXEC and surfaces on the // next /runner/status as last_exit_code. -static void __not_in_flash_func(handle_runner_exec)(http_conn_t *c) { +static void handle_runner_exec(http_conn_t *c) { if (!emul_isRunnerActive()) { write_error(c, 409, "Conflict", "runner_inactive", "Runner mode is not active; boot via [U] first"); @@ -1794,7 +1794,7 @@ static void __not_in_flash_func(handle_runner_exec)(http_conn_t *c) { // usually means the basepage was never allocated). 409 // no_program_loaded if nothing to free. #define RUNNER_UNLOAD_TIMEOUT_US 5000000 -static void __not_in_flash_func(handle_runner_unload)(http_conn_t *c) { +static void handle_runner_unload(http_conn_t *c) { if (!emul_isRunnerActive()) { write_error(c, 409, "Conflict", "runner_inactive", "Runner mode is not active; boot via [U] first"); @@ -1869,7 +1869,7 @@ static void __not_in_flash_func(handle_runner_unload)(http_conn_t *c) { // Runner busy and fires RUNNER_CMD_CD on the cartridge sentinel; the // m68k's Dsetpath result lands asynchronously via the chandler // RUNNER_CMD_DONE_CD callback (runner.c). -static void __not_in_flash_func(handle_runner_cd)(http_conn_t *c) { +static void handle_runner_cd(http_conn_t *c) { if (!emul_isRunnerActive()) { write_error(c, 409, "Conflict", "runner_inactive", "Runner mode is not active; boot via [U] first"); @@ -1980,7 +1980,7 @@ static void __not_in_flash_func(handle_runner_cd)(http_conn_t *c) { // m68k-readable cartridge slot. Byte-pair-swapped so the m68k's // `move.l RUNNER_BASEPAGE, ...` lands the right value, same // cartridge-bus quirk as runner_write_path. -static void __not_in_flash_func(runner_write_u32)(uint32_t offset, +static void runner_write_u32(uint32_t offset, uint32_t value) { uint8_t *dst = (uint8_t *)(runner_app_free_address() + offset); uint8_t b0 = (uint8_t)((value >> 24) & 0xFF); @@ -1996,7 +1996,7 @@ static void __not_in_flash_func(runner_write_u32)(uint32_t offset, // APP_FREE so the m68k handler can read it. u16 in the low half of // the longword. Byte-pair-swapped so the m68k's word-load lands // the right value (cartridge-bus quirk — same as runner_write_path). -static void __not_in_flash_func(runner_write_rez)(uint16_t rez) { +static void runner_write_rez(uint16_t rez) { uint8_t *dst = (uint8_t *)(runner_app_free_address() + RUNNER_REZ_OFFSET); // Zero the 4-byte slot, then write the u16 swapped. uint8_t hi = (uint8_t)((rez >> 8) & 0xFF); @@ -2014,7 +2014,7 @@ static void __not_in_flash_func(runner_write_rez)(uint16_t rez) { // detect monochrome (rez == 2) and refuse, otherwise XBIOS Setscreen // with the requested rez. Errno (i32) returns via RUNNER_CMD_DONE_RES // and surfaces as `last_res_errno` in the status envelope. -static void __not_in_flash_func(handle_runner_res)(http_conn_t *c) { +static void handle_runner_res(http_conn_t *c) { if (!emul_isRunnerActive()) { write_error(c, 409, "Conflict", "runner_inactive", "Runner mode is not active; boot via [U] first"); @@ -2105,7 +2105,7 @@ static void __not_in_flash_func(handle_runner_res)(http_conn_t *c) { // to the patched PC. // // No busy-lock gate — escaping wedged state is the whole point. -static void __not_in_flash_func(handle_runner_adv_jump)(http_conn_t *c) { +static void handle_runner_adv_jump(http_conn_t *c) { if (!emul_isRunnerActive()) { write_error(c, 409, "Conflict", "runner_inactive", "Runner mode is not active; boot via [U] first"); @@ -2207,7 +2207,7 @@ static void __not_in_flash_func(handle_runner_adv_jump)(http_conn_t *c) { #define ADV_LOAD_CHUNK_SIZE 8192u #define ADV_LOAD_TIMEOUT_US 1000000 -static uint8_t *__not_in_flash_func(adv_load_buf_base)(void) { +static uint8_t *adv_load_buf_base(void) { // RUNNER_ADV_LOAD_BUF_OFFSET in runner.s. Mirrors at APP_FREE + // 0x4000; APP_FREE is 46 KB so 0x4000..0x6000 (8 KB) is comfortably // inside the arena and clear of the GEMDRIVE / Runner-meta block @@ -2221,7 +2221,7 @@ static uint8_t *__not_in_flash_func(adv_load_buf_base)(void) { // dispatch the chunk and reset the cursor for the next one. The // final partial chunk (chunk_pos > 0 at end-of-content) is flushed // by adv_load_finish_ok(). -static void __not_in_flash_func(adv_load_drain_pbuf)(http_conn_t *c, +static void adv_load_drain_pbuf(http_conn_t *c, struct pbuf *p, size_t off, size_t n) { uint8_t *base = adv_load_buf_base(); @@ -2258,7 +2258,7 @@ static void __not_in_flash_func(adv_load_drain_pbuf)(http_conn_t *c, // runner_command_cb -> emul_recordRunnerAdvLoadAck), then advance // the destination cursor and reset the chunk cursor. Returns false // on per-chunk timeout (1 s). -static bool __not_in_flash_func(adv_load_dispatch_chunk)(http_conn_t *c) { +static bool adv_load_dispatch_chunk(http_conn_t *c) { uint32_t base = (uint32_t)&__rom_in_ram_start__; uint32_t len = c->adv_load_chunk_pos; if (len == 0) return true; @@ -2289,7 +2289,7 @@ static bool __not_in_flash_func(adv_load_dispatch_chunk)(http_conn_t *c) { // End of body — flush the final partial chunk (if any) and send // the success envelope. -static void __not_in_flash_func(adv_load_finish_ok)(http_conn_t *c) { +static void adv_load_finish_ok(http_conn_t *c) { if (c->adv_load_chunk_pos > 0) { if (!adv_load_dispatch_chunk(c)) { return; @@ -2312,7 +2312,7 @@ static void __not_in_flash_func(adv_load_finish_ok)(http_conn_t *c) { // body bytes that arrived in the same TCP segment as the headers. // Returns false if any validation failed (an error response was // already written). -static bool __not_in_flash_func(handle_runner_adv_load_init)( +static bool handle_runner_adv_load_init( http_conn_t *c, const char *body_start, size_t leftover) { if (!emul_isRunnerActive()) { write_error(c, 409, "Conflict", "runner_inactive", @@ -2461,7 +2461,7 @@ static bool __not_in_flash_func(handle_runner_adv_load_init)( // // Intentionally skips the busy-lock gate — the busy state is what // we want to escape (a wedged Pexec'd program holds it set forever). -static void __not_in_flash_func(handle_runner_adv_meminfo)(http_conn_t *c) { +static void handle_runner_adv_meminfo(http_conn_t *c) { if (!emul_isRunnerActive()) { write_error(c, 409, "Conflict", "runner_inactive", "Runner mode is not active; boot via [U] first"); @@ -2519,7 +2519,7 @@ static void __not_in_flash_func(handle_runner_adv_meminfo)(http_conn_t *c) { // at $400 — chosen via the ACONFIG_PARAM_ADV_HOOK_VECTOR setting in // the setup menu). The flag and vector ID arrive together in the // HELLO payload; both clear on emul_resetRunnerSession. -static void __not_in_flash_func(handle_runner_adv_status)(http_conn_t *c) { +static void handle_runner_adv_status(http_conn_t *c) { bool active = emul_isRunnerActive(); bool installed = active && emul_isRunnerAdvancedInstalled(); uint8_t vec = installed ? emul_getRunnerAdvHookVector() @@ -2562,7 +2562,7 @@ static void __not_in_flash_func(handle_runner_adv_status)(http_conn_t *c) { // wrapped past the cursor while the host's // TX FIFO stalled. Cumulative since boot.> // } -static void __not_in_flash_func(handle_debug_status)(http_conn_t *c) { +static void handle_debug_status(http_conn_t *c) { uint32_t ring_used = 0; uint32_t ring_capacity = 0; uint32_t bytes_dropped = 0; @@ -2603,7 +2603,7 @@ static void __not_in_flash_func(handle_debug_status)(http_conn_t *c) { // us to encode binary or non-printable bytes; the contract for // the public ABI is "you get exactly what was emitted", so // octet-stream is honest. -static void __not_in_flash_func(stream_debug_drive)(http_conn_t *c) { +static void stream_debug_drive(http_conn_t *c) { // Pull as many bytes as we can fit in c->resp (re-used as a // scratch buffer for the chunk body). uint8_t *buf = (uint8_t *)c->resp; @@ -2626,7 +2626,7 @@ static void __not_in_flash_func(stream_debug_drive)(http_conn_t *c) { } } -static void __not_in_flash_func(handle_debug_log)(http_conn_t *c) { +static void handle_debug_log(http_conn_t *c) { // Send status line + headers (chunked encoding, no Content-Length). int hn = snprintf(c->resp, sizeof(c->resp), "HTTP/1.1 200 OK\r\n" @@ -2680,7 +2680,7 @@ static void __not_in_flash_func(handle_debug_log)(http_conn_t *c) { // addresses, the two decoded bank sizes (0/0 = unrecognised MMU // config), and a simple "decoded" boolean derived from the banks. #define RUNNER_MEMINFO_TIMEOUT_US 1000000 -static void __not_in_flash_func(handle_runner_meminfo)(http_conn_t *c) { +static void handle_runner_meminfo(http_conn_t *c) { if (!emul_isRunnerActive()) { write_error(c, 409, "Conflict", "runner_inactive", "Runner mode is not active; boot via [U] first"); @@ -2754,7 +2754,7 @@ static void __not_in_flash_func(handle_runner_meminfo)(http_conn_t *c) { // Intentionally no busy-lock gate — the busy state is exactly what // we want to escape. 409 runner_inactive when the user hasn't // picked [U] at boot. -static void __not_in_flash_func(handle_runner_reset)(http_conn_t *c) { +static void handle_runner_reset(http_conn_t *c) { if (!emul_isRunnerActive()) { write_error(c, 409, "Conflict", "runner_inactive", "Runner mode is not active; boot via [U] first"); @@ -2783,7 +2783,7 @@ static void __not_in_flash_func(handle_runner_reset)(http_conn_t *c) { static bool body_appendf(char *body, size_t cap, size_t *len, const char *fmt, ...) __attribute__((format(printf, 4, 5))); -static bool __not_in_flash_func(body_appendf)(char *body, size_t cap, size_t *len, +static bool body_appendf(char *body, size_t cap, size_t *len, const char *fmt, ...) { if (*len >= cap) return false; va_list args; @@ -2942,7 +2942,7 @@ static void handle_debug_test(http_conn_t *c) { // Append one entry (with its leading comma when needed) to `out`. // Returns false if the formatted entry didn't fit. -static bool __not_in_flash_func(stream_append_entry)(http_conn_t *c, +static bool stream_append_entry(http_conn_t *c, char *out, size_t out_cap, size_t *out_len, @@ -2992,7 +2992,7 @@ static bool __not_in_flash_func(stream_append_entry)(http_conn_t *c, // envelope opener for the first chunk; NULL for subsequent chunks). // Returns the body length. Side effects: may set // c->stream_truncated and c->stream_body_done. -static size_t __not_in_flash_func(stream_build_body)(http_conn_t *c, +static size_t stream_build_body(http_conn_t *c, const char *prefix, char *out, size_t out_cap) { @@ -3059,7 +3059,7 @@ static err_t __not_in_flash_func(stream_send_chunk)(http_conn_t *c, } // Send the chunked-encoding terminator (zero-length chunk). -static err_t __not_in_flash_func(stream_send_terminator)(http_conn_t *c) { +static err_t stream_send_terminator(http_conn_t *c) { err_t err = tcp_write(c->pcb, "0\r\n\r\n", 5, TCP_WRITE_FLAG_COPY); if (err != ERR_OK) return err; tcp_output(c->pcb); @@ -3070,7 +3070,7 @@ static err_t __not_in_flash_func(stream_send_terminator)(http_conn_t *c) { // chunk, decide whether to also send the terminator and close. // Called both from handle_files_list (initial round) and from // srv_sent_cb (subsequent rounds, driven by peer acks). -static void __not_in_flash_func(stream_listing_drive)(http_conn_t *c) { +static void stream_listing_drive(http_conn_t *c) { // Worst-case bytes we'd queue this round: chunk header + body + // CRLF + terminator. Need send buffer headroom for it. size_t needed = HTTP_RESPONSE_BUF_BYTES + 16 + 8; @@ -3104,7 +3104,7 @@ static void __not_in_flash_func(stream_listing_drive)(http_conn_t *c) { } } -static void __not_in_flash_func(handle_files_list)(http_conn_t *c) { +static void handle_files_list(http_conn_t *c) { // Extract ?path=, default to "/". char rel[HTTP_PATH_BUF_BYTES]; rel[0] = '\0'; @@ -3223,7 +3223,7 @@ static void __not_in_flash_func(handle_files_list)(http_conn_t *c) { // still containing percent-encoded bytes. The handlers URL-decode, // normalise, jail, validate 8.3 on the last segment, then call FatFs. -static void __not_in_flash_func(write_path_error)(http_conn_t *c, norm_status_t s) { +static void write_path_error(http_conn_t *c, norm_status_t s) { if (s == NORM_TOO_LONG) { write_error(c, 400, "Bad Request", "name_too_long", "Path or name exceeds FAT 8.3 limits"); @@ -3235,7 +3235,7 @@ static void __not_in_flash_func(write_path_error)(http_conn_t *c, norm_status_t // Resolve a URL-decoded relative path into normalised form (norm) and // FatFs absolute form (abs). Returns NORM_OK on success or a status // the caller maps to the right HTTP error. -static norm_status_t __not_in_flash_func(resolve_pair)(const char *url_rel, char *norm, +static norm_status_t resolve_pair(const char *url_rel, char *norm, size_t norm_cap, char *abs, size_t abs_cap) { char decoded[HTTP_PATH_BUF_BYTES]; @@ -3248,11 +3248,11 @@ static norm_status_t __not_in_flash_func(resolve_pair)(const char *url_rel, char // Test whether the FILINFO returned by f_stat indicates a directory. // Only valid when f_stat returned FR_OK. -static bool __not_in_flash_func(finfo_is_dir)(const FILINFO *info) { +static bool finfo_is_dir(const FILINFO *info) { return (info->fattrib & AM_DIR) != 0; } -static void __not_in_flash_func(handle_folder_create)(http_conn_t *c, const char *url_rel) { +static void handle_folder_create(http_conn_t *c, const char *url_rel) { char norm[HTTP_PATH_BUF_BYTES]; char abs_path[HTTP_FAT_PATH_BUF_BYTES]; norm_status_t s = resolve_pair(url_rel, norm, sizeof(norm), abs_path, @@ -3317,7 +3317,7 @@ static void __not_in_flash_func(handle_folder_create)(http_conn_t *c, const char (extra[0] != '\0') ? extra : NULL, body, (size_t)n); } -static void __not_in_flash_func(handle_folder_delete)(http_conn_t *c, const char *url_rel) { +static void handle_folder_delete(http_conn_t *c, const char *url_rel) { char norm[HTTP_PATH_BUF_BYTES]; char abs_path[HTTP_FAT_PATH_BUF_BYTES]; norm_status_t s = resolve_pair(url_rel, norm, sizeof(norm), abs_path, @@ -3362,7 +3362,7 @@ static void __not_in_flash_func(handle_folder_delete)(http_conn_t *c, const char write_response(c, 204, "No Content", "application/json", NULL, 0); } -static void __not_in_flash_func(handle_folder_rename)(http_conn_t *c, const char *url_rel) { +static void handle_folder_rename(http_conn_t *c, const char *url_rel) { if (c->content_length == 0) { write_error(c, 411, "Length Required", "length_required", "JSON body required"); @@ -3555,7 +3555,7 @@ static void __not_in_flash_func(stream_download_drive)(http_conn_t *c) { } } -static void __not_in_flash_func(handle_file_download)(http_conn_t *c, +static void handle_file_download(http_conn_t *c, const char *url_rel) { // Body-stream lock. A streaming GET counts as a body request; if // another download or upload is already in flight, return 503. @@ -3774,7 +3774,7 @@ static void __not_in_flash_func(handle_file_download)(http_conn_t *c, // the partial file — leaving the upload's lock entry in FatFs's // lock table (FF_FS_LOCK in ffconf.h) would block any future delete // or overwrite of the same name until the next power cycle. -static void __not_in_flash_func(upload_finish_ok)(http_conn_t *c) { +static void upload_finish_ok(http_conn_t *c) { FRESULT close_fr = FR_OK; if (c->upload_file_open) { close_fr = f_close(&c->upload_file); @@ -3817,7 +3817,7 @@ static void __not_in_flash_func(upload_finish_ok)(http_conn_t *c) { // upload was already complete after the leftover write, calls // upload_finish_ok); false means upload_init wrote the error response // itself and the caller should just return. -static bool __not_in_flash_func(handle_file_upload_init)( +static bool handle_file_upload_init( http_conn_t *c, const char *body_start, size_t leftover) { // Single-streamer lock. if (g_body_stream_busy) { @@ -3969,7 +3969,7 @@ static bool __not_in_flash_func(handle_file_upload_init)( // return 404 with an `is_directory` code so the client can detect it // and switch namespace. -static void __not_in_flash_func(handle_file_delete)(http_conn_t *c, +static void handle_file_delete(http_conn_t *c, const char *url_rel) { char norm[HTTP_PATH_BUF_BYTES]; char abs_path[HTTP_FAT_PATH_BUF_BYTES]; @@ -4017,7 +4017,7 @@ static void __not_in_flash_func(handle_file_delete)(http_conn_t *c, write_response(c, 204, "No Content", "application/json", NULL, 0); } -static void __not_in_flash_func(handle_file_rename)(http_conn_t *c, +static void handle_file_rename(http_conn_t *c, const char *url_rel) { if (c->content_length == 0) { write_error(c, 411, "Length Required", "length_required", @@ -4181,7 +4181,7 @@ static const route_t g_routes[] = { #define ROUTES_COUNT (sizeof(g_routes) / sizeof(g_routes[0])) // Build an "Allow:" header value string from a methods mask. -static void __not_in_flash_func(format_allow)(uint8_t mask, char *out, size_t out_cap) { +static void format_allow(uint8_t mask, char *out, size_t out_cap) { out[0] = '\0'; size_t off = 0; const struct { @@ -4204,7 +4204,7 @@ static void __not_in_flash_func(format_allow)(uint8_t mask, char *out, size_t ou // Detect a trailing "/rename" action suffix and (if present) chop it // off in place by NUL-terminating before the slash. Returns true if // the action was chopped. -static bool __not_in_flash_func(strip_rename_action)(char *rel) { +static bool strip_rename_action(char *rel) { size_t len = strlen(rel); static const char suffix[] = "/rename"; static const size_t suffix_len = sizeof(suffix) - 1; @@ -4215,7 +4215,7 @@ static bool __not_in_flash_func(strip_rename_action)(char *rel) { return false; } -static void __not_in_flash_func(route)(http_conn_t *c) { +static void route(http_conn_t *c) { health_setPhase(HEALTH_PHASE_HTTP_REQUEST); // HEAD is treated as GET for matching purposes (the dispatcher @@ -4431,7 +4431,7 @@ static void __not_in_flash_func(send_buffered)(http_conn_t *c) { // Write a response with optional extra header lines (each must end // with "\r\n"). Pass NULL for no extras. Used for 201 Created (which // also emits a Location header) and 405 (which emits Allow:). -static void __not_in_flash_func(write_response_ex)(http_conn_t *c, int status, const char *reason, +static void write_response_ex(http_conn_t *c, int status, const char *reason, const char *content_type, const char *extra_headers, const char *body, size_t body_len) { @@ -4466,13 +4466,13 @@ static void __not_in_flash_func(write_response_ex)(http_conn_t *c, int status, c send_buffered(c); } -static void __not_in_flash_func(write_response)(http_conn_t *c, int status, const char *reason, +static void write_response(http_conn_t *c, int status, const char *reason, const char *content_type, const char *body, size_t body_len) { write_response_ex(c, status, reason, content_type, NULL, body, body_len); } -static void __not_in_flash_func(write_error)(http_conn_t *c, int status, const char *reason, +static void write_error(http_conn_t *c, int status, const char *reason, const char *code_symbol, const char *message) { char body[256]; int n = snprintf(body, sizeof(body), @@ -4495,7 +4495,7 @@ static void write_fs_error(http_conn_t *c, FRESULT fr, const char *message) { write_error(c, 500, "Internal Server Error", "disk_error", message); } -static void __not_in_flash_func(write_405)(http_conn_t *c, const char *allow) { +static void write_405(http_conn_t *c, const char *allow) { char body[160]; int bn = snprintf(body, sizeof(body), "{\"ok\":false,\"code\":\"method_not_allowed\"," diff --git a/rp/src/runner.c b/rp/src/runner.c index 5ec49aa..70265df 100644 --- a/rp/src/runner.c +++ b/rp/src/runner.c @@ -13,7 +13,7 @@ // (RUNNER_CMD_DONE_EXECUTE so far). The payload follows the same // shape gemdrive_command_cb uses — TPROTO_GET_PAYLOAD_PARAM32 reads // the next 32-bit user payload word in m68k order. -static void __not_in_flash_func(runner_command_cb)( +static void runner_command_cb( TransmissionProtocol *protocol, uint16_t *payload) { switch (protocol->command_id) { case RUNNER_CMD_DONE_EXECUTE: { diff --git a/rp/src/select.c b/rp/src/select.c index 2401d54..d80fddf 100644 --- a/rp/src/select.c +++ b/rp/src/select.c @@ -35,7 +35,7 @@ static uint32_t select_getPressDurationMs(void) { return (uint32_t)(elapsedUs / 1000); } -void __not_in_flash_func(select_waitPush)() { +void select_waitPush() { DPRINTF("Waiting for SELECT button release\n"); if (!select_detectStableState(true)) { diff --git a/rp/src/term.c b/rp/src/term.c index 6292226..f5af210 100644 --- a/rp/src/term.c +++ b/rp/src/term.c @@ -158,7 +158,7 @@ void term_setLastSingleKeyCommand(char key) { lastSingleKeyCommand = key; } * the random token) but term doesn't use it directly — it re-derives the * pointer from the published snapshot inside term_loop(). */ -void __not_in_flash_func(term_command_cb)(TransmissionProtocol *protocol, +void term_command_cb(TransmissionProtocol *protocol, uint16_t *payloadPtr) { (void)payloadPtr; uint8_t writeIndex = protocolWriteIndex; @@ -621,7 +621,7 @@ void term_init(void) { // Invoke this function to process the commands from the active loop in the // main function -void __not_in_flash_func(term_loop)() { +void term_loop() { TransmissionProtocol protocolSnapshot = {0}; bool protocolReady = false; uint32_t overwriteCountSnapshot = 0; diff --git a/tools/dev/flash.sh b/tools/dev/flash.sh index 25136ee..4814c76 100755 --- a/tools/dev/flash.sh +++ b/tools/dev/flash.sh @@ -45,7 +45,11 @@ while [ $# -gt 0 ]; do done NAME="$TYPE" -[ "$SRC" = "$REPO/rp/src" ] || NAME="$TYPE-$(basename "$SRC")" +# A source outside the repo gets its own build folder, keyed by its path: two +# checkouts are both called rp/src, and sharing a folder confuses CMake's cache. +if [ "$SRC" != "$REPO/rp/src" ]; then + NAME="$TYPE-$(basename "$(dirname "$(dirname "$SRC")")")-$(printf '%s' "$SRC" | shasum | cut -c1-6)" +fi OUT="$HERE/builds/$NAME" mkdir -p "$OUT" "$HERE/builds/elf" From 1adb0792709ad345508d3bbd8c64c04c21ebf72c Mon Sep 17 00:00:00 2001 From: Diego Parrilla Date: Wed, 16 Sep 2026 17:23:09 +0200 Subject: [PATCH 02/12] Allocate the folder picker only while it is open (EPIC-12 STORY-02) DirNavigation was 24,774 bytes of permanent BSS for a browser that is open for a few seconds: 256 names of 96 bytes. Upstream allocates it on entry and frees it on exit, which is what this does now. A failed allocation says "Not enough memory to open the folder picker." on the menu instead of following a NULL, and a read error closes the picker with a message too. Release heap 60,048 -> 84,820 bytes, debug 55,900 -> 80,672. Verified on hardware: opening the picker with [o] took the heap from 71,352 to 46,568 bytes (24,784), the listing appeared, and ESC returned it to exactly 71,352. With the heap held at 22,184 bytes free the picker refused with the message on screen and the menu intact. --- rp/src/emul.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/rp/src/emul.c b/rp/src/emul.c index 3c16350..95363dd 100644 --- a/rp/src/emul.c +++ b/rp/src/emul.c @@ -1001,8 +1001,25 @@ typedef struct { char topDir[MAX_FILENAME_LENGTH + 1]; } DirNavigation; -static DirNavigation navStateStorage; -static DirNavigation *navState = &navStateStorage; +// 24.8 KB, so it exists only while the folder picker is open (upstream's +// pattern): allocated when [o] opens the picker, freed when it closes. +static DirNavigation *navState = NULL; + +static bool navStateOpen(void) { + if (navState != NULL) return true; + navState = calloc(1, sizeof(DirNavigation)); + if (navState == NULL) { + DPRINTF("Folder picker: cannot allocate %u bytes\n", + (unsigned)sizeof(DirNavigation)); + return false; + } + return true; +} + +static void navStateClose(void) { + free(navState); + navState = NULL; +} // Filter: directories only — we list folders, never files. Hidden dotfiles // are skipped. Mirrors the spirit of source's floppiesFilter for our case. @@ -1468,6 +1485,11 @@ void cmdGemdriveFolder(const char *arg) { switch (term_getCommandLevel()) { case TERM_COMMAND_LEVEL_SINGLE_KEY: { DPRINTF("Folder picker entering reentry mode.\n"); + if (!navStateOpen()) { + drawSetupInfoLine("Not enough memory to open the folder picker."); + display_refresh(); + return; + } SettingsConfigEntry *gemDriveFolder = settings_find_entry( aconfig_getContext(), ACONFIG_PARAM_GEMDRIVE_FOLDER); const char *seed = @@ -1485,6 +1507,12 @@ void cmdGemdriveFolder(const char *arg) { char key = arg[0]; // ESC cancels the picker and returns to the menu. if (key == 27) { + navStateClose(); + term_setCommandLevel(TERM_COMMAND_LEVEL_SINGLE_KEY); + menu(); + return; + } + if (navState == NULL) { term_setCommandLevel(TERM_COMMAND_LEVEL_SINGLE_KEY); menu(); return; @@ -1508,8 +1536,17 @@ void cmdGemdriveFolder(const char *arg) { settings_put_string(aconfig_getContext(), ACONFIG_PARAM_GEMDRIVE_FOLDER, navState->folderPath); (void)saveAppSettings(); + navStateClose(); + term_setCommandLevel(TERM_COMMAND_LEVEL_SINGLE_KEY); + menu(); + break; + } + case NAV_DIR_ERROR: { + navStateClose(); term_setCommandLevel(TERM_COMMAND_LEVEL_SINGLE_KEY); menu(); + drawSetupInfoLine("Could not read the folder from the SD card."); + display_refresh(); break; } default: From 3d9da75b8677829d3b638e5634ecdf55ec2f5f00 Mon Sep 17 00:00:00 2001 From: Diego Parrilla Date: Wed, 16 Sep 2026 19:02:24 +0200 Subject: [PATCH 03/12] Quieten our interrupts before jumping to Booster (EPIC-12) Pressing [X] left the Atari ST showing this app's farewell screen and Booster never appeared. The jump itself ran: the debug probe showed Booster's stack pointer loaded and VTOR pointing at 0x10120100. But the core was in lockup, PC 0xfffffffe. The jump writes VTOR and branches without stopping anything of ours, so from that instruction on, our interrupts (the buffered console's UART transmit, USB, alarms) vector through Booster's table into handlers it has not installed yet; the fault handler is not installed either, so the core locks up. Masking and clearing every NVIC interrupt first fixes it: after the change the probe reads PC inside Booster's code with its own RAM vector table installed, and Diego confirmed the ST now boots into Booster. The jump sequence itself is unchanged and still matches the template. --- rp/src/gemdrive.c | 2 +- rp/src/include/reset.h | 14 ++++++++++++++ rp/src/runner.c | 2 +- rp/src/term.c | 4 ++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/rp/src/gemdrive.c b/rp/src/gemdrive.c index ad73979..2f03c6f 100644 --- a/rp/src/gemdrive.c +++ b/rp/src/gemdrive.c @@ -1282,7 +1282,7 @@ static void handleDtaReleaseCall(uint16_t *payload) { // Dispatcher // --------------------------------------------------------------------------- -void gemdrive_command_cb(TransmissionProtocol *protocol, +void __not_in_flash_func(gemdrive_command_cb)(TransmissionProtocol *protocol, uint16_t *payload) { if ((protocol->command_id & 0xFF00u) == GEMDRIVE_APP) { health_setPhase(HEALTH_PHASE_GEMDRIVE); diff --git a/rp/src/include/reset.h b/rp/src/include/reset.h index e6f4f3e..ce61b8d 100644 --- a/rp/src/include/reset.h +++ b/rp/src/include/reset.h @@ -13,6 +13,8 @@ #include "debug.h" #include "gconfig.h" #include "health.h" +#include "hardware/irq.h" +#include "hardware/regs/m0plus.h" #include "hardware/sync.h" #include "hardware/watchdog.h" #include "pico/multicore.h" @@ -35,6 +37,18 @@ static inline void reset_jump_to_booster(void) { // The jump does not reset the chip: stop our watchdog, or it reboots // Booster 8 s later. health_prepareJump(); + + // Nor does the jump quieten our interrupts, and from the instruction that + // writes VTOR onwards they would vector through Booster's table, into + // handlers it has not installed yet. One of ours (the buffered console's + // UART transmit, USB, an alarm) then locked the core up: after the jump the + // debug probe read PC 0xfffffffe with Booster's stack pointer loaded, so + // the ST kept showing this app's last screen and Booster never ran. Mask and + // clear every NVIC interrupt first; Booster enables what it needs itself. + irq_set_mask_enabled(0xFFFFFFFFu, false); + *((volatile uint32_t *)(PPB_BASE + M0PLUS_NVIC_ICPR_OFFSET)) = 0xFFFFFFFFu; + __dsb(); + __isb(); // This code jumps to the Booster application at the top of the flash memory. // The reason to perform this jump is for performance reasons. // It should be placed at the beginning of main() if the SELECT signal or diff --git a/rp/src/runner.c b/rp/src/runner.c index 70265df..5ec49aa 100644 --- a/rp/src/runner.c +++ b/rp/src/runner.c @@ -13,7 +13,7 @@ // (RUNNER_CMD_DONE_EXECUTE so far). The payload follows the same // shape gemdrive_command_cb uses — TPROTO_GET_PAYLOAD_PARAM32 reads // the next 32-bit user payload word in m68k order. -static void runner_command_cb( +static void __not_in_flash_func(runner_command_cb)( TransmissionProtocol *protocol, uint16_t *payload) { switch (protocol->command_id) { case RUNNER_CMD_DONE_EXECUTE: { diff --git a/rp/src/term.c b/rp/src/term.c index f5af210..6292226 100644 --- a/rp/src/term.c +++ b/rp/src/term.c @@ -158,7 +158,7 @@ void term_setLastSingleKeyCommand(char key) { lastSingleKeyCommand = key; } * the random token) but term doesn't use it directly — it re-derives the * pointer from the published snapshot inside term_loop(). */ -void term_command_cb(TransmissionProtocol *protocol, +void __not_in_flash_func(term_command_cb)(TransmissionProtocol *protocol, uint16_t *payloadPtr) { (void)payloadPtr; uint8_t writeIndex = protocolWriteIndex; @@ -621,7 +621,7 @@ void term_init(void) { // Invoke this function to process the commands from the active loop in the // main function -void term_loop() { +void __not_in_flash_func(term_loop)() { TransmissionProtocol protocolSnapshot = {0}; bool protocolReady = false; uint32_t overwriteCountSnapshot = 0; From 944e974632541d011ce0a469043e3e513dc2cb44 Mon Sep 17 00:00:00 2001 From: Diego Parrilla Date: Wed, 16 Sep 2026 19:02:24 +0200 Subject: [PATCH 04/12] Give the ST time for a slow SD write, and fail cleanly when it cannot (EPIC-12) Copying 4 MB from the ST to the drive failed with a TOS error and left the last file truncated. The ST waits for the RP's answer to each 1 KB chunk, and an SD write that allocates a cluster and updates the FAT blocks for tens of milliseconds: 70 ms measured on this card, with the console instrumented to report writes over 20 ms. Its budget was nowhere near that. This project had COMMAND_TIMEOUT $0000FFFF and 3 retries, where md-drives-emulator ships $0006FFFF (about 800 ms) and 5 retries for the same protocol, with a comment saying the value exists to cover FatFs SD operations. Both values are restored, in gemdrive.s and runner.s. Three more faults on the same path: - The RP slept up to SLEEP_LOOP_MS before draining the command ring, so every chunk paid that latency while the ST was already waiting. chandler_loop() now runs before the wait as well as after. - A failed write published 0 bytes written, which the ST's loop treats as progress: it would re-issue the same chunk for ever. It now bails out with EIO. - f_write ran without feeding the watchdog, so a card that stalls for 8 s would reboot the RP mid-copy. Every GEMDRIVE function also runs from RAM again (Diego's rule). STORY-01 had moved the command callback to flash, where a first execution waits on the XIP cache while the ST is blocked; only that callback was ever marked before, so the handlers themselves ran from flash even upstream. Costs about 16 KB: debug heap 80,672 -> 64,288 bytes, still +41,156 on the epic's start. term.c no longer traces every command (two lines per 1 KB chunk broke the transfer by itself; EPIC-10 STORY-04 left that trimming open), and debug builds report only writes slower than GEMDRIVE_SLOW_WRITE_US. Verified on hardware: eight 512 KB files copied from the ST, all exactly 524,288 bytes, on release and on debug. --- rp/src/emul.c | 7 +- rp/src/gemdrive.c | 149 ++++++----- rp/src/include/gemdrive.h | 3 + rp/src/include/target_firmware.h | 416 +++++++++++++++---------------- rp/src/term.c | 10 +- target/atarist/src/gemdrive.s | 12 +- target/atarist/src/runner.s | 5 +- 7 files changed, 322 insertions(+), 280 deletions(-) diff --git a/rp/src/emul.c b/rp/src/emul.c index 95363dd..b0b8df1 100644 --- a/rp/src/emul.c +++ b/rp/src/emul.c @@ -2048,13 +2048,18 @@ void emul_start() { while (getKeepActive()) { health_feed(); health_setPhase(HEALTH_PHASE_MAIN_LOOP); + // Drain the ROM3 command ring → dispatch to registered callbacks. First, + // before the wait below: the ST blocks on its answer, and nothing here + // wakes the wait early for a cartridge command, so a command that arrived + // during the wait would otherwise sit for the whole SLEEP_LOOP_MS. + chandler_loop(); + #if PICO_CYW43_ARCH_POLL network_safePoll(); cyw43_arch_wait_for_work_until(make_timeout_time_ms(SLEEP_LOOP_MS)); #else sleep_ms(SLEEP_LOOP_MS); #endif - // Drain the ROM3 command ring → dispatch to registered callbacks. chandler_loop(); // Pump pending debug bytes out the USB CDC interface. diff --git a/rp/src/gemdrive.c b/rp/src/gemdrive.c index 2f03c6f..6077f33 100644 --- a/rp/src/gemdrive.c +++ b/rp/src/gemdrive.c @@ -81,28 +81,28 @@ static bool gemdrivePhystopMismatch = false; // aconfig helpers // --------------------------------------------------------------------------- -static uint32_t aconfigInt(const char *key) { +static uint32_t __not_in_flash_func(aconfigInt)(const char *key) { SettingsConfigEntry *entry = settings_find_entry(aconfig_getContext(), key); if (entry == NULL) return 0; return (uint32_t)strtoul(entry->value, NULL, 0); } -static bool aconfigBool(const char *key, bool defaultValue) { +static bool __not_in_flash_func(aconfigBool)(const char *key, bool defaultValue) { SettingsConfigEntry *entry = settings_find_entry(aconfig_getContext(), key); if (entry == NULL) return defaultValue; return strcmp(entry->value, "true") == 0; } -static const char *aconfigString(const char *key, const char *defaultValue) { +static const char *__not_in_flash_func(aconfigString)(const char *key, const char *defaultValue) { SettingsConfigEntry *entry = settings_find_entry(aconfig_getContext(), key); if (entry == NULL) return defaultValue; return entry->value; } -static char resolveDriveLetter(void) { +static char __not_in_flash_func(resolveDriveLetter)(void) { const char *value = aconfigString(ACONFIG_PARAM_GEMDRIVE_DRIVE, "C"); if (value == NULL || value[0] == '\0') return 'C'; char letter = (char)toupper((unsigned char)value[0]); @@ -120,29 +120,29 @@ static char resolveDriveLetter(void) { // (filename) use memcpy + CHANGE_ENDIANESS_BLOCK16. // --------------------------------------------------------------------------- -static uint32_t sharedBaseAddress(void) { +static uint32_t __not_in_flash_func(sharedBaseAddress)(void) { return (uint32_t)&__rom_in_ram_start__; } -static uint32_t appFreeAddress(void) { +static uint32_t __not_in_flash_func(appFreeAddress)(void) { return sharedBaseAddress() + CHANDLER_APP_FREE_OFFSET; } -static void writeAppFreeLong(uint32_t offsetFromAppFree, uint32_t value) { +static void __not_in_flash_func(writeAppFreeLong)(uint32_t offsetFromAppFree, uint32_t value) { WRITE_AND_SWAP_LONGWORD(appFreeAddress(), offsetFromAppFree, value); } -static void writeAppFreeWord(uint32_t offsetFromAppFree, uint16_t value) { +static void __not_in_flash_func(writeAppFreeWord)(uint32_t offsetFromAppFree, uint16_t value) { WRITE_WORD(appFreeAddress(), offsetFromAppFree, value); } -static void writeAppFreeBytes(uint32_t offsetFromAppFree, const void *data, +static void __not_in_flash_func(writeAppFreeBytes)(uint32_t offsetFromAppFree, const void *data, size_t length) { uint8_t *dst = (uint8_t *)(appFreeAddress() + offsetFromAppFree); memcpy(dst, data, length); } -static void writeAppFreeBytesSwapped(uint32_t offsetFromAppFree, +static void __not_in_flash_func(writeAppFreeBytesSwapped)(uint32_t offsetFromAppFree, const void *data, size_t length) { uint8_t *dst = (uint8_t *)(appFreeAddress() + offsetFromAppFree); memcpy(dst, data, length); @@ -165,7 +165,7 @@ static void writeAppFreeBytesSwapped(uint32_t offsetFromAppFree, // 2. "\foo" → absolute on the emulated drive, take verbatim under // hdFolder (ignore dpathStr). // 3. "foo" → relative, prepend hdFolder + dpathStr. -static void getLocalFullPathname(const char *atariPath, char *out, +static void __not_in_flash_func(getLocalFullPathname)(const char *atariPath, char *out, size_t outSize) { const char *folder = aconfigString(ACONFIG_PARAM_GEMDRIVE_FOLDER, "/devops"); @@ -223,7 +223,7 @@ static void getLocalFullPathname(const char *atariPath, char *out, // volumes the short name is what the Atari sees. // --------------------------------------------------------------------------- -static bool wildcardMatch(const char *pat, const char *name) { +static bool __not_in_flash_func(wildcardMatch)(const char *pat, const char *name) { while (*pat) { if (*pat == '*') { pat++; @@ -249,7 +249,7 @@ static bool wildcardMatch(const char *pat, const char *name) { // File-handle table // --------------------------------------------------------------------------- -static int allocFileSlot(void) { +static int __not_in_flash_func(allocFileSlot)(void) { for (int i = 0; i < GEMDRIVE_MAX_OPEN_FILES; i++) { if (!fileTable[i].inUse) { fileTable[i].inUse = true; @@ -260,7 +260,7 @@ static int allocFileSlot(void) { return -1; } -static GemFileSlot *fileSlotByHandle(uint16_t handle) { +static GemFileSlot *__not_in_flash_func(fileSlotByHandle)(uint16_t handle) { if (handle < GEMDRIVE_FIRST_FD) return NULL; int idx = handle - GEMDRIVE_FIRST_FD; if (idx < 0 || idx >= GEMDRIVE_MAX_OPEN_FILES) return NULL; @@ -268,9 +268,9 @@ static GemFileSlot *fileSlotByHandle(uint16_t handle) { return &fileTable[idx]; } -static int handleFromSlotIndex(int idx) { return GEMDRIVE_FIRST_FD + idx; } +static int __not_in_flash_func(handleFromSlotIndex)(int idx) { return GEMDRIVE_FIRST_FD + idx; } -static void releaseFileSlot(int idx) { +static void __not_in_flash_func(releaseFileSlot)(int idx) { if (idx < 0 || idx >= GEMDRIVE_MAX_OPEN_FILES) return; fileTable[idx].inUse = false; } @@ -279,7 +279,7 @@ static void releaseFileSlot(int idx) { // DTA tracking // --------------------------------------------------------------------------- -static GemDtaSlot *findDtaSlot(uint32_t dtaAddr) { +static GemDtaSlot *__not_in_flash_func(findDtaSlot)(uint32_t dtaAddr) { for (int i = 0; i < GEMDRIVE_MAX_DTAS; i++) { if (dtaTable[i].inUse && dtaTable[i].dtaAddr == dtaAddr) { dtaTable[i].lruStamp = ++dtaLruCounter; @@ -293,7 +293,7 @@ static GemDtaSlot *findDtaSlot(uint32_t dtaAddr) { // we approximate with a fixed table + LRU eviction so the table can // never refuse an Fsfirst (which would crash the desktop's directory // walk). The slot least-recently-touched wins eviction. -static GemDtaSlot *allocDtaSlot(uint32_t dtaAddr) { +static GemDtaSlot *__not_in_flash_func(allocDtaSlot)(uint32_t dtaAddr) { GemDtaSlot *existing = findDtaSlot(dtaAddr); if (existing != NULL) { if (existing->hasDir) { @@ -331,7 +331,7 @@ static GemDtaSlot *allocDtaSlot(uint32_t dtaAddr) { return &dtaTable[victim]; } -static void releaseDtaSlot(uint32_t dtaAddr) { +static void __not_in_flash_func(releaseDtaSlot)(uint32_t dtaAddr) { GemDtaSlot *slot = findDtaSlot(dtaAddr); if (slot == NULL) return; if (slot->hasDir) { @@ -347,9 +347,9 @@ static void releaseDtaSlot(uint32_t dtaAddr) { // 22-23=DOS time, 24-25=DOS date, 26-29=size, 30-43=8.3 filename. // --------------------------------------------------------------------------- -static void normalizeShort83(const char *src, char out[14]); +static void __not_in_flash_func(normalizeShort83)(const char *src, char out[14]); -static void writeDtaFromFilinfo(const FILINFO *info) { +static void __not_in_flash_func(writeDtaFromFilinfo)(const FILINFO *info) { // Drive number at offset 12 so m68k Fsnext can verify it. WRITE_AND_SWAP_LONGWORD(appFreeAddress(), GEMDRIVE_DTA_TRANSFER_OFFSET + 12, @@ -376,7 +376,7 @@ static void writeDtaFromFilinfo(const FILINFO *info) { writeAppFreeWord(GEMDRIVE_DTA_F_FOUND_OFFSET, 0); // 0 = found } -static void clearDtaFound(uint16_t errorCode) { +static void __not_in_flash_func(clearDtaFound)(uint16_t errorCode) { writeAppFreeWord(GEMDRIVE_DTA_F_FOUND_OFFSET, errorCode); } @@ -384,7 +384,7 @@ static void clearDtaFound(uint16_t errorCode) { // Handlers // --------------------------------------------------------------------------- -static void publishDriveAndReentry(uint8_t driveNumber, char driveLetter) { +static void __not_in_flash_func(publishDriveAndReentry)(uint8_t driveNumber, char driveLetter) { uint32_t base = sharedBaseAddress(); SET_SHARED_VAR(GEMDRIVE_SVAR_DRIVE_NUMBER, driveNumber, base, CHANDLER_SHARED_VARIABLES_OFFSET); @@ -396,7 +396,7 @@ static void publishDriveAndReentry(uint8_t driveNumber, char driveLetter) { base, CHANDLER_SHARED_VARIABLES_OFFSET); } -static void handleSaveVectors(uint16_t *payload) { +static void __not_in_flash_func(handleSaveVectors)(uint16_t *payload) { uint32_t oldVec = TPROTO_GET_PAYLOAD_PARAM32(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); uint32_t cellAddr = TPROTO_GET_PAYLOAD_PARAM32(payload); @@ -413,7 +413,7 @@ static void handleSaveVectors(uint16_t *payload) { (unsigned long)oldVec, (unsigned long)cellAddr); } -static void handleResetGem(void) { +static void __not_in_flash_func(handleResetGem)(void) { for (int i = 0; i < GEMDRIVE_MAX_OPEN_FILES; i++) { if (fileTable[i].inUse) { f_close(&fileTable[i].fp); @@ -436,17 +436,17 @@ static void handleResetGem(void) { DPRINTF("GEMDRIVE RESET_GEM: cleared file/DTA state.\n"); } -static void handleReentryLock(void) { +static void __not_in_flash_func(handleReentryLock)(void) { SET_SHARED_VAR(GEMDRIVE_SVAR_REENTRY_TRAP, 1, sharedBaseAddress(), CHANDLER_SHARED_VARIABLES_OFFSET); } -static void handleReentryUnlock(void) { +static void __not_in_flash_func(handleReentryUnlock)(void) { SET_SHARED_VAR(GEMDRIVE_SVAR_REENTRY_TRAP, 0, sharedBaseAddress(), CHANDLER_SHARED_VARIABLES_OFFSET); } -static void handleDfreeCall(void) { +static void __not_in_flash_func(handleDfreeCall)(void) { FATFS *fs = NULL; DWORD freeClusters = 0; uint32_t status = 0, totalFree = 0, totalClusters = 0; @@ -478,7 +478,7 @@ static void handleDfreeCall(void) { // Receives a 256-byte path buffer; concatenates with existing dpathStr // if relative, replaces it if absolute. Validates with f_stat under // hdFolder. Writes status to GEMDRIVE_SET_DPATH_STATUS. -static void handleDsetpathCall(uint16_t *payload) { +static void __not_in_flash_func(handleDsetpathCall)(uint16_t *payload) { TPROTO_NEXT32_PAYLOAD_PTR(payload); // skip d3 TPROTO_NEXT32_PAYLOAD_PTR(payload); // skip d4 TPROTO_NEXT32_PAYLOAD_PTR(payload); // skip d5 @@ -548,13 +548,13 @@ static void handleDsetpathCall(uint16_t *payload) { } // Forward declarations: definitions live further down. -static void readPayloadAtariPath(uint16_t *payload, char *out, size_t outSize); -static void normalizeShort83(const char *src, char out[14]); -static uint8_t attribsStToFat(uint8_t stAttribs); +static void __not_in_flash_func(readPayloadAtariPath)(uint16_t *payload, char *out, size_t outSize); +static void __not_in_flash_func(normalizeShort83)(const char *src, char out[14]); +static uint8_t __not_in_flash_func(attribsStToFat)(uint8_t stAttribs); // ---- S5: Fsetdta / DTA exist / Pexec / SAVE_BASEPAGE / SAVE_EXEC_HEADER ---- -static void handleFsetdtaCall(uint16_t *payload) { +static void __not_in_flash_func(handleFsetdtaCall)(uint16_t *payload) { uint32_t dtaAddr = TPROTO_GET_PAYLOAD_PARAM32(payload); // Match md-drives-emulator's insertDTA: if a slot for this address // already exists, leave its iterator state alone — Fsetdta is just @@ -576,7 +576,7 @@ static void handleFsetdtaCall(uint16_t *payload) { (unsigned long)dtaAddr); } -static void handleDtaExistCall(uint16_t *payload) { +static void __not_in_flash_func(handleDtaExistCall)(uint16_t *payload) { uint32_t dtaAddr = TPROTO_GET_PAYLOAD_PARAM32(payload); GemDtaSlot *slot = findDtaSlot(dtaAddr); uint32_t result = (slot != NULL) ? dtaAddr : 0; @@ -588,7 +588,7 @@ static void handleDtaExistCall(uint16_t *payload) { // to skip past the frame's leading 6 bytes (PC.l + SR.w + funcCode.w = // 8 bytes, but the protocol layout starts the buffer 8 words into // payload — see md-drives-emulator/rp/src/gemdrive.c line 2170). -static void handlePexecCall(uint16_t *payload) { +static void __not_in_flash_func(handlePexecCall)(uint16_t *payload) { uint32_t stackAddr = TPROTO_GET_PAYLOAD_PARAM32(payload); // Source skips 6 words to reach the buffer start (4 d-regs + framing), @@ -618,7 +618,7 @@ static void handlePexecCall(uint16_t *payload) { } // SAVE_EXEC_HEADER: m68k just shipped 28 bytes of PRG header, copy as-is. -static void handleSaveExecHeader(uint16_t *payload) { +static void __not_in_flash_func(handleSaveExecHeader)(uint16_t *payload) { TPROTO_NEXT32_PAYLOAD_PTR(payload); // skip d3 TPROTO_NEXT32_PAYLOAD_PTR(payload); // skip d4 TPROTO_NEXT32_PAYLOAD_PTR(payload); // skip d5 @@ -629,7 +629,7 @@ static void handleSaveExecHeader(uint16_t *payload) { } // SAVE_BASEPAGE: 256 bytes of basepage. -static void handleSaveBasepage(uint16_t *payload) { +static void __not_in_flash_func(handleSaveBasepage)(uint16_t *payload) { TPROTO_NEXT32_PAYLOAD_PTR(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); @@ -640,7 +640,7 @@ static void handleSaveBasepage(uint16_t *payload) { // ---- Write-side handlers (direct ports of md-drives-emulator) ---- -static void handleDcreateCall(uint16_t *payload) { +static void __not_in_flash_func(handleDcreateCall)(uint16_t *payload) { TPROTO_NEXT32_PAYLOAD_PTR(payload); // skip d3 TPROTO_NEXT32_PAYLOAD_PTR(payload); // skip d4 TPROTO_NEXT32_PAYLOAD_PTR(payload); // skip d5 @@ -657,7 +657,7 @@ static void handleDcreateCall(uint16_t *payload) { writeAppFreeWord(GEMDRIVE_DCREATE_STATUS_OFFSET, status); } -static void handleDdeleteCall(uint16_t *payload) { +static void __not_in_flash_func(handleDdeleteCall)(uint16_t *payload) { TPROTO_NEXT32_PAYLOAD_PTR(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); @@ -682,7 +682,7 @@ static void handleDdeleteCall(uint16_t *payload) { writeAppFreeWord(GEMDRIVE_DDELETE_STATUS_OFFSET, status); } -static void handleFcreateCall(uint16_t *payload) { +static void __not_in_flash_func(handleFcreateCall)(uint16_t *payload) { uint16_t mode = TPROTO_GET_PAYLOAD_PARAM16(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); @@ -725,7 +725,7 @@ static void handleFcreateCall(uint16_t *payload) { writeAppFreeWord(GEMDRIVE_FCREATE_HANDLE_OFFSET, (uint16_t)handle); } -static void handleFdeleteCall(uint16_t *payload) { +static void __not_in_flash_func(handleFdeleteCall)(uint16_t *payload) { TPROTO_NEXT32_PAYLOAD_PTR(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); @@ -750,7 +750,7 @@ static void handleFdeleteCall(uint16_t *payload) { writeAppFreeLong(GEMDRIVE_FDELETE_STATUS_OFFSET, status); } -static void handleFattribCall(uint16_t *payload) { +static void __not_in_flash_func(handleFattribCall)(uint16_t *payload) { uint16_t flag = TPROTO_GET_PAYLOAD_PARAM16(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); uint16_t newAttribs = TPROTO_GET_PAYLOAD_PARAM16(payload); @@ -785,7 +785,7 @@ static void handleFattribCall(uint16_t *payload) { (unsigned)flag, (unsigned)newAttribs, (int)res); } -static void handleFrenameCall(uint16_t *payload) { +static void __not_in_flash_func(handleFrenameCall)(uint16_t *payload) { TPROTO_NEXT32_PAYLOAD_PTR(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); @@ -824,7 +824,7 @@ static void handleFrenameCall(uint16_t *payload) { // d4=handle, d5=DOS time word in low half, d6=DOS date word in low half. // On get: read fattrib's date/time from f_stat by looking up the open // file's path (we keep one in the slot for tracking — see below). -static void handleFdatetimeCall(uint16_t *payload) { +static void __not_in_flash_func(handleFdatetimeCall)(uint16_t *payload) { uint16_t flag = TPROTO_GET_PAYLOAD_PARAM16(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); uint16_t handle = TPROTO_GET_PAYLOAD_PARAM16(payload); @@ -854,7 +854,7 @@ static void handleFdatetimeCall(uint16_t *payload) { writeAppFreeLong(GEMDRIVE_FDATETIME_STATUS_OFFSET, 0); } -static void handleWriteBuffCall(uint16_t *payload) { +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); @@ -874,8 +874,27 @@ static void handleWriteBuffCall(uint16_t *payload) { COPY_AND_CHANGE_ENDIANESS_BLOCK16(payload, tmp, (bytes + 1) & ~1); UINT bw = 0; + // An SD write can block for tens of milliseconds, and much longer on a card + // that stalls; the dispatcher already set the GEMDRIVE phase, so just keep + // the watchdog fed either side of it (CLAUDE.md). + health_feed(); +#if defined(_DEBUG) && (_DEBUG != 0) + // A write that blocks longer than the ST is willing to wait breaks its + // synchronous handshake, so report only the slow ones. + uint32_t writeStartUs = (uint32_t)time_us_32(); +#endif FRESULT res = f_write(&slot->fp, tmp, (UINT)bytes, &bw); +#if defined(_DEBUG) && (_DEBUG != 0) + uint32_t writeUs = (uint32_t)time_us_32() - writeStartUs; + if (writeUs > GEMDRIVE_SLOW_WRITE_US) { + DPRINTF("GEMDRIVE Fwrite: slow, %lu us for %u bytes\n", + (unsigned long)writeUs, (unsigned)bytes); + } +#endif + health_feed(); 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. DPRINTF("GEMDRIVE Fwrite: handle=%u fr=%d\n", (unsigned)handle, (int)res); writeAppFreeLong(GEMDRIVE_WRITE_BYTES_OFFSET, 0); return; @@ -883,7 +902,7 @@ static void handleWriteBuffCall(uint16_t *payload) { writeAppFreeLong(GEMDRIVE_WRITE_BYTES_OFFSET, (uint32_t)bw); } -static void handleDgetpathCall(void) { +static void __not_in_flash_func(handleDgetpathCall)(void) { size_t len = strlen(dpathStr); if (len >= GEMDRIVE_DEFAULT_PATH_LEN) len = GEMDRIVE_DEFAULT_PATH_LEN - 1; writeAppFreeBytes(GEMDRIVE_DEFAULT_PATH_OFFSET, dpathStr, len); @@ -897,7 +916,7 @@ static void handleDgetpathCall(void) { // with every pair swapped (e.g. "DESKTOP.INF" → "EDKSOT.PNI"). Use the // shared CHANGE_ENDIANESS helper to undo that, matching what // md-drives-emulator's getLocalFullPathname does. -static void readPayloadAtariPath(uint16_t *payload, char *out, +static void __not_in_flash_func(readPayloadAtariPath)(uint16_t *payload, char *out, size_t outSize) { if (outSize == 0) return; size_t copy = outSize - 1; @@ -910,7 +929,7 @@ static void readPayloadAtariPath(uint16_t *payload, char *out, } } -static void handleFopenCall(uint16_t *payload) { +static void __not_in_flash_func(handleFopenCall)(uint16_t *payload) { // The send_write_sync_far macro sent: d0=cmd, d1=size, d3=mode, // d4 unused, d5 unused, d6=size. Then the buffer (256 bytes from a4 = // pattern address) follows. Chandler's ring captures both the args @@ -965,7 +984,7 @@ static void handleFopenCall(uint16_t *payload) { writeAppFreeLong(GEMDRIVE_FOPEN_HANDLE_OFFSET, (uint32_t)handle); } -static void handleFcloseCall(uint16_t *payload) { +static void __not_in_flash_func(handleFcloseCall)(uint16_t *payload) { uint16_t handle = (uint16_t)TPROTO_GET_PAYLOAD_PARAM32(payload); GemFileSlot *slot = fileSlotByHandle(handle); if (slot == NULL) { @@ -978,7 +997,7 @@ static void handleFcloseCall(uint16_t *payload) { (res == FR_OK) ? 0 : (uint32_t)-37); } -static void handleFseekCall(uint16_t *payload) { +static void __not_in_flash_func(handleFseekCall)(uint16_t *payload) { uint32_t offset = TPROTO_GET_PAYLOAD_PARAM32(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); uint16_t handle = (uint16_t)TPROTO_GET_PAYLOAD_PARAM32(payload); @@ -1014,7 +1033,7 @@ static void handleFseekCall(uint16_t *payload) { writeAppFreeLong(GEMDRIVE_FSEEK_STATUS_OFFSET, (uint32_t)f_tell(&slot->fp)); } -static void handleReadBuffCall(uint16_t *payload) { +static void __not_in_flash_func(handleReadBuffCall)(uint16_t *payload) { uint16_t handle = (uint16_t)TPROTO_GET_PAYLOAD_PARAM32(payload); TPROTO_NEXT32_PAYLOAD_PTR(payload); uint32_t bytesThisChunk = TPROTO_GET_PAYLOAD_PARAM32(payload); @@ -1043,7 +1062,7 @@ static void handleReadBuffCall(uint16_t *payload) { writeAppFreeLong(GEMDRIVE_READ_BYTES_OFFSET, (uint32_t)bytesRead); } -static void splitDirAndPattern(const char *atariSpec, char *outDir, +static void __not_in_flash_func(splitDirAndPattern)(const char *atariSpec, char *outDir, size_t outDirSize, char *outPattern, size_t outPatSize) { // Find the last separator. Atari uses '\\'; tolerate '/' too. @@ -1082,14 +1101,14 @@ static void splitDirAndPattern(const char *atariSpec, char *outDir, // Skip noise that desktops shouldn't see and that md-drives-emulator // also filters: dotfiles ("._foo" macOS metadata, "." / ".." entries). -static bool isHiddenEntry(const FILINFO *info) { +static bool __not_in_flash_func(isHiddenEntry)(const FILINFO *info) { if (info->fname[0] == '.') return true; if (info->fname[0] == '\0') return true; return false; } // FAT→ST attribute mask — direct port of source's sdcard_attribsFAT2ST. -static uint8_t attribsFatToSt(uint8_t fatAttribs) { +static uint8_t __not_in_flash_func(attribsFatToSt)(uint8_t fatAttribs) { return fatAttribs & (AM_RDO | AM_HID | AM_SYS | AM_DIR | AM_ARC); } @@ -1097,14 +1116,14 @@ static uint8_t attribsFatToSt(uint8_t fatAttribs) { // FS_ST_* bit positions match AM_* exactly for read-only/hidden/system/ // directory/archive, so masking on those bits gives the right FatFs // attribute byte. -static uint8_t attribsStToFat(uint8_t stAttribs) { +static uint8_t __not_in_flash_func(attribsStToFat)(uint8_t stAttribs) { return stAttribs & (AM_RDO | AM_HID | AM_SYS | AM_DIR | AM_ARC); } // Returns true when this entry should be visible per the caller's // `attribs` mask. Source: `(attribs & sdcard_attribsFAT2ST(fattrib))`, // with FS_ST_ARCH OR'd into attribs unless FS_ST_LABEL was already set. -static bool entryMatchesAttribs(const FILINFO *info, uint8_t attribs) { +static bool __not_in_flash_func(entryMatchesAttribs)(const FILINFO *info, uint8_t attribs) { uint8_t st = attribsFatToSt(info->fattrib); uint8_t want = attribs; // Normal files always have ARCH set in FAT — match source's "OR ARCH @@ -1118,7 +1137,7 @@ static bool entryMatchesAttribs(const FILINFO *info, uint8_t attribs) { // Skip dot-prefixed entries AND entries that don't match the caller's // attribs mask. Mirrors the source's combined while-loop. -static FRESULT advancePastFiltered(DIR *dir, FILINFO *info, uint8_t attribs) { +static FRESULT __not_in_flash_func(advancePastFiltered)(DIR *dir, FILINFO *info, uint8_t attribs) { FRESULT res = FR_OK; while (res == FR_OK && info->fname[0] && (isHiddenEntry(info) || !entryMatchesAttribs(info, attribs))) { @@ -1132,7 +1151,7 @@ static FRESULT advancePastFiltered(DIR *dir, FILINFO *info, uint8_t attribs) { // Up to 8 chars before '.', up to 3 after; if base too long, suffix // "~1" before truncating; uppercase; strip everything that isn't an // alphanumeric or one of the DOS-friendly punctuation characters. -static int isDosNameChar(int c) { +static int __not_in_flash_func(isDosNameChar)(int c) { static const char allowed[] = "_!@#$%^&()+=-~`;'<,>.|[]{}"; if (c >= '0' && c <= '9') return 1; if (c >= 'A' && c <= 'Z') return 1; @@ -1143,7 +1162,7 @@ static int isDosNameChar(int c) { return 0; } -static void normalizeShort83(const char *src, char out[14]) { +static void __not_in_flash_func(normalizeShort83)(const char *src, char out[14]) { // Filter + upper-case in one pass. char filtered[14] = {0}; size_t fi = 0; @@ -1185,7 +1204,7 @@ static void normalizeShort83(const char *src, char out[14]) { } } -static void handleFsfirstCall(uint16_t *payload) { +static void __not_in_flash_func(handleFsfirstCall)(uint16_t *payload) { // Match md-drives-emulator's payload-walk: 1 PARAM32 + 2 NEXT32_PARAM32 // + 1 NEXT32 advances `payload` to the start of the pattern buffer. uint32_t dtaAddr = TPROTO_GET_PAYLOAD_PARAM32(payload); @@ -1249,7 +1268,7 @@ static void handleFsfirstCall(uint16_t *payload) { writeDtaFromFilinfo(&info); } -static void handleFsnextCall(uint16_t *payload) { +static void __not_in_flash_func(handleFsnextCall)(uint16_t *payload) { uint32_t dtaAddr = TPROTO_GET_PAYLOAD_PARAM32(payload); GemDtaSlot *slot = findDtaSlot(dtaAddr); if (slot == NULL) { @@ -1273,7 +1292,7 @@ static void handleFsnextCall(uint16_t *payload) { writeDtaFromFilinfo(&info); } -static void handleDtaReleaseCall(uint16_t *payload) { +static void __not_in_flash_func(handleDtaReleaseCall)(uint16_t *payload) { uint32_t dtaAddr = TPROTO_GET_PAYLOAD_PARAM32(payload); releaseDtaSlot(dtaAddr); } @@ -1466,21 +1485,21 @@ void __not_in_flash_func(gemdrive_command_cb)(TransmissionProtocol *protocol, emul_onGemdriveHello(); } -void gemdrive_init(void) { +void __not_in_flash_func(gemdrive_init)(void) { for (int i = 0; i < GEMDRIVE_MAX_OPEN_FILES; i++) fileTable[i].inUse = false; for (int i = 0; i < GEMDRIVE_MAX_DTAS; i++) dtaTable[i].inUse = false; chandler_addCB(gemdrive_command_cb); DPRINTF("GEMDRIVE callback registered.\n"); } -bool gemdrive_getPhystop(uint32_t *out_phystop, bool *out_mismatch) { +bool __not_in_flash_func(gemdrive_getPhystop)(uint32_t *out_phystop, bool *out_mismatch) { if (!gemdriveHelloLanded) return false; if (out_phystop != NULL) *out_phystop = gemdrivePhystop; if (out_mismatch != NULL) *out_mismatch = gemdrivePhystopMismatch; return true; } -bool gemdrive_getScreenmem(uint32_t *out_screenmem) { +bool __not_in_flash_func(gemdrive_getScreenmem)(uint32_t *out_screenmem) { if (!gemdriveHelloLanded) return false; if (out_screenmem != NULL) *out_screenmem = gemdriveScreenmem; return true; diff --git a/rp/src/include/gemdrive.h b/rp/src/include/gemdrive.h index 8d42d6f..6638db2 100644 --- a/rp/src/include/gemdrive.h +++ b/rp/src/include/gemdrive.h @@ -101,6 +101,9 @@ #define GEMDRIVE_WRITE_BYTES_OFFSET 0x10F0 // 4 bytes (bytes written) #define GEMDRIVE_WRITE_BUFFER_OFFSET 0x10F4 // 1024 bytes #define GEMDRIVE_WRITE_BUFFER_SIZE 1024 +// 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 // Pexec / DTA state. #define GEMDRIVE_PEXEC_MODE_OFFSET 0x14F4 // 4 bytes (mode word at +2) diff --git a/rp/src/include/target_firmware.h b/rp/src/include/target_firmware.h index bfc775b..8c825b9 100644 --- a/rp/src/include/target_firmware.h +++ b/rp/src/include/target_firmware.h @@ -1,6 +1,6 @@ const uint16_t target_firmware[] __attribute__((aligned(4))) = { - 0xABCD, 0xEF42, 0x0000, 0x0000, 0x08FA, 0x001E, 0x0000, 0x0000, 0x8C97, 0x5D2F, 0x0000, 0x06B4, 0x5445, 0x524D, 0x0000, 0x6100, - 0x0594, 0x3F3C, 0x0002, 0x4E4E, 0x548F, 0x2440, 0x45EA, 0xF000, 0x264A, 0x2C3C, 0x0000, 0x056A, 0x43F9, 0x00FA, 0x004A, 0xE44E, + 0xABCD, 0xEF42, 0x0000, 0x0000, 0x08FA, 0x001E, 0x0000, 0x0000, 0x83BC, 0x5D30, 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, 0x3401, 0x20C2, 0x20C2, 0x51C8, 0xFFF0, 0x2C39, 0x00FA, 0x2800, 0xBCBC, 0x0000, 0x0003, 0x6664, 0x3F3C, 0x000B, 0x4E41, 0x548F, @@ -23,7 +23,7 @@ const uint16_t target_firmware[] __attribute__((aligned(4))) = { 0x7F00, 0x7204, 0x303C, 0x0001, 0x6100, 0x0118, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x6000, 0x0020, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0000, 0x6100, 0x00F6, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x6000, 0xFEAC, 0x2C3C, 0x000F, 0xFFFF, 0x5386, 0x66FC, 0x42B8, 0x0420, 0x42B8, 0x043A, 0x42B8, 0x051A, 0x2078, 0x0004, 0x4ED0, 0x4E71, 0x4E75, 0x4EB9, - 0x00FA, 0x063C, 0x4EF9, 0x00FA, 0x0804, 0x4EB9, 0x00FA, 0x063C, 0x4EF9, 0x00FA, 0x1C00, 0x2038, 0x05A0, 0x6700, 0x001A, 0x2040, + 0x00FA, 0x064C, 0x4EF9, 0x00FA, 0x0804, 0x4EB9, 0x00FA, 0x064C, 0x4EF9, 0x00FA, 0x1C00, 0x2038, 0x05A0, 0x6700, 0x001A, 0x2040, 0x2018, 0x6700, 0x0012, 0xB0BC, 0x5F4D, 0x4348, 0x6704, 0x5848, 0x60EE, 0x2818, 0x6002, 0x4284, 0x2F04, 0x263C, 0x0000, 0x0000, 0x3E3C, 0x0003, 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, @@ -35,26 +35,26 @@ const uint16_t target_firmware[] __attribute__((aligned(4))) = { 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, 0x0000, 0xFFFF, 0x7000, 0xB491, 0x6706, 0x5387, 0x66F8, 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, 0x0000, 0xFFFF, 0x7000, 0xB491, 0x6706, 0x5386, 0x66F8, 0x5380, 0x4E75, 0x48E7, 0xFFF0, 0x3F3C, 0x0002, 0x4E4E, 0x548F, - 0x2600, 0x2838, 0x042E, 0x7A00, 0x7000, 0x1039, 0xFFFF, 0x8001, 0xC07C, 0x000F, 0xB03C, 0x0000, 0x6608, 0x2A3C, 0x0000, 0x0100, - 0x6036, 0xB03C, 0x0004, 0x6608, 0x2A3C, 0x0000, 0x0280, 0x6028, 0xB03C, 0x0005, 0x6608, 0x2A3C, 0x0000, 0x0400, 0x601A, 0xB03C, - 0x0008, 0x6608, 0x2A3C, 0x0000, 0x0880, 0x600C, 0xB03C, 0x000A, 0x6606, 0x2A3C, 0x0000, 0x1000, 0x3E3C, 0x0003, 0x48E7, 0x7F00, - 0x720C, 0x303C, 0x0450, 0x6100, 0xFD9A, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4CDF, 0x0FFF, 0x4E75, 0x48E7, 0xFFF0, - 0x2039, 0x00FA, 0x2838, 0x2239, 0x00FA, 0x283C, 0x2600, 0x280F, 0xB883, 0x6500, 0x000E, 0xD6BC, 0x0000, 0x4000, 0xB883, 0x6500, - 0x0028, 0x2240, 0x207C, 0x00FA, 0x0800, 0x243C, 0x0000, 0x1400, 0xE44A, 0x5342, 0x22D8, 0x51CA, 0xFFFC, 0x21C1, 0x0436, 0x2240, - 0x4E91, 0x4CDF, 0x0FFF, 0x4E75, 0x4879, 0x00FA, 0x0698, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x60FE, 0x0D0A, 0x5265, 0x6C6F, 0x632F, - 0x7374, 0x6163, 0x6B20, 0x6F76, 0x6572, 0x6C61, 0x702E, 0x0D0A, 0x5261, 0x6973, 0x6520, 0x5B52, 0x5D20, 0x696E, 0x2073, 0x6574, - 0x7570, 0x206D, 0x656E, 0x752C, 0x2072, 0x6573, 0x6574, 0x2E0D, 0x0A00, 0xDEAD, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x7000, 0x4842, 0x2E3C, 0x0000, 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, 0x0000, 0xFFFF, 0x7000, 0xB491, 0x6608, 0xB4B9, 0x00FA, 0x2808, 0x6606, 0x5386, 0x66F0, + 0x5380, 0x4E75, 0x48E7, 0xFFF0, 0x3F3C, 0x0002, 0x4E4E, 0x548F, 0x2600, 0x2838, 0x042E, 0x7A00, 0x7000, 0x1039, 0xFFFF, 0x8001, + 0xC07C, 0x000F, 0xB03C, 0x0000, 0x6608, 0x2A3C, 0x0000, 0x0100, 0x6036, 0xB03C, 0x0004, 0x6608, 0x2A3C, 0x0000, 0x0280, 0x6028, + 0xB03C, 0x0005, 0x6608, 0x2A3C, 0x0000, 0x0400, 0x601A, 0xB03C, 0x0008, 0x6608, 0x2A3C, 0x0000, 0x0880, 0x600C, 0xB03C, 0x000A, + 0x6606, 0x2A3C, 0x0000, 0x1000, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x720C, 0x303C, 0x0450, 0x6100, 0xFD8A, 0x4CDF, 0x00FE, 0x4A40, + 0x6704, 0x51CF, 0xFFE8, 0x4CDF, 0x0FFF, 0x4E75, 0x48E7, 0xFFF0, 0x2039, 0x00FA, 0x2838, 0x2239, 0x00FA, 0x283C, 0x2600, 0x280F, + 0xB883, 0x6500, 0x000E, 0xD6BC, 0x0000, 0x4000, 0xB883, 0x6500, 0x0028, 0x2240, 0x207C, 0x00FA, 0x0800, 0x243C, 0x0000, 0x1400, + 0xE44A, 0x5342, 0x22D8, 0x51CA, 0xFFFC, 0x21C1, 0x0436, 0x2240, 0x4E91, 0x4CDF, 0x0FFF, 0x4E75, 0x4879, 0x00FA, 0x06A8, 0x3F3C, + 0x0009, 0x4E41, 0x5C8F, 0x60FE, 0x0D0A, 0x5265, 0x6C6F, 0x632F, 0x7374, 0x6163, 0x6B20, 0x6F76, 0x6572, 0x6C61, 0x702E, 0x0D0A, + 0x5261, 0x6973, 0x6520, 0x5B52, 0x5D20, 0x696E, 0x2073, 0x6574, 0x7570, 0x206D, 0x656E, 0x752C, 0x2072, 0x6573, 0x6574, 0x2E0D, + 0x0A00, 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, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -64,10 +64,10 @@ 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, 0x6000, 0x0006, 0x6000, 0x0072, 0x48E7, 0xFFFE, 0x41FA, 0x00D6, 0x2F08, 0x3F3C, 0x0021, 0x3F3C, 0x0005, 0x4E4D, 0x508F, 0x43FA, - 0x00C0, 0x2280, 0x2600, 0x2809, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7208, 0x303C, 0x0401, 0x6100, 0x1152, 0x4CDF, 0x00FE, 0x4A40, + 0x00C0, 0x2280, 0x2600, 0x2809, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7208, 0x303C, 0x0401, 0x6100, 0x1156, 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, 0x0003, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0452, 0x6100, 0x10EC, + 0x2F08, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2638, 0x0436, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0452, 0x6100, 0x10F0, 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, @@ -75,197 +75,197 @@ const uint16_t target_firmware[] __attribute__((aligned(4))) = { 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, 0x0978, + 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, 0x06B8, 0x6000, 0x02AC, 0x6000, 0x073C, 0x6000, 0x07DC, 0x6000, 0x0858, 0x6000, 0x0630, 0x6000, 0x033E, 0x6000, 0x080C, + 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, 0x0932, 0x6000, 0xFEC4, 0x6000, 0xFEC0, 0x6000, 0x0C20, 0x6000, 0x0D02, 0x6000, 0xFEB4, 0x6000, 0xFEB0, 0x6000, 0xFEAC, + 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, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0ED8, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, - 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0EB0, 0x4CDF, 0x00FE, - 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x261F, 0x5283, 0x5383, 0xB6B9, 0x00FA, 0x2840, 0x6600, 0xFE34, 0x3E3C, 0x0003, 0x48E7, 0x7F00, - 0x7202, 0x303C, 0x0436, 0x6100, 0x0E82, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2039, 0x00FA, 0x2B80, 0x4A80, 0x6610, + 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, 0x0003, 0x48E7, 0x7F00, 0x7202, 0x303C, 0x0447, 0x6100, - 0x0E2A, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x303C, 0x007F, 0x4BF9, 0x00FA, 0x2B00, 0x4A15, 0x6706, 0x18DD, 0x51C8, + 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, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0DD2, 0x4CDF, 0x00FE, 0x4A40, - 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, - 0x0DAA, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xFD2C, - 0x3C3C, 0x0003, 0x48E7, 0x7E08, 0x303C, 0x0439, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0E4C, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, + 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, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0D30, 0x4CDF, 0x00FE, - 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, - 0x6100, 0x0D08, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, - 0xFC8A, 0x3C3C, 0x0003, 0x48E7, 0x7E08, 0x303C, 0x043A, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0DAA, 0x4CDF, 0x107E, 0x4A40, 0x6704, + 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, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, - 0x0C8A, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0003, 0x48E7, 0x7F00, - 0x7200, 0x303C, 0x0404, 0x6100, 0x0C62, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, - 0x00FA, 0x2840, 0x6600, 0xFBE4, 0x3C3C, 0x0003, 0x48E7, 0x7E08, 0x303C, 0x043C, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0D04, 0x4CDF, + 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, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, - 0x6100, 0x0BE8, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0003, 0x48E7, - 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0BC0, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, - 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xFB42, 0x3C3C, 0x0003, 0x48E7, 0x7E08, 0x303C, 0x0441, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0C62, + 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, 0x0003, - 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0B3E, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, - 0x548F, 0x2F00, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0B16, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, - 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xFA98, 0x3C3C, 0x0003, 0x48E7, 0x7E08, 0x303C, 0x0443, - 0x2C3C, 0x0000, 0x0080, 0x6100, 0x0BB8, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x2039, 0x00FA, 0x3BE8, 0x4CDF, 0x7CFE, + 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, 0x0003, 0x48E7, 0x7F00, - 0x7200, 0x303C, 0x0403, 0x6100, 0x0A82, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, - 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0A5A, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, - 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF9DC, 0x2F0C, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7210, 0x303C, 0x0457, - 0x6100, 0x0A28, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x285F, 0x4DF9, 0x00FA, 0x4124, 0x196E, 0x0002, 0x0000, 0x196E, + 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, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x09BA, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, - 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0992, 0x4CDF, 0x00FE, 0x4A40, + 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, 0x0003, 0x48E7, 0x7E08, 0x303C, 0x0456, - 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0A18, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x4FEF, 0x0100, 0x2039, 0x00FA, 0x3BEC, + 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, 0x0003, 0x48E7, - 0x7F08, 0x303C, 0x0488, 0x2C05, 0x6100, 0x09B6, 0x4CDF, 0x10FE, 0x4A40, 0x670C, 0x51CF, 0xFFE8, 0x70A4, 0x4CDF, 0x7CFE, 0x4E73, - 0x2439, 0x00FA, 0x3BF0, 0xD9C2, 0xDC82, 0x9882, 0x6704, 0x6A00, 0xFFBA, 0x2006, 0x4CDF, 0x7CFE, 0x4E73, 0x2868, 0x0008, 0x3E3C, - 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x089C, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, - 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0874, 0x4CDF, 0x00FE, 0x4A40, 0x6704, - 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF7F6, 0x3C3C, 0x0003, 0x48E7, 0x7E08, 0x303C, - 0x043B, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0916, 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, - 0xF7AA, 0x6058, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x07F6, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, - 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x07CE, 0x4CDF, - 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF750, 0x3C3C, 0x0003, - 0x48E7, 0x7E08, 0x303C, 0x043D, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0870, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x2039, - 0x00FA, 0x2B94, 0x4CDF, 0x7CFE, 0x4E73, 0x3628, 0x0008, 0xC6BC, 0x0000, 0xFFFF, 0xB679, 0x00FA, 0x284E, 0x6D00, 0xF70E, 0x3E3C, - 0x0003, 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, 0xF6CC, - 0x3E3C, 0x0003, 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, 0xF68C, - 0x6100, 0x0008, 0x4CDF, 0x7CFE, 0x4E73, 0x2A04, 0x7C00, 0x3E3C, 0x0003, 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, 0x0003, 0x48E7, - 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0660, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, - 0x2F00, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x0638, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, - 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, 0x6600, 0xF5BA, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x041A, - 0x6100, 0x0608, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x6000, 0xF598, 0x2608, 0x2848, 0x0C2C, 0x003A, 0x0001, 0x660E, - 0x1014, 0xB039, 0x00FA, 0x2847, 0x6600, 0xF580, 0x6058, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x05CC, - 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, - 0x303C, 0x0404, 0x6100, 0x05A4, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, - 0x2840, 0x6600, 0xF526, 0x3C3C, 0x0003, 0x48E7, 0x7E08, 0x303C, 0x044B, 0x2C3C, 0x0000, 0x0020, 0x6100, 0x0646, 0x4CDF, 0x107E, - 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x0C79, 0x0000, 0x00FA, 0x3FF4, 0x670C, 0x0C79, 0x0003, 0x00FA, 0x3FF4, 0x6600, 0xF4EE, 0x2879, - 0x00FA, 0x3FFC, 0x4243, 0x3C3C, 0x0003, 0x48E7, 0x7E08, 0x303C, 0x043D, 0x2C3C, 0x0000, 0x0100, 0x6100, 0x0606, 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, 0x0003, 0x48E7, - 0x7E08, 0x303C, 0x0484, 0x2C3C, 0x0000, 0x001C, 0x6100, 0x05B2, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x4FEF, 0x0020, - 0x3E3C, 0x0003, 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, 0x0003, - 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, 0x0003, 0x48E7, 0x7E08, 0x303C, 0x0483, - 0x2C3C, 0x0000, 0x0100, 0x6100, 0x04F8, 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, 0x0003, 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, 0xF2DE, 0x2039, 0x00FA, 0x4034, 0x4CDF, 0x7CFE, 0x4E73, 0x4FEF, 0x0020, 0x2639, - 0x00FA, 0x2B94, 0x3E3C, 0x0003, 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, 0xF282, 0x6058, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x02CE, 0x4CDF, - 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x0019, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, - 0x0404, 0x6100, 0x02A6, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x201F, 0xC0BC, 0x0000, 0xFFFF, 0xB0B9, 0x00FA, 0x2840, - 0x6600, 0xF228, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0276, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, - 0xFFE8, 0x3F3C, 0x002F, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x024E, 0x4CDF, - 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2617, 0x2A0C, 0x3C3C, 0x0003, 0x48E7, 0x7E08, 0x303C, 0x044E, 0x2C3C, 0x0000, 0x00C0, - 0x6100, 0x02FE, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x6000, 0x007E, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, - 0x0403, 0x6100, 0x0206, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3F3C, 0x002F, 0x4E41, 0x548F, 0x2F00, 0x3E3C, 0x0003, - 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0404, 0x6100, 0x01DE, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2057, 0x2028, 0x000C, - 0xB0B9, 0x00FA, 0x2840, 0x6622, 0x2617, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x044F, 0x6100, 0x01B0, 0x4CDF, 0x00FE, - 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x6006, 0x201F, 0x6000, 0xF13C, 0x2A5F, 0x3039, 0x00FA, 0x3BA4, 0x4A40, 0x6662, 0x49F9, 0x00FA, - 0x3BA8, 0x742B, 0x1ADC, 0x51CA, 0xFFFC, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x0170, 0x4CDF, 0x00FE, - 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2039, 0x00FA, 0x2840, 0x3F00, 0x3F3C, 0x000E, 0x4E41, 0x588F, 0x3E3C, 0x0003, 0x48E7, 0x7F00, - 0x7200, 0x303C, 0x0404, 0x6100, 0x0142, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x7000, 0x4CDF, 0x7CFE, 0x4E73, 0x2F00, - 0x260D, 0x742B, 0x421D, 0x51CA, 0xFFFC, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x048B, 0x6100, 0x0110, 0x4CDF, 0x00FE, - 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0403, 0x6100, 0x00F2, 0x4CDF, 0x00FE, 0x4A40, - 0x6704, 0x51CF, 0xFFE8, 0x2039, 0x00FA, 0x2840, 0x3F00, 0x3F3C, 0x000E, 0x4E41, 0x588F, 0x3E3C, 0x0003, 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, 0x0003, 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, 0x0003, 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, 0x0000, 0xFFFF, 0x7000, 0xB491, 0x6706, 0x5387, 0x66F8, 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, 0x0000, 0xFFFF, 0x7000, 0xB491, 0x6706, 0x5386, 0x66F8, 0x5380, 0x4E75, 0xDEAD, 0xFFFF, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 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, 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, 0x51C9, 0xFFFC, 0x2040, 0xD1FC, 0x0000, 0x002E, 0x4ED0, 0x2639, 0x00FA, 0x2840, 0x3F03, 0x3F3C, 0x000E, 0x4E41, 0x588F, 0x487A, - 0x0A0C, 0x3F3C, 0x003B, 0x4E41, 0x5C8F, 0x2439, 0x00FA, 0x2850, 0x4A82, 0x6606, 0x243C, 0x0000, 0x0400, 0x2442, 0x43FA, 0x06BE, + 0x0A1C, 0x3F3C, 0x003B, 0x4E41, 0x5C8F, 0x2439, 0x00FA, 0x2850, 0x4A82, 0x6606, 0x243C, 0x0000, 0x0400, 0x2442, 0x43FA, 0x06BE, 0x2282, 0x40E7, 0x007C, 0x0700, 0x43FA, 0x06AE, 0x2292, 0x41FA, 0x04E8, 0x2488, 0x46DF, 0x7600, 0x163C, 0x0001, 0x283A, 0x069E, 0x0C84, 0x0000, 0x0070, 0x6602, 0x6016, 0x0C84, 0x0000, 0x0400, 0x6608, 0x0083, 0x0000, 0x0100, 0x6006, 0x0083, 0x0000, 0xFF00, - 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0584, 0x6100, 0x078A, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x487A, - 0x098E, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2C39, 0x00FA, 0x2800, 0xBCBC, 0x0000, 0x0502, 0x6700, 0x0040, 0xBCBC, 0x0000, 0x0503, + 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0584, 0x6100, 0x078A, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x487A, + 0x099E, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2C39, 0x00FA, 0x2800, 0xBCBC, 0x0000, 0x0502, 0x6700, 0x0040, 0xBCBC, 0x0000, 0x0503, 0x6700, 0x02A4, 0xBCBC, 0x0000, 0x0504, 0x6700, 0x0302, 0xBCBC, 0x0000, 0x0505, 0x6700, 0x0382, 0xBCBC, 0x0000, 0x0506, 0x6700, - 0x00C8, 0xBCBC, 0x0000, 0x0507, 0x6700, 0x0162, 0xBCBC, 0x0000, 0x0508, 0x6700, 0x01F0, 0x60B2, 0x487A, 0x0990, 0x3F3C, 0x0009, - 0x4E41, 0x5C8F, 0x4879, 0x00FA, 0x4300, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x487A, 0x09F0, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2639, + 0x00C8, 0xBCBC, 0x0000, 0x0507, 0x6700, 0x0162, 0xBCBC, 0x0000, 0x0508, 0x6700, 0x01F0, 0x60B2, 0x487A, 0x09A0, 0x3F3C, 0x0009, + 0x4E41, 0x5C8F, 0x4879, 0x00FA, 0x4300, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x487A, 0x0A00, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2639, 0x00FA, 0x2840, 0x3F03, 0x3F3C, 0x000E, 0x4E41, 0x588F, 0x42A7, 0x2F3C, 0x00FA, 0x4380, 0x2F3C, 0x00FA, 0x4300, 0x3F3C, 0x0000, - 0x3F3C, 0x004B, 0x4E41, 0x4FEF, 0x0010, 0x2F00, 0x487A, 0x0954, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2617, 0x6100, 0x05A4, 0x487A, - 0x094C, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x4879, 0x00FA, 0x4300, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x487A, 0x097C, 0x3F3C, 0x0009, - 0x4E41, 0x5C8F, 0x261F, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0582, 0x6100, 0x0684, 0x4CDF, 0x00FE, 0x4A40, 0x6704, - 0x51CF, 0xFFE8, 0x6000, 0xFF04, 0x487A, 0x095E, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x4879, 0x00FA, 0x4300, 0x3F3C, 0x0009, 0x4E41, - 0x5C8F, 0x487A, 0x0940, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2639, 0x00FA, 0x2840, 0x3F03, 0x3F3C, 0x000E, 0x4E41, 0x588F, 0x42A7, - 0x2F3C, 0x00FA, 0x4380, 0x2F3C, 0x00FA, 0x4300, 0x3F3C, 0x0003, 0x3F3C, 0x004B, 0x4E41, 0x4FEF, 0x0010, 0x2F00, 0x487A, 0x0920, - 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2617, 0x6100, 0x04F4, 0x487A, 0x08F4, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x261F, 0x3E3C, 0x0003, + 0x3F3C, 0x004B, 0x4E41, 0x4FEF, 0x0010, 0x2F00, 0x487A, 0x0964, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2617, 0x6100, 0x05A4, 0x487A, + 0x095C, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x4879, 0x00FA, 0x4300, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x487A, 0x098C, 0x3F3C, 0x0009, + 0x4E41, 0x5C8F, 0x261F, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0582, 0x6100, 0x0684, 0x4CDF, 0x00FE, 0x4A40, 0x6704, + 0x51CF, 0xFFE8, 0x6000, 0xFF04, 0x487A, 0x096E, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x4879, 0x00FA, 0x4300, 0x3F3C, 0x0009, 0x4E41, + 0x5C8F, 0x487A, 0x0950, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2639, 0x00FA, 0x2840, 0x3F03, 0x3F3C, 0x000E, 0x4E41, 0x588F, 0x42A7, + 0x2F3C, 0x00FA, 0x4380, 0x2F3C, 0x00FA, 0x4300, 0x3F3C, 0x0003, 0x3F3C, 0x004B, 0x4E41, 0x4FEF, 0x0010, 0x2F00, 0x487A, 0x0930, + 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2617, 0x6100, 0x04F4, 0x487A, 0x0904, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x261F, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0587, 0x6100, 0x05EE, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2C39, 0x00FA, 0x2800, - 0xBCBC, 0x0000, 0x0506, 0x67F2, 0x6000, 0xFE60, 0x487A, 0x08E2, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2639, 0x00FA, 0x4494, 0x6100, - 0x04A0, 0x487A, 0x08A0, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x42A7, 0x2F39, 0x00FA, 0x4494, 0x42A7, 0x3F3C, 0x0004, 0x3F3C, 0x004B, - 0x4E41, 0x4FEF, 0x0010, 0x2F00, 0x487A, 0x0818, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2617, 0x6100, 0x0468, 0x487A, 0x0810, 0x3F3C, - 0x0009, 0x4E41, 0x5C8F, 0x487A, 0x084E, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x261F, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7204, 0x303C, + 0xBCBC, 0x0000, 0x0506, 0x67F2, 0x6000, 0xFE60, 0x487A, 0x08F2, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2639, 0x00FA, 0x4494, 0x6100, + 0x04A0, 0x487A, 0x08B0, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x42A7, 0x2F39, 0x00FA, 0x4494, 0x42A7, 0x3F3C, 0x0004, 0x3F3C, 0x004B, + 0x4E41, 0x4FEF, 0x0010, 0x2F00, 0x487A, 0x0828, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2617, 0x6100, 0x0468, 0x487A, 0x0820, 0x3F3C, + 0x0009, 0x4E41, 0x5C8F, 0x487A, 0x085E, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x261F, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0588, 0x6100, 0x0556, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2C39, 0x00FA, 0x2800, 0xBCBC, 0x0000, 0x0507, 0x67F2, - 0x6000, 0xFDC8, 0x487A, 0x0860, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2639, 0x00FA, 0x4494, 0x6100, 0x0408, 0x487A, 0x0808, 0x3F3C, - 0x0009, 0x4E41, 0x5C8F, 0x2F39, 0x00FA, 0x4494, 0x3F3C, 0x0049, 0x4E41, 0x5C8F, 0x2F00, 0x487A, 0x0844, 0x3F3C, 0x0009, 0x4E41, - 0x5C8F, 0x2617, 0x6100, 0x03DA, 0x487A, 0x07DA, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x261F, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7204, + 0x6000, 0xFDC8, 0x487A, 0x0870, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2639, 0x00FA, 0x4494, 0x6100, 0x0408, 0x487A, 0x0818, 0x3F3C, + 0x0009, 0x4E41, 0x5C8F, 0x2F39, 0x00FA, 0x4494, 0x3F3C, 0x0049, 0x4E41, 0x5C8F, 0x2F00, 0x487A, 0x0854, 0x3F3C, 0x0009, 0x4E41, + 0x5C8F, 0x2617, 0x6100, 0x03DA, 0x487A, 0x07EA, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x261F, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0589, 0x6100, 0x04D4, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x2C39, 0x00FA, 0x2800, 0xBCBC, 0x0000, 0x0508, - 0x67F2, 0x6000, 0xFD46, 0x487A, 0x074A, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x4879, 0x00FA, 0x4300, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, - 0x487A, 0x0782, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2639, 0x00FA, 0x2840, 0x3F03, 0x3F3C, 0x000E, 0x4E41, 0x588F, 0x2F3C, 0x00FA, - 0x4300, 0x3F3C, 0x003B, 0x4E41, 0x5C8F, 0x2600, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0583, 0x6100, 0x045E, 0x4CDF, - 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x6000, 0xFCDE, 0x487A, 0x06F0, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x3F3C, 0x0004, 0x4E4E, + 0x67F2, 0x6000, 0xFD46, 0x487A, 0x075A, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x4879, 0x00FA, 0x4300, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, + 0x487A, 0x0792, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x2639, 0x00FA, 0x2840, 0x3F03, 0x3F3C, 0x000E, 0x4E41, 0x588F, 0x2F3C, 0x00FA, + 0x4300, 0x3F3C, 0x003B, 0x4E41, 0x5C8F, 0x2600, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, 0x303C, 0x0583, 0x6100, 0x045E, 0x4CDF, + 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x6000, 0xFCDE, 0x487A, 0x0700, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x3F3C, 0x0004, 0x4E4E, 0x548F, 0xB07C, 0x0002, 0x6604, 0x76FF, 0x604A, 0x3839, 0x00FA, 0x4490, 0xB87C, 0x0001, 0x623C, 0x3F04, 0x2F3C, 0xFFFF, 0xFFFF, - 0x2F3C, 0xFFFF, 0xFFFF, 0x3F3C, 0x0005, 0x4E4E, 0x4FEF, 0x000C, 0x3F3C, 0x0025, 0x4E4E, 0x548F, 0x487A, 0x05F2, 0x3F3C, 0x0006, - 0x4E4E, 0x5C8F, 0x487A, 0x0608, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x7600, 0x6002, 0x76FE, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7204, - 0x303C, 0x0585, 0x6100, 0x03D4, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x6000, 0xFC54, 0x487A, 0x0672, 0x3F3C, 0x0009, + 0x2F3C, 0xFFFF, 0xFFFF, 0x3F3C, 0x0005, 0x4E4E, 0x4FEF, 0x000C, 0x3F3C, 0x0025, 0x4E4E, 0x548F, 0x487A, 0x0602, 0x3F3C, 0x0006, + 0x4E4E, 0x5C8F, 0x487A, 0x0618, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x7600, 0x6002, 0x76FE, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7204, + 0x303C, 0x0585, 0x6100, 0x03D4, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x6000, 0xFC54, 0x487A, 0x0682, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x4FEF, 0xFFE8, 0x284F, 0x42AC, 0x0000, 0x42AC, 0x0004, 0x42AC, 0x0008, 0x42AC, 0x000C, 0x42AC, 0x0010, 0x42AC, 0x0014, 0x2978, 0x0432, 0x0000, 0x2978, 0x0436, 0x0004, 0x2978, 0x042E, 0x0008, 0x2978, 0x044E, 0x000C, 0x2978, 0x04F2, 0x0010, 0x7600, 0x1639, 0xFFFF, 0x8001, 0xC67C, 0x000F, 0xB63C, 0x0000, 0x660E, 0x397C, 0x0080, 0x0014, 0x397C, 0x0080, 0x0016, 0x604E, 0xB63C, 0x0004, 0x660E, 0x397C, 0x0200, 0x0014, 0x397C, 0x0080, 0x0016, 0x603A, 0xB63C, 0x0005, 0x660E, 0x397C, 0x0200, 0x0014, 0x397C, 0x0200, 0x0016, 0x6026, 0xB63C, 0x0008, 0x660E, 0x397C, 0x0800, 0x0014, 0x397C, 0x0080, 0x0016, 0x6012, 0xB63C, 0x000A, - 0x660C, 0x397C, 0x0800, 0x0014, 0x397C, 0x0800, 0x0016, 0x3C3C, 0x0003, 0x48E7, 0x7E08, 0x303C, 0x0586, 0x2C3C, 0x0000, 0x0018, - 0x6100, 0x03CE, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x4FEF, 0x0018, 0x6000, 0xFB74, 0x48E7, 0xC080, 0x2039, 0x00FA, + 0x660C, 0x397C, 0x0800, 0x0014, 0x397C, 0x0800, 0x0016, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x0586, 0x2C3C, 0x0000, 0x0018, + 0x6100, 0x03D6, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x4FEF, 0x0018, 0x6000, 0xFB74, 0x48E7, 0xC080, 0x2039, 0x00FA, 0x2800, 0x2200, 0x0281, 0xFFFF, 0xFF00, 0x0C81, 0x0000, 0x0600, 0x6600, 0x002A, 0x0C80, 0x0000, 0x0601, 0x6700, 0x002A, 0x0C80, 0x0000, 0x0603, 0x6700, 0x0032, 0x0C80, 0x0000, 0x0604, 0x6700, 0x00E8, 0x0C80, 0x0000, 0x0605, 0x6700, 0x0122, 0x4CDF, 0x0103, 0x2F3A, 0x0176, 0x4E75, 0x42B8, 0x0420, 0x42B8, 0x043A, 0x42B8, 0x051A, 0x2078, 0x0004, 0x4ED0, 0x48E7, 0x3F78, 0x4FEF, 0xFFE8, @@ -273,49 +273,49 @@ const uint16_t target_firmware[] __attribute__((aligned(4))) = { 0x42AC, 0x0014, 0x7600, 0x1639, 0xFFFF, 0x8001, 0xC67C, 0x000F, 0x7800, 0x7400, 0xB63C, 0x0000, 0x660A, 0x383C, 0x0080, 0x343C, 0x0080, 0x603E, 0xB63C, 0x0004, 0x660A, 0x383C, 0x0200, 0x343C, 0x0080, 0x602E, 0xB63C, 0x0005, 0x660A, 0x383C, 0x0200, 0x343C, 0x0200, 0x601E, 0xB63C, 0x0008, 0x660A, 0x383C, 0x0800, 0x343C, 0x0080, 0x600E, 0xB63C, 0x000A, 0x6608, 0x383C, 0x0800, 0x343C, - 0x0800, 0x3944, 0x0014, 0x3942, 0x0016, 0x3C3C, 0x0003, 0x48E7, 0x7E08, 0x303C, 0x0586, 0x2C3C, 0x0000, 0x0018, 0x6100, 0x02B2, + 0x0800, 0x3944, 0x0014, 0x3942, 0x0016, 0x3C3C, 0x0005, 0x48E7, 0x7E08, 0x303C, 0x0586, 0x2C3C, 0x0000, 0x0018, 0x6100, 0x02BA, 0x4CDF, 0x107E, 0x4A40, 0x6704, 0x51CE, 0xFFE4, 0x4FEF, 0x0018, 0x4CDF, 0x1EFC, 0x6000, 0xFF26, 0x223A, 0x00A2, 0x0C81, 0x0000, - 0x0070, 0x6600, 0xFF18, 0x48E7, 0x3F78, 0x2039, 0x00FA, 0x2854, 0x2F40, 0x0036, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, + 0x0070, 0x6600, 0xFF18, 0x48E7, 0x3F78, 0x2039, 0x00FA, 0x2854, 0x2F40, 0x0036, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0680, 0x6100, 0x0196, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4CDF, 0x1EFC, 0x4CDF, 0x0103, 0x4E73, 0x48E7, 0x3F78, 0x2279, 0x00FA, 0x2858, 0x2439, 0x00FA, 0x285C, 0x41F9, 0x00FA, 0x6B00, 0x2602, 0xE28B, 0x6708, 0x5383, 0x32D8, 0x51CB, 0xFFFC, - 0x0802, 0x0000, 0x6702, 0x12D8, 0x3E3C, 0x0003, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0681, 0x6100, 0x0142, 0x4CDF, 0x00FE, 0x4A40, + 0x0802, 0x0000, 0x6702, 0x12D8, 0x3E3C, 0x0005, 0x48E7, 0x7F00, 0x7200, 0x303C, 0x0681, 0x6100, 0x0142, 0x4CDF, 0x00FE, 0x4A40, 0x6704, 0x51CF, 0xFFE8, 0x4CDF, 0x1EFC, 0x6000, 0xFE90, 0x0000, 0x5842, 0x5241, 0x5344, 0x5241, 0x0000, 0x0000, 0x0000, 0x0000, 0x48E7, 0xECC0, 0x2803, 0x4A84, 0x6A0E, 0x3F3C, 0x002D, 0x3F3C, 0x0002, 0x4E41, 0x588F, 0x4484, 0x4FEF, 0xFFF4, 0x204F, 0x43E8, 0x000B, 0x4211, 0x5389, 0x4A84, 0x6606, 0x12BC, 0x0030, 0x6028, 0x2004, 0x4240, 0x4840, 0x80FC, 0x000A, 0x3A00, 0x4840, 0x3004, 0x80FC, 0x000A, 0x4845, 0x3A00, 0x4840, 0xD03C, 0x0030, 0x1280, 0x5389, 0x2805, 0x4A84, 0x66D8, 0x5289, 0x2F09, 0x3F3C, 0x0009, 0x4E41, 0x5C8F, 0x4FEF, 0x000C, 0x4CDF, 0x0337, 0x4E75, 0x2038, 0x05A0, 0x6700, 0x001A, 0x2040, 0x2018, 0x6700, 0x0012, 0xB0BC, - 0x5F4D, 0x4348, 0x6704, 0x5848, 0x60EE, 0x2818, 0x6002, 0x4284, 0x2F04, 0x263C, 0x0000, 0x0000, 0x3E3C, 0x0003, 0x48E7, 0x7F00, + 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, 0x0003, 0x48E7, 0x7F00, + 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, 0x0000, - 0xFFFF, 0x7000, 0xB491, 0x6706, 0x5387, 0x66F8, 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, 0x0000, 0xFFFF, 0x7000, - 0xB491, 0x6706, 0x5386, 0x66F8, 0x5380, 0x4E75, 0x0FFF, 0x0F00, 0x00F0, 0x0000, 0x000F, 0x0F0F, 0x00FF, 0x0555, 0x0333, 0x0F33, - 0x03F3, 0x0FF3, 0x033F, 0x0F3F, 0x03FF, 0x0000, 0x5C00, 0x1B45, 0x4465, 0x764F, 0x7073, 0x2052, 0x756E, 0x6E65, 0x7220, 0x0D0A, - 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, - 0x2D2D, 0x2D2D, 0x2D2D, 0x2D0D, 0x0A5B, 0x5245, 0x4144, 0x595D, 0x202D, 0x2057, 0x6169, 0x7469, 0x6E67, 0x2066, 0x6F72, 0x2063, - 0x6F6D, 0x6D61, 0x6E64, 0x730D, 0x0A00, 0x0D0A, 0x5B52, 0x554E, 0x2020, 0x5D20, 0x2D20, 0x4C61, 0x756E, 0x6368, 0x696E, 0x6720, - 0x0000, 0x0D0A, 0x5B45, 0x5849, 0x5420, 0x0000, 0x5D20, 0x2D20, 0x0000, 0x0D0A, 0x5B43, 0x4420, 0x2020, 0x5D20, 0x2D20, 0x0000, - 0x0D0A, 0x5B52, 0x4553, 0x2020, 0x5D0D, 0x0A00, 0x0D0A, 0x5B4D, 0x454D, 0x494E, 0x5D20, 0x2D20, 0x5265, 0x6164, 0x696E, 0x6720, - 0x6D65, 0x6D6F, 0x7279, 0x2069, 0x6E66, 0x6F72, 0x6D61, 0x7469, 0x6F6E, 0x0D0A, 0x0000, 0x2074, 0x6572, 0x6D69, 0x6E61, 0x7465, - 0x640D, 0x0A00, 0x0D0A, 0x0000, 0x0D0A, 0x5B4C, 0x4F41, 0x4420, 0x5D20, 0x2D20, 0x4C6F, 0x6164, 0x696E, 0x6720, 0x0000, 0x5B4C, - 0x4F41, 0x4420, 0x5D20, 0x2D20, 0x7265, 0x7375, 0x6C74, 0x2000, 0x0D0A, 0x5B45, 0x5845, 0x4320, 0x5D20, 0x2D20, 0x6261, 0x7365, - 0x7061, 0x6765, 0x2000, 0x0D0A, 0x5B55, 0x4E4C, 0x4420, 0x5D20, 0x2D20, 0x6261, 0x7365, 0x7061, 0x6765, 0x2000, 0x5B55, 0x4E4C, - 0x4420, 0x5D20, 0x2D20, 0x7265, 0x7375, 0x6C74, 0x2000, 0xFFFF + 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, 0x0FFF, 0x0F00, + 0x00F0, 0x0000, 0x000F, 0x0F0F, 0x00FF, 0x0555, 0x0333, 0x0F33, 0x03F3, 0x0FF3, 0x033F, 0x0F3F, 0x03FF, 0x0000, 0x5C00, 0x1B45, + 0x4465, 0x764F, 0x7073, 0x2052, 0x756E, 0x6E65, 0x7220, 0x0D0A, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, + 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D2D, 0x2D0D, 0x0A5B, 0x5245, 0x4144, 0x595D, + 0x202D, 0x2057, 0x6169, 0x7469, 0x6E67, 0x2066, 0x6F72, 0x2063, 0x6F6D, 0x6D61, 0x6E64, 0x730D, 0x0A00, 0x0D0A, 0x5B52, 0x554E, + 0x2020, 0x5D20, 0x2D20, 0x4C61, 0x756E, 0x6368, 0x696E, 0x6720, 0x0000, 0x0D0A, 0x5B45, 0x5849, 0x5420, 0x0000, 0x5D20, 0x2D20, + 0x0000, 0x0D0A, 0x5B43, 0x4420, 0x2020, 0x5D20, 0x2D20, 0x0000, 0x0D0A, 0x5B52, 0x4553, 0x2020, 0x5D0D, 0x0A00, 0x0D0A, 0x5B4D, + 0x454D, 0x494E, 0x5D20, 0x2D20, 0x5265, 0x6164, 0x696E, 0x6720, 0x6D65, 0x6D6F, 0x7279, 0x2069, 0x6E66, 0x6F72, 0x6D61, 0x7469, + 0x6F6E, 0x0D0A, 0x0000, 0x2074, 0x6572, 0x6D69, 0x6E61, 0x7465, 0x640D, 0x0A00, 0x0D0A, 0x0000, 0x0D0A, 0x5B4C, 0x4F41, 0x4420, + 0x5D20, 0x2D20, 0x4C6F, 0x6164, 0x696E, 0x6720, 0x0000, 0x5B4C, 0x4F41, 0x4420, 0x5D20, 0x2D20, 0x7265, 0x7375, 0x6C74, 0x2000, + 0x0D0A, 0x5B45, 0x5845, 0x4320, 0x5D20, 0x2D20, 0x6261, 0x7365, 0x7061, 0x6765, 0x2000, 0x0D0A, 0x5B55, 0x4E4C, 0x4420, 0x5D20, + 0x2D20, 0x6261, 0x7365, 0x7061, 0x6765, 0x2000, 0x5B55, 0x4E4C, 0x4420, 0x5D20, 0x2D20, 0x7265, 0x7375, 0x6C74, 0x2000, 0xFFFF }; uint16_t target_firmware_length = sizeof(target_firmware) / sizeof(target_firmware[0]); diff --git a/rp/src/term.c b/rp/src/term.c index 6292226..6c808c2 100644 --- a/rp/src/term.c +++ b/rp/src/term.c @@ -642,11 +642,17 @@ void __not_in_flash_func(term_loop)() { uint32_t randomToken = TPROTO_GET_RANDOM_TOKEN(protocolSnapshot.payload); uint16_t *payloadPtr = ((uint16_t *)(protocolSnapshot).payload); uint16_t commandId = protocolSnapshot.command_id; + // One line per command floods the console during a GEMDRIVE transfer (two + // per 1 KB chunk) and the traffic itself breaks the ST's synchronous + // handshake, so the commands term handles trace below instead. Set + // TERM_TRACE_EVERY_COMMAND to 1 when studying the command stream. +#if defined(TERM_TRACE_EVERY_COMMAND) && (TERM_TRACE_EVERY_COMMAND != 0) DPRINTF( "Command ID: %d. Size: %d. Random token: 0x%08X, Checksum: 0x%04X, " "Overwrites: %lu\n", protocolSnapshot.command_id, protocolSnapshot.payload_size, randomToken, protocolSnapshot.final_checksum, (unsigned long)overwriteCountSnapshot); +#endif #if defined(_DEBUG) && (_DEBUG != 0) // Jump the random token @@ -738,8 +744,8 @@ void __not_in_flash_func(term_loop)() { break; } default: - // Unknown command - DPRINTF("Unknown command\n"); + // Not a terminal command: GEMDRIVE and the Runner have their own + // callbacks. Silent, for the reason above. break; } // Random-token publish is owned by chandler_loop; nothing more to do here. diff --git a/target/atarist/src/gemdrive.s b/target/atarist/src/gemdrive.s index ea33a6d..be19a15 100644 --- a/target/atarist/src/gemdrive.s +++ b/target/atarist/src/gemdrive.s @@ -37,9 +37,14 @@ RANDOM_TOKEN_SEED_ADDR equ (SHARED_BLOCK_ADDR + 8) ; $FA2808 RANDOM_TOKEN_POST_WAIT equ $1 ROMCMD_START_ADDR equ $FB0000 CMD_MAGIC_NUMBER equ $ABCD -CMD_RETRIES_COUNT equ 3 +CMD_RETRIES_COUNT equ 5 CMD_SET_SHARED_VAR equ 1 -COMMAND_TIMEOUT equ $0000FFFF +; The RP answers a command after it has done the work, and an SD write that +; allocates a cluster and updates the FAT can block for tens of milliseconds +; (70 ms measured on a 29 GB FAT32 card). $FFFF gave up far too early and the +; ST then retried the chunk, which the RP had already written. These are the +; values md-drives-emulator ships for the same protocol: about 800 ms. +COMMAND_TIMEOUT equ $0006FFFF COMMAND_WRITE_TIMEOUT equ COMMAND_TIMEOUT ; --- Macros + GEMDOS sysvar / function constants. --- @@ -710,11 +715,14 @@ gemdrive_trap: tst.w d0 beq.s .fwrite_chunk_ok dbf d7, .fwrite_retry +.fwrite_failed: moveq.l #GEMDOS_EIO_WRITE, d0 return_rte .fwrite_chunk_ok: move.l GEMDRIVE_WRITE_BYTES, d2 ; bytes RP actually wrote + tst.l d2 ; nothing written: the RP failed + ble.s .fwrite_failed ; (0 would loop here for ever) add.l d2, a4 add.l d2, d6 sub.l d2, d4 diff --git a/target/atarist/src/runner.s b/target/atarist/src/runner.s index ffb607e..5f39196 100644 --- a/target/atarist/src/runner.s +++ b/target/atarist/src/runner.s @@ -89,9 +89,10 @@ RANDOM_TOKEN_SEED_ADDR equ (SHARED_BLOCK_ADDR + 8) ; $FA2808 RANDOM_TOKEN_POST_WAIT equ $1 ROMCMD_START_ADDR equ $FB0000 CMD_MAGIC_NUMBER equ $ABCD -CMD_RETRIES_COUNT equ 3 +CMD_RETRIES_COUNT equ 5 CMD_SET_SHARED_VAR equ 1 -COMMAND_TIMEOUT equ $0000FFFF +; Same budget as gemdrive.s: the Runner's commands also wait on SD work. +COMMAND_TIMEOUT equ $0006FFFF COMMAND_WRITE_TIMEOUT equ COMMAND_TIMEOUT _dskbufp equ $4C6 From 2194d63523c36a6a88795de6728cc75bbe26fec6 Mon Sep 17 00:00:00 2001 From: Diego Parrilla Date: Wed, 16 Sep 2026 19:02:46 +0200 Subject: [PATCH 05/12] Port the template's fix for false token detection (EPIC-12) md-devops forked the microfirmware template before its commit d7ec84e, "fix(sync): prevent false positive token detection", so its synchronous wait accepted a bare token match. A stale token from an earlier command could therefore be taken as the answer to the current one, which desynchronises the handshake: one chunk appears to succeed early and the next waits for a token that never arrives. The template's version requires the seed to have advanced as well, and is now copied verbatim into both wait loops; the file is identical to the template again. Found while chasing TOS write errors on multi-megabyte copies from the ST. It moved the first failure from the first file to the last, so it was one of several causes, not the only one. --- target/atarist/src/inc/sidecart_functions.s | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/target/atarist/src/inc/sidecart_functions.s b/target/atarist/src/inc/sidecart_functions.s index 003b824..4ec1ea3 100644 --- a/target/atarist/src/inc/sidecart_functions.s +++ b/target/atarist/src/inc/sidecart_functions.s @@ -225,7 +225,10 @@ _start_sync_code_in_stack: moveq #0, d0 ; No Timeout _start_sync_code_in_stack_loop: cmp.l (a1), d2 ; Compare the random number with the token - beq.s _sync_token_found ; Token found, we can finish succesfully + bne.s _sync_token_not_ready + cmp.l RANDOM_TOKEN_SEED_ADDR, d2 ; Seed must advance to prove a real response + bne.s _sync_token_found ; Token found, we can finish succesfully +_sync_token_not_ready: subq.l #1, d7 ; Decrement the inner loop bne.s _start_sync_code_in_stack_loop ; If the inner loop is not finished, continue @@ -433,7 +436,10 @@ _start_sync_write_code_in_stack: moveq #0, d0 ; Timeout _start_sync_write_code_in_stack_loop: cmp.l (a1), d2 ; Compare the random number with the token - beq.s _sync_write_token_found ; Token found, we can finish succesfully + bne.s _sync_write_token_not_ready + cmp.l RANDOM_TOKEN_SEED_ADDR, d2 ; Seed must advance to prove a real response + bne.s _sync_write_token_found ; Token found, we can finish succesfully +_sync_write_token_not_ready: subq.l #1, d6 ; Decrement the inner loop bne.s _start_sync_write_code_in_stack_loop ; If the inner loop is not finished, continue @@ -447,4 +453,4 @@ _sync_write_token_found: ;_no_wait_write_me: rts ; Return to the code -_end_sync_write_code_in_stack: \ No newline at end of file +_end_sync_write_code_in_stack: From 9215de1527fdf4de40a4395b5b71d0cfc3dc7759 Mon Sep 17 00:00:00 2001 From: Diego Parrilla Date: Wed, 16 Sep 2026 20:24:37 +0200 Subject: [PATCH 06/12] Stop discarding a command frame that spans two drains (EPIC-12 STORY-08) Writes from the ST ran at 4.6 to 25 KB/s and the total time tracked the ST's command timeout, although no retry was ever visible: the counters showed 0 repeated tokens, the RP busy 0.5 ms per command, and a 1 KB frame apparently taking 45 ms to arrive, spread over 13 main-loop passes. The parser explains all of it. tprotocol_parse restarts on PROTOCOL_READ_RESTART_MICROSECONDS (10 ms) of silence, but it refreshed its timestamp only while hunting for a header, so the window was a deadline for the whole frame. Samples are timestamped when they are parsed, in batches drained from the DMA ring, and this app's main loop sleeps up to SLEEP_LOOP_MS between drains: any 1 KB payload that did not land in a single drain was thrown away mid-frame. The ST then waited its full timeout and resent with a fresh token, which is why the time scaled with the timeout and no repeat was ever counted. md-drives-emulator has the same parser and the same constant, but its runtime loop never sleeps, so a frame never spans a gap. The timestamp is now refreshed on every sample, which is what "restart after silence" means, and the window is 50 ms to cover this loop's own gap between two drains. Measured on hardware, 4 MB copied from the ST with the timeout at $0006FFFF: 13-14 minutes before, 47 seconds after (87 KB/s), every file byte-exact, no checksum errors, no repeats. A 1 KB frame now arrives in 0.91 ms across 1.24 passes instead of 45 ms across 13. chandler.c keeps the counters this was found with (handled, dropped, repeated, checksum errors, busy/gap/quiet microseconds, passes per frame). They cost a few microseconds per command and are read over SWD by symbol, so a release build can be measured. --- rp/src/chandler.c | 66 ++++++++++++++++++++++++++++++++ rp/src/include/target_firmware.h | 2 +- rp/src/include/tprotocol.h | 11 +++++- 3 files changed, 76 insertions(+), 3 deletions(-) diff --git a/rp/src/chandler.c b/rp/src/chandler.c index 7cf7657..55134c8 100644 --- a/rp/src/chandler.c +++ b/rp/src/chandler.c @@ -18,6 +18,37 @@ static TransmissionProtocol pendingProtocol; static bool protocolPending = false; +// Diagnostics for the ST's synchronous handshake, read over SWD by symbol so +// a release build can be measured (EPIC-12 STORY-08). chandlerDropped counts +// commands thrown away because another was still pending; chandlerRepeated +// counts commands carrying the token of the command before them, which is what +// the ST's retry after a timeout looks like. +uint32_t chandlerHandled = 0; +uint32_t chandlerDropped = 0; +uint32_t chandlerRepeated = 0; +// Where the time of a command goes: chandlerBusyUs is what this side spends +// handling one (the SD write included), chandlerGapUs the time from answering +// one command to seeing the next, which is the ST's turnaround. +uint32_t chandlerBusyUs = 0; +uint32_t chandlerGapUs = 0; +uint32_t chandlerMaxGapUs = 0; +uint32_t chandlerMaxBusyUs = 0; +// Of that gap, how long the ST takes to touch the command window at all after +// being answered: its spin-wait polls the shared block ($FA2804), which is not +// this space, so no sample arrives until it starts sending the next command. +uint32_t chandlerQuietUs = 0; +uint32_t chandlerMaxQuietUs = 0; +// How many main-loop passes a frame spans between its first sample and its +// last, and how long this side spends draining the sample ring: tells a slow +// sender apart from slow polling on our part. +uint32_t chandlerFramePolls = 0; +uint32_t chandlerChecksumErrors = 0; +uint32_t chandlerPollUs = 0; +static volatile bool chandlerFrameInFlight = false; +static volatile bool chandlerAwaitingFirstSample = false; +static uint32_t chandlerLastToken = 0; +static uint32_t chandlerAnsweredAtUs = 0; + static uint32_t incrementalCmdCount = 0; // Address of the random-token reply slot (chandler_loop publishes the @@ -126,6 +157,7 @@ static inline void __not_in_flash_func(handle_protocol_command)( uint16_t size = tprotocol_clamp_payload_size(protocol->payload_size); if (protocolPending) { + chandlerDropped++; if (!chandler_protocol_matches_pending(protocol, size)) { DPRINTF("Ignoring protocol %04x (%u bytes) while %04x is pending\n", protocol->command_id, protocol->payload_size, @@ -159,6 +191,7 @@ bool chandler_injectProtocol(uint16_t commandId, const uint16_t *payload, static inline void __not_in_flash_func(handle_protocol_checksum_error)( const TransmissionProtocol *protocol) { + chandlerChecksumErrors++; DPRINTF( "Checksum error detected (CommandID=%x, Size=%x, Bytes Read=%x, " "Chksum=%x, RTOKEN=%x)\n", @@ -168,6 +201,13 @@ static inline void __not_in_flash_func(handle_protocol_checksum_error)( static inline void __not_in_flash_func(chandler_consume_rom3_sample)( uint16_t sample) { + if (chandlerAwaitingFirstSample) { + chandlerAwaitingFirstSample = false; + chandlerFrameInFlight = true; + uint32_t quiet = (uint32_t)time_us_32() - chandlerAnsweredAtUs; + chandlerQuietUs += quiet; + if (quiet > chandlerMaxQuietUs) chandlerMaxQuietUs = quiet; + } // Consumer 2: debug-byte filter. External programs // emit one byte per cartridge cycle by reading at $FBFF00 + c // (where c is the byte). The captured value's high byte is then @@ -194,13 +234,26 @@ static inline void __not_in_flash_func(chandler_consume_rom3_sample)( // Invoke this function to process the commands from the active loop in the // main function void __not_in_flash_func(chandler_loop)() { + uint32_t pollStartUs = (uint32_t)time_us_32(); + bool frameWasInFlight = chandlerFrameInFlight; commemul_poll(chandler_consume_rom3_sample); + chandlerPollUs += (uint32_t)time_us_32() - pollStartUs; + if (frameWasInFlight || chandlerFrameInFlight) { + chandlerFramePolls++; + } if (!protocolPending) { // No command to process return; } + uint32_t startedAtUs = (uint32_t)time_us_32(); + if (chandlerAnsweredAtUs != 0) { + uint32_t gap = startedAtUs - chandlerAnsweredAtUs; + chandlerGapUs += gap; + if (gap > chandlerMaxGapUs) chandlerMaxGapUs = gap; + } + // Shared by all commands // Read the random token from the command and increment the payload // pointer to the first parameter available in the payload @@ -222,6 +275,19 @@ void __not_in_flash_func(chandler_loop)() { if (cur->cb) cur->cb(&pendingProtocol, payloadPtr); } + chandlerFrameInFlight = false; + uint32_t busy = (uint32_t)time_us_32() - startedAtUs; + chandlerBusyUs += busy; + if (busy > chandlerMaxBusyUs) chandlerMaxBusyUs = busy; + chandlerAnsweredAtUs = (uint32_t)time_us_32(); + chandlerAwaitingFirstSample = true; + + chandlerHandled++; + if (randomToken == chandlerLastToken) { + chandlerRepeated++; + } + chandlerLastToken = randomToken; + incrementalCmdCount++; TPROTO_SET_RANDOM_TOKEN64( memoryRandomTokenAddress, diff --git a/rp/src/include/target_firmware.h b/rp/src/include/target_firmware.h index 8c825b9..f1f4e4b 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, 0x83BC, 0x5D30, 0x0000, 0x06C4, 0x5445, 0x524D, 0x0000, 0x6100, + 0xABCD, 0xEF42, 0x0000, 0x0000, 0x08FA, 0x001E, 0x0000, 0x0000, 0x92BB, 0x5D30, 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, diff --git a/rp/src/include/tprotocol.h b/rp/src/include/tprotocol.h index df2eea9..6b830ce 100644 --- a/rp/src/include/tprotocol.h +++ b/rp/src/include/tprotocol.h @@ -20,7 +20,14 @@ 0 // Set to 1 to clear the memory before starting the protocol #define PROTOCOL_HEADER 0xABCD -#define PROTOCOL_READ_RESTART_MICROSECONDS 10000 +// Resynchronise the parser after this much silence on the command space. The +// timestamp is refreshed on every sample, so this is a gap between samples, +// not a deadline for a whole frame: a 1 KB payload arrives over tens of +// milliseconds and used to be thrown away mid-frame, which cost the ST a full +// command timeout and a resend (EPIC-12 STORY-08). Samples are timestamped +// when they are parsed, in batches from the ring, so this must also cover the +// main loop's own gap between two drains. +#define PROTOCOL_READ_RESTART_MICROSECONDS 50000 #define MAX_PROTOCOL_PAYLOAD_SIZE \ 2048 + 64 // 2048 bytes of payload plus 64 bytes of overhead for safety @@ -185,6 +192,7 @@ static inline void __not_in_flash_func(tprotocol_parse)( PROTOCOL_READ_RESTART_MICROSECONDS) { tprotocol_nextTPstep = HEADER_DETECTION; } + tprotocol_last_header_found = tprotocol_new_header_found; switch (tprotocol_nextTPstep) { case HEADER_DETECTION: @@ -192,7 +200,6 @@ static inline void __not_in_flash_func(tprotocol_parse)( // Move to command read tprotocol_nextTPstep = COMMAND_READ; } - tprotocol_last_header_found = tprotocol_new_header_found; break; case COMMAND_READ: From 8b887fa29b309507995121990a078f9e3604f9b8 Mon Sep 17 00:00:00 2001 From: Diego Parrilla Date: Wed, 16 Sep 2026 20:40:10 +0200 Subject: [PATCH 07/12] Take the big buffers off the stack (EPIC-12 STORY-03) The deepest static paths were 5,696 bytes through the terminal, 5,120 through GEMDRIVE and 3,784 through the HTTP server, against a 2 KB reserved stack. Four frames accounted for most of it: - term_loop copied the published protocol slot into a 4,184-byte local. It reads the slot in place now; the double buffer already keeps the producer off it and both run on core 0. - handleReadBuffCall read into a 4 KB local and then copied it into the shared window. It reads straight into the window and swaps there. - handleWriteBuffCall copied the chunk into a 1 KB local to byte-swap it. It swaps it where the parser already put it. - pathUp held 256 pointers (1 KB) for a path that cannot contain more than half its length in segments. FATFS fsys moved out of emul_start's frame into .bss, and the path buffers of the nine largest HTTP handlers are static: 6.2 KB of RAM for 1,672-byte frames, safe because the server is single-threaded and its spin-waits pump chandler_loop only, never lwIP. Deepest static path now: release 2,976 bytes, debug 2,952, MinSizeRel debug 2,928 -- all under the story's 3 KB. On hardware the measured high-water fell from 5,772 to 2,564 bytes and the smoke script passes. measure_builds.sh also lost its way to the repo root when the tools moved into tools/dev. --- rp/src/emul.c | 8 +++-- rp/src/gemdrive.c | 17 +++++---- rp/src/http_server.c | 72 ++++++++++++++++++++----------------- rp/src/term.c | 39 ++++++++++---------- tools/dev/measure_builds.sh | 2 +- 5 files changed, 76 insertions(+), 62 deletions(-) diff --git a/rp/src/emul.c b/rp/src/emul.c index b0b8df1..60c30ae 100644 --- a/rp/src/emul.c +++ b/rp/src/emul.c @@ -1034,7 +1034,10 @@ static bool foldersOnlyFilter(const char *name, // Remove last path component (".." navigation). static void pathUp(void) { char temp[MAX_FILENAME_LENGTH + 1]; - char *segments[MAX_ENTRIES_DIR]; + // One segment needs at least a separator and a character, so a path of + // MAX_FILENAME_LENGTH cannot have more than half that many (EPIC-12 + // STORY-03; this array held 256 pointers, 1 KB of stack). + char *segments[(MAX_FILENAME_LENGTH / 2) + 1]; int sp = 0; strncpy(temp, navState->folderPath, sizeof(temp)); @@ -1891,7 +1894,8 @@ void emul_start() { // files are stored. The folder name is defined in the configuration. // If there is no folder in the micro SD card, the app will create it. - FATFS fsys; + // Static: it lives for the whole run and FATFS carries a sector buffer. + static FATFS fsys; SettingsConfigEntry *folder = settings_find_entry(aconfig_getContext(), ACONFIG_PARAM_FOLDER); char *folderName = "/devops"; diff --git a/rp/src/gemdrive.c b/rp/src/gemdrive.c index 6077f33..20968fa 100644 --- a/rp/src/gemdrive.c +++ b/rp/src/gemdrive.c @@ -869,9 +869,10 @@ static void __not_in_flash_func(handleWriteBuffCall)(uint16_t *payload) { return; } - // Pull the chunk out of the wire buffer (byte-swapped per word). - uint8_t tmp[GEMDRIVE_WRITE_BUFFER_SIZE]; - COPY_AND_CHANGE_ENDIANESS_BLOCK16(payload, tmp, (bytes + 1) & ~1); + // 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; + CHANGE_ENDIANESS_BLOCK16(tmp, (bytes + 1) & ~1u); UINT bw = 0; // An SD write can block for tens of milliseconds, and much longer on a card @@ -1050,15 +1051,17 @@ static void __not_in_flash_func(handleReadBuffCall)(uint16_t *payload) { bytesThisChunk = GEMDRIVE_READ_BUFFER_SIZE; } - uint8_t tmp[GEMDRIVE_READ_BUFFER_SIZE]; + // Read into the window the ST reads from and swap there: a 4 KB copy on the + // stack was the deepest frame in the firmware (EPIC-12 STORY-03). + uint8_t *dst = (uint8_t *)(appFreeAddress() + GEMDRIVE_READ_BUFFER_OFFSET); UINT bytesRead = 0; - FRESULT res = f_read(&slot->fp, tmp, (UINT)bytesThisChunk, &bytesRead); + FRESULT res = f_read(&slot->fp, dst, (UINT)bytesThisChunk, &bytesRead); if (res != FR_OK) { writeAppFreeLong(GEMDRIVE_READ_BYTES_OFFSET, (uint32_t)-93); // EIO_READ return; } - // Copy into shared region; m68k reads byte-by-byte so swap pairs. - writeAppFreeBytesSwapped(GEMDRIVE_READ_BUFFER_OFFSET, tmp, bytesRead); + // m68k reads byte-pairs in BE order. + CHANGE_ENDIANESS_BLOCK16(dst, bytesRead & ~1u); writeAppFreeLong(GEMDRIVE_READ_BYTES_OFFSET, (uint32_t)bytesRead); } diff --git a/rp/src/http_server.c b/rp/src/http_server.c index 101df52..4f667db 100644 --- a/rp/src/http_server.c +++ b/rp/src/http_server.c @@ -44,6 +44,12 @@ extern unsigned char __rom_in_ram_start__[]; // truncating large JSON responses; chunked streaming for big bodies // arrives in S5. #define HTTP_RESPONSE_BUF_BYTES 1024 +// The path buffers of the larger handlers are declared `static` rather than on +// the stack (EPIC-12 STORY-03): they made single frames of up to 1,672 bytes, +// and the deepest path through this file 3,784. Safe because the server is +// single-threaded (C-09) and a handler runs to completion within one call -- +// the Runner's spin-waits pump chandler_loop only, never lwIP, so no second +// request can enter a handler while one is in progress. #define HTTP_PATH_BUF_BYTES 192 #define HTTP_QUERY_BUF_BYTES 192 @@ -1296,7 +1302,7 @@ static void handle_runner_status(http_conn_t *c) { snprintf(last_load_errno_buf, sizeof(last_load_errno_buf), "null"); } - char body[640]; + static char body[640]; int n = snprintf( body, sizeof(body), "{\"ok\":true,\"active\":%s,\"busy\":%s,\"cwd\":\"%s\"," @@ -1456,7 +1462,7 @@ static void handle_runner_run(http_conn_t *c) { return; } - char path[RUNNER_PATH_LEN]; + static char path[RUNNER_PATH_LEN]; json_status_t js = json_extract_string(c->body, c->body_received, "path", path, sizeof(path)); if (js == JSON_BAD) { @@ -1494,14 +1500,14 @@ static void handle_runner_run(http_conn_t *c) { // for the m68k stays in user-supplied form (see below) so a bare // filename gets resolved by GEMDOS against the m68k's TOS cwd // (which the previous Dsetpath kept in sync with our cwd mirror). - char rebased[RUNNER_PATH_LEN]; + static char rebased[RUNNER_PATH_LEN]; if (!runner_resolve_relative(path, rebased, sizeof(rebased))) { write_error(c, 400, "Bad Request", "name_too_long", "Path too long after cwd resolution"); return; } - char norm[HTTP_PATH_BUF_BYTES]; - char abs_path[HTTP_FAT_PATH_BUF_BYTES]; + static char norm[HTTP_PATH_BUF_BYTES]; + static char abs_path[HTTP_FAT_PATH_BUF_BYTES]; norm_status_t s = resolve_pair(rebased, norm, sizeof(norm), abs_path, sizeof(abs_path)); if (s != NORM_OK) { @@ -1535,7 +1541,7 @@ static void handle_runner_run(http_conn_t *c) { // paths still work — they just don't depend on cwd. The Runner // Dsetdrvs to the emulated drive before each Pexec, so a bare // backslash form (no drive letter) resolves on our drive. - char st_path[RUNNER_PATH_LEN]; + static char st_path[RUNNER_PATH_LEN]; size_t out = 0; for (size_t i = 0; path[i] != '\0' && out < sizeof(st_path) - 1; i++) { char ch = path[i]; @@ -1603,7 +1609,7 @@ static void handle_runner_load(http_conn_t *c) { return; } - char path[RUNNER_PATH_LEN]; + static char path[RUNNER_PATH_LEN]; json_status_t js = json_extract_string(c->body, c->body_received, "path", path, sizeof(path)); if (js == JSON_BAD) { @@ -1635,14 +1641,14 @@ static void handle_runner_load(http_conn_t *c) { } // Same path-resolution + jail-check + f_stat as /runner/run. - char rebased[RUNNER_PATH_LEN]; + static char rebased[RUNNER_PATH_LEN]; if (!runner_resolve_relative(path, rebased, sizeof(rebased))) { write_error(c, 400, "Bad Request", "name_too_long", "Path too long after cwd resolution"); return; } - char norm[HTTP_PATH_BUF_BYTES]; - char abs_path[HTTP_FAT_PATH_BUF_BYTES]; + static char norm[HTTP_PATH_BUF_BYTES]; + static char abs_path[HTTP_FAT_PATH_BUF_BYTES]; norm_status_t s = resolve_pair(rebased, norm, sizeof(norm), abs_path, sizeof(abs_path)); if (s != NORM_OK) { @@ -1671,7 +1677,7 @@ static void handle_runner_load(http_conn_t *c) { } // Same backslash-form path translation as /runner/run. - char st_path[RUNNER_PATH_LEN]; + static char st_path[RUNNER_PATH_LEN]; size_t out = 0; for (size_t i = 0; path[i] != '\0' && out < sizeof(st_path) - 1; i++) { char ch = path[i]; @@ -1894,7 +1900,7 @@ static void handle_runner_cd(http_conn_t *c) { return; } - char path[RUNNER_PATH_LEN]; + static char path[RUNNER_PATH_LEN]; json_status_t js = json_extract_string(c->body, c->body_received, "path", path, sizeof(path)); if (js == JSON_BAD) { @@ -1910,14 +1916,14 @@ static void handle_runner_cd(http_conn_t *c) { // Resolve relative paths against the current cwd so e.g. `cd SUB` // from /TEST lands on /TEST/SUB. - char rebased[RUNNER_PATH_LEN]; + static char rebased[RUNNER_PATH_LEN]; if (!runner_resolve_relative(path, rebased, sizeof(rebased))) { write_error(c, 400, "Bad Request", "name_too_long", "Path too long after cwd resolution"); return; } - char norm[HTTP_PATH_BUF_BYTES]; - char abs_path[HTTP_FAT_PATH_BUF_BYTES]; + static char norm[HTTP_PATH_BUF_BYTES]; + static char abs_path[HTTP_FAT_PATH_BUF_BYTES]; norm_status_t s = resolve_pair(rebased, norm, sizeof(norm), abs_path, sizeof(abs_path)); if (s != NORM_OK) { @@ -1950,7 +1956,7 @@ static void handle_runner_cd(http_conn_t *c) { // m68k on /TEST/ARKANOID just like our mirror. Absolute inputs work // independently of cwd. The Runner Dsetdrvs before Dsetpath so a // bare backslash path resolves on the GEMDRIVE drive. - char st_path[RUNNER_PATH_LEN]; + static char st_path[RUNNER_PATH_LEN]; size_t out = 0; for (size_t i = 0; path[i] != '\0' && out < sizeof(st_path) - 1; i++) { char ch = path[i]; @@ -3106,7 +3112,7 @@ static void stream_listing_drive(http_conn_t *c) { static void handle_files_list(http_conn_t *c) { // Extract ?path=, default to "/". - char rel[HTTP_PATH_BUF_BYTES]; + static char rel[HTTP_PATH_BUF_BYTES]; rel[0] = '\0'; if (c->query[0] != '\0') { if (!query_get(c->query, "path", rel, sizeof(rel))) { @@ -3118,7 +3124,7 @@ static void handle_files_list(http_conn_t *c) { } } - char abs_path[HTTP_FAT_PATH_BUF_BYTES]; + static char abs_path[HTTP_FAT_PATH_BUF_BYTES]; norm_status_t s = resolve_jail(rel, abs_path, sizeof(abs_path)); if (s == NORM_BAD_PATH) { write_error(c, 400, "Bad Request", "bad_path", "Path not allowed"); @@ -3159,7 +3165,7 @@ static void handle_files_list(http_conn_t *c) { c->stream_body_done = false; // Canonical normalised path to echo in the envelope. - char norm[HTTP_PATH_BUF_BYTES]; + static char norm[HTTP_PATH_BUF_BYTES]; if (normalize_rel(rel, norm, sizeof(norm)) != NORM_OK) { norm[0] = '/'; norm[1] = '\0'; @@ -3253,8 +3259,8 @@ static bool finfo_is_dir(const FILINFO *info) { } static void handle_folder_create(http_conn_t *c, const char *url_rel) { - char norm[HTTP_PATH_BUF_BYTES]; - char abs_path[HTTP_FAT_PATH_BUF_BYTES]; + static char norm[HTTP_PATH_BUF_BYTES]; + static char abs_path[HTTP_FAT_PATH_BUF_BYTES]; norm_status_t s = resolve_pair(url_rel, norm, sizeof(norm), abs_path, sizeof(abs_path)); if (s != NORM_OK) { @@ -3377,7 +3383,7 @@ static void handle_folder_rename(http_conn_t *c, const char *url_rel) { return; } - char to_url[HTTP_PATH_BUF_BYTES]; + static char to_url[HTTP_PATH_BUF_BYTES]; json_status_t js = json_extract_string(c->body, c->body_received, "to", to_url, sizeof(to_url)); if (js == JSON_BAD) { @@ -3392,8 +3398,8 @@ static void handle_folder_rename(http_conn_t *c, const char *url_rel) { } // Resolve source. - char src_norm[HTTP_PATH_BUF_BYTES]; - char src_abs[HTTP_FAT_PATH_BUF_BYTES]; + static char src_norm[HTTP_PATH_BUF_BYTES]; + static char src_abs[HTTP_FAT_PATH_BUF_BYTES]; norm_status_t s = resolve_pair(url_rel, src_norm, sizeof(src_norm), src_abs, sizeof(src_abs)); if (s != NORM_OK) { @@ -3406,13 +3412,13 @@ static void handle_folder_rename(http_conn_t *c, const char *url_rel) { } // Resolve target. `to` is taken as-is (already-decoded JSON string). - char dst_norm[HTTP_PATH_BUF_BYTES]; + static char dst_norm[HTTP_PATH_BUF_BYTES]; s = normalize_rel(to_url, dst_norm, sizeof(dst_norm)); if (s != NORM_OK) { write_path_error(c, s); return; } - char dst_abs[HTTP_FAT_PATH_BUF_BYTES]; + static char dst_abs[HTTP_FAT_PATH_BUF_BYTES]; s = resolve_jail(dst_norm, dst_abs, sizeof(dst_abs)); if (s != NORM_OK) { write_path_error(c, s); @@ -3570,8 +3576,8 @@ static void handle_file_download(http_conn_t *c, return; } - char norm[HTTP_PATH_BUF_BYTES]; - char abs_path[HTTP_FAT_PATH_BUF_BYTES]; + static char norm[HTTP_PATH_BUF_BYTES]; + static char abs_path[HTTP_FAT_PATH_BUF_BYTES]; norm_status_t s = resolve_pair(url_rel, norm, sizeof(norm), abs_path, sizeof(abs_path)); if (s != NORM_OK) { @@ -4030,7 +4036,7 @@ static void handle_file_rename(http_conn_t *c, return; } - char to_url[HTTP_PATH_BUF_BYTES]; + static char to_url[HTTP_PATH_BUF_BYTES]; json_status_t js = json_extract_string(c->body, c->body_received, "to", to_url, sizeof(to_url)); if (js == JSON_BAD) { @@ -4045,8 +4051,8 @@ static void handle_file_rename(http_conn_t *c, } // Resolve source. - char src_norm[HTTP_PATH_BUF_BYTES]; - char src_abs[HTTP_FAT_PATH_BUF_BYTES]; + static char src_norm[HTTP_PATH_BUF_BYTES]; + static char src_abs[HTTP_FAT_PATH_BUF_BYTES]; norm_status_t s = resolve_pair(url_rel, src_norm, sizeof(src_norm), src_abs, sizeof(src_abs)); if (s != NORM_OK) { @@ -4060,13 +4066,13 @@ static void handle_file_rename(http_conn_t *c, // Resolve target. `to` was JSON-decoded already so we run it through // normalize_rel directly (no URL-decoding needed). - char dst_norm[HTTP_PATH_BUF_BYTES]; + static char dst_norm[HTTP_PATH_BUF_BYTES]; s = normalize_rel(to_url, dst_norm, sizeof(dst_norm)); if (s != NORM_OK) { write_path_error(c, s); return; } - char dst_abs[HTTP_FAT_PATH_BUF_BYTES]; + static char dst_abs[HTTP_FAT_PATH_BUF_BYTES]; s = resolve_jail(dst_norm, dst_abs, sizeof(dst_abs)); if (s != NORM_OK) { write_path_error(c, s); diff --git a/rp/src/term.c b/rp/src/term.c index 6c808c2..e25a8e6 100644 --- a/rp/src/term.c +++ b/rp/src/term.c @@ -622,14 +622,15 @@ void term_init(void) { // Invoke this function to process the commands from the active loop in the // main function void __not_in_flash_func(term_loop)() { - TransmissionProtocol protocolSnapshot = {0}; + // Read the published slot in place. Copying it cost 4,184 bytes of stack, + // the deepest frame in the firmware; the double buffer already keeps the + // producer off this slot, and both run on core 0 (C-09, EPIC-12 STORY-03). + const TransmissionProtocol *snapshot = NULL; bool protocolReady = false; uint32_t overwriteCountSnapshot = 0; - // Snapshot the latest published slot. Producer and consumer are both - // on core 0 and never re-enter, so no critical section is needed. if (protocolBufferReady) { - protocolSnapshot = protocolBuffers[protocolReadIndex]; + snapshot = &protocolBuffers[protocolReadIndex]; protocolBufferReady = false; protocolReady = true; } @@ -639,9 +640,9 @@ void __not_in_flash_func(term_loop)() { // Shared by all commands // Read the random token from the command and increment the payload // pointer to the first parameter available in the payload - uint32_t randomToken = TPROTO_GET_RANDOM_TOKEN(protocolSnapshot.payload); - uint16_t *payloadPtr = ((uint16_t *)(protocolSnapshot).payload); - uint16_t commandId = protocolSnapshot.command_id; + uint32_t randomToken = TPROTO_GET_RANDOM_TOKEN(snapshot->payload); + uint16_t *payloadPtr = ((uint16_t *)(*snapshot).payload); + uint16_t commandId = snapshot->command_id; // One line per command floods the console during a GEMDRIVE transfer (two // per 1 KB chunk) and the traffic itself breaks the ST's synchronous // handshake, so the commands term handles trace below instead. Set @@ -650,8 +651,8 @@ void __not_in_flash_func(term_loop)() { DPRINTF( "Command ID: %d. Size: %d. Random token: 0x%08X, Checksum: 0x%04X, " "Overwrites: %lu\n", - protocolSnapshot.command_id, protocolSnapshot.payload_size, randomToken, - protocolSnapshot.final_checksum, (unsigned long)overwriteCountSnapshot); + snapshot->command_id, snapshot->payload_size, randomToken, + snapshot->final_checksum, (unsigned long)overwriteCountSnapshot); #endif #if defined(_DEBUG) && (_DEBUG != 0) @@ -660,33 +661,33 @@ void __not_in_flash_func(term_loop)() { // Read the payload parameters uint16_t payloadSizeTmp = 4; - if ((protocolSnapshot.payload_size > payloadSizeTmp) && - (protocolSnapshot.payload_size <= TERM_PARAMETERS_MAX_SIZE)) { + if ((snapshot->payload_size > payloadSizeTmp) && + (snapshot->payload_size <= TERM_PARAMETERS_MAX_SIZE)) { DPRINTF("Payload D3: 0x%04X\n", TPROTO_GET_PAYLOAD_PARAM32(payloadPtr)); TPROTO_NEXT32_PAYLOAD_PTR(payloadPtr); } payloadSizeTmp += 4; - if ((protocolSnapshot.payload_size > payloadSizeTmp) && - (protocolSnapshot.payload_size <= TERM_PARAMETERS_MAX_SIZE)) { + if ((snapshot->payload_size > payloadSizeTmp) && + (snapshot->payload_size <= TERM_PARAMETERS_MAX_SIZE)) { DPRINTF("Payload D4: 0x%04X\n", TPROTO_GET_PAYLOAD_PARAM32(payloadPtr)); TPROTO_NEXT32_PAYLOAD_PTR(payloadPtr); } payloadSizeTmp += 4; - if ((protocolSnapshot.payload_size > payloadSizeTmp) && - (protocolSnapshot.payload_size <= TERM_PARAMETERS_MAX_SIZE)) { + if ((snapshot->payload_size > payloadSizeTmp) && + (snapshot->payload_size <= TERM_PARAMETERS_MAX_SIZE)) { DPRINTF("Payload D5: 0x%04X\n", TPROTO_GET_PAYLOAD_PARAM32(payloadPtr)); TPROTO_NEXT32_PAYLOAD_PTR(payloadPtr); } payloadSizeTmp += 4; - if ((protocolSnapshot.payload_size > payloadSizeTmp) && - (protocolSnapshot.payload_size <= TERM_PARAMETERS_MAX_SIZE)) { + if ((snapshot->payload_size > payloadSizeTmp) && + (snapshot->payload_size <= TERM_PARAMETERS_MAX_SIZE)) { DPRINTF("Payload D6: 0x%04X\n", TPROTO_GET_PAYLOAD_PARAM32(payloadPtr)); TPROTO_NEXT32_PAYLOAD_PTR(payloadPtr); } #endif // Handle the command - switch (protocolSnapshot.command_id) { + switch (snapshot->command_id) { case APP_TERMINAL_START: { display_termStart(DISPLAY_TILES_WIDTH, DISPLAY_TILES_HEIGHT); commandLevel = TERM_COMMAND_LEVEL_SINGLE_KEY; @@ -699,7 +700,7 @@ void __not_in_flash_func(term_loop)() { DPRINTF("Send command to display: DISPLAY_COMMAND_TERM\n"); } break; case APP_TERMINAL_KEYSTROKE: { - uint16_t *payload = ((uint16_t *)(protocolSnapshot).payload); + uint16_t *payload = ((uint16_t *)(*snapshot).payload); // Jump the random token TPROTO_NEXT32_PAYLOAD_PTR(payload); // Extract the 32 bit payload diff --git a/tools/dev/measure_builds.sh b/tools/dev/measure_builds.sh index 88034a2..29ccf36 100755 --- a/tools/dev/measure_builds.sh +++ b/tools/dev/measure_builds.sh @@ -13,7 +13,7 @@ # assemble. set -Eeo pipefail -REPO="$(cd "$(dirname "$0")/../../.." && pwd)" +REPO="$(cd "$(dirname "$0")/../.." && pwd)" OUT="${1:-$(mktemp -d)}" mkdir -p "$OUT" From 81b8a4fe70b36ae669981c9cb17b4067bf087c67 Mon Sep 17 00:00:00 2001 From: Diego Parrilla Date: Wed, 16 Sep 2026 20:47:48 +0200 Subject: [PATCH 08/12] Share one FatFs sector buffer instead of one per file (EPIC-12 STORY-03) FF_FS_TINY 0 gives every open FIL its own 512-byte sector buffer, 6 KB across the slots this app opens. Measured both ways on hardware: eight 512 KB files copied from the ST, which interleaves a read and a write through the shared buffer and is the case the setting can hurt, took 47 s at 0 and 48 s at 1; the 256 KB HTTP round trips stayed inside their run-to-run spread. Release heap 61,556 -> 67,700 bytes. --- rp/src/ff/ffconf.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rp/src/ff/ffconf.h b/rp/src/ff/ffconf.h index 77dab09..ea4cdde 100644 --- a/rp/src/ff/ffconf.h +++ b/rp/src/ff/ffconf.h @@ -209,7 +209,12 @@ function needs to implement / GET_SECTOR_SIZE command. */ /* The same value for every build type: a debug build must differ from a / release build only by its traces, not by the size of every FIL object. */ -#define FF_FS_TINY 0 +#define FF_FS_TINY 1 +/* 1 (EPIC-12 STORY-03): each open FIL keeps its own 512-byte sector buffer at +/ 0, which is 6 KB of RAM across the file slots this app opens. Measured with +/ both settings: an 8 x 512 KB copy from the ST, which interleaves a read and +/ a write through the shared buffer, took 47 s at 0 and 48 s at 1, and the +/ HTTP round trips were within their run-to-run spread. */ /* This option switches tiny buffer configuration. (0:Normal or 1:Tiny) / At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes. / Instead of private sector buffer eliminated from the file object, From ab86ec2f6942d21a80ad11b6dccb07a4b88d4eba Mon Sep 17 00:00:00 2001 From: Diego Parrilla Date: Wed, 16 Sep 2026 20:54:05 +0200 Subject: [PATCH 09/12] Give core 0 a real stack at the top of RAM (EPIC-12 STORY-04, D-02) The SDK default put core 0's stack at the end of the 4 KB SCRATCH_Y bank with PICO_STACK_SIZE reserving 2 KB of it. This firmware's measured peak was 2,564 bytes before this epic's work and up to 7,700 during a Runner session, so it was already running through the rest of SCRATCH_Y and into core 1's SCRATCH_X, silently. The stack now occupies the top of main RAM and the heap is capped at its bottom, porting Booster's memmap_booster.ld block and its reasoning. Size follows D-02: peak x 2 + 1 KB, rounded to 4 KB, never below 16 KB; 2,564 x 2 + 1,024 rounds to 8 KB, so the 16 KB floor decides. Set in the linker script only, never through PICO_STACK_SIZE, which would move core 1's stack as well. EPIC-09's painting and high-water scan follow the stack: one plain region between __StackBottom and __StackTop, with no code interleaved as there was in the scratch banks. Release heap 67,700 -> 51,316 bytes (35,472 at the start of this epic), debug 47,164. Measured on hardware: reserved 16,384, peak 2,580 during the smoke script on release and 2,008 on debug, no overflow, and both build types pass the smoke script. --- rp/src/health.c | 23 ++++++----------------- rp/src/memmap_rp.ld | 26 +++++++++++++++++++++----- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/rp/src/health.c b/rp/src/health.c index bed064d..8b5ac42 100644 --- a/rp/src/health.c +++ b/rp/src/health.c @@ -65,9 +65,6 @@ extern char end; extern char __StackLimit; extern char __StackTop; extern char __StackBottom; -extern char __scratch_x_end__; -extern char __scratch_y_start__; -extern char __scratch_y_end__; extern char __data_start__; extern char __data_end__; @@ -108,28 +105,20 @@ static void health_paintRange(uint32_t from, uint32_t to) { } } -// Everything the core-0 stack can reach before it leaves the scratch -// regions: SCRATCH_X after its code, then SCRATCH_Y after its code, up -// to just below the current stack pointer. +// The core-0 stack is a plain region at the top of main RAM now (D-02), so +// paint all of it below the current stack pointer. No code lives in it, unlike +// the scratch banks it used to share. static __attribute__((noinline)) void health_paintStack(void) { uint32_t here = 0; uint32_t sp = (uint32_t)&here - STACK_PAINT_MARGIN_WORDS * 4u; - health_paintRange((uint32_t)&__scratch_x_end__, - (uint32_t)&__scratch_y_start__); - health_paintRange((uint32_t)&__scratch_y_end__, sp); -} - -static bool health_isCode(uint32_t a) { - return a >= (uint32_t)&__scratch_y_start__ && - a < (uint32_t)&__scratch_y_end__; + health_paintRange((uint32_t)&__StackBottom, sp); } // Lowest address below __StackTop that no longer holds the pattern. static uint32_t health_stackLowestTouched(void) { - uint32_t a = ((uint32_t)&__scratch_x_end__ + 3u) & ~3u; + uint32_t a = ((uint32_t)&__StackBottom + 3u) & ~3u; uint32_t top = (uint32_t)&__StackTop; for (; a < top; a += 4u) { - if (health_isCode(a)) continue; if (*(uint32_t *)a != STACK_PAINT) return a; } return top; @@ -473,7 +462,7 @@ void health_getReport(health_report_t *out) { out->sbrk_high_water = sbrkHighWater; uint32_t top = (uint32_t)&__StackTop; - uint32_t lowestPainted = ((uint32_t)&__scratch_x_end__ + 3u) & ~3u; + uint32_t lowestPainted = ((uint32_t)&__StackBottom + 3u) & ~3u; uint32_t lowest = health_stackLowestTouched(); out->stack_reserved = top - (uint32_t)&__StackBottom; out->stack_high_water = top - lowest; diff --git a/rp/src/memmap_rp.ld b/rp/src/memmap_rp.ld index 7944594..0afc5ec 100644 --- a/rp/src/memmap_rp.ld +++ b/rp/src/memmap_rp.ld @@ -237,8 +237,8 @@ SECTIONS * * stack1 section may be empty/missing if platform_launch_core1 is not used */ - /* by default we put core 0 stack at the end of scratch Y, so that if core 1 - * stack is not used then all of SCRATCH_X is free. + /* Core 1 keeps its SCRATCH_X stack; core 0's now lives at the top of main + * RAM (see __Core0StackSize below), so SCRATCH_Y is left unused. */ .stack1_dummy (NOLOAD): { @@ -311,11 +311,27 @@ SECTIONS * ASSERT below) or an out-of-memory failure at runtime — both of * which are loud and easy to diagnose, instead of a mystery * cartridge boot failure later. */ - __StackLimit = ORIGIN(RAM) + LENGTH(RAM); + /* Core 0's stack lives at the top of main RAM, not in SCRATCH_Y (D-02, + * porting Booster D-03). The SDK default put it at the end of the 4 KB + * SCRATCH_Y bank with PICO_STACK_SIZE reserving 2 KB of it, and this + * firmware's measured peak was already 2,564 bytes: it was running into + * the rest of SCRATCH_Y and, past that, into core 1's SCRATCH_X. + * + * Size is D-02's rule: largest measured peak on release and debug x 2 + + * 1 KB of interrupt headroom, rounded up to 4 KB, never below 16 KB. + * 2,564 x 2 + 1,024 = 6,152 -> 8 KB, so the 16 KB floor applies. + * + * Set only here, never with -DPICO_STACK_SIZE: that macro also feeds + * PICO_CORE1_STACK_SIZE and would move core 1's stack too. */ + __Core0StackSize = 16K; __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X); - __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y); + __StackTop = ORIGIN(RAM) + LENGTH(RAM); __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy); - __StackBottom = __StackTop - SIZEOF(.stack_dummy); + __StackBottom = __StackTop - __Core0StackSize; + /* The heap cap, per the comment above: it must now stop at the stack's + * bottom rather than at the start of ROM_IN_RAM, or the heap would grow + * up into the stack. */ + __StackLimit = __StackBottom; PROVIDE(__stack = __StackTop); /* Check if data + heap + stack exceeds RAM limit */ From c51d2f71f1a24b9e4e3ff800fc263e9ca3ec36c0 Mon Sep 17 00:00:00 2001 From: Diego Parrilla Date: Wed, 16 Sep 2026 21:36:06 +0200 Subject: [PATCH 10/12] Fault at the stack guard instead of corrupting memory (EPIC-12 STORY-05) With the stack at the top of RAM, an overflow would write down through the heap and, past that, whatever else it reached. PICO_USE_STACK_GUARDS puts an MPU region over the lowest 32 bytes of core 0's stack, so an overflow faults there and reboots with a breadcrumb (D-03). Enabled in both build types, not just debug: in a shipping build the alternative is silent corruption that surfaces much later as a mystery. It costs one of the eight MPU regions, which nothing else here uses, the lowest 32 bytes of the stack, and a few instructions per core at boot. EPIC-09's stack painting had to move above the guard: it painted from __StackBottom and faulted on the guarded bytes at every boot, which put the RP in a crash loop tight enough that neither picotool nor the probe could attach -- recovery needed BOOTSEL. Painted stack is now 16,352 of 16,384 bytes. POST /api/v1/debug/test/stack-overflow (debug builds) recurses until it hits the guard. Verified on hardware: HARDFAULT with pc inside the recursion and sp 0x2002bff8, eight bytes below the 0x2002c000 stack bottom, then a reboot with reason hardfault and a clean recovery. Two earlier versions of that test were optimised into a loop by GCC and never grew the stack; the frame has to escape through a volatile pointer to stop it. Release: smoke passes, stack peak 1,936 of 16,384, heap unchanged. --- docs/api.md | 1 + rp/src/CMakeLists.txt | 9 +++++++++ rp/src/health.c | 44 ++++++++++++++++++++++++++++++++++++++--- rp/src/http_server.c | 5 ++++- rp/src/include/health.h | 1 + 5 files changed, 56 insertions(+), 4 deletions(-) diff --git a/docs/api.md b/docs/api.md index 15f8a56..1b1c845 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1185,6 +1185,7 @@ that the firmware recovers from a crash or a hang and reports it. | `/api/v1/debug/test/panic` | Calls `panic()` from the main loop. The RP reboots with reason `panic`. | | `/api/v1/debug/test/hardfault` | Reads an unmapped address from the main loop. The RP reboots with reason `hardfault`. | | `/api/v1/debug/test/hang` | Spins forever in the main loop. After 8 s the watchdog reboots the RP with reason `hang`, phase `main_loop`. | +| `/api/v1/debug/test/stack-overflow` | Recurses until the stack reaches its guard. The MPU faults on the guarded 32 bytes at the stack bottom, so the RP reboots with reason `hardfault` and an `sp` just below `__StackBottom`, instead of writing down through the heap. | | `/api/v1/debug/test/http-hang` | Spins forever inside the request handler and never answers. Reason `hang`, phase `http_request`. | | `/api/v1/debug/test/stall` | Blocks the main loop for 500 ms without reading the ROM3 ring. With the ST streaming debug bytes, `rom3_overruns` goes up. | diff --git a/rp/src/CMakeLists.txt b/rp/src/CMakeLists.txt index 5b23a95..edba65d 100644 --- a/rp/src/CMakeLists.txt +++ b/rp/src/CMakeLists.txt @@ -296,6 +296,15 @@ endif() # Pass the _DEBUG flag to the C compiler add_definitions(-D_DEBUG=${_DEBUG}) +# Guard the bottom of core 0's stack with the MPU (EPIC-12 STORY-05): an +# overflow faults at the guard instead of writing down through the heap and, +# past it, the cartridge window the ST reads. Both build types on purpose: in a +# shipping build the alternative is silent corruption that surfaces later as a +# mystery, while a fault reboots with a breadcrumb (D-03). Costs one of the +# eight MPU regions (nothing else here uses the MPU), the lowest 32 bytes of +# the stack, and a few instructions per core at boot. +add_definitions(-DPICO_USE_STACK_GUARDS=1) + # lwIP statistics are opt-in and debug-only (lwipopts.h). Set # DEVOPS_LWIP_STATS=1 in the environment of a debug build to report the # lwIP pool counters in GET /api/v1/system/health. diff --git a/rp/src/health.c b/rp/src/health.c index 8b5ac42..56ea811 100644 --- a/rp/src/health.c +++ b/rp/src/health.c @@ -45,6 +45,14 @@ #define STACK_PAINT 0x57AC57ACu // Words left unpainted below the current SP when painting. #define STACK_PAINT_MARGIN_WORDS 16u +// The SDK's MPU stack guard (PICO_USE_STACK_GUARDS) protects the lowest 32 +// bytes of the stack, rounded up to a 32-byte boundary. Painting or scanning +// them would fault, so the paint starts above the guard. +#if PICO_USE_STACK_GUARDS +#define STACK_GUARD_BYTES 32u +#else +#define STACK_GUARD_BYTES 0u +#endif #define HEAP_SAMPLE_INTERVAL_MS 100u #define WINDOW_UPDATE_INTERVAL_MS 1000u @@ -108,15 +116,19 @@ static void health_paintRange(uint32_t from, uint32_t to) { // The core-0 stack is a plain region at the top of main RAM now (D-02), so // paint all of it below the current stack pointer. No code lives in it, unlike // the scratch banks it used to share. +static uint32_t health_stackPaintFloor(void) { + return (((uint32_t)&__StackBottom + STACK_GUARD_BYTES) + 31u) & ~31u; +} + static __attribute__((noinline)) void health_paintStack(void) { uint32_t here = 0; uint32_t sp = (uint32_t)&here - STACK_PAINT_MARGIN_WORDS * 4u; - health_paintRange((uint32_t)&__StackBottom, sp); + health_paintRange(health_stackPaintFloor(), sp); } // Lowest address below __StackTop that no longer holds the pattern. static uint32_t health_stackLowestTouched(void) { - uint32_t a = ((uint32_t)&__StackBottom + 3u) & ~3u; + uint32_t a = health_stackPaintFloor(); uint32_t top = (uint32_t)&__StackTop; for (; a < top; a += 4u) { if (*(uint32_t *)a != STACK_PAINT) return a; @@ -383,6 +395,27 @@ void health_requestTest(health_test_t test) { pendingTest = test; } +// Recurse with a frame big enough to reach the guard quickly. The frame has to +// escape into a volatile sink and be used again after the call, or GCC turns +// this accumulator recursion into a plain loop and the stack never grows (it +// did: the first version ran to completion with a 2,136-byte high-water). +// The POINTER must be volatile, not what it points at: with `volatile uint32_t +// *sink` the stores were dead code, the call became a tail call and GCC +// rewrote the recursion as a loop over one frame. +static volatile uint32_t *volatile healthBurnSink; + +static __attribute__((noinline)) void health_burnStack(uint32_t depth) { + volatile uint32_t block[64]; + for (size_t i = 0; i < sizeof(block) / sizeof(block[0]); i++) { + block[i] = depth + (uint32_t)i; + } + healthBurnSink = block; + if (depth < 100000u) { + health_burnStack(depth + 1u); + } + healthBurnSink = block; +} + static void health_runPendingTest(uint32_t now) { if (pendingTest == HEALTH_TEST_NONE || now < pendingTestAtMs) return; health_test_t test = pendingTest; @@ -407,6 +440,11 @@ static void health_runPendingTest(uint32_t now) { DPRINTF("health: test stall %u ms\n", (unsigned)TEST_STALL_MS); busy_wait_ms(TEST_STALL_MS); break; + case HEALTH_TEST_STACK_OVERFLOW: + DPRINTF("health: test stack overflow, stack bottom 0x%08lx\n", + (unsigned long)(uint32_t)&__StackBottom); + health_burnStack(0); + break; default: break; } @@ -462,7 +500,7 @@ void health_getReport(health_report_t *out) { out->sbrk_high_water = sbrkHighWater; uint32_t top = (uint32_t)&__StackTop; - uint32_t lowestPainted = ((uint32_t)&__StackBottom + 3u) & ~3u; + uint32_t lowestPainted = health_stackPaintFloor(); uint32_t lowest = health_stackLowestTouched(); out->stack_reserved = top - (uint32_t)&__StackBottom; out->stack_high_water = top - lowest; diff --git a/rp/src/http_server.c b/rp/src/http_server.c index 4f667db..d4d20ce 100644 --- a/rp/src/http_server.c +++ b/rp/src/http_server.c @@ -2895,7 +2895,7 @@ static void handle_system_health(http_conn_t *c) { } #if defined(_DEBUG) && (_DEBUG != 0) -// POST /api/v1/debug/test/ — +// POST /api/v1/debug/test/ — // debug builds only. Injects a fault to verify crash and hang recovery. // All but http-hang answer 202 and fire from the main loop shortly // after; http-hang never answers and hangs inside this handler. @@ -2911,6 +2911,8 @@ static void handle_debug_test(http_conn_t *c) { test = HEALTH_TEST_HANG; } else if (strcmp(what, "stall") == 0) { test = HEALTH_TEST_STALL; + } else if (strcmp(what, "stack-overflow") == 0) { + test = HEALTH_TEST_STACK_OVERFLOW; } else if (strcmp(what, "http-hang") == 0) { DPRINTF("health: test hang inside an HTTP handler\n"); for (;;) tight_loop_contents(); @@ -4180,6 +4182,7 @@ static const route_t g_routes[] = { {"/api/v1/debug/test/hardfault", M_POST, handle_debug_test}, {"/api/v1/debug/test/hang", M_POST, handle_debug_test}, {"/api/v1/debug/test/stall", M_POST, handle_debug_test}, + {"/api/v1/debug/test/stack-overflow", M_POST, handle_debug_test}, {"/api/v1/debug/test/http-hang", M_POST, handle_debug_test}, #endif }; diff --git a/rp/src/include/health.h b/rp/src/include/health.h index b16ee17..35ed0d8 100644 --- a/rp/src/include/health.h +++ b/rp/src/include/health.h @@ -127,6 +127,7 @@ typedef enum { HEALTH_TEST_HARDFAULT, HEALTH_TEST_HANG, // hang in the main loop HEALTH_TEST_STALL, // stop the main loop for 500 ms + HEALTH_TEST_STACK_OVERFLOW, // recurse until the stack guard faults } health_test_t; // Runs the test from the main loop after a short delay, so the HTTP From 35a7de2aa5869348e3b3f7ae5678d659fc72949a Mon Sep 17 00:00:00 2001 From: Diego Parrilla Date: Wed, 16 Sep 2026 21:41:37 +0200 Subject: [PATCH 11/12] Fail the link when the RAM budget is gone (EPIC-12 STORY-06) Three asserts in memmap_rp.ld, so a change that eats RAM stops at the build instead of on a desk: the heap may not fall below __MinHeapSize (40K), the stack may not overlap the heap, and the core-0 stack may not drop below D-02's 16K floor. 40K is what this epic's measurements support: 51,316 bytes of heap on release and 47,164 on debug, about 15 KB ever claimed and 31 KB free at the worst moment of a smoke run. Every link now prints the same size report the CI job summary uses, so local and CI builds report identical numbers. Two of its rows were wrong since the stack moved: it read the stack from .stack_dummy, still 2 KB after STORY-04 put the real 16 KB stack at the top of RAM, and the heap from __bss_end__ rather than __end__. Checked by raising the floor to 52K: the link fails with "heap is below __MinHeapSize: something new is eating RAM, see EPIC-12 STORY-06". --- .github/scripts/firmware_size_report.py | 12 +++++++----- rp/src/CMakeLists.txt | 14 ++++++++++++++ rp/src/memmap_rp.ld | 17 +++++++++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/scripts/firmware_size_report.py b/.github/scripts/firmware_size_report.py index 0ae0e90..02cbcb1 100644 --- a/.github/scripts/firmware_size_report.py +++ b/.github/scripts/firmware_size_report.py @@ -3,9 +3,10 @@ Usage: firmware_size_report.py -Used by the CI workflows to fill the job summary. Section sizes come from -arm-none-eabi-size; the heap, the code copied to RAM and the flash use come -from the linker map, so they follow memmap_rp.ld if it changes. +Used by the CI workflows to fill the job summary and printed after every local +link (EPIC-12 STORY-06). Section sizes come from arm-none-eabi-size; the heap, +the stack, the code copied to RAM and the flash use come from the linker map, +so they follow memmap_rp.ld if it changes. """ import re import subprocess @@ -73,8 +74,9 @@ def main(): (".data (copied to RAM)", sizes.get(".data", 0)), ("Code copied to RAM", code_in_ram(map_text, stack_limit)), (".bss", sizes.get(".bss", 0)), - ("Heap (end of .bss to __StackLimit)", stack_limit - map_symbol(map_text, "__bss_end__")), - ("Core-0 stack reserved", sizes.get(".stack_dummy", 0)), + ("Heap (__end__ to __StackLimit)", stack_limit - map_symbol(map_text, "__end__")), + ("Core-0 stack reserved", + map_symbol(map_text, "__StackTop") - map_symbol(map_text, "__StackBottom")), ("Flash used", map_symbol(map_text, "__flash_binary_end") - FLASH_ORIGIN), ] print(f"### Firmware size: {title}\n") diff --git a/rp/src/CMakeLists.txt b/rp/src/CMakeLists.txt index edba65d..6403fb7 100644 --- a/rp/src/CMakeLists.txt +++ b/rp/src/CMakeLists.txt @@ -331,6 +331,20 @@ add_definitions(-DPICO_FLASH_ASSUME_CORE0_SAFE=1) # undefined behaviour. add_definitions(-DCFG_TUD_CDC_TX_BUFSIZE=1024) +# Print the RAM and flash budget after every link (EPIC-12 STORY-06), with the +# same script that fills the CI job summary, so a local build and a CI build +# report the same numbers. Skipped when no python3 is around. +find_package(Python3 COMPONENTS Interpreter QUIET) +if(Python3_Interpreter_FOUND) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${Python3_EXECUTABLE} + ${CMAKE_CURRENT_LIST_DIR}/../../.github/scripts/firmware_size_report.py + $<TARGET_FILE:${PROJECT_NAME}> + $<TARGET_FILE:${PROJECT_NAME}>.map + "$<IF:$<STREQUAL:${_DEBUG},0>,release,debug>" + VERBATIM) +endif() + # Remove unused data # Symbols stay in rp.elf: they are not part of the flashed image, and crash # addresses and debug probes need them. diff --git a/rp/src/memmap_rp.ld b/rp/src/memmap_rp.ld index 0afc5ec..464391a 100644 --- a/rp/src/memmap_rp.ld +++ b/rp/src/memmap_rp.ld @@ -334,8 +334,25 @@ SECTIONS __StackLimit = __StackBottom; PROVIDE(__stack = __StackTop); + /* Budgets, so a change that eats the heap or the stack fails the link + * instead of failing on a desk (EPIC-12 STORY-06). + * + * The floor is what this firmware measured after EPIC-12: 51,316 bytes of + * heap on release and 47,164 on debug, with 15 KB the most ever claimed + * and roughly 31 KB free at the worst moment of a smoke run. 40 KB leaves + * both build types several KB of room to grow and still catches anything + * that swallows the heap wholesale. Raise the floor when the measurements + * allow it; lowering it is a decision, not a fix. */ + __MinHeapSize = 40K; + /* Check if data + heap + stack exceeds RAM limit */ ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed") + ASSERT(__StackBottom >= __HeapLimit, + "the core-0 stack overlaps the heap: see __Core0StackSize in memmap_rp.ld") + ASSERT(__StackLimit - __end__ >= __MinHeapSize, + "heap is below __MinHeapSize: something new is eating RAM, see EPIC-12 STORY-06") + ASSERT(__Core0StackSize >= 16K, + "the core-0 stack is below the 16K floor of D-02") ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary") /* todo assert on extra code */ From 398247a2e58ae23adea38465d5582e2f6a7603a9 Mon Sep 17 00:00:00 2001 From: Diego Parrilla <diego.parrilla.santamaria@gmail.com> Date: Wed, 16 Sep 2026 22:23:02 +0200 Subject: [PATCH 12/12] Ignore compiled Python files The developer tools in tools/dev leave .pyc files behind when they import each other. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ea01bea..d4b3979 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,7 @@ Module.symvers Mkfile.old dkms.conf +*.pyc ffconf.h.bak secrets.sh upload_s3.sh