spi-ch341-usb icon indicating copy to clipboard operation
spi-ch341-usb copied to clipboard

Fixes to run on current kernels, better IRQ support, more GPIOs supported, fix race condition on unload

Open geeksville opened this issue 3 years ago • 6 comments

Alas, I haven't yet packed this up as a nice PR. Are you still maintaining this project? If so, I can scrub my changes to collapse commits into something more atomic.

  • Also includes support for more of the GPIOs based on reading the chinese datasheet.
  • @icenowy did reverse engineering of the closed-source Windows driver to find operations needed to read/write these GPIOs
  • Based on that work, it is no longer necessary for the user to wire an extra GPIO input to the dedicated IRQ line. This driver can now read that IRQ state directly.
  • Fix race condition (kernel crash) with thread on driver unload
  • Prevent bogus CS assertions during transactions

Alas, I haven't yet packed this up as a nice PR. Are you still maintaining this project? If so, I can scrub my changes to collapse commits into something more atomic.

geeksville avatar May 30 '21 02:05 geeksville

Thank you very much!

Although I don't use kernel driver anymore, I often use CH341 from userspace (via pyusb) and additional GPIOs will help a lot.

Nable80 avatar May 30 '21 11:05 Nable80

Hi! I can use GPIO, but the spi device does not appear in the /dev directory. , I'm not sure if it is a problem with my device or the driver.

yueduz avatar Oct 23 '21 00:10 yueduz

@geeksville These are a lot of changes. Some of the compilation issues have alredy been solved by other PRs. It seems that there are a lot of changes in your PR that could improve the driver. So I would be very grateful if you would provide them. Maybe, it is possible to restructure and squash them a bit to become more clear. There are still some WIP commits.

gschorcht avatar Oct 24 '21 18:10 gschorcht

@geeksville Does this PR make PR #16 obsolete. It seems that you pushed your changes also to @rogerjames99 branch.

gschorcht avatar Oct 24 '21 18:10 gschorcht

@gschorcht oh yes, this does make PR #16 obsolete. I've been using this on recent kernels just fine. I hadn't heard anything back (wasn't sure if you were still maintaining - it is great you are!) so I also pushed to @rogerjames99 because at the time he had your code and a few other good fixes. I started my work from his branch.

Yes, I can squash a bit if you are interested in these PRs?

geeksville avatar Oct 25 '21 20:10 geeksville

I'm really sorry to hijack this conversation, but I don't know where I could ask my question : I'm using this fork of this driver (which I think contains @geeksville changes) to communicate with a SX1262 (LoRa module) via a CH341 (this module).

@rogerjames99 's fork works very well for me so I'm would be happy to see those changes merged!

Well... it was working fine on kernel 5.10. Now that I'm running 5.14, the `/dev/spidevx.y' entries are not created anymore. I guess there were a few changes in spi/spidev in newer versions of the kernel that are not supported by this driver... I would like to try to fix this but I don't really know where to start looking... Do you have any ideas or pointers to help me?

JF002 avatar Dec 30 '21 11:12 JF002