Open hansfbaier opened 2 years ago
If I comment out the following lines, the tool works just fine for CH569:
diff --git a/src/flashing.rs b/src/flashing.rs
index ab6f6dc..0c9b4cd 100644
--- a/src/flashing.rs
+++ b/src/flashing.rs
@@ -159,7 +159,8 @@ impl<T: Transport> Flashing<T> {
let isp_key = Command::isp_key(vec![0; 0x1e]);
let resp = self.transport.transfer(isp_key)?;
anyhow::ensure!(resp.is_ok(), "isp_key failed");
- anyhow::ensure!(resp.payload()[0] == key_checksum, "isp_key checksum failed");
+ println!("key_checksum: {:x?} payload checksum: {:x?}", key_checksum, resp.payload()[0]);
+ // anyhow::ensure!(resp.payload()[0] == key_checksum, "isp_key checksum failed");
const CHUNK: usize = 56;
let mut address = 0x0;
@@ -184,7 +185,7 @@ impl<T: Transport> Flashing<T> {
let isp_key = Command::isp_key(vec![0; 0x1e]);
let resp = self.transport.transfer(isp_key)?;
anyhow::ensure!(resp.is_ok(), "isp_key failed");
- anyhow::ensure!(resp.payload()[0] == key_checksum, "isp_key checksum failed");
+ //anyhow::ensure!(resp.payload()[0] == key_checksum, "isp_key checksum failed");
const CHUNK: usize = 56;
let mut address = 0x0;
The program is flashed and verified successfully and the target resets.
Be-careful also the flash code sector size is 256 Bytes on WCH CH56x and not 1024 Bytes like for other CH32VXXX For more details see my modifications on the C version here https://github.com/jmaselbas/wch-isp/pull/1
This is where bvernoux added support for the newer version of the bootloader which come with CH569 .
https://github.com/jmaselbas/wch-isp/commit/9fdfcbb35f2724a25bb8871f421f1c5be9543d87
I just hit the same problem with a brand new CH569.
$ wchisp -v flash test.bin
07:53:00 [DEBUG] (1) wchisp::transport::usb: Found USB Device Bus 003 Device 005: ID 4348:55e0
07:53:00 [DEBUG] (1) wchisp::transport: => a11200 00004d4355204953502026205743482e434e
07:53:00 [DEBUG] (1) wchisp::transport: <= a1000200 6910
07:53:00 [DEBUG] (1) wchisp::transport: => a11200 00004d4355204953502026205743482e434e
07:53:00 [DEBUG] (1) wchisp::transport: <= a1000200 6910
07:53:00 [DEBUG] (1) wchisp::flashing: found chip: CH569[0x6910]
07:53:00 [DEBUG] (1) wchisp::transport: => a70200 1f00
07:53:00 [DEBUG] (1) wchisp::transport: <= a7001a00 1f0011bff9f713bff9ec45f2ffcf000207001c983b263b3892f6
07:53:00 [DEBUG] (1) wchisp::flashing: read_config: 11bff9f713bff9ec45f2ffcf000207001c983b263b3892f6
07:53:00 [INFO] Chip: CH569[0x6910] (Code Flash: 448KiB, Data EEPROM: 32KiB)
07:53:00 [INFO] Chip UID: 1C-98-3B-26-3B-38-92-F6
07:53:00 [INFO] BTVER(bootloader ver): 02.70
07:53:00 [DEBUG] (1) wchisp::transport: => a70200 1f00
07:53:00 [DEBUG] (1) wchisp::transport: <= a7001a00 1f0011bff9f713bff9ec45f2ffcf000207001c983b263b3892f6
07:53:00 [INFO] Current config registers: 11bff9f713bff9ec45f2ffcf000207001c983b263b3892f6
UNKNOWN0: 0xF7F9BF11
UNKNOWN1: 0xECF9BF13
NV_INFO: 0xCFFFF245
[31:30] USER_MEM 0x3 (0b11)
- RAMX 96KB + ROM 32KB [29:29] LOCKUP_RST_EN 0x0 (0b0)
- NotReset
[28:28] RESERVED1 0x0 (0b0)
- Reserved [27:12] RESERVED2 0xFFFF (0b1111111111111111)
- Reserved
[11:10] RESERVED3 0x0 (0b0)
- Reserved [9:8] RESERVED4 0x2 (0b10)
- Reserved
[7:7] CODE_READ_EN 0x0 (0b0)
- Disable [6:6] BOOT_EN 0x1 (0b1)
- Enable
[5:5] DEBUG_EN 0x0 (0b0)
- Disable [4:4] RESET_EN 0x0 (0b0)
- Disable, PB15 is used as GPIO
[3:0] RESERVED5 0x5 (0b101)
`- Reserved
07:53:00 [INFO] Read test.bin as Binary format
07:53:00 [INFO] Firmware size: 22528
07:53:00 [INFO] Erasing...
07:53:00 [DEBUG] (1) wchisp::transport: => a40400 17000000
07:53:00 [DEBUG] (1) wchisp::transport: <= a4000200 0000
07:53:00 [INFO] Erased 23 code flash sectors
07:53:01 [INFO] Erase done
07:53:01 [INFO] Writing to code flash...
07:53:01 [DEBUG] (1) wchisp::transport: => a31e00 000000000000000000000000000000000000000000000000000000000000
07:53:01 [DEBUG] (1) wchisp::transport: <= a3000200 0000
Error: isp_key checksum failed
$
For CH569, it reports isp_checksum failed, but if I comment out those checks, the flashing works fine, and the binary runs well. Here is the log (with the first checksum check commented out):