From 5903f6aefa6782500ada33818b9c07192d34e1a2 Mon Sep 17 00:00:00 2001
From: cnlohr <lohr85@gmail.com>
Date: Tue, 28 Feb 2023 16:55:48 -0800
Subject: [PATCH] Add documentation for minichlink

---
 minichlink/99-WCH-LinkE.rules |  1 +
 minichlink/Makefile           |  2 +-
 minichlink/README.md          | 29 +++++++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 minichlink/99-WCH-LinkE.rules
 create mode 100644 minichlink/README.md

diff --git a/minichlink/99-WCH-LinkE.rules b/minichlink/99-WCH-LinkE.rules
new file mode 100644
index 0000000..ff1d733
--- /dev/null
+++ b/minichlink/99-WCH-LinkE.rules
@@ -0,0 +1 @@
+SUBSYSTEMS=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="8010", GROUP="plugdev", MODE="0666"
diff --git a/minichlink/Makefile b/minichlink/Makefile
index c39a0e1..bc4b278 100644
--- a/minichlink/Makefile
+++ b/minichlink/Makefile
@@ -9,7 +9,7 @@ minichlink : minichlink.c
 	gcc -o $@ $^ $(LDFLAGS) $(CFLAGS)
 
 install_udev_rules :
-	echo "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"1a86\", ATTRS{idProduct}==\"8010\", GROUP=\"plugdev\", MODE=\"0666\"" > /etc/udev/rules.d/99-qch-LinkE.rules
+	cp 99-WCH-LinkE.rules /etc/udev/rules.d/
 	service udev restart
 
 clean :
diff --git a/minichlink/README.md b/minichlink/README.md
new file mode 100644
index 0000000..6b8d8c6
--- /dev/null
+++ b/minichlink/README.md
@@ -0,0 +1,29 @@
+# minichlink
+
+A free, open mechanism to use the CH-LinkE $4 programming dongle for the CH32V003.
+
+If on Linux, be sure to type make sure to install the `99-WCH-LinkE.rules` build rule to `/etc/udev/rules.d/`
+
+On Windows, if you need to you can install the WinUSB driver over the WCH interface 1.
+
+The exe here is about 12kB and contains everything except for the libusb driver.  In Linux you need `libusb-1.0-dev`.
+
+## Usage
+
+```
+Usage: minichlink [args]
+ single-letter args may be combined, i.e. -3r
+ multi-part args cannot.
+	-3 Enable 3.3V
+	-5 Enable 5V
+	-t Disable 3.3V
+	-f Disable 5V
+	-r Release from reest
+	-R Place into Reset
+	-D Configure NRST as GPIO **WARNING** If you do this and you reconfig
+		the SWIO pin (PD1) on boot, your part can never again be programmed!
+	-d Configure NRST as NRST
+	-w [binary image to write]
+	-o [memory address, decimal or 0x, try 0x08000000] [size, decimal or 0x, try 16384] [output binary image]
+```
+ 
-- 
GitLab