A handy tool to have on the bench is a Flash chip programmer, and the ones based around the CH341A USB bus converter chip are readily available. But the chip is capable of so much more than simply programming nonvolatile memory, so [Tomasz Ostrowski] has created a utility program that expands its capabilities. The software provides easy access to a range of common i2c peripherals. He’s got it talking to smart batteries, GPIOs, environmental sensors, an OLED display, and even an FM radio module. The code can all be found in a GitHub repository. The software is Windows-only so no fun and games for Linux users yet — but since it’s open source, new features are just a pull request away.
The CH341A is much more than an i2C controller, it also supports a surprising range of other interfaces including SPI, UARTs, and even a bidirectional parallel printer port. Maybe this software will serve to fire the imagination of a few others, and who knows, we could see more extended use of this versatile chip. Oddly we’ve featured these programmer boards before, though in a tricky flashing job.
Still hunting for libusb examples to pilot the all the GPIOs, here it’s only one:
https://github.com/sarim/ch341a-bitbang-userland
As this particular example shows reading AVR signature and fusebits, maybe https://github.com/maxxproff/avrdude-ch341 or https://github.com/Alx2000y/avrdude_ch341a would be interesting for you.
I was wondering for a minute why GPIO instead of SPI was used here (for avrdude there are actually both modes), but it looks like CH341A SPI might be limited to single speed, 1.4 MHz (https://github.com/gschorcht/spi-ch341-usb/blob/master/README.md).
Only tangentially related, but I’m surprised there isn’t a go-to project to turn a microcontroller board into a multipurpose flasher like this one yet.
Bus Pirate (http://dangerousprototypes.com/docs/Bus_Pirate) might be the one, with 2 or 3 dozen articles on hackaday – supported by avrdude, flashrom, OpenOCD. I’m pretty sure it still has many users, though boards are not available at the moment at Seed Studio so I don’t know what’s going on. On adafruit.com it is marked as discontinued.
Good grief. The Adafruit one ($37) says it’s discontinued, but links to another model–which costs $60, and is also discontinued, but links to another model–which is $100.
Sparkfun seems to have the Bus Pirate v3.6a in stock for $32.50.
The links from the DP site to Seeed Studio all take me to “you have been blocked by CloudFlare”, but going to their home page and searching work, but both versions are still out of stock.
IIRC the chip shortage caused Bus Pirate’s discontinuance, and Adafruit has/had a Kickstarter campaign for an RP2040-based reimagining/spiritual successor to the Bus Pirate. Could be pretty slick.
Isn’t the Bus Pirate source code open-source? The chip shortage appears to be abating, so maybe we will see more PIC micro-controllers re-stocked in the future; or if it hasn’t happened already, we will get cloned PIC chips from China.
Dangerous Prototype is close to launching Bus Pirate v5, which is based around the RP2040: https://buspirate.com/
Today there are dirt cheap 8-ch 24 MHz logic analyzers compatible with the free open-source cross-platform Sigrok/Pulseview software.[1][2] The logic analyzer hardware is available from Amazon [3] or any of your usual slow-to-ship Chinese parts vendors.
* References:
1. Sigrok
https://sigrok.org/wiki/Main_Page
2. PulseView
https://sigrok.org/wiki/PulseView
3. HiLetgo USB Logic Analyzer Device With EMI Ferrite Ring USB Cable 24MHz 8CH 24MHz 8 Channel UART IIC SPI Debug 4.5 out of 5 stars 442 ratings 100+ bought in past month $12.69
https://www.amazon.com/HiLetgo-Analyzer-Ferrite-Channel-Arduino/dp/B077LSG5P2/
That programmer comes with design mistake, although it’s lowering 3.3V for Vcc of the programmed chip it’s still having 5V on it’s data lines, which can cause problems especially when in-circuit programming BIOS chips.
It can easily be fixed with piece of wire and soldering iron to use 3.3V on data lines.
https://www.eevblog.com/forum/repair/ch341a-serial-memory-programmer-power-supply-fix/msg1323775/#msg1323775
For Linux this is the most advanced driver so far and the author seems to try to get it into mainline as well.
https://github.com/frank-zago/ch341-i2c-spi-gpio
Version 1.1 is released, adding support for HD44780 over GPIO, HD44780 over I2C (PCF8574), AHT10/AHT20 temperature/humidity sensors, raw SPI data reading/writing, MAX7129 8×8 LED matrix display, AS5600 magnetic angle sensor.