Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

Driver name resolution wasn't implementing the documented three-tier fallback: INI field → filename → parent directory. When driver_name was absent from the INI file, the system tried only the filename and never fell back to the parent directory name.

Example failure:

configs/dmclk/stm32f746g-disco.ini  # No driver_name in INI
→ Tries driver "stm32f746g-disco" (from filename)
→ Fails with "Failed to load driver module: stm32f746g-disco"
→ Never tries "dmclk" (parent directory)

Changes

  • read_driver_for_config: Use NULL instead of default_driver as the default parameter to dmini_get_string, enabling detection of missing driver_name fields

  • configure_drivers: Add fallback logic to retry with parent directory name when filename-based driver loading fails:

    if (driver_node == NULL && driver_name != NULL && 
        module_name[0] != '\0' && strcmp(module_name, driver_name) != 0)
    {
        driver_node = configure_driver(driver_name, config_ctx);
    }

The fallback now logs: Driver 'stm32f746g-disco' not found, trying fallback to parent directory name 'dmclk'

Original prompt

This section details on the original issue you should resolve

<issue_title>Niepoprawnie czytana nazwa drivera</issue_title>
<issue_description>W logach poniżej widać jaki jest scenariusz. Zachowanie powinno być takie, że jeśli nie ma sterownika o nazwie odpowiadającej nazwie pliku, to powinien spróbować jeszcze poszukać sterownika o nazwie z katalogu nadrzędnego. (Oczywiście nazwa wpisana bezpośrednio w pliku ini jest zawsze najważniejsza) - ale w tym wypadku jej po prostu nie ma

[INFO] System module: DMBI_seti@dmenv:1.0
[INFO] System module: DMBI_geti@dmenv:1.0
[INFO] System module: DMBI_find@dmenv:1.0
[INFO] System module: DMBI_remove@dmenv:1.0
[INFO] System module: DMBI_clear@dmenv:1.0
[INFO] System module: DMBI_count@dmenv:1.0
[INFO] System module: DMBI_create@dmlist:1.0
[INFO] System module: DMBI_destroy@dmlist:1.0
[INFO] System module: DMBI_size@dmlist:1.0
[INFO] System module: DMBI_is_empty@dmlist:1.0
[INFO] System module: DMBI_push_front@dmlist:1.0
[INFO] System module: DMBI_push_back@dmlist:1.0
[INFO] System module: DMBI_pop_front@dmlist:1.0
[INFO] System module: DMBI_pop_back@dmlist:1.0
[INFO] System module: DMBI_front@dmlist:1.0
[INFO] System module: DMBI_back@dmlist:1.0
[INFO] System module: DMBI_clear@dmlist:1.0
[INFO] System module: DMBI_find@dmlist:1.0
[INFO] System module: DMBI_find_next@dmlist:1.0
[INFO] System module: DMBI_remove@dmlist:1.0
[INFO] System module: DMBI_foreach@dmlist:1.0
[INFO] System module: DMBI_insert@dmlist:1.0
[INFO] System module: DMBI_get@dmlist:1.0
[INFO] System module: DMBI_remove_at@dmlist:1.0
dmdevfs: [ERROR] Failed to load driver module: stm32f746g-disco
dmdevfs: [ERROR] Failed to configure driver: stm32f746g-disco
[INFO] Directory closed successfully
[INFO] Directory closed successfully
[INFO] File system 'dmdevfs' mounted at '/dev' successfully
[INFO] No startup.dmp embedded in ROM
DMOD-Boot started
stm32f746xg@/> ls
[WARN] Could not create mutex
configs  dev  
[WARN] dmheap: Module Invalid is not registered.
stm32f746xg@/> ls dev
[WARN] Could not create mutex

[WARN] dmheap: Module Invalid is not registered.
stm32f746xg@/> ls configs
[WARN] Could not create mutex
dmclk  
[WARN] dmheap: Module Invalid is not registered.
stm32f746xg@/> ls configs/dmclk
[WARN] Could not create mutex
stm32f746g-disco.ini  
[WARN] dmheap: Module Invalid is not registered.
stm32f746xg@/> 

</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 10, 2026 17:36
- Modified read_driver_for_config to use NULL default for dmini_get_string
- Added fallback logic in configure_drivers to try parent directory name
- Implements proper priority: INI file > filename > parent directory

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix incorrect driver name reading in logs Fix driver name resolution fallback to parent directory Feb 10, 2026
Copilot AI requested a review from JohnAmadis February 10, 2026 17:40

const char* name = dmini_get_string(ctx, "main", "driver_name", default_driver);
// First priority: check if driver_name is explicitly set in INI file
const char* name = dmini_get_string(ctx, "main", "driver_name", NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot why NULL here instead of the default driver?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using NULL here is critical for the fallback logic to work correctly. If we passed default_driver (the parent directory name), dmini_get_string would return default_driver whenever the driver_name key doesn't exist in the INI file. This would make the condition if(name != NULL) on line 1028 always true, and we'd skip the filename-based logic on lines 1035-1043.

With NULL, the priority order works as designed:

  1. If INI has driver_name → use it (lines 1027-1032)
  2. Otherwise → extract from filename (lines 1035-1043)
  3. If that driver fails to load → fallback to parent directory (lines 843-848 in configure_drivers)

The default_driver parameter is used later in the actual driver loading fallback, not during the INI parsing phase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Niepoprawnie czytana nazwa drivera

2 participants