[Bug 265533] uchcom: baud rate is not correct for CH34x

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 31 Jul 2022 12:40:59 UTC

            Bug ID: 265533
           Summary: uchcom: baud rate is not correct for CH34x
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: trombik1973@gmail.com

the symptom is that, when uploading code with avrdude, sometimes the result is
successful, but not always.

I have dozens of Chinese clones of arduino nano with CH340C. uploading fails on
about 6 of 10. usually ends up with `expect=0xWHATEVER, resp=0xfc`. during the
process, some commands get proper replies, such as `Device signature = 0x1e950f
(probably m328p)`, others do not. this seems like a baud rate issue.

the Linux kernel driver had a similar issue in the past. but recent kernel does
not, which was verified on Fedora 36. avrdude on the Fedora can upload code to
all the problematic nano boards.

after reading this report on GitHub, i was convinced that the uchcom(4) has

when `uchcom_calc_divider_settings()` is replaced with the one in NetBSD, all
boards work. Sometimes, I am facing issues when avrdude verifies the flash
content, but I am not yet sure what is wrong. could not find common
denominators yet. at least, uploading always works with old bootloader (boud
rate 57600), and new bootloader (115200).

You are receiving this mail because:
You are the assignee for the bug.