From 8a5a1f5047ce3a60d49ae140729b72aabf05af0b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 18:31:24 +0000 Subject: [PATCH 1/3] Initial plan From d91cb5e0ddb3c74be1368e1e5a993065e65b890e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 18:34:06 +0000 Subject: [PATCH 2/3] Fix config parser to support both short and long key names with comma/semicolon separators Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com> --- src/dmffs.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/dmffs.c b/src/dmffs.c index f18b6b3..cb409b3 100644 --- a/src/dmffs.c +++ b/src/dmffs.c @@ -106,11 +106,12 @@ static size_t parse_hex_string(const char* hex_str) static bool parse_config_string( dmfsi_context_t ctx, const char* config ) { // Example config string: "flash_addr=0x08000000;flash_size=0x100000" + // Also supports: "addr=0x08000000,size=0x100000" const char* ptr = config; while (*ptr) { // Parse key const char* key_start = ptr; - while (*ptr && *ptr != '=' && *ptr != ';') ptr++; + while (*ptr && *ptr != '=' && *ptr != ';' && *ptr != ',') ptr++; size_t key_len = ptr - key_start; if (*ptr != '=') { @@ -122,15 +123,17 @@ static bool parse_config_string( dmfsi_context_t ctx, const char* config ) // Parse value const char* value_start = ptr; - while (*ptr && *ptr != ';') ptr++; + while (*ptr && *ptr != ';' && *ptr != ',') ptr++; size_t value_len = ptr - value_start; - // Process key-value pair - if (key_len == 10 && strncmp(key_start, "flash_addr", 10) == 0) { + // Process key-value pair - support both long and short key names + if ((key_len == 10 && strncmp(key_start, "flash_addr", 10) == 0) || + (key_len == 4 && strncmp(key_start, "addr", 4) == 0)) { char value_str[20] = {0}; strncpy(value_str, value_start, value_len < 19 ? value_len : 19); ctx->flash_addr = (const void*)parse_hex_string(value_str); - } else if (key_len == 10 && strncmp(key_start, "flash_size", 10) == 0) { + } else if ((key_len == 10 && strncmp(key_start, "flash_size", 10) == 0) || + (key_len == 4 && strncmp(key_start, "size", 4) == 0)) { char value_str[20] = {0}; strncpy(value_str, value_start, value_len < 19 ? value_len : 19); ctx->flash_size = parse_hex_string(value_str); @@ -138,7 +141,8 @@ static bool parse_config_string( dmfsi_context_t ctx, const char* config ) DMOD_LOG_WARN("Unknown config key: '%.*s'\n", (int)key_len, key_start); } - if (*ptr == ';') ptr++; // Skip ';' + // Skip separator (semicolon or comma) + if (*ptr == ';' || *ptr == ',') ptr++; } return true; @@ -518,7 +522,8 @@ int dmod_deinit(void) * * The function initializes the DMFFS file system with the provided configuration string. * The configuration string can specify flash parameters such as address and size, in format: - * "flash_addr=0x08000000;flash_size=0x100000" + * "flash_addr=0x08000000;flash_size=0x100000" or "addr=0x08000000,size=0x100000" + * Both semicolon and comma separators are supported. * * If no configuration string is provided, default parameters from environment variables. * From ec8f877109f2236ec441fe13ce03e8d53f430301 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 18:34:59 +0000 Subject: [PATCH 3/3] Update documentation and fix incomplete sentence in code comment Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com> --- README.md | 19 ++++++++++++++++++- src/dmffs.c | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 81781cb..365ed75 100644 --- a/README.md +++ b/README.md @@ -329,11 +329,28 @@ dmfsi_context_t ctx = dmfsi_dmffs_init(NULL); #### 2. Configuration String (Per-Instance) +The configuration string supports flexible formats for convenience: + ```c -// Pass configuration directly +// Long format with semicolon (original) dmfsi_context_t ctx = dmfsi_dmffs_init("flash_addr=0x08080000;flash_size=0x80000"); + +// Short format with comma (also supported) +dmfsi_context_t ctx = dmfsi_dmffs_init("addr=0x08080000,size=0x80000"); + +// Mixed formats work too +dmfsi_context_t ctx = dmfsi_dmffs_init("addr=0x08080000;size=0x80000"); +dmfsi_context_t ctx = dmfsi_dmffs_init("flash_addr=0x08080000,flash_size=0x80000"); ``` +Supported key names: +- `flash_addr` or `addr` - Flash memory base address (hex value) +- `flash_size` or `size` - Flash memory size (hex value) + +Supported separators: +- `;` (semicolon) +- `,` (comma) + ### Advanced Features #### Directory Support diff --git a/src/dmffs.c b/src/dmffs.c index cb409b3..14c439e 100644 --- a/src/dmffs.c +++ b/src/dmffs.c @@ -525,7 +525,7 @@ int dmod_deinit(void) * "flash_addr=0x08000000;flash_size=0x100000" or "addr=0x08000000,size=0x100000" * Both semicolon and comma separators are supported. * - * If no configuration string is provided, default parameters from environment variables. + * If no configuration string is provided, default parameters are loaded from environment variables. * * @param config (optional) Configuration string (FS-specific) * @return Context pointer on success, NULL on failure