frank-zago / isp55e0

An ISP flashing tool for the WCH CH55x, CH579, CH32F103 under linux
GNU General Public License v3.0
52 stars 18 forks source link

ch32v203 support #8

Closed nikitos1550 closed 1 year ago

nikitos1550 commented 1 year ago

Hello! I want tune tool for CH32V203G8R6

This is first try:

nikita1550@nikita1550-nix ~/s/w/T/a/t/isp55e0> sudo ./isp55e0 -d
Dump - request
a1 12 00 00 00 4d 43 55 20 49 53 50 20 26 20 57 
43 48 2e 43 4e 
Dump - response
a1 00 02 00 3b 19 
isp55e0: Device family 0x19 type 0x3b is not supported

Maybe need some help, device should be similar to ch32v103

nikitos1550 commented 1 year ago
nikita1550@nikita1550-nix ~/s/w/c/isp55e0> git diff
diff --git a/isp55e0.c b/isp55e0.c
index 287a080..0cf7992 100644
--- a/isp55e0.c
+++ b/isp55e0.c
@@ -110,6 +110,15 @@ static const struct ch_profile profiles[] = {
                .need_remove_wp = true,
                .need_last_write = true,
        },
+    {
+        .name = "CH32V203",
+        .family = 0x19,
+        .type = 0x3b,
+        .code_flash_size = 65536,
+        .mcu_id_len = 8,
+        .need_remove_wp = true,
+        .need_last_write = true,
+    },
        {
                .name = "CH582",
                .family = 0x16,
nikita1550@nikita1550-nix:/home/nikita1550/seatbelt/wch/ch32v203/isp55e0$ 
nikita1550@nikita1550-nix ~/s/w/c/isp55e0> sudo ./isp55e0 -d
Dump - request
a1 12 00 00 00 4d 43 55 20 49 53 50 20 26 20 57 
43 48 2e 43 4e 
Dump - response
a1 00 02 00 3b 19 
Found device CH32V203
Dump - request
a7 02 00 1f 00 
Dump - response
a7 00 1a 00 1f 00 a5 5a 3f c0 00 ff 00 ff ff ff 
ff ff 00 02 06 00 cd ab 11 35 51 bc 2f 9d 
Bootloader version 2.6.0
Unique chip ID cd-ab-11-35-51-bc-2f-9d
nikitos1550 commented 1 year ago

Later will make some firmware example and try burn it. Will report here.

frank-zago commented 1 year ago

That looks about right.

Besides testing with a real firmware, you can flash any file and use the -c option to check it's been flashed properly. A good file for that test has almost the size of the flash memory, and is of odd size (e.g. 65417 here). If that passes, then it's probably all good.

nikitos1550 commented 1 year ago

yep, seem ok.

nikita1550@nikita1550-nix ~/s/w/c/isp55e0> ls -la ./test.bin 
-rw-rw-r-- 1 nikita1550 nikita1550 65417 Feb 17 09:34 ./test.bin
nikita1550@nikita1550-nix:/home/nikita1550/seatbelt/wch/ch32v203/isp55e0$ 
nikita1550@nikita1550-nix ~/s/w/c/isp55e0> sudo ./isp55e0 -f ./test.bin 
Found device CH32V203
Bootloader version 2.6.0
Unique chip ID cd-ab-11-35-51-bc-2f-9d
Code flashing successful
Firmware is good
nikita1550@nikita1550-nix:/home/nikita1550/seatbelt/wch/ch32v203/isp55e0$ 
nikita1550@nikita1550-nix ~/s/w/c/isp55e0> sudo ./isp55e0 -c ./test.bin 
Found device CH32V203
Bootloader version 2.6.0
Unique chip ID cd-ab-11-35-51-bc-2f-9d
Firmware is good
nikitos1550 commented 1 year ago

Could you add this chip to readme and trunk?

frank-zago commented 1 year ago

Chip added. I should probably add the whole family too one day.