Skip to content

seanavery/lib-ch340

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libch340

read/write to ch340 device without tty driver


why?

You bought an off brand arduino and realize that it comes with a ch340 instead of ftdi. Can't find arm64 binary for tty driver? Use lib-ch340 to easily read/write to your microcontroller from any linux host.

development

make build # locally builds static and dynamic target
TARGET=amd64 make build-docker # builds x86 targets in docker
TARGET=arm64 make build-docker # builds arm64 targets in docker
TARGET=[amd64|arm64] make sync # copies build to local fs

test

Run lsusb to find vendor and product id for ch340 device. Look for description such as:

Bus 003 Device 072: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapte

Run test script with vendor and prouct:

./build/tests/test_ch340 1a86 7523

remove sudo requirement

Replace vendor and product id from lsusb query.

echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE="0666"' | \
sudo tee /etc/udev/rules.d/99-usb-serial.rules > /dev/null && \
sudo udevadm control --reload-rules && sudo udevadm trigger

Reconnect the device to trigger rule.