wch-ch56x-isp is a small utility to program WCH micro-controllers. This utility is a rewrite in C of the rust tool wchisp based on https://github.com/jmaselbas/wch-isp. This utility support only WCH CH569W & CH565.
Contributor shall check CODING_STYLE.md
-
-
riscv-none-embed-objcopy -O binary "${ProjName}.elf" "${ProjName}.bin"
-
Create Flash Image BIN
-
- Run Zadig (executable can be found on https://zadig.akeo.ie/)
- Install or Reinstall driver for "USB Module" (with USB ID
4348
55E0
) withlibusb-win32
orWinUSB
- Note: After 10s without any activity the device "USB Module" (with USB ID
4348
55E0
) will disappear as the bootloader timeout so it shall be restarted
- See the document How_To_Build.md
-
Start a shell(on GNU/Linux) or execute cmd(on Windows)
-
For usage type
wch-ch56x-isp -h
Usage: wch-ch56x-isp [OPTION]...
-V, --Version Print version
-h, --help Show help
-c, --config Print CH569 config(after isp_init and before isp_fini)
-p, --progress Display progress
-v, --verify Do verify after erase/program
-r, --reset Reset MCU at end
-d, --mcudebug=VALUE Set MCU debug mode on or off
-f, --flashfile=VALUE Flash file (binary file *.bin)
- Standard use case to flash a bin file with verify and reset
-
wch-ch56x-isp -vr -f=fullpath/file.bin
-
wch-ch56x-isp.exe -vr -f=fullpath/file.bin
-
With the new version v0.3 or more the flash is automatically set depending on flash file size to set internally flash32k
, flash64k
or flash96k
flash32k
will change the RAMX maximum usable size to 96KB and ROM(flash code running in 0 wait sate) to 32KB- It is used for any code which does not exceed 32KB to run with maximum performances, application shall not use more than 96KB of RAMX
flash64k
will change the RAMX maximum usable size to 64KB and ROM(flash code running in 0 wait sate) to 64KB- It is used for any code which does not exceed 64KB to run with maximum performances, application shall not use more than 64KB of RAMX
flash96k
will change the RAMX maximum usable size to 32KB and ROM(flash code running in 0 wait sate) to 96KB- It is used for any code which does not exceed 96KB to run with maximum performances, application shall not use more than 32KB of RAMX
- If the CH56x config
debug
mode ison/enabled
it is impossible to flash a program withwch-ch56x-isp
and it will return error "Fail to program chunk @ 0 error: e0 00" (the booloader refuse to flash anything when debug mode ison/enabled
and the program shall be flashed with 2-Wire Debug). - To enable the
debug
mode, launchwch-ch56x-isp -d=on
- To disable the
debug
mode, launchwch-ch56x-isp -d=off
- To check the CH569 config
debug
mode, launchwch-ch56x-isp -c
and it will display the config of the CH569 including debug state (DEBUG_EN
1: enabled
or0: disabled
)
Example WCH569 config with debug enabled/on:
wch-ch56x-isp -c
...
config after isp_init() nv=0xCFFFF245
[4] RESET_EN 0: disabled
[5] DEBUG_EN 1: enabled
[6] BOOT_EN 1: enabled
[7] CODE_READ_EN 1: enabled
[29] LOCKUP_RST_EN 0: disabled
[31:30] USER_MEM 0x02: RAMX 96KB + ROM 32KB
config before isp_fini() nv=0xCFFFF245
...
Example WCH569 config with debug disabled/off:
wch-ch56x-isp -c
...
config after isp_init() nv=0x8FFFF245
[4] RESET_EN 0: disabled
[5] DEBUG_EN 0: disabled
[6] BOOT_EN 1: enabled
[7] CODE_READ_EN 0: disabled
[29] LOCKUP_RST_EN 0: disabled
[31:30] USER_MEM 0x02: RAMX 96KB + ROM 32KB
...
Warning: After any change to CH56x Debug mode old binary previously flashed will not run correctly, so it is mandatory to flash the program again with a binary like in example How to use wch-ch56x-isp