CH341A, USB-UART converter and I2C / SPI programmer for $ 5

    Once upon a time, I wrote a couple of articles about the FTDI FT232H chip, widely known in narrow circles, and its various applications. FT232H for DIY was good for everyone, but it also had several drawbacks - the LQFP48 case is relatively unpleasant for manual soldering (for true hardcore lovers there is another option in QFN48, I do not want to solder it , DIHALT will not let me lie), the price for the original chip is from 250 rubles, the likelihood of problems with drivers on fake chips and some functional redundancy, for example, not everyone needs JTAG support .

    The solution, as usual, came from the Middle Kingdom, in which, after several years of stupidly tearing apart the creative adaptation of other people's chips, they finally released their own USB-TTL converter -WinChipHead CH341A in SOP-28 package (not DIP, but also soldered without problems).

    The chip production was started in the year around 2006, but it only came to my attention in 2014, when I2C / SPI programmers on this chip flooded European EBAY, and sellers offered a price of 3.5 euros or more with delivery, which at an average cost a good Chinese programmer like the MiniPro TL866A at 50 euros turned out to be such a tempting offer that it did not work out.

    If you are still interested in what this Chinese chip can do for $ 1 and whether it is worth paying more, if you can’t see the difference, I ask for a cut.

    Briefly about the chip


    CH341 is a multifunctional converter from USB 2.0 to UART, EPP, I2C and SPI.
    In UART mode, not only RX / TX, but other control signals are supported, so you can make a USB modem on the chip. In parallel port mode, the EPP interface and printer emulation are implemented (which allows connecting LPT printers directly to USB without writing additional drivers). In serial mode, I2C and SPI are supported.

    The chip requires minimal additional strapping (external quartz and several capacitors). It is possible to use an external EEPROM to store custom Vendor ID, Device ID and some chip settings. Power supply from 5 V (via the built-in LDO regulator), or from 3.3 V directly.

    In addition to the CH341A in the SOP-28 package, there are two options in the SSOP-20 - CH341T and CH341H, the first is deprived of SPI support, the second is I2C, so I will not consider them in this article.

    Possible applications


    Described in the article about FT232H , I won’t repeat myself, I’ll just notice that on CH341A I checked only the performance of TX and RX, and not the entire UART interface, if suddenly there are some kind of sudden underwater rake, as it was with I2C on FT232H - write a comment, I will be glad to add it to the article.

    Finished goods


    The Chinese industry offers a million and one versions of the universal I2C / SPI programmer on this chip, one cheaper than the other.

    The option that I got for 3.5 euros, according to the assurances of its manufacturer, can program chips of the 24xx (I2C) and 25xx (SPI) series, which are supposed to be inserted into the ZIF socket (if they are in the DIP-8-300 package), or pressed / soldered to the landing pad on the back of the board (if they are in SOIC-8 or SOIC-16), or connect with wires. Only UART and SPI are brought to the comb, and I2C will have to be taken from the ZIF socket, if necessary (this defect has been fixed in newer versions, but they are more expensive).


    The programmer circuit differs from the reference of the datasheetonly using an external LDO controller instead of the built-in one, apparently, the built-in turned out to be not very reliable. On my copy, everything was saved on everything, and except for the CH341A, there are 2 LEDs (Power and Run), 2 resistors, 5 capacitors (2 for quartz and 3 for the LDO regulator), 12 MHz quartz, the AMS1117 LDO regulator on 1 A and a ZIF socket for two chips in the DIP-8-300 package. From the settings there is a single jumper that switches the programmer between I2C / SPI and USB-UART, while changing its Device ID.


    In Windows 8.1, drivers for both modes are automatically pulled from the network, and on Linux they have been in the kernel for several years.

    For programming in Windows, Chinese software of authorship of a certain SkyGz is used, which is distributed illegally by most sellers with EBAY, but does not stop working from this. Here is a link to it - malthus.mooo.com/download/file.php?id=893 - just do not forget to feed the mother parrot then and fix the blindfold on the eye .

    For Linux, there are open projects ch341prog (SPI) and ch341eepromtool (I2C), both work quite well, but it would be nice to add support for both modes in flashrom (look, xvilka , folk programmers for the price of dirt, but FR still can not )

    I tested the programmer in Windows 8.1 x64 and Xubuntu Core 15.04 x64 on the OnSemi 24C16 I2C chip and the Winbond W25Q64CV SPI chip, working with I2C takes seconds (because the chip has 2 KB of memory and you can read it if you wish write almost with your hands ), but an eight-megabyte SPI chip is read in a minute, and written in two, which, of course, is far from a record, but not too long for a device for $ 5.

    Conclusion


    If you do not need support for JTAG, tens of thousands of various chips and ICSPs, then you need a quick backup / restore tool for firmware of various devices from routers to PCs and servers - I recommend the CH341A programmer for purchase, it works out its 5 bucks. And when its support is added to flashrom - it will become very good.

    On the other hand, I would not put CH341A in the design of my devices, because its reliability with constant use raises some doubts, and if questions arise, there will be no one to ask them, because even the site of the chip manufacturer from outside of China opens once.

    Thanks to the readers for their attention, and let your firmware never fall.

    Also popular now: