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

Unable to revert config after calling config reset #40

Open martell opened 10 months ago

martell commented 10 months ago

I ran wchisp config reset on a We Act Studio 582 Which resulted in flashing/verification breaking

wchisp config reset
[INFO] Current config registers: ffffffffffffffff4d0fff4f
[INFO] Reset config registers:   ffffffffffffffffd50fff4f
wchisp flash target/riscv32imac-unknown-none-elf/release/examples/blinky
...
[INFO] Firmware size: 6144
[INFO] Erasing...
[WARN] erase_code: set min number of erased sectors to 8
[INFO] Erased 8 code flash sectors
[INFO] Erase done
[INFO] Writing to code flash...
[INFO] Code flash 6144 bytes written
[INFO] Verifying...
Error: Verify failed, mismatch

You can not set the config currently

wchisp config set ffffffffffffffff4d0fff4f
[INFO] setting cfg value ffffffffffffffff4d0fff4f
thread 'main' panicked at src/main.rs:277:21:
not implemented

Work around is to update the default in the CH58X yaml (for anyone else who runs into this)

diff --git a/devices/0x16-CH58x.yaml b/devices/0x16-CH58x.yaml
index 5f0cc64..e3c78b6 100644
--- a/devices/0x16-CH58x.yaml
+++ b/devices/0x16-CH58x.yaml
@@ -36,7 +36,7 @@ config_registers:
     # Enable 2-wire debug
     # reset: 0xd73f0f4d
     # See-also: #26
-    reset: 0x4d0fff4f # official default
+    reset: 0xd50fff4f # official default
     type: u32
     fields:
       - bit_range: [2, 0]

After this we should see USER_CFG: 0x4FFF0FD5 when running flash