-
Notifications
You must be signed in to change notification settings - Fork 267
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
support for FX2 cables #71
base: master
Are you sure you want to change the base?
Conversation
Thanks for this PR, but some remark:
|
Thank you for your comments. I am copying the author of fpgalink because I am not sure I know the answer to some of your questions.
1. I opted for a simple experience and I am targeting FX2 chips specifically. I am assuming a non programmed FX2 chip or one that has been program to the default fpgalink firmware. As it is, my code passes specific USB vid:pid that correspond to the configuration I described. That was the reason to call my class fx2 it is a specific cable configuration out of other permitted by fpgalink. I can rename fx2 to fpgalink if you still want to after reading this.
2. OFF is fine with me.
3. Sure I will make this change
4. I did include the files after I discovered that the original include directory (install/include) isn't usable as it is. In Makestuff repo, the 2 .h files of interest (common.h and libfpgalink.h) are coming from 2 different directories and it is ok for libfpgalink.h to include <makestuff/common.h>. When the 2 files are in the same directory, libfpgalink.h should include <common.h> otherwise the include fails. So I decided to modify the include in fpgalink.h and include them as part of my code. These include files are very stable so I thought it was ok. @makestuff should voice his opinion and suggest a better solution.... Thank you.
5. I have no idea.... That's not what I am seeing when I use MinGW32 when I compile on Windows. I see the libraries being .dll and their static stubs being .dll.a as expected. Again, @makestuff, if you can field this question, I will be very grateful
I want to thank you both for your kind attention to this PR.
Patrick
…________________________________
From: Gwenhael Goavec-Merou <[email protected]>
Sent: Saturday, January 9, 2021 5:20 AM
To: trabucayre/openFPGALoader <[email protected]>
Cc: phdussud <[email protected]>; Author <[email protected]>
Subject: Re: [trabucayre/openFPGALoader] support for FX2 cables (#71)
Thanks for this PR, but some remark:
* your class is called fx2 but this class implement the fpgalink protocol, it seems more logical to rename this to fpgalink.{hpp,cpp} (globally to replace all fx2 by fpgalink since it's possible to use this firmware with avr (exactly as DirtyJTAG))
* ENABLE_FPGALINK is set to ON by default. I prefer to a default OFF and user select ON if he wan't (with that fpgalink is an optional dependency instead of required by default)
* you update the default list of source/includes, but this list must be updated only if this cable is enabled
* your subdirectory is really mandatory? (fpgalink repo provides this in install/include)
* why libfpgalink.dll.a libraries installed in install/bin are .so ?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftrabucayre%2FopenFPGALoader%2Fpull%2F71%23issuecomment-757181647&data=04%7C01%7C%7C786b2f196c4a4b28c53e08d8b4a167e3%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637457952611070539%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=t%2BhMwnnQv0rNl02sDvZS4x6HdqHalbJCf%2BKVCZxv0EU%3D&reserved=0>, or unsubscribe<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABVQKX2GK4CKVNBDRGG5ZF3SZBJ3XANCNFSM4VZLGU2A&data=04%7C01%7C%7C786b2f196c4a4b28c53e08d8b4a167e3%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637457952611080495%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NgW2yoNCrLAZH%2F7XJhgM1kZV7kMX%2BsM4E7U%2Fq1Bn8zk%3D&reserved=0>.
|
While working on 2. and 3. I realized that the name ENABLE_FPGALINK is contrary to my earlier comment. Based on the final decision on 1. I will adjust the name accordingly.
Thanks,
Patrick
…________________________________
From: Patrick Dussud <[email protected]>
Sent: Saturday, January 9, 2021 10:40 AM
To: trabucayre/openFPGALoader <[email protected]>; trabucayre/openFPGALoader <[email protected]>
Cc: Author <[email protected]>
Subject: Re: [trabucayre/openFPGALoader] support for FX2 cables (#71)
Thank you for your comments. I am copying the author of fpgalink because I am not sure I know the answer to some of your questions.
1. I opted for a simple experience and I am targeting FX2 chips specifically. I am assuming a non programmed FX2 chip or one that has been program to the default fpgalink firmware. As it is, my code passes specific USB vid:pid that correspond to the configuration I described. That was the reason to call my class fx2 it is a specific cable configuration out of other permitted by fpgalink. I can rename fx2 to fpgalink if you still want to after reading this.
2. OFF is fine with me.
3. Sure I will make this change
4. I did include the files after I discovered that the original include directory (install/include) isn't usable as it is. In Makestuff repo, the 2 .h files of interest (common.h and libfpgalink.h) are coming from 2 different directories and it is ok for libfpgalink.h to include <makestuff/common.h>. When the 2 files are in the same directory, libfpgalink.h should include <common.h> otherwise the include fails. So I decided to modify the include in fpgalink.h and include them as part of my code. These include files are very stable so I thought it was ok. @makestuff should voice his opinion and suggest a better solution.... Thank you!
5. I have no idea.... That's not what I am seeing when I use MinGW32 when I compile on Windows. I see the libraries being .dll and their static stubs being .dll.a as expected. Again, @makestuff, if you can field this question, I will be very grateful
I want to thank you both for your kind attention to this PR.
Patrick
________________________________
From: Gwenhael Goavec-Merou <[email protected]>
Sent: Saturday, January 9, 2021 5:20 AM
To: trabucayre/openFPGALoader <[email protected]>
Cc: phdussud <[email protected]>; Author <[email protected]>
Subject: Re: [trabucayre/openFPGALoader] support for FX2 cables (#71)
Thanks for this PR, but some remark:
* your class is called fx2 but this class implement the fpgalink protocol, it seems more logical to rename this to fpgalink.{hpp,cpp} (globally to replace all fx2 by fpgalink since it's possible to use this firmware with avr (exactly as DirtyJTAG))
* ENABLE_FPGALINK is set to ON by default. I prefer to a default OFF and user select ON if he wan't (with that fpgalink is an optional dependency instead of required by default)
* you update the default list of source/includes, but this list must be updated only if this cable is enabled
* your subdirectory is really mandatory? (fpgalink repo provides this in install/include)
* why libfpgalink.dll.a libraries installed in install/bin are .so ?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftrabucayre%2FopenFPGALoader%2Fpull%2F71%23issuecomment-757181647&data=04%7C01%7C%7C786b2f196c4a4b28c53e08d8b4a167e3%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637457952611070539%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=t%2BhMwnnQv0rNl02sDvZS4x6HdqHalbJCf%2BKVCZxv0EU%3D&reserved=0>, or unsubscribe<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABVQKX2GK4CKVNBDRGG5ZF3SZBJ3XANCNFSM4VZLGU2A&data=04%7C01%7C%7C786b2f196c4a4b28c53e08d8b4a167e3%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637457952611080495%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NgW2yoNCrLAZH%2F7XJhgM1kZV7kMX%2BsM4E7U%2Fq1Bn8zk%3D&reserved=0>.
|
I need to recheck fpgalink because being unable to install files in a different location (and having libraries in bin directory) grieves me |
The reason for installing libraries in the bin directory is that Windows lacks a notion of RPATH, so putting everything in a single directory (i.e bin) means that only one directory needs to be added to PATH in order to make it work. So I just follow the same convention on Linux (because it would be extra complexity to do $ORIGIN/../lib on Linux). But I'm open to suggestions about that. |
Thank for your comments.
|
I rebased and pushed #65. CI runs are not shown in the PR, because CI is not enabled for this repo yet. However, you can see the Actions tab of my fork: https://github.com/umarcor/openFPGALoader/actions. The latest run has an artifact: https://github.com/umarcor/openFPGALoader/actions/runs/475847257. The artifact contains MINGW64 and MINGW32 packages, which you can extract to see which files were included. The build recipe is rather simple (~10 relevant lines): https://github.com/trabucayre/openFPGALoader/pull/65/files#diff-57c1a8b93f074586ac89e2e3f65f87bc428edc786ae3ca176cba639141dcf95fR18-R40. You can create a temporary branch based on my PR and rebase it on top of this one. Then, push and CI will run. The relevant lines with regard to the prefix/path on MSYS2 recipes are the following:
Therefore, if the cmake recipes are properly written, #65 should work as is (that's the point of using cmake).
That is correct. On MSYS2, all DLLs are installed to # ls -la /mingw64/bin/*.dll | wc -l
446
# ls -la /mingw64/lib/*.dll | wc -l
2
# ls -la /mingw32/bin/*.dll | wc -l
52
# ls -la /mingw32/lib/*.dll | wc -l
ls: cannot access '/mingw32/lib/*.dll': No such file or directory
0
# ls -la /mingw64/lib/*.a | wc -l
934
# ls -la /mingw64/bin/*.a | wc -l
2 You might have noted that two DLLs exist in My suggestion would be for both GHDL and openFPGALoader to handle it in the most natural way: use |
Yep, happy to go that way if someone wants to raise a PR for it. |
I updated #65. Now, contents of packages are shown in CI. No need to download and extract the artifacts. See https://github.com/umarcor/openFPGALoader/runs/1677313883?check_suite_focus=true#step:8:11. |
@umarcor thanks for your comment. In fact it's not really for openFPGALoader, since no library is installed but for fpgalink. |
On MSYS2, should https://github.com/makestuff/fpgalink be a different package, which openFPGALoader depends on? |
@umarcor : yes. Topic of this PR is to add fpgalink protocol support (optional) and to communicate with the cable through fpgalink. |
My latest commit tries to address some of the issues raised in the PR review:
|
Thanks.
|
@trabucayre, pkg-config is supported on MSYS2 and used by many packages. It's ok and desirable to use that. Am I correct assuming the upstream is https://github.com/makestuff/libfpgalink/ and https://github.com/makestuff/fpgalink is just a utility repo for building it manually? |
|
@trabucayre : The files are named fc2.cpp and fx2.hpp. I am sorry it took so long to do this. I got confused because I renamed fx2.xpp earlier, Windows showed the name in lower case but I didn't notice git didn't do anything to rename the file. |
@umarcor thanks for this information. I think it's a good approach to simplify retrieving informations about a library. As soon my first serie of patches has been accepted by @makestuff I'll send a new serie about |
I got you now! Sorry for being dense. |
Sorry for the delay, I have prefered to wait for a status of
I have a certain tendency to prefer the second solution for two reasons:
For example this: jtagClockFSM(handle, bitPattern, (ulen > 0) ? 32 : 32 + ulen, &error); is more or less the same than that uint8_t buffer[4] = {
buffer[0] = (bitPattern >> 0) & 0xff,
buffer[1] = (bitPattern >> 8) & 0xff,
buffer[2] = (bitPattern >> 16) & 0xff,
buffer[3] = (bitPattern >> 24) & 0xff};
int status = libusb_control_transfer(dev_handle,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
CMD_JTAG_CLOCK_FSM, (ulen > 0) ? 32 : 32 + ulen, 0x0000, buffer, 4, 5000); Ok, it's more verbose, I haven't added verifications and some calls are a bit more complex but it's finally feasible and it's depending of the situation it's more easy to maintain. What do you think about these options? |
I would like @makestuff to opine on this issue. I believe there is value in the fpgalink library beyond being a middle man between openFPGALoader and libusb. It also provides and loads the firmware for the FX2. |
I don't have much of an opinion. It's true that this could be made to work fairly easily just by replicating the FPGALink wire protocol, and I completely understand the preference for fewer dependencies. I guess the other thing I'm not so clear about is who this work is intended for? FPGALink had its heyday way back in 2013, with an active user group, etc. But despite my best efforts, continually adding support for more and more FPGA boards, more host platforms, more language-bindings (Python, Perl, Java, even Excel VBA), and more microcontrollers, it was abundantly clear back in 2014 that it was never going to take off in the way I intended. If this was a thriving project with thousands of users and a plethora of cheap FPGA boards available on AliExpress all claiming "FPGALink Compatible!" then I could see the point of all this. As it is, the world has kinda moved on. I'm only committing to those repos because they're dependencies of other unrelated projects, or as a template project-set for some unrelated work I'm doing for my employer. |
I, usually, prefer to use an library when it's possible instead of reinventing the wheel. For fpgalink my problem is to limit the complexity to obtain all required informations to be able to build support. This why my first idea was to propose the pkg-config support. The result is not limited to openFPGALoader but to all apps and library using fpgalink. |
OK so how about @phdussud forks the FPGALink top-level repo, leaving all the individual library submodules as they are, and adds the pkg-config stuff you need at the top level. It should be enough to produce pkgconfig stuff only for |
I will give it a shot. Just to make sure I understand: The package will need to contain pretty much what is in the install of fpgalink |
No, I think it just needs to add the install location's |
I am following what you are saying and it is useful. I was talking about the package itself. As I understand it, cmake needs to be told how to make a package out of the binaries and includes of libfpgalink. The package will be installed somehow (I know how to install packages in msys2 if they are on the msys2 repo). Once it is installed, I understand that the lib command and the include command will be fetched from the package definition and I agree with what you said about that. |
The idea to create a fork is, in my mind, the worst solution. if each one with a specific contribution has to fork a repository, user will be unable to determine which to use. |
@trabucayre I see what you are saying. @makestuff I misunderstood what the fork is intended for. I thought I would fork, do the work and then PR back to the official fpgalink repo. I am with @trabucayre if it would mean people have to get my forked repo in order to produce the package. |
Fair enough. |
I have already created PR for a subset of repository. No for all, in a first time, to have a go/nogo before continuing... |
Conditionalization of pin mapping for FX2
Fixed CMakeLists.txt so fx2 related include files are not part of the default build
replaced the defined ENABLE_FX2 with USE_LIBFPGALINK so more cables than just fx2 can be supported with the use of libfpgalink removed the src/makestuff directory and use the libfpgalink install include directory instead. This is subject to solving the discovery of the install directory problem
Created a base class FpgaLink to encapsulate the general fpgalink functionality (could be used to create a avr cable) Converted the printf calls to printError and printInfo calls.
Here you go.
Thanks,
Patrick