ch32-rs / wchisp

WCH ISP Tool in Rust
https://ch32-rs.github.io/wchisp/
GNU General Public License v2.0
166 stars 28 forks source link

Support CH32V20x(CH32V203G6 and CH32V203C8T6) #19

Closed andelf closed 1 year ago

andelf commented 1 year ago

Config register for CH32V20x family is added via 2203439ad0d086e8f55e83c0c77a75e0d9bb294f. This family is almost identical to CH32V30x, except for SRAM_CODE_MODE.

Recently I got a FlappyBoard, which has a CH32V203G6U6[0x3619] mcu.

> ./target/debug/wchisp info
06:26:39 [INFO] Found USB Device Bus 002 Device 001: ID 4348:55e0
06:26:39 [DEBUG] (1) wchisp::transport: => a11200   00004d4355204953502026205743482e434e
06:26:39 [DEBUG] (1) wchisp::transport: <= a1000200 3619
06:26:39 [DEBUG] (1) wchisp::flashing: found chip: CH32V203G6U6[0x3619]
06:26:39 [DEBUG] (1) wchisp::transport: => a70200   1f00
06:26:39 [DEBUG] (1) wchisp::transport: <= a7001a00 1f00a55a3fc0ff00ff00ffffffff00020600cdabb4ae45bcc616
06:26:39 [DEBUG] (1) wchisp::flashing: read_config: a55a3fc0ff00ff00ffffffff00020600cdabb4ae45bcc616
06:26:39 [INFO] Chip: CH32V203G6U6[0x3619] (Code Flash: 32KiB)
06:26:39 [INFO] Chip UID: cd-ab-b4-ae-45-bc-c6-16
06:26:39 [INFO] BTVER(bootloader ver): 02.60
06:26:39 [INFO] Code Flash protected: false
06:26:39 [DEBUG] (1) wchisp::transport: => a70200   0700
06:26:39 [DEBUG] (1) wchisp::transport: <= a7000e00 0700a55a3fc0ff00ff00ffffffff
RDPR_USER: 0xC03F5AA5
  [7:0] RDPR 0b10100101 (0xA5)
    `- Unprotected
  [16:16] IWDG_SW 0b1 (0x1)
    `- IWDG enabled by the software, and disabled by hardware
  [17:17] STOP_RST 0b1 (0x1)
    `- Disable
  [18:18] STANDBY_RST 0b1 (0x1)
    `- Disable, entering standby-mode without RST
  [23:22] SRAM_CODE_MODE 0b0 (0x0)
    `- CODE-192KB + RAM-128KB / CODE-128KB + RAM-64KB depending on the chip
DATA: 0x00FF00FF
  [7:0] DATA0 0b11111111 (0xFF)
  [23:16] DATA1 0b11111111 (0xFF)
WRP: 0xFFFFFFFF
  `- Unprotected

Flash the LED_Toggle.hex from official repo.

> wchisp flash /Users/mono/Temp/20221113/LED_Toggle.hex
....
06:27:40 [INFO] Verify OK
06:27:40 [INFO] Now reset device and skip any communication errors
06:27:40 [DEBUG] (1) wchisp::transport: => a20100   01
06:27:40 [DEBUG] (1) wchisp::transport: <= a2000200 0000
06:27:40 [INFO] Device reset
andelf commented 1 year ago

It also works on my nanoCH32V203 board from the MUSE Lab. https://github.com/wuxx/nanoCH32V203

06:31:23 [INFO] Found USB Device Bus 002 Device 001: ID 4348:55e0
06:31:23 [DEBUG] (1) wchisp::transport: => a11200   00004d4355204953502026205743482e434e
06:31:23 [DEBUG] (1) wchisp::transport: <= a1000200 3119
06:31:23 [DEBUG] (1) wchisp::flashing: found chip: CH32V203C8T6[0x3119]
06:31:23 [DEBUG] (1) wchisp::transport: => a70200   1f00
06:31:23 [DEBUG] (1) wchisp::transport: <= a7001a00 1f00a55a3fc000ff00ffffffffff00020600cdab51fc5bbc7964
06:31:23 [DEBUG] (1) wchisp::flashing: read_config: a55a3fc000ff00ffffffffff00020600cdab51fc5bbc7964
06:31:23 [INFO] Chip: CH32V203C8T6[0x3119] (Code Flash: 64KiB)
06:31:23 [INFO] Chip UID: cd-ab-51-fc-5b-bc-79-64
06:31:23 [INFO] BTVER(bootloader ver): 02.60
06:31:23 [INFO] Code Flash protected: false
06:31:23 [DEBUG] (1) wchisp::transport: => a70200   0700
06:31:23 [DEBUG] (1) wchisp::transport: <= a7000e00 0700a55a3fc000ff00ffffffffff
RDPR_USER: 0xC03F5AA5
  [7:0] RDPR 0b10100101 (0xA5)
    `- Unprotected
  [16:16] IWDG_SW 0b1 (0x1)
    `- IWDG enabled by the software, and disabled by hardware
  [17:17] STOP_RST 0b1 (0x1)
    `- Disable
  [18:18] STANDBY_RST 0b1 (0x1)
    `- Disable, entering standby-mode without RST
  [23:22] SRAM_CODE_MODE 0b0 (0x0)
    `- CODE-192KB + RAM-128KB / CODE-128KB + RAM-64KB depending on the chip
DATA: 0xFF00FF00
  [7:0] DATA0 0b0 (0x0)
  [23:16] DATA1 0b0 (0x0)
WRP: 0xFFFFFFFF
  `- Unprotected
andelf commented 1 year ago

Close this for that the device support is stable enough.