Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows MinGW64 executables have problems #438

Closed
xor-gate opened this issue Jun 20, 2016 · 24 comments · Fixed by #695, #578, #610, #582 or #584
Closed

Windows MinGW64 executables have problems #438

xor-gate opened this issue Jun 20, 2016 · 24 comments · Fixed by #695, #578, #610, #582 or #584

Comments

@xor-gate
Copy link
Member

xor-gate commented Jun 20, 2016

Using:

  • toolchain mingw-w64\x86_64-5.3.0-win32-sjlj-rt_v4-rev0
  • libusb 1.0.20
  • cmake 3.2

Problems:

Log:

C:\Users\Jerry\Downloads\stlink-deprecate_autotools\build>st-info.exe --serial
libusb: error [init_device] device '\\.\USB#VID_0483&PID_374B&MI_02#6&2E55A1F8&0&0002' is no longer connected!
303636454646343835353530373535

C:\Users\Jerry\Downloads\stlink-deprecate_autotools\build>st-info.exe --descr
libusb: error [init_device] device '\\.\USB#VID_0483&PID_374B&MI_02#6&2E55A1F8&0&0002' is no longer connected!
L4 device

C:\Users\Jerry\Downloads\stlink-deprecate_autotools\build>st-info.exe --flash
libusb: error [init_device] device '\\.\USB#VID_0483&PID_374B&MI_02#6&2E55A1F8&0&0002' is no longer connected!
0xzx

C:\Users\Jerry\Downloads\stlink-deprecate_autotools\build>st-info.exe --sram
libusb: error [init_device] device '\\.\USB#VID_0483&PID_374B&MI_02#6&2E55A1F8&0&0002' is no longer connected!
0xzx

C:\Users\Jerry\Downloads\stlink-deprecate_autotools\build>st-info.exe --probe
Found zu stlink programmers

This is a followup of issues found in PR #434 when updating MingGW/MSYS build for windows.

@xor-gate xor-gate added this to the Unplanned (Contributions Welcome) milestone Jun 20, 2016
@xor-gate xor-gate changed the title MinGW64 executables have problems Windows MinGW64 executables have problems Jun 20, 2016
@xor-gate
Copy link
Member Author

Probably the device <devpath> is no longer connected! is due to the nucleo is a composite device:
http://libusb.6.n5.nabble.com/libusb-Two-libusb-devices-for-a-single-physical-device-td5715528.html

@texane
Copy link
Collaborator

texane commented Jun 20, 2016

%zu formatting issue fixed (the hard way). 3f7d0f9..72fbf6a

@xor-gate
Copy link
Member Author

xor-gate commented Jun 20, 2016

Yeah indeed, this seems brute-forced. I'm not 100% happy with this "fix", but for now it works. I'm wondering why the MinGW64 toolchain libc doesn't implement that. I'm not sure if the printf format we used is C99 or GNU99.

@texane
Copy link
Collaborator

texane commented Jun 20, 2016

It will do until a better solution is proposed. A tool / code first has to
be correct
from the functional point of view. Of course, it is better if the
implementation is
good too, but stdio makes that very difficult.

2016-06-20 20:48 GMT+02:00 Jerry Jacobs notifications@github.com:

Yeah indeed, this seems brute-forced. I'm not 100% happy with this "fix",
but for now I don't care. I'm wondering why the MinGW64 toolchain libc
doesn't implement that. I'm not sure if the printf format we used is C99 or
GNU99.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#438 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAEeH2l9yXt8mGa7KRu444N2I_uqHPHGks5qNuBrgaJpZM4I5zeh
.

@xor-gate
Copy link
Member Author

xor-gate commented Jun 20, 2016

Yes I agree it has to be functional.

It seems we don't use it correctly as others have the same problem:
http://stackoverflow.com/questions/10678124/mingw-gcc-unknown-conversion-type-character-h-snprintf
https://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/4F893862.1060206@users.sourceforge.net/
http://www.embedded.com/electronics-blogs/programming-pointers/4007254/A-case-study-in-portability

The suggestion would be just to use everywhere where possible the formatting from <inttypes.h> like PRIuMAX for size_t.

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/inttypes.h.html

I will leave this open, for now it is okay. But needs correct reworking.

@texane
Copy link
Collaborator

texane commented Jun 20, 2016

I checked that all the cases were safe to downcast to unsigned int.
Regarding PRIuMAX,
it needs a cast too, plus it adds the macro. So I do not see any added
value in our case.
OK to let it open, it was not the only problem of the issue.

2016-06-20 20:59 GMT+02:00 Jerry Jacobs notifications@github.com:

Yes I agree it has to be functional.

It seems we don't use it correctly as others have the same problem:

http://stackoverflow.com/questions/10678124/mingw-gcc-unknown-conversion-type-character-h-snprintf

https://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/4F893862.1060206@users.sourceforge.net/

http://www.embedded.com/electronics-blogs/programming-pointers/4007254/A-case-study-in-portability

The suggestion would be just to use everywhere where possible the
formatting from <inttypes.h> like PRIuMAX for size_t.

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/inttypes.h.html

I will leave this open, for now it is okay. But needs correct reworking.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#438 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAEeH_B_wy2CzK8U0ew1BTh6mQL84Q3Hks5qNuMegaJpZM4I5zeh
.

@xor-gate xor-gate removed this from the Unplanned (Contributions Welcome) milestone Sep 18, 2016
@xor-gate
Copy link
Member Author

xor-gate commented Sep 18, 2016

Related to #465, I have tested this myself and --probe seems to work now as expected. Others not tested.

@Nightwalker-87
Copy link
Member

Can somebody with a MinGW64 environment test this properly?
Has this been addressed in Release v1.3.0?

@slyshykO
Copy link
Collaborator

This is output for stlink-v1.5.1

e:\test-st\stlink-1.5.1\build-mingw64>st-info.exe --serial
303637324646343835353530373535

e:\test-st\stlink-1.5.1\build-mingw64>st-info.exe --descr
F7 device

e:\test-st\stlink-1.5.1\build-mingw64>st-info.exe --flash
0x100000

e:\test-st\stlink-1.5.1\build-mingw64>st-info.exe --sram
0x50000

e:\test-st\stlink-1.5.1\build-mingw64>st-info.exe --probe
Found 1 stlink programmers
 serial: 303637324646343835353530373535
openocd: "\x30\x36\x37\x32\x46\x46\x34\x38\x35\x35\x35\x30\x37\x35\x35"
  flash: 1048576 (pagesize: 2048)
   sram: 327680
 chipid: 0x0449
  descr: F7 device

Before v1.5.1, I observe issues in output of st-info.

@Nightwalker-87 Nightwalker-87 modified the milestones: Feedback required, v1.5.1 Mar 21, 2020
@Nightwalker-87
Copy link
Member

Could be PR 680, 695 or 704...

@slyshykO
Copy link
Collaborator

slyshykO commented Mar 22, 2020

I give up 😪.
PR #680 still have an issue.
PR #695 & #704 won't compile (somesibg wrong with cmake project).

CMake Error at CMakeLists.txt:116 (set_target_properties):
  set_target_properties called with incorrect number of arguments.

@Nightwalker-87
Copy link
Member

Don't try to force it - things will become clearer someday. I may take a closer look, as soon as I find some time. Can you give me some advice regarding a correct MinGW setup in a Win10 VM (which appears useful anyway) besides the (outdated?) documentation?

@slyshykO
Copy link
Collaborator

  • I did never really "install" toolchains. Always just download archive and simply extract it in the destination folder.
  • A folder path should contain only ASCII without spaces.

For compile with a certain toolchain, I usually write a simple *.bat script. Like this:

set STLINKVER=git
set CMAKE=e:\test-st\cmake-3.4.0-win32-x86\bin\cmake.exe

set "CUR_DIR=%CD%"
cd %~dp0

PATH=e:\test-st\mingw64\bin;e:\test-st\cmake-3.4.0-win32-x86\bin\;%PATH%

cd %~dp0\stlink-%STLINKVER%

mkdir build-mingw64

cd .\build-mingw64

%CMAKE% -G "Ninja" -DCMAKE_BUILD_TYPE=Release ..

%CMAKE% --build .

@Nightwalker-87
Copy link
Member

@slyshykO: I have some news on this. As you can see, I have created new branches for old versions that fix the git version tag bug (introduced when the version numbering scheme was alligned for earlier versions) in each of these earlier versions, which prevented cmake from compiling. With this fix (which is nothing functional really, and did not exist in earlier days) I can compile quite a few releases with the newest cmake and MinGW-w64 going backwards. With this I find that compiling works without any warnings down to v1.4.0 (incl.). Testing st-info after each compile gives:

C:\Users\user-10\git\stlink\scripts>st-info.exe --probe
Found 1 stlink programmers
 serial: 3f70050132124647524b4e00
openocd: "\x3f\x70\x05\x01\x32\x12\x46\x47\x52\x4b\x4e\x00"
  flash: 65536 (pagesize: 1024)
   sram: 20480
 chipid: 0x0410
  descr: F1 Medium-density device

... which is very nice to see. Going back further, warnings occur in v1.3.1 and v1.3.0, but that does not prevent the compilation to conclude successfully down to the very end. The result from st-info.exe --probe is the same as above. I have completely wiped the previous build before every new build and can see the the version string changes when the package is built at the end of compilation, so I can rule out any accidental rebuilds of already tested versions. Can you try the v1.3.0-patch branch to verify that on a second windows environment? For convenience you may use the latest cmake and MinGW tools, if you like. It should not affect whether the build is successful or not, I shall think by now.

Looking at this I think this issue here has been finally fixed with Release v1.4.0, as all warnings are resolved since then, but as mentioned before, an easy verify should be of common interest.

@slyshykO
Copy link
Collaborator

slyshykO commented Apr 7, 2020

On my PC I receive appropriate output for v1.5.1-patch. Libusb was updated to 1.0.22 in this version.
Before v1.5.1-patch libusb warnings appear in the output.

@Nightwalker-87
Copy link
Member

Nightwalker-87 commented Apr 10, 2020

@slyshykO: Could be that a newer libusb package had accidentally been reused during my previous tests. I can hardly tell by now, but however - the key fact is that I can now somehow reproduce your observations regarding v1.5.1.

This is the history of bugfixing related to this issue:
v1.3.1: Building succeeds with compilation warnings, but some features don't work (see #846)
v1.4.0: libusb 1.0.21 introduced a bug causing builds to fail. Several fixes for MinGW (#578, #582, #584, #610) mainly address this issue.
v1.5.0: - no change -
v1.5.1: Update to libusb 1.0.22 finally fixes the remaining related bug in this external library. Function 'libusb_set_debug' is deprecated since then, what was subsequently fixed in #704.

With these findings we are now finally able to close this issue as resolved and verified.

@Nightwalker-87 Nightwalker-87 linked a pull request Apr 10, 2020 that will close this issue
@stlink-org stlink-org locked as resolved and limited conversation to collaborators Apr 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.