boundarydevices / imx_usb_loader

USB & UART loader for i.MX5/6/7/8 series

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

config file search order

kristianlm opened this issue · comments

I find the default config search order a little unintuitive. The first priority is the ./imx_usb executable's path, which is located in this git repo's root folder. There is also a imx_usb.conf file commited there.

As a result, the config argument ./imx_usb -c /home/user/usb-config-dir has no effect since the repository's imx_usb.conf is always found first. It either has to be deleted, or you have to copy/symlink imx_usb out of its repo root folder.

Reversing the config-path ordering solves my problem. Please consider applying this simple fix:

diff --git a/imx_sdp.c b/imx_sdp.c
index 3dec8d5..d525fcc 100644
--- a/imx_sdp.c
+++ b/imx_sdp.c
@@ -156,15 +156,15 @@ char const *conf_file_name(char const *file, char const *base_path, char const *
 {
    char const *conf;

-   // First priority, base path, relative path of binary...
-   dbg_printf("checking with base_path %s\n", base_path);
-   conf = conf_path_ok(base_path, file);
+   // First priority, conf path... (either -c, binary or /etc/imx-loader.d/)
+   dbg_printf("checking with conf_path %s\n", conf_path);
+   conf = conf_path_ok(conf_path, file);
    if (conf != NULL)
        return conf;

-   // Second priority, conf path... (either -c, binary or /etc/imx-loader.d/)
-   dbg_printf("checking with conf_path %s\n", conf_path);
-   conf = conf_path_ok(conf_path, file);
+   // Second priority, base path, relative path of binary...
+   dbg_printf("checking with base_path %s\n", base_path);
+   conf = conf_path_ok(base_path, file);
    if (conf != NULL)
        return conf;

Hi Kristian,

This looks good. Can you submit a proper patch?