From e2717ef7ca7dc0e6aff4f8efd31a8faa7ed1b4f5 Mon Sep 17 00:00:00 2001 From: logicog Date: Fri, 17 Apr 2026 06:39:04 +0200 Subject: [PATCH] Count pages instead of bytes reading config in execute_config() --- cmd_parser.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd_parser.c b/cmd_parser.c index ae95d38..a63fec7 100644 --- a/cmd_parser.c +++ b/cmd_parser.c @@ -1162,10 +1162,14 @@ void clear_command_history(void) __banked #define FLASH_READ_BURST_SIZE 0x100 #define PASSWORD "1234" + +#if CONFIG_LEN % FLASH_READ_BURST_SIZE + #error "CONFIG_LEN not a multiple of FLASH_READ_BURST_SIZE" +#endif void execute_config(void) __banked { __xdata uint32_t pos = CONFIG_START; - __xdata uint16_t len_left = CONFIG_LEN; + __xdata uint8_t pages_left = CONFIG_LEN / FLASH_READ_BURST_SIZE; // Set default password, it can be overwritten in the configuration file strtox(passwd, PASSWORD); @@ -1206,9 +1210,9 @@ void execute_config(void) __banked cmd_idx++; } while (cfg_idx); - len_left -= FLASH_READ_BURST_SIZE; + pages_left--; pos += FLASH_READ_BURST_SIZE; - } while(len_left); + } while(pages_left); config_done: // Start saving commands to cmd_history