From 3a6f62b1d574915b193f4a999fe2771a22e1cb0a Mon Sep 17 00:00:00 2001 From: d00f <8052722+DrDoof@users.noreply.github.com> Date: Fri, 18 Sep 2026 04:59:37 +0200 Subject: [PATCH] config: skip a line the parser cannot buffer instead of stopping execute_config() replays the saved configuration line by line into cmd_buffer. A line that does not fit, or one cmd_tokenize() rejects, ended the replay right there: everything below it was silently left unapplied, while the file itself and the editor showing it stayed complete. On a switch here, a 130-byte line placed after the last real setting was enough to lose every line that followed it on the next boot. Report the offending line and carry on with the next one. The skip flag lives across the flash page refill, so a long line that crosses a page boundary is not resumed halfway and run as a truncated command. --- cmd_parser.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/cmd_parser.c b/cmd_parser.c index d4c4df8b..d4fe030e 100644 --- a/cmd_parser.c +++ b/cmd_parser.c @@ -1956,6 +1956,7 @@ void execute_config(void) __banked save_cmd = 0; uint8_t cmd_idx = 0; + uint8_t skipping = 0; do { flash_region.addr = pos; flash_region.len = FLASH_READ_BURST_SIZE; @@ -1966,20 +1967,23 @@ void execute_config(void) __banked do { if (cmd_idx >= (CMD_BUF_SIZE - 1)) { cmd_buffer[cmd_idx] = NUL; - print_string("ERROR: Command too long: "); + print_string("ERROR: Command too long, skipped: "); print_string_x(cmd_buffer); write_char('\n'); - err_status = ERR_CMD_TOO_LONG; - goto config_done; + cmd_idx = 0; + skipping = 1; } c = flash_buf[cfg_idx++]; if (c == 0 || c == '\n') { - cmd_buffer[cmd_idx] = NUL; - if (cmd_idx) { - cmd_tokenize(); - if (err_status != ERR_OK) - goto config_done; - cmd_parser(); + if (skipping) { + skipping = 0; + } else { + cmd_buffer[cmd_idx] = NUL; + if (cmd_idx) { + cmd_tokenize(); + if (err_status == ERR_OK) + cmd_parser(); + } } if (c == 0) goto config_done; @@ -1987,8 +1991,10 @@ void execute_config(void) __banked continue; } - cmd_buffer[cmd_idx] = c; - cmd_idx++; + if (!skipping) { + cmd_buffer[cmd_idx] = c; + cmd_idx++; + } } while (cfg_idx); pages_left--;