f32c / tools

ULX2S / ULX3S FPGA JTAG programmer & tools (Lattice XP2 / ECP5)
22 stars 16 forks source link

Windows ujprog compile error: 'EOPNOTSUPP' undeclared, 'usleep' is deprecated #8

Closed gojimmypi closed 5 years ago

gojimmypi commented 5 years ago

I encountered a bunch of warnings that usleep is deprecated, and more importantly a critical error that 'EOPNOTSUPP' undeclared when compiling ujprog in MinGW32 for Windows:

cp Makefile.win Makefile
make

Output:

gcc.exe -c ujprog.c -o ujprog.o -I.

[... snip ...]

c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c: In function 'shutdown_usb':
ujprog.c:621:2: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
  ms_sleep(10);
  ^~~~~~~~
In file included from ujprog.c:55:
c:\mingw\include\unistd.h:100:29: note: declared here
 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
ujprog.c: In function 'async_read_block':
ujprog.c:2788:4: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
    ms_sleep(backoff * 4);
    ^~~~~~~~
In file included from ujprog.c:55:

[... snip ...]
gcc.exe ujprog.o  -lftd2xx -o "ujprog.exe" -s -static -L. -lftd2xx

The solution that worked for me here for the error: 'EOPNOTSUPP' undeclared was the same as https://github.com/nmap/nmap/issues/183 in adding these two lines to ujprog.c:

#undef EOPNOTSUPP
#define EOPNOTSUPP      WSAEOPNOTSUPP  /* Operation not supported */

After that change, I was able to create an exe for ujprog.

gojimmypi commented 5 years ago

I created this PR to fix: https://github.com/f32c/tools/pull/9

gornjas commented 5 years ago

ujprog builds perfectly fine (no errors or warnings whatsoever) as-is from day 0 on M$ windows, using MSYS MINGW32. make -f Makefile.win is all it takes.

I'm not inclined to accept the proposed patch, as it more likely reflects some problem in the build system (probably including a wrong errno.h) rather than a problem in ujprog.c itself.

Note that we went to great lengths to make and keep ujprog portable across a broad range of platforms (Win32, Linux, FreeBSD, OSX), hence my reluctance to accept a windows-specific fix for a non-issue.

gojimmypi commented 5 years ago

@gornjas - I appreciate the efforts to make it ujprog portable. Respectfully, this is what I see in mingw32 on Windows 10 1803 17134.556:

$ gcc --version
gcc.exe (MinGW.org GCC-8.2.0-3) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Here's the entire output:

$ make -f Makefile.win
gcc.exe -c ujprog.c -o ujprog.o -I.
ujprog.c: In function 'set_port_mode':
ujprog.c:463:4: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
    ms_sleep(20);
    ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c:479:5: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
     ms_sleep(10);
     ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c:483:4: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
    ms_sleep(10);
    ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c: In function 'shutdown_usb':
ujprog.c:620:2: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
  ms_sleep(10);
  ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c: In function 'exec_svf_tokenized':
ujprog.c:1487:9: error: 'EOPNOTSUPP' undeclared (first use in this function); did you mean 'WSAEOPNOTSUPP'?
   res = EOPNOTSUPP;
         ^~~~~~~~~~
         WSAEOPNOTSUPP
ujprog.c:1487:9: note: each undeclared identifier is reported only once for each function it appears in
ujprog.c: In function 'async_read_block':
ujprog.c:2787:4: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
    ms_sleep(backoff * 4);
    ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c: In function 'txfile':
ujprog.c:2978:3: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
   ms_sleep(50);
   ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c:2994:3: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
   ms_sleep(200);
   ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c:2996:3: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
   ms_sleep(100);
   ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c:3008:3: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
   ms_sleep(50);
   ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c:3028:4: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
    ms_sleep(txfu_ms);
    ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c:3070:5: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
     ms_sleep(txfu_ms);
     ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c:3073:4: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
    for(crc_retry = 4; crc_retry > 0 && res != 4; ms_sleep(10), crc_retry--)
    ^~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c:3131:3: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
   ms_sleep(50);
   ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c: In function 'genbrk':
ujprog.c:3148:3: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
   ms_sleep(BREAK_MS);
   ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c:3160:3: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
   ms_sleep(BREAK_MS);
   ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c:3168:2: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
  ms_sleep(20);
  ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c: In function 'debug_cmd':
ujprog.c:3439:4: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
    ms_sleep(c / 50000);
    ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c: In function 'term_emul':
ujprog.c:3562:4: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
    ms_sleep(50);
    ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c:3930:4: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
    ms_sleep(sleep_t);
    ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
ujprog.c: In function 'main':
ujprog.c:4215:3: warning: 'usleep' is deprecated [-Wdeprecated-declarations]
   ms_sleep(1); // small delay for f32c to start
   ^~~~~~~~
In file included from ujprog.c:54:
c:\mingw\include\unistd.h:100:29: note: declared here
 int __cdecl __MINGW_NOTHROW usleep( useconds_t )__MINGW_ATTRIB_DEPRECATED;
                             ^~~~~~
make: *** [ujprog.o] Error 1

with these versions, fresh clone: git clone https://github.com/f32c/tools.git f32c_tools

$ git log -1 -- Makefile.win
commit 9b9fc13c59f179c4a71ab6314181984f516754bd
Author: Marko Zec <zec@fer.hr>
Date:   Sun Dec 17 00:59:08 2017 +0100

    Unbreak build with MSYS2 MinGW 32-bit.  Dev-C++ build will no longer work.

    ujprog xp2.svf works out of the box.

    ujprog ecp5.svf still doesn't, investigating why...
$ git log -1 -- ujprog.c
commit c02dc41b925729f7edf0030e5c94eee9735b6824
Author: gornjas <zec@fer.hr>
Date:   Sat Dec 29 14:24:34 2018 +0100

    Add -f addr specifies a base address for SPI writes using -j flash.

Perhaps I'm still doing something wrong? I do agree that if there's a better solution such as using the proper errno.h - that's probably a better change.

gojimmypi commented 5 years ago

heads up that I appended some other minor, non-code changes to this PR (recent FTDI lib file, add README, etc). Perhaps I should have created a separate PR, but you are welcome to cherry-pick if you find any of this useful.

emard commented 5 years ago

HI

actually I'm not great git expert with cherrypicking; I'm planning first to start from your readme updates, and copy paste them to mainstream. Better docs are always welcome.

I can't decide what to do with ujprog code and win32 changes, I must leave up to "gornjas" the author of ujprog

Have you succeeded in staticaly compiled windows executable? (so all dll's compiled in, no external files needed) That's a great achievement and would improve compatibility

On 2/15/19, gojimmypi notifications@github.com wrote:

heads up that I appended some other minor, non-code changes to this PR (recent FTDI lib file, add README, etc). Perhaps I should have created a separate PR, but you are welcome to cherry-pick if you find any of this useful.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/f32c/tools/issues/8#issuecomment-464208434

gojimmypi commented 5 years ago

@emard if you let me know the destination, I can create a specific PR for you.

regarding your comment on statically compiled windows executable - well, I am able to compile ujprog in WSL Ubuntu for the Windows target (64 bit) using mingw-w64 (see my blog here), copying the latest FTDI ftd2xx.h and ftd2xx.lib files from the FTDI zip download into the ujprog directory.

specifically:

sudo apt-get install mingw-w64

# Get a make file if PR not yet merged
wget https://raw.githubusercontent.com/gojimmypi/f32c_tools/master/ujprog/Makefile.ming32_64

# My c:\download\ftdi\ directory...
cp "/mnt/c/download/ftdi/CDM v2.12.28 WHQL Certified/amd64/ftd2xx.lib" ./ftd2xx.lib
cp "/mnt/c/download/ftdi/CDM v2.12.28 WHQL Certified/ftd2xx.h" ./ftd2xx.h

make clean -f Makefile.ming32_64
make -f Makefile.ming32_64

Note my Makefile.ming32_64 (also included in the PR) specifies the MinGW cross compiler:

CPP  = x86_64-w64-mingw32-gcc
CC   = x86_64-w64-mingw32-gcc

However you specifically noted statically compiled. Well, there is a ftd2xx.lib file in the "static" download directory; this is not the one I used (I tried, it did not compile):

CDM v2.12.28 WHQL Certified\Static\amd64\ftd2xx.lib

Otherwise the executable created is portable, in that I can move it to any directory and there are no DLL's or other files needed... however Windows of course still has the DLL's installed in the system for the device (otherwise it would not work anyhow)

C:\test>ujprog ulx3s.bit
ULX2S / ULX3S JTAG programmer v 3.0.92 (built Feb 15 2019 14:18:16)
Using USB cable: ULX3S FPGA 12K v3.0.3
Programming: 100%
Completed in 16.63 seconds.

Pardon my lack of knowledge here; Sorry if I've not answered your question clearly.

gojimmypi commented 5 years ago

One thing I'd like to add is that the @TinyFPGA can be programmed without any special drivers, using only the /dev/ttySn serial devices. (see my blog here) This would be a highly desirable feature for the ULX3S - particularly in that OpenOCD (libusbK) and ujprog (FTDI) cannot be used concurrently in Windows - and in my case, libusbK cannot be used at all in WSL,

emard commented 5 years ago

HI

I cleaned up your makefile and improved it to automatically download and unzip the required file.

Makefile.ming32_64

can you check this makefile and and output does it really work on your windows?

It compiles ujprog.exe on my debian without any modification of ujprog.c

On 2/15/19, gojimmypi notifications@github.com wrote:

@emard if you let me know the destination, I can create a specific PR for you.

regarding your comment on statically compiled windows executable - well, I am able to compile ujprog in WSL Ubuntu for the Windows target (64 bit) using mingw-w64 (see my blog here), copying the latest FTDI ftd2xx.h and ftd2xx.lib files from the FTDI zip download into the ujprog directory.

specifically:

sudo apt-get install mingw-w64

# Get a make file if PR not yet merged
wget
https://raw.githubusercontent.com/gojimmypi/f32c_tools/master/ujprog/Makefile.ming32_64

# My c:\download\ftdi\ directory...
cp "/mnt/c/download/ftdi/CDM v2.12.28 WHQL Certified/amd64/ftd2xx.lib"
./ftd2xx.lib
cp "/mnt/c/download/ftdi/CDM v2.12.28 WHQL Certified/ftd2xx.h" ./ftd2xx.h

make clean -f Makefile.ming32_64
make -f Makefile.ming32_64

Note my Makefile.ming32_64 (also included in the PR) specifies the MinGW cross compiler:

CPP  = x86_64-w64-mingw32-gcc
CC   = x86_64-w64-mingw32-gcc

However you specifically noted statically compiled. Well, there is a ftd2xx.lib file in the "static" download directory; this is not the one I used (I tried, it did not compile):

CDM v2.12.28 WHQL Certified\Static\amd64\ftd2xx.lib

Otherwise the executable created is portable, in that I can move it to any directory and there are no DLL's or other files needed... however Windows of course still has the DLL's installed in the system for the device (otherwise it would not work anyhow)

C:\test>ujprog ulx3s.bit
ULX2S / ULX3S JTAG programmer v 3.0.92 (built Feb 15 2019 14:18:16)
Using USB cable: ULX3S FPGA 12K v3.0.3
Programming: 100%
Completed in 16.63 seconds.

Pardon my lack of knowledge here; Sorry if I've not answered your question clearly.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/f32c/tools/issues/8#issuecomment-464230982

emard commented 5 years ago

You can take my tinyfpgasp yes ulx3s can be flash over us2 port similar like tinyfpga. tinyfpga USB protocol is not 100% compatible, something is wrong when USB errors need to be retried and it will drop packets.

It's better off to use different usb-serial core but I tried to make a cleaner one but it still drops packets but in different way :)

On 2/16/19, D EMARD vordah@gmail.com wrote:

HI

I cleaned up your makefile and improved it to automatically download and unzip the required file.

Makefile.ming32_64

can you check this makefile and and output does it really work on your windows?

It compiles ujprog.exe on my debian without any modification of ujprog.c

On 2/15/19, gojimmypi notifications@github.com wrote:

@emard if you let me know the destination, I can create a specific PR for you.

regarding your comment on statically compiled windows executable - well, I am able to compile ujprog in WSL Ubuntu for the Windows target (64 bit) using mingw-w64 (see my blog here), copying the latest FTDI ftd2xx.h and ftd2xx.lib files from the FTDI zip download into the ujprog directory.

specifically:

sudo apt-get install mingw-w64

# Get a make file if PR not yet merged
wget
https://raw.githubusercontent.com/gojimmypi/f32c_tools/master/ujprog/Makefile.ming32_64

# My c:\download\ftdi\ directory...
cp "/mnt/c/download/ftdi/CDM v2.12.28 WHQL Certified/amd64/ftd2xx.lib"
./ftd2xx.lib
cp "/mnt/c/download/ftdi/CDM v2.12.28 WHQL Certified/ftd2xx.h" ./ftd2xx.h

make clean -f Makefile.ming32_64
make -f Makefile.ming32_64

Note my Makefile.ming32_64 (also included in the PR) specifies the MinGW cross compiler:

CPP  = x86_64-w64-mingw32-gcc
CC   = x86_64-w64-mingw32-gcc

However you specifically noted statically compiled. Well, there is a ftd2xx.lib file in the "static" download directory; this is not the one I used (I tried, it did not compile):

CDM v2.12.28 WHQL Certified\Static\amd64\ftd2xx.lib

Otherwise the executable created is portable, in that I can move it to any directory and there are no DLL's or other files needed... however Windows of course still has the DLL's installed in the system for the device (otherwise it would not work anyhow)

C:\test>ujprog ulx3s.bit
ULX2S / ULX3S JTAG programmer v 3.0.92 (built Feb 15 2019 14:18:16)
Using USB cable: ULX3S FPGA 12K v3.0.3
Programming: 100%
Completed in 16.63 seconds.

Pardon my lack of knowledge here; Sorry if I've not answered your question clearly.

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/f32c/tools/issues/8#issuecomment-464230982

gojimmypi commented 5 years ago

@emard regarding Makefile.ming32_64; ah yes, that is graceful and efficient, and not dependent on a mystery lib file from someone's repo (although when the FTDI web site gets updated, the Makefile breaks).

yes, it works in WSL Ubuntu (the only thing missing for me was unzip):

sudo apt-get install unzip
mkdir temp2
cd temp2
git clone https://github.com/f32c/tools.git
cd tools/ujprog
make -f Makefile.ming32_64

and the build was succcessful!

0 $ make -f Makefile.ming32_64
x86_64-w64-mingw32-gcc -c ujprog.c -o ujprog.o -I.
wget -c "https://www.ftdichip.com/Drivers/CDM/CDM%20v2.12.28%20WHQL%20Certified.zip" -O ftdi.zip
Will not apply HSTS. The HSTS database must be a regular and non-world-writable file.
ERROR: could not open HSTS store at '/home/gojimmypi/.wget-hsts'. HSTS will be disabled.
--2019-02-15 15:42:38--  https://www.ftdichip.com/Drivers/CDM/CDM%20v2.12.28%20WHQL%20Certified.zip
Resolving www.ftdichip.com (www.ftdichip.com)... 217.160.0.65
Connecting to www.ftdichip.com (www.ftdichip.com)|217.160.0.65|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1682976 (1.6M) [application/zip]
Saving to: ‘ftdi.zip’

ftdi.zip                             100%[=====================================================================>]   1.60M  1.12MB/s    in 1.4s

2019-02-15 15:42:40 (1.12 MB/s) - ‘ftdi.zip’ saved [1682976/1682976]

unzip ftdi.zip amd64/ftd2xx.lib
Archive:  ftdi.zip
  inflating: amd64/ftd2xx.lib
touch amd64/ftd2xx.lib
x86_64-w64-mingw32-gcc ujprog.o  -o "ujprog.exe" -s -static -L. -lamd64/ftd2xx

then copy to C:\test2 for Windows

cp ujprog.exe /mnt/c/test2

tada!

C:\test2>ujprog ulx3s.bit
ULX2S / ULX3S JTAG programmer v 3.0.92 (built Feb 15 2019 15:42:37)
Using USB cable: ULX3S FPGA 12K v3.0.3
Programming: 100%
Completed in 16.59 seconds.

edit: even more interesting is that yes, it compiles... specifically these lines are not in the ujprog.c - yet I also did not encounter the EOPNOTSUPP errors originally described in this issue (above):

#undef EOPNOTSUPP
#define EOPNOTSUPP      WSAEOPNOTSUPP  /* Operation not supported */
gojimmypi commented 5 years ago

@emard regarding tinyfpga USB protocol - I recall reading something about "ValentyUSB" enhancements for the tomu board. I think some progress was made, but I cannot immediately seem to find it. Are you on twitter? perhaps ask there.

emard commented 5 years ago

Eheheee great when ftdi removes this file let me know I will fix it easy

I slightly fixed Makefile.ming32 now it compiles for win32 version of ftdi library. I don't know if win32 binary can also work on win64 machine, maybe you can try and test it too :)?

I also included your readme and images

On 2/16/19, gojimmypi notifications@github.com wrote:

@emard regarding Makefile.ming32_64; ah yes, that is graceful and efficient, and not dependent on a mystery lib file from someone's repo (although when the FTDI web site gets updated, the Makefile breaks).

yes, it works in WSL Ubuntu (the only thing missing for me was unzip):


sudo apt-get install unzip

mkdir temp2

cd temp2

git clone https://github.com/f32c/tools.git

cd tools/ujprog

make -f Makefile.ming32_64

and the build was succcessful!


0 $ make -f Makefile.ming32_64

x86_64-w64-mingw32-gcc -c ujprog.c -o ujprog.o -I.

wget -c
"https://www.ftdichip.com/Drivers/CDM/CDM%20v2.12.28%20WHQL%20Certified.zip"
-O ftdi.zip

Will not apply HSTS. The HSTS database must be a regular and
non-world-writable file.

ERROR: could not open HSTS store at '/home/gojimmypi/.wget-hsts'. HSTS will
be disabled.

--2019-02-15 15:42:38--
https://www.ftdichip.com/Drivers/CDM/CDM%20v2.12.28%20WHQL%20Certified.zip

Resolving www.ftdichip.com (www.ftdichip.com)... 217.160.0.65

Connecting to www.ftdichip.com (www.ftdichip.com)|217.160.0.65|:443...
connected.

HTTP request sent, awaiting response... 200 OK

Length: 1682976 (1.6M) [application/zip]

Saving to: ‘ftdi.zip’

ftdi.zip
100%[=====================================================================>]
  1.60M  1.12MB/s    in 1.4s

2019-02-15 15:42:40 (1.12 MB/s) - ‘ftdi.zip’ saved [1682976/1682976]

unzip ftdi.zip amd64/ftd2xx.lib

Archive:  ftdi.zip

  inflating: amd64/ftd2xx.lib

touch amd64/ftd2xx.lib

x86_64-w64-mingw32-gcc ujprog.o  -o "ujprog.exe" -s -static -L.
-lamd64/ftd2xx

then copy to C:\test2 for Windows


cp ujprog.exe /mnt/c/test2

tada!


C:\test2>ujprog ulx3s.bit

ULX2S / ULX3S JTAG programmer v 3.0.92 (built Feb 15 2019 15:42:37)

Using USB cable: ULX3S FPGA 12K v3.0.3

Programming: 100%

Completed in 16.59 seconds.

--

You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub:

https://github.com/f32c/tools/issues/8#issuecomment-464251672

gojimmypi commented 5 years ago

the root cause of the 'EOPNOTSUPP' undeclared error message appears to be using the old header and lib file (the ones from 4 years ago in this repo) to compile.

Using the most recent ftd2xx.h and ftd2xx.lib from the FTDI zip file resolves the error (and all the warnings) without having to make the code change suggested above.

emard commented 5 years ago

Makefile.ming32 and Makefile.ming32_64 fix this