Skip to content

update ftd2xx files; fix for Win32 compile error: 'EOPNOTSUPP' undeclared - #9

Closed
gojimmypi wants to merge 24 commits into
f32c:masterfrom
gojimmypi:master
Closed

gojimmypi wants to merge 24 commits into
f32c:masterfrom
gojimmypi:master

Conversation

@gojimmypi

Copy link
Copy Markdown

See #8

 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c: In function 'exec_svf_tokenized':
ujprog.c:1488:9: error: 'EOPNOTSUPP' undeclared (first use in this function); did you mean 'WSAEOPNOTSUPP'?
   res = EOPNOTSUPP;
         ^~~~~~~~~~
         WSAEOPNOTSUPP
ujprog.c:1488:9: note: each undeclared identifier is reported only once for each function it appears in

@gojimmypi

gojimmypi commented Feb 13, 2019 •

Copy link
Copy Markdown
Author

Added more changes:

Changes by gojimmypi Feb 13 2019:

README.md

Microsoft dumpbin reports 51E00677 time/date Fri Jul 12 06:36:55 2013 for current repo ftd2xx.lib

The most recent ftd2xx.lib in 2.12.28 is 599AE440 time/date Mon Aug 21 06:46:40 2017

See https://www.ftdichip.com/Drivers/CDM/CDM%20v2.12.28%20WHQL%20Certified.zip on https://www.ftdichip.com/Drivers/D2XX.htm

I copied the FTDI zip file:

  • CDM v2.12.28 WHQL Certified\ftd2xx.h to ./ftd2xx.h
  • CDM v2.12.28 WHQL Certified\i386\ftd2xx.lib to repo ./ftd2xx.lib
  • CDM v2.12.28 WHQL Certified\amd64\ftd2xx.lib to repo ./ftd2xx.amd64.lib

Compiling with x86_64-w64-mingw32-gcc results in this incompatibility error for ftd2xx.lib (32 bit vs 64 bit conflict):

$ make -f Makefile.ming32_64
x86_64-w64-mingw32-gcc ujprog.o  -lftd2xx -o "ujprog.exe" -s -static -L. -lftd2xx.amd64.lib
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible ./ftd2xx.lib when searching for -lftd2xx
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lftd2xx
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lftd2xx.amd64.lib
collect2: error: ld returned 1 exit status
Makefile.ming32_64:26: recipe for target 'ujprog.exe' failed
make: *** [ujprog.exe] Error 1

So I created Makefile.ming32_64 and added the 64-bit (not static) version (CDM v2.12.28 WHQL Certified\amd64\ftd2xx.lib) as ftd2xx.amd64.lib

I also added a Makefile.ming32 to compile with i686-w64-mingw32 but I could not test this.

Feel free to cherry pick.

@gojimmypi gojimmypi changed the title fix for Win32 compile error: 'EOPNOTSUPP' undeclared update ftd2xx files; fix for Win32 compile error: 'EOPNOTSUPP' undeclared Feb 13, 2019
@gojimmypi

Copy link
Copy Markdown
Author

these issues were manually addressed and fixed by @emard (including a much cooler Makefile!) see #8

@gojimmypi gojimmypi closed this Feb 16, 2019
@emard

emard commented Feb 17, 2019 via email

Copy link
Copy Markdown
Member

@gojimmypi

Copy link
Copy Markdown
Author

hello @emard I can confirm both your 32 bit (renamed to ujprog32.exe ) and 64 bit (renamed to ujprog64.exe) compiled exe files were able to successfully upload the blinky binary to my ULX3S. I was able to do this in a standard command prompt, with elevated permissions not needed.

Admittedly, I needed to tell my AV software that I trusted the files. One ended up going to quarantine that I needed to manually restore. (I must really trust you! ;)

Although your ujprog64.exe and the 64 bit ujprog.exe that I compiled on my system are the same size, I find it curious that the binaries contents differ.

image

If someone is having problems, I'd check to ensure the device shows up as a COM port using FTDI drivers, and that the right USB port is being used (literally - as facing the connectors - the one on the right, closest to the LED's)

Note that the 32 bit file arrived apparently without the Windows security block setting, but the 64 bit does have it set:
image
I did not need to check the "Unblock" checkbox to get it to work.

These tests were performed on Windows 10 64 bit; I'm not sure I have a 32 bit machine to try.

@gojimmypi

Copy link
Copy Markdown
Author

@emard the other thing I just learned is that Windows executables can be run from within WSL!!

So, despite the native USB drivers not being available in WSL, the entire toolchain can remain in WSL by compiling those apps for Windows.

image

image

@gojimmypi

Copy link
Copy Markdown
Author

@emard - I did stumble upon something really odd: it appears compiling the Windows ujprog.exe with -f Makefile.ming32_64 in WSL on a Windows filesystem directory (/mnt/c ...) works just fine... however when compiling on a WSL directory (/home/ ...) - the app compiles without error, but also does not appear to work.

Here are side-by side fresh git clone and make, both from the same repo just minutes apart: on the left in /mnt/c/test_mntc/tools/ujprog and on the right in /home/gojimmypi/test_wsl/tools/ujprog; Note the app on the left returns help info. The app on the right does not show anything when running ujprog.exe.

image

This is not the case with the linux version, that works fine (as expected!) regardless of directory:

image

@emard

emard commented Feb 18, 2019 via email

Copy link
Copy Markdown
Member

@gojimmypi

Copy link
Copy Markdown
Author

ok, now I understand why you asked me to test those. So you've apparently seen this behavior as well - and more importantly from a "real" Linux environment. (I assume your reference was not to WSL Debian)

At first, I thought perhaps this was another manifestation of that annoying CR/CRLF issue I encountered with the DoctorWkt/ULX3S-Blinky#2 (specifically with the lpf file: YosysHQ/nextpnr#235 ) but in that case I was using git to check out actually in a Windows command prompt vs a WSL Ubuntu prompt; Visual Studio "saw" there were changes, but oddly nothing was highlighted.

I'd open an issue in the WSL repo, but I don't know where I'd even start. And the fact that you've seen this in Debian is even more bizarre (thus probably not WSL specific). I'll poke around some and see what I can find.

@gojimmypi

Copy link
Copy Markdown
Author

ok, so more info on this: I've discovered the problem is not where the code is compiled, rather where it is executed. Running the same .exe file from a WSL directory (/home/...) results in the no-output, quiet fail. Copying the same .exe to a non-WSL directory (/mnt/c/...) and the code works.

This behavior was not observed with other native Windows apps launched from WSL (Notepad.exe, Calc.exe, VS Code). They all worked regardless of launch point. (but then they don't use USB drivers)

I've only recently discovered that Windows .exe files can be launched from WSL prompt at all.

ujprog.exe always seems to work properly from a Windows command prompt.

Note I added a printf("Startup!"); immediately after the main(); - and it never even displays when launching from WSL directory, but works just find when launching from /mnt/c/ in WSL...

image

I'm open to suggestions. Per you know how to single-step debug a Windows app compiled with x86_64-w64-mingw32-gcc ?

@emard

emard commented Feb 19, 2019 via email

Copy link
Copy Markdown
Member

@gojimmypi

Copy link
Copy Markdown
Author

interesting comment about the dll; I wonder if somehow the search path is processed differently in /mnt/c/ directories ? I tried moving the app to /other to see if perhaps there was an issue with ~/ user directory, but no:

image

this is really unfortunate, given the obvious importance of ujprog.

@emard

emard commented Feb 19, 2019 via email

Copy link
Copy Markdown
Member

@gojimmypi

Copy link
Copy Markdown
Author

Glad to help. Always nice to be appreciated. :)

It seems that from the gitter a short time later, there was quite a discussion on the FT2232 vs FT231X topic.

I would agree that for a relatively small incremental cost, if there's a substantial increase in reliability & usability - it is probably a good idea.

I'm not sure I agree with you on OpenOCD. The ujprog (usually) works out of the box, first time, default FTDI drivers when the ULX3S is plugged in. To get OpenOCD working, I had to use zadig to install libusbK drivers. Yes, perhaps minor annoyance - but an annoyance and tripping point nonetheless. Even more annoying when you come back to your computer and Windows has decided to apply updates. Of, no worries that everything you left running was closed. Hopefully everything was saved. But often Windows updates will change back to default drivers. Now that can be rather frustrating, particularly if you don't know you need to manually run zadig again.

But: I have a hard time believing the fault on the topic of ujprog operation in WSL is based solely on the ujprog code and/or the type of chip used. I'm still probably going to open a WSL issue on this, as it is just too weird and unbelievable.

Have you seen ujprog problems on plain Windows and/or plain Linux? Sounds that way with the when it works comment. In all fairness, WSL is still relatively new.

See also the What’s new for WSL in Windows 10 version 1903.

@emard

emard commented Feb 20, 2019 via email

Copy link
Copy Markdown
Member

@gojimmypi

Copy link
Copy Markdown
Author

I wonder if these problem are perhaps related to an improper copy of DLL's at install time? Note the 64bit DLL is the larger, 314k version:
image

the 64 bit version appears to have been renamed and placed in my system32 directory, but not renamed in the DriverStore\FileRepository:

image

btw - I saw your README.md updates; for me, having either of these DLL's included in the same directory as the ujprog.exe made no difference in the case where it is launched from the "wrong" directory (e.g. not /mnt/c/ ...)

@gojimmypi

gojimmypi commented Feb 20, 2019 •

Copy link
Copy Markdown
Author

more details on the "wrong" directory (currently noted as this in the README troubleshooting, of course for lack of better info). Perhaps it is more accurate to describe this as: when launching ujprog.exe from VoIFS. See this thread in askubuntu.

Given that - I wonder what is different in VoIFS to cause ujprog.exe to not work?

@emard

emard commented Feb 20, 2019 via email

Copy link
Copy Markdown
Member

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.

2 participants