Experiences with CH341a programmer and sysutils/flashrom

Is there anyone who has recently (or longer ago) used sysutils/flashrom in conjunction with a cheap CH341a-based programmer?

I personally haven't been able to use Flashrom in FreeBSD until I patched it slightly with any of the programmers that I own. Windows-based AsProgrammer worked fine.
So I'd like to know if I'm the only one or this is a common occurrence.

Short story on the patch: the code for all other USB-based programmers that use libusb program without any parallelization. The CH341a code though tries to set up multiple transfers and for some reason this appears not to work. Maybe it's a hardware bug or anything else, but when I patch Flashrom everything works as expected.

Patch that I use:
Code:
--- ch341a_spi.c.orig    2024-10-24 15:36:39 UTC
+++ ch341a_spi.c
@@ -70,7 +70,7 @@
 
 
 /* Number of parallel IN transfers. 32 seems to produce the most stable throughput on Windows. */
-#define USB_IN_TRANSFERS 32
+#define USB_IN_TRANSFERS 1
 
 /* We need to use many queued IN transfers for any resemblance of performance (especially on Windows)
  * because USB spec says that transfers end on non-full packets and the device sends the 31 reply
@@ -436,7 +436,7 @@ static int ch341a_spi_init(const struct programmer_cfg
 
     /* Enable information, warning, and error messages (only). */
 #if LIBUSB_API_VERSION < 0x01000106
-    libusb_set_debug(NULL, 3);
+    libusb_set_debug(NULL, 0);
 #else
     libusb_set_option(NULL, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_INFO);
 #endif
(second part is to disable quite useless debug output while programming)
 
Is there anyone who has recently (or longer ago) used sysutils/flashrom in conjunction with a cheap CH341a-based programmer?
[...]
Maybe it's a hardware bug or anything else, but when I patch Flashrom everything works as expected.
Possibly *completely* unrelated but I do recall having issues with the CH340 (on a cheap Arduino Nano clone). The rx/tx loopback didn't work, the voltages were quite wrong. I was actually intending to use this as a "poor man's" 8051 programmer at the time.

A post that I think details it better (and why) than I could is here:

https://arduino.stackexchange.com/questions/20327/arduino-uno-rx-tx-speaks-to-itself

Perhaps you are running into something related? Maybe its not getting a reply due to that same weird voltage issue.
 
sysctl hw.usb.no_cs_fail=1
does this change anything ?
It appears this doesn't make a difference. I also don't see anything in dmesg, which reinforces my current thoughts.
Perhaps you are running into something related? Maybe its not getting a reply due to that same weird voltage issue.
The voltages should be ok, it's one of the reasons I bought multiple (and different) programmers. I did verify voltages with a multimeter, and they're perfectly in spec.

Is there anyone who has one of these programmers and a flash chip nearby? It would really help me to propose a patch to the port's maintainer via Bugzilla (e-mailed him before, but I don't know if he can test it himself).
 
Back
Top