Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New chip and probe support #28

Merged
merged 13 commits into from
Oct 3, 2023
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Add `--speed` option to specify protocol speed
- Add `erase --method power-off` option to support erase with power off
- Add a simple chip ID db, now wlink can identify chip type automatically

### Fixed

- Regression in `flash` command
- Use chip type from the protocol, close #25
- Support 2.10 (aka. v30) firmware, close #27

### Changed

- Allow underscore `_` in number literals in command line
- Refine protocol naming
- Add a simple DMI algorithm skeleton

## [0.0.5] - 2023-07-31

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Current firmware version: 2.9
- [CH592]/CH591
- [ ] [CH643] - I don't have this chip, help wanted
- [CH32X035]
- [ ] [CH32L103] - I don't have this chip, help wanted
- [ ] [CH8571] - No other source about this chip, help wanted
- ... (Feel free to open an issue if you have tested on other chips)

[CH32V003]: http://www.wch-ic.com/products/CH32V003.html
Expand All @@ -58,11 +60,13 @@ Current firmware version: 2.9
[CH32V208]: http://www.wch-ic.com/products/CH32V208.html
[CH32V307]: http://www.wch-ic.com/products/CH32V307.html
[CH32X035]: http://www.wch-ic.com/products/CH32X035.html
[CH32L103]: http://www.wch-ic.com/products/CH32L103.html
[CH569]: http://www.wch-ic.com/products/CH569.html
[CH573]: http://www.wch-ic.com/products/CH573.html
[CH583]: http://www.wch-ic.com/products/CH583.html
[CH592]: https://www.wch-ic.com/products/CH592.html
[CH643]: https://www.wch-ic.com/products/CH643.html
[CH8571]: https://www.wch.cn/news/606.html

## Install

Expand Down
14 changes: 14 additions & 0 deletions docs/CH32L103.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# CH32L103


## Chips

```
* CH32L103C8U6-0x103007x0
* CH32L103C8T6-0x103107x0
* CH32L103F8P6-0x103A07x0
* CH32L103G8R6-0x103B07x0
* CH32L103K8U6-0x103207x0
* CH32L103F8U6-0x103D07x0
* CH32L103F7P6-0x103707x0
```
9 changes: 9 additions & 0 deletions docs/CH32V003.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ GND <-> GND@MCU
13:41:51 [INFO] resume executing...
13:41:51 [WARN] resume fails
```

## Chips

```
* CH32V003F4P6-0x003005x0
* CH32V003F4U6-0x003105x0
* CH32V003A4M6-0x003205x0
* CH32V003J4M6-0x003305x0
```
7 changes: 7 additions & 0 deletions docs/CH32V103.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ SWCLK - PA14 @ MCU
## USBISP

BOOT0 to VCC

## Chips

```
* CH32F103C8T6-0x20004102
* CH32F103R8T6-0x2000410F
```
24 changes: 24 additions & 0 deletions docs/CH32V20x.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,27 @@

[nanoCH32V203]: https://github.com/wuxx/nanoCH32V203
[FlappyBoard]: https://github.com/metro94/FlappyBoard

## Notes

- Erased bytes `39 e3 39 e3`

## Chips

```
* CH32V203C8U6-0x203005x0
* CH32V203C8T6-0x203105x0
* CH32V203K8T6-0x203205x0
* CH32V203C6T6-0x203305x0
* CH32V203K6T6-0x203505x0
* CH32V203G6U6-0x203605x0
* CH32V203G8R6-0x203B05x0
* CH32V203F8U6-0x203E05x0
* CH32V203F6P6-0x203705x0-0x203905x0
* CH32V203F8P6-0x203A05x0
* CH32V203RBT6-0x203405xC
* CH32V208WBU6-0x208005xC
* CH32V208RBT6-0x208105xC
* CH32V208CBU6-0x208205xC
* CH32V208GBU6-0x208305xC
```
20 changes: 20 additions & 0 deletions docs/CH32V307.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,23 @@ wlink -v dump 0x08000000 0x10`
14:40:22 [INFO] Read memory from 0x08000000 to 0x08000010
08000000: b7 00 00 08 67 80 80 00 73 50 40 30 73 50 40 34 ×00•g××0sP@0sP@4
```

## Notes

- erased flash `39 e3 39 e3`

## Chips

```
* CH32V303CBT6-0x303305x4
* CH32V303RBT6-0x303205x4
* CH32V303RCT6-0x303105x4
* CH32V303VCT6-0x303005x4
* CH32V305FBP6-0x305205x8
* CH32V305RBT6-0x305005x8
* CH32V305GBU6-0x305B05x8
* CH32V307WCU6-0x307305x8
* CH32V307FBP6-0x307205x8
* CH32V307RCT6-0x307105x8
* CH32V307VCT6-0x307005x8
```
22 changes: 22 additions & 0 deletions docs/CH32X035.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,25 @@ SWDIO - PC18/DIO @ MCU
SWCLK - PC19/DCK @ MCU

PC17 to High, enable USB ISP DOWNLOAD MODE

## Boards

Official CH32X035EVT

- CH32X035F8U6-R0
- CH32X035G8U6-R0
- CH32X035C8T6-R0

LED1, LED2 blue LED, active low, open, connected to open jumper

## Chips

```
* CH32X035R8T6-0x035006x1
* CH32X035C8T6-0x035106x1
* CH32X035F8U6-0x035E06x1
* CH32X035G8U6-0x035606x1
* CH32X035G8R6-0x035B06x1
* CH32X035F7P6-0x035706x1
* CH32X033F8P6-0x035A06x1
```
10 changes: 10 additions & 0 deletions docs/CH56X.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# CH569

## Boards

- CH569W-R0-1v0

## Pins

- TCK=HTACK=PA10
- TIO=HTCLK=PA11
6 changes: 6 additions & 0 deletions docs/CH57x_CH58x_CH59x.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@

- PB15 TCK
- PB14 TIO

## Notes

- Enable debug using WCHISPTool
- After debug enabled, flash should be prgrammed at lease once
- `a9 bd f9 f3` means erased flash or protected flash, the detailed mechanism is unknown
10 changes: 10 additions & 0 deletions docs/CH643.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# CH643

## Chips

```
* CH643W-0x64300601
* CH643Q-0x64310601
* CH643L-0x64330601
* CH643U-0x64340601
```
90 changes: 90 additions & 0 deletions src/chips.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//! The chip DB.

pub fn chip_id_to_chip_name(chip_id: u32) -> Option<&'static str> {
match chip_id & 0xFFF00000 {
0x650_00000 => Some("CH565"),
0x690_00000 => Some("CH569"),
0x710_00000 => Some("CH571"),
0x730_00000 => Some("CH573"),
0x810_00000 => Some("CH581"),
0x820_00000 => Some("CH582"),
0x830_00000 => Some("CH583"),
0x920_00000 => Some("CH592"),
0x003_00000 => match chip_id & 0xFFFFFF0F {
0x003_00500 => Some("CH32V003F4P6"),
0x003_10500 => Some("CH32V003F4U6"),
0x003_20500 => Some("CH32V003A4M6"),
0x003_30500 => Some("CH32V003J4M6"),
_ => None,
},
0x035_00000 => match chip_id & 0xFFFFFF0F {
0x035_00601 => Some("CH32X035R8T6"),
0x035_10601 => Some("CH32X035C8T6"),
0x035_E0601 => Some("CH32X035F8U6"),
0x035_60601 => Some("CH32X035G8U6"),
0x035_B0601 => Some("CH32X035G8R6"),
0x035_70601 => Some("CH32X035F7P6"),
0x035_A0601 => Some("CH32X033F8P6"),
_ => None,
},
0x103_00000 => match chip_id & 0xFFFFFF0F {
0x103_00700 => Some("CH32L103C8U6"),
0x103_10700 => Some("CH32L103C8T6"),
0x103_A0700 => Some("CH32L103F8P6"),
0x103_B0700 => Some("CH32L103G8R6"),
0x103_20700 => Some("CH32L103K8U6"),
0x103_D0700 => Some("CH32L103F8U6"),
0x103_70700 => Some("CH32L103F7P6"),
_ => None,
},
0x200_00000 => match chip_id {
0x200_04102 => Some("CH32F103C8T6"),
0x200_0410F => Some("CH32F103R8T6"),
_ => None,
},
0x203_00000 => match chip_id & 0xFFFFFF0F {
0x203_00500 => Some("CH32V203C8U6"),
0x203_10500 => Some("CH32V203C8T6"),
0x203_20500 => Some("CH32V203K8T6"),
0x203_30500 => Some("CH32V203C6T6"),
0x203_50500 => Some("CH32V203K6T6"),
0x203_60500 => Some("CH32V203G6U6"),
0x203_B0500 => Some("CH32V203G8R6"),
0x203_E0500 => Some("CH32V203F8U6"),
0x203_70500 => Some("CH32V203F6P6"),
0x203_90500 => Some("CH32V203F6P6"),
0x203_A0500 => Some("CH32V203F8P6"),
0x203_4050C => Some("CH32V203RBT6"),
_ => None,
},
0x208_00000 => match chip_id & 0xFFFFFF0F {
0x208_0050C => Some("CH32V208WBU6"),
0x208_1050C => Some("CH32V208RBT6"),
0x208_2050C => Some("CH32V208CBU6"),
0x208_3050C => Some("CH32V208GBU6"),
_ => None,
},
0x303_00000 | 0x305_00000 | 0x307_00000 => match chip_id & 0xFFFFFF0F {
0x303_30504 => Some("CH32V303CBT6"),
0x303_20504 => Some("CH32V303RBT6"),
0x303_10504 => Some("CH32V303RCT6"),
0x303_00504 => Some("CH32V303VCT6"),
0x305_20508 => Some("CH32V305FBP6"),
0x305_00508 => Some("CH32V305RBT6"),
0x305_B0508 => Some("CH32V305GBU6"),
0x307_30508 => Some("CH32V307WCU6"),
0x307_20508 => Some("CH32V307FBP6"),
0x307_10508 => Some("CH32V307RCT6"),
0x307_00508 => Some("CH32V307VCT6"),
_ => None,
},
0x643_00000 => match chip_id {
0x643_00601 => Some("CH643W"),
0x643_10601 => Some("CH643Q"),
0x643_30601 => Some("CH643L"),
0x643_40601 => Some("CH643U"),
_ => None,
},
_ => None,
}
}
Loading