(SOLVED) CH-340 USB to Serial Download issue

User avatar
Posts: 230
Joined: Fri May 22, 2015 12:58 am
Location: Silicon Valley Vortex

Re: (SOLVED) CH-340 USB to Serial Download issue

Postby sheepdoll » Wed Feb 24, 2016 5:47 pm

Interesting thread.

I was at the local makerspace last night and picked up a cheap Arduino clone that they were selling. I still have Yousemite on my laptop. Spent most of the time installing the driver. The first board failed to upload blink, the second worked. I basically wanted a burner Arduino. I was also curious about this bridge chip. I may pull parts off of the clone if the CH-340 is working. (It is likely the clone is missing a bootloader.)

User avatar
Posts: 1779
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta

Re: (SOLVED) CH-340 USB to Serial Download issue

Postby mrburnette » Wed Feb 24, 2016 6:27 pm

sheepdoll wrote:Interesting thread.
I may pull parts off of the clone if the CH-340 is working. (It is likely the clone is missing a bootloader.)

That would be my guess too as I have received clones with no boothoader or perhaps a corrupted bootloader... guess I I could have read the fuses to determine if the configuration was even attempted.


Posts: 18
Joined: Thu Oct 08, 2015 5:44 am

Re: (SOLVED) CH-340 USB to Serial Download issue

Postby jbforrer » Thu Feb 25, 2016 12:49 am

As pointed out by @mrburnette, drivers can be downloaded from the manufacturer's site:

Details are in Chinese. The Linux package contains driver source code (.cpp) and a Makefile.
Being Linux, one need to build a loadable module that will work with your specific kernel.

I understand some Linux distros might already have the correct driver. Plug the device into a USB port and check the list of kernal modules, i.e.,
>$ lsmod | grep usbserial.
If you find "ch341" is being associated with "usbserial", that will be an issue with the CH-340 USB-to-Serial part and STM32duino serial download.

Unfortunately, still seems tricky to get the thing working properly. I'm no Linux expert so your mileage may vary. This what I found:
On my system, "make" fails due to incompatible "printk's" sprinkled through the driver source. Guess these serve for debugging purposes.
Commenting all affected "printk" lines succeeded in building the driver, finishing with "ch34x.ko".

Although the Makefile allows one to load/unload the new driver, one first need to unload the old driver, "ch341" otherwise it will clash with the new one, "ch34x". There are various ways to clean this up, but be very careful how you proceed.

My kernel driver modules are in /lib/modules/3.13.0-24-generic/kernel/drivers/usb/serial ... (you will likely have a different kernel).
"ch341.ko" was renamed "ch341.ko.OLD", then the new driver copied in and named as "ch341.ko".

Plugging the device into a USB port automatically loads the correct kernel drivers. Verify actions with "lsmod", as shown below.
$ lsmod | grep ch34x
ch34x 17618 0
usbserial 45014 1 ch34x

Example results of a serial download:
Sketch uses 23,872 bytes (4%) of program storage space. Maximum is 524,288 bytes.
Global variables use 2,760 bytes of dynamic memory.
stm32flash Arduino_STM32_0.9


Using Parser : Raw BINARY
Interface serial_posix: 230400 8E1
Version : 0x22
Option 1 : 0x00
Option 2 : 0x00
Device ID : 0x0414 (High-density)
- RAM : 64KiB (512b reserved by bootloader)
- Flash : 512KiB (sector size: 2x2048)
- Option RAM : 16b
- System RAM : 2KiB
Write to memory
Erasing memory
Wrote address 0x08005d40 (100.00%) Done.

Starting execution at address 0x08000000... done.

Hope that helps.
Best Regards.

Posts: 1099
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: (SOLVED) CH-340 USB to Serial Download issue

Postby zmemw16 » Thu Feb 25, 2016 1:20 am

aren't printk calls controlled by a writing a number to somewhere under /proc?

since i played with kernel code, when did the pci interface get a massive change 2.2/2.4/2.6?? eons ago - i had to
update/rewrite my pci device drivers. O'Reilly reissued their biblical tome on the subject, pretty sure they're both on my bookshelf. updated since then as well. 3rd 2000 probably not, i'd moved on to a different project by then.

so i googled 'linux kernel controlling printk output'

first 2
and the search drop down has in it



Return to “USB to Serial adaptors”

Who is online

Users browsing this forum: No registered users and 2 guests