Skip to content

Failed to unprotect on CH32V203 #104

@wbchn

Description

@wbchn

I try to unprotect CH32 before flash it, but after run config unprotect, the chip still protected:

$ wchisp -s -p /dev/cu.usbserial-0001 config unprotect
17:07:43 [INFO] Opening serial port: "/dev/cu.usbserial-0001" @ 115200 baud
17:07:44 [INFO] Code Flash unprotected
17:07:44 [INFO] Device reset

$ wchisp -s -p /dev/cu.usbserial-0001 info
17:07:47 [INFO] Opening serial port: "/dev/cu.usbserial-0001" @ 115200 baud
17:07:47 [INFO] Chip: CH32V203C8T6[0x3119] (Code Flash: 64KiB)
17:07:47 [INFO] Chip UID: CD-AB-90-D7-E1-BD-3E-41
17:07:47 [INFO] BTVER(bootloader ver): 02.70
17:07:47 [INFO] Code Flash protected: true
17:07:47 [INFO] Current config registers: ff003fc000ff00ffffffffff00020700cdab90d7e1bd3e41
RDPR_USER: 0xC03F00FF
  [7:0]   RDPR 0xFF (0b11111111)
    `- Protected
  [16:16] IWDG_SW 0x1 (0b1)
    `- IWDG enabled by the software, and disabled by hardware
  [17:17] STOP_RST 0x1 (0b1)
    `- Disable
  [18:18] STANDBY_RST 0x1 (0b1)
    `- Disable, entering standby-mode without RST
  [23:22] SRAM_CODE_MODE 0x0 (0b0)
    `- CODE-192KB + RAM-128KB / CODE-128KB + RAM-64KB depending on the chip
DATA: 0xFF00FF00
  [7:0]   DATA0 0x0 (0b0)
  [23:16] DATA1 0x0 (0b0)
WRP: 0xFFFFFFFF
  `- Unprotected

if flash when the chip is proteced, i'll get an verify error:

$ wchisp -s -p /dev/cu.usbserial-0001 -b Baud115200 flash firmware.bin
17:06:53 [INFO] Firmware size: 44032
17:06:53 [INFO] Erasing...
17:06:53 [INFO] Erased 44 code flash sectors
17:06:54 [INFO] Erase done
17:06:54 [INFO] Writing to code flash...
█████████████████████ 44032/44032
17:07:01 [INFO] Code flash 44032 bytes written
17:07:01 [INFO] Verifying...
Error: Verify failed, mismatch

I also try to using config reset, but the chip still on protected.

$ wchisp -s -p /dev/cu.usbserial-0001 config reset
17:13:11 [INFO] Opening serial port: "/dev/cu.usbserial-0001" @ 115200 baud
17:13:11 [INFO] Current config registers: ff003fc000ff00ffffffffff
17:13:11 [INFO] Reset config registers:   a55aff0000ff00ffffffffff
17:13:11 [INFO] Config register restored to default value(non-protected, debug-enabled)

Is there something wrong with my usage? How to unprotected code flash on CH32V203C8T6?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions