command-tab / ch341eeprom

A libusb based programming tool for 24Cxx serial EEPROMs using the WinChipHead CH341A IC
GNU General Public License v3.0
149 stars 58 forks source link

Repurposing to assign Serial Number on CH-341 based USB-Serial adapter #8

Open SlySven opened 7 years ago

SlySven commented 7 years ago

Thanks for including the documentation in English for the CH341 IC - my Chinese is non-existent! :relieved:

I just purchased a cheap-as-chips HL-340 translucent bodied USB to serial adapter/lead and from the idVendor and idProduct codes it seems to be based on one of the CH340/1 I.C.s. Notable for this type of unit (unlike say the FTDI ones) is that it does not have a unique SerialNumber - I have heard that all units report a "0" value. This seems to be because when the SDA and SCL pins are floating (?) during reset, the device assumes a default configuration as a USB to Serial. Gazing through the casing on the specimen I have, I can see that that the active device(s) seem to be something bonded directly to the PWB - which conceals what RS232 driver I.C. is being used along side the CH34x I.C. . Also it does not show whether there IS an I2C NVRam present and connected or not.

I was thinking that it might be possible to use the resources here to test and see whether there is an NVRam attached in these units and, if so, it might be worth forking off a project to provide a utility that could carefully reprogram specific values therein, which are used to configure the Unit, to allow a user to assign a different number to several otherwise identical USB-to-Serial units. This would make distinguishing amongst them in, say udev rules very feasible, rather than having to rely on noting which USB port they were plugged into. Any thoughts anyone?

Nable80 commented 4 years ago

Thanks for including the documentation in English for the CH341 IC - my Chinese is non-existent!

IMHO translate.google.com does an awesome job when you try to translate from Chinese to English. Probably there are better alternatives but at least it's works much better than manual translation that can be found in some manuals from China factories.

CH340/1 I.C.s

CH340 (except the rare CH340S IC, heh) and CH341 are really-really different ICs. Even if they're based on the same kind of mask-ROM (or OTP) MCU, it's not good to confuse them, please avoid it.

Most USB-UART (USB serial) dongles use CH340 ICs, while CH341 is used for serial EEPROM programmers and USB to I²C / SPI / LPT (EPP) adapters. CH340 doesn't have I²C pins (SDA/SCL) at all. Some of them (such as CH340B) have an internal EEPROM for USB identifiers but it's unlikely that you can buy ready-made adapters with these one, they're obviously more expensive.

Btw, if you need better USB-serial adapters, I can definitely recommend CP2102-based ones. They have stronger output drivers, better datasheets and CP2102N has an internal EEPROM for customized identifiers and options (btw, most other CP210x have OTP ROM instead). I can't say that CH340-based ones are bad (they are good enough for most use-cases) but these ones have more features and they're quite affordable too.

senthil-embrava commented 2 years ago

Here is one software tool that can be used to update serial number of CH340B.

https://github.com/klpmicro/tools/releases/tag/CH340BConfigurev1.0.0

senthilnathant commented 2 years ago

Here is one software tool that can be used to update serial number of CH340B.

https://github.com/klpmicro/tools/releases/tag/CH340BConfigurev1.0.0

Get the source code licensed under MIT License from the following link:

https://github.com/senthilnathant/tools-ch340b-configuration