This repository has been archived by the owner on Feb 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwch-isp.1
140 lines (137 loc) · 3.19 KB
/
wch-isp.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
.TH WCH-ISP 1 wch-isp\-VERSION
.SH NAME
wch-isp \- firmware programmer for WCH microcontrollers
.SH SYNOPSIS
.B wch-isp
.RI [ OPTIONS ]
.I COMMAND
.RI [ ARG ...]
.SH DESCRIPTION
.B wch-isp
is an utility to write firmware into the flash of WCH microcontrollers, over USB or COM-port.
By default the flash content is verified after writing.
.SH OPTIONS
.TP
.B \-n
Do not verify flash content after writing, verification is done by default.
.TP
.B \-p
Prints a progress during command operation.
.TP
.B \-r
Reset the microcontroller after the command is completed.
.TP
.B \-b
Do not read database
.TP
.B \-f
Ignore if firmware size more than cached flash size (program memory)
.TP
.B \-F
Ignore if firmware size more than total flash size (program memory + const data memory)
.TP
.B \-d
Enable debug information, print raw isp commands sent over USB or COM-port.
.TP
.B \-v
Prints version information to stdout, then exits.
.TP
.B \-h, --help
Prints help message to stdout, then exits.
.TP
.B \--port=<PORT> [baudrate]
Specify port to connect the device. It may be 'USB' or '/dev/ttyUSB0' or '//./COM2' or something else
.TP
.B \--device=<DEV>
Test if connected device is DEV and exit if they differ. <DEV> may be read by 'info' option.
Example: --device=CH32V203G8R6
.TP
.B \--uid=<uid>
Select the microcontroller that matches the uid.
.TP
.B \--reset=<pin>
Specify COM-port control pin as RESET signal. May be RTS, DTR, nRTS or nDTR
.TP
.B \--boot0=<pin>
Specify COM-port control pin as Boot0 signal. May be RTS, DTR, nRTS or nDTR
.TP
.B \--address=<addr>
Start writing from addr
.SH COMMANDS
.TP
.B list
List the currently detected compatible devices.
.TP
.BI write " FILE"
Write
.I FILE
into flash, this will automatically erase sufficient flash sectors before writing to it.
.TP
.BI verify " FILE"
Verify
.I FILE
content against the flash content.
.TP
.B erase
Erase all the flash content (not implemented yet).
.TP
.B unlock
Disable flash write protection (modifies the chip configuration) (not implemented yet)
.TP
.B info
Print a device information and memory dump of the chip configuration.
.TP
.BI optionbytes 'CMD'
change optionbytes
example: ./wch-isp optionbytes 'RDPR=0xA5, DATA0 = 0x42'
.TP
.BI optionshow 'CMD'
show changes after apply CMD to optionbytes; Do not write
.SH EXAMPLES
.PP
List detected devices:
.PP
.in +4n
.EX
.RB "$ " "wch-isp list"
found 0x19 0x3B ( CH32V203G8R6 ), bt ver.0206 uid = [ CD-AB-1D-36-51-BC-3B-9E ]
found 0x17 0x71 ( CH32V307RCT6 ), bt ver.0209 uid = [ 87-80-CB-26-3B-38-8D-DF ]
.EE
.in
.PP
Flash the
.B firmware.bin
file via USB,
.B \-p
enable the progress bar.
.PP
.in +4n
.EX
.RB "$ " "./wch-isp --port=USB -p write firmware.bin"
Erase 1 sectors (1024 bytes)
Write: 100.0 % Write 792 bytes: DONE
Verify: 100.0 % Verify 792 bytes: DONE
.EE
.in
.PP
Verify the
.B firmware.bin
via COM-port (reset connected to RTS, Boot0 connected to DTR):
.PP
.in +4n
.EX
.RB "$ " "./wch-isp --port=/dev/ttyUSB0 --reset=RTS --boot0=DTR verify firmware.hex
Verify 792 bytes: DONE
.EE
.in
.PP
Unlock read-protection and write 0x42 to DATA0 field in optionbytes:
.PP
.in +4n
.EX
.RB "$ " "./wch-isp --port=/dev/tty_CH32_PROG_0 9600 optionbytes 'RDPR=0xA5 DATA0 = 0x42'"
Option bytes write:
0x609F5AA5
0xFF00FF42
0xFFFFFFFF
Done