The conversion from /c/ to c:/ takes place somewhere in msys2 shell, before 
passing arguments to main.c
Of course the shell does not convert the path if it is a part of a complex 
parameter.
Neither stat() nor fopen() can use a path starting with /c/ as a disk name.
https://www.msys2.org/docs/filesystem-paths/

BTW I suspect you faked the results of your test program shown on stackoverflow

PS The whole OpenOCD command is horrible and has more issues than useless usage 
of absolute file paths.
See https://openocd.org/doc/html/Flash-Programming.html


---

** [tickets:#335] OpenOCD does not recognize POSIX absolute path names on 
mingw**

**Status:** new
**Milestone:** 0.11.0
**Labels:** mingw mingw64 msys2 
**Created:** Mon Feb 07, 2022 07:54 AM UTC by themole
**Last Updated:** Mon Feb 07, 2022 07:54 AM UTC
**Owner:** nobody


OpenOCD seems to misinterpret absolute path names on Windows running with MSYS2 
and mingw64.

I also asked for help on 
[stackoverflow](https://stackoverflow.com/questions/70840794/openocd-on-msys2-mingw64),
 where you could possibly find more details.

Here is the excerpt from the Q&A on Stackoverflow:
I traced down the problem to the point, where the absolute path to the 
stlink.cfg is somehow misinterpreted. While all command line tools can find the 
file `/c/somepath/RIOT/dist/tools/openocd/adapters/stlink.cfg`, openocd does 
not. OpenOCD is the mingw64 version residing in `/mingw64/bin/openocd`.

The command in question, executed by RIOTs Makefiles is:
~~~
sh -c "openocd \
    -c 'set stlink_version 2;source 
/c/somepath/RIOT/dist/tools/openocd/adapters/stlink.cfg' \
    -c 'transport select hla_swd' \
    -f '/c/somepath/RIOT/boards/common/stm32/dist/stm32f4.cfg' \
    -c 'tcl_port 0' \
    -c 'telnet_port 0' \
    -c 'gdb_port 0' \
    -c 'init' \
    -c 'targets' \
    -c 'reset halt' \
    -c 'flash write_image erase 
\"/c/somepath/RIOT/hello_world/bin/stm32f429i-disco/helloworld.elf\" 0 ' \
    -c 'verify_image 
"/c/somepath/RIOT/hello_world/bin/stm32f429i-disco/helloworld.elf" 0' \
    -c 'reset run' \
    -c 'shutdown'"
~~~

and also when I just execute:
~~~
openocd -d -c 'set stlink_version 2;source 
/c/somepath/RIOT/dist/tools/openocd/adapters/stlink.cfg'
~~~

Same error occurs:
~~~
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
User : 13 2 options.c:63 configuration_output_handler(): debug_level: 3
[...]
User : 24 3 command.c:694 command_run_line(): couldn't read file 
"/c/somepath/RIOT/dist/tools/openocd/adapters/stlink.cfg": No such file or 
directory
~~~

But when I execute:
~~~
openocd -d -c 'set stlink_version 2;source 
c:/somepath/RIOT/dist/tools/openocd/adapters/stlink.cfg'
~~~
it seems to work.

A simple `cat /c/somepath/RIOT/dist/tools/openocd/adapters/stlink.cfg` shows 
the correct content of the file, the same when I prepend `c:/` instead of `/c/`.

I tried to dig into openocd's code, but since thissomehow involves the 
interpreter, there is no chance for me to dig deep enough.


---

Sent from sourceforge.net because openocd-devel@lists.sourceforge.net is 
subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/openocd/admin/tickets/options.  Or, if this is a 
mailing list, you can unsubscribe from the mailing list.


Reply via email to