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

CH573F #2

Closed nikitos1550 closed 2 years ago

nikitos1550 commented 2 years ago

Hello!

lsusb
[cut]
Bus 001 Device 028: ID 4348:55e0 WinChipHead 
[cut]
./isp55e0 
isp55e0: Device family 13 type 73 is not supported

What info can I provide you to add ch573f/ch571f to your app? Bootloader is 2.8.0 for these chips.

nikitos1550 commented 2 years ago

I added this:

    {
        .name = "CH573",
        .family = 0x13,
        .type = 0x73,
        .code_flash_size = 458752,
        .data_flash_size = 32768,
        .mcu_id_len = 7,
        .xor_key_id_len = 8,
    },

Got this:

./isp55e0 -d -f firmware.hex 
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 73 13 
Found device CH573
Dump - request
a7 02 00 1f 00 
Dump - response
a7 00 1a 00 1f 00 a5 5a ff ff ff ff ff ff ff 3f 
ff 6f 00 02 08 00 0b 5d dc e4 c2 84 a9 c6 
Bootloader version 2.8.0
Unique chip ID 0b-5d-dc-e4-c2-84-a9
Dump - request
a3 1e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 
Dump - response
a3 00 02 00 5b 00 
Dump - request
a8 0e 00 07 00 a5 5a ff ff ff ff ff ff ff 3f ff 
6f 
Dump - response
a8 00 02 00 00 00 
Dump - request
a4 04 00 92 00 00 00 
Dump - response
a4 00 02 00 00 00 
Dump - request
a5 3d 00 00 00 00 00 00 e7 ed e9 ed ed ed ed 60 
ed eb 9b ed ed e5 ed 66 eb 9c ea d0 d7 e7 ec 60 
ed ed ed e9 ed ed ed 60 ed ed ed ed ed ed ed 60 
ed ed ed ed ed ed eb 16 ed ed e5 ed ed e5 eb 16 
Dump - response
a5 00 02 00 fe 00 
isp55e0: Write code flash failure at offset 0
frank-zago commented 2 years ago

Hello. I usually see that error when the device is hosed. Have you tried to power cycle the chip?

nikitos1550 commented 2 years ago

Hello. I usually see that error when the device is hosed. Have you tried to power cycle the chip?

Seems not. What is it?

frank-zago commented 2 years ago

Just power it off, then on, and try again.

xor_key_id_len is gone, and set mcu_id_len to 8. Other parameters look good.

nikitos1550 commented 2 years ago

I will try and report you soon.

nikitos1550 commented 2 years ago
> sudo ./isp55e0 -d --code-flash firmware.hex 
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 73 13 
Found device CH573
Dump - request
a7 02 00 1f 00 
Dump - response
a7 00 1a 00 1f 00 a5 5a ff ff ff ff ff ff ff 3f 
ff 6f 00 02 08 00 0b 5d dc e4 c2 84 a9 c6 
Bootloader version 2.8.0
Unique chip ID 0b-5d-dc-e4-c2-84-a9-c6
Dump - request
a3 1e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 
Dump - response
a3 00 02 00 5b 00 
Dump - request
a8 0e 00 07 00 a5 5a ff ff ff ff ff ff ff 3f ff 
6f 
Dump - response
a8 00 02 00 00 00 
Dump - request
a4 04 00 92 00 00 00 
Dump - response
a4 00 02 00 00 00 
Dump - request
a5 3d 00 00 00 00 00 00 e7 ed e9 ed ed ed ed 60 
ed eb 9b ed ed e5 ed 66 eb 9c ea d0 d7 e7 ec 60 
ed ed ed e9 ed ed ed 60 ed ed ed ed ed ed ed 60 
ed ed ed ed ed ed eb 16 ed ed e5 ed ed e5 eb 16 
Dump - response
a5 00 02 00 fe 00 
isp55e0: Write code flash failure at offset 0

> git diff ./isp55e0.c 
diff --git a/isp55e0.c b/isp55e0.c
index dd60ef6..23967ee 100644
--- a/isp55e0.c
+++ b/isp55e0.c
@@ -75,6 +75,14 @@ static const struct ch_profile profiles[] = {
                .data_flash_size = 1024,
                .mcu_id_len = 4,
        },
+    {
+        .name = "CH573",
+        .family = 0x13,
+        .type = 0x73,
+        .code_flash_size = 458752,
+        .data_flash_size = 32768,
+        .mcu_id_len = 8,
+    },
        {
                .name = "CH579",
                .family = 0x13,

I tried several times with poweron/poweroff, but seems it doesn't matter. Maybe there is something wrong with configure bits?

nikitos1550 commented 2 years ago

Here https://github.com/ch32-rs/wchisp/issues/5 I am discussing same support for ch573f, in that tool response code fe seems to be ok, but I don't know why.

10:34:15 [DEBUG] (1) wchisp::transport: => a53d00   0000000077b2cd9dfedddddd50ddddddddb2dd5d58b2dd9dc3dddddd50dddddddddddddd50dddddddddddddd50dddddddddddddd50ddddddddb2dd9d56
10:34:15 [DEBUG] (1) wchisp::transport: <= a5000200 fe00
10:34:15 [DEBUG] (1) wchisp::transport: => a53d00   3800000077ddddddddb2dd3d55ddddddddb2dd7d7db2dd1df2b2dd9d55b2ddfdd8b2dddd55b2dd3dd9b2dd1d54ddddddddb2ddbd54b2dd9dd9b2ddfd54
10:34:15 [DEBUG] (1) wchisp::transport: <= a5000200 fe00
10:34:15 [DEBUG] (1) wchisp::transport: => a53d00   700000007cb2ddddd9b2dd1d4eb2dd1ddedddddd50b2ddbddeb2dd9d53b2ddfddeb2dddd53b2dd3ddfdc7ddcf0dc7ddc7ddc7ddcf0dc7ddc7ddc7ddcf0
10:34:15 [DEBUG] (1) wchisp::transport: <= a5000200 fe00

maybe this also will be helpful

nikitos1550 commented 2 years ago

I also used some proprietary WCH Linux app that can burn ch573 (and maybe some others) via usb and uart1. It's quality is bery bad, for usb some ko module needed and all device pathes are hardcoded or choosed accoding some internal logic.

Using https://github.com/geoffmeyers/interceptty tool I saved dump, that can be useful sudo ./interceptty -o ./log /dev/ttyUSB0 /dev/ttyS0

Proprieatary app used /dev/ttyS0

Set isp option success!
here1....
0#ISP DEV:/dev/ttyS0
1#ISP DEV:/dev/ttyS1
2#ISP DEV:/dev/ttyS2
3#ISP DEV:/dev/ttyS3
4#ISP DEV:/dev/ttyS4
5#ISP DEV:/dev/ttyS5
6#ISP DEV:/dev/ttyS6
7#ISP DEV:/dev/ttyS7
8#ISP DEV:/dev/ttyS8
9#ISP DEV:/dev/ttyS9
10#ISP DEV:/dev/ttyS10
11#ISP DEV:/dev/ttyS11
12#ISP DEV:/dev/ttyS12
13#ISP DEV:/dev/ttyS13
14#ISP DEV:/dev/ttyS14
15#ISP DEV:/dev/ttyS15
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
UID:00-00-00-00-00-00,BTVER:0.0
enum devices num: 16
begin download...
ConfigBitVal: 0x3f4f
BTVER:02.80
FileSize: 149344

    HEX convert to BIN format.
**Read file succ,get download data:53096 B
SeedData2=73
key:8d-ab-54-e0-1f-8d-32-00
Erasing...
complete
Programing...
 complete
Verifying...
SeedData2=73
key:c4-99-fa-cb-ff-7e-eb-37
 complete
0#DEVICEDownloadSuccess
download success
Download Total:1, Success:1, Fail:0
Download success!

Here https://paste.c-net.org/DanielleMadre I uploaded log Seems for UART 0x75 0xAB used as cmd prefix and last byte is some kind of crc

< 0x57 (W)
< 0xab («)
< 0xa1 (¡)
< 0x12 ([DC2])
< 0x00 ([NUL])
< 0x00 ([NUL])
< 0x00 ([NUL])
< 0x4d (M)
< 0x43 (C)
< 0x55 (U)
< 0x20 ( )
< 0x49 (I)
< 0x53 (S)
< 0x50 (P)
< 0x20 ( )
< 0x26 (&)
< 0x20 ( )
< 0x57 (W)
< 0x43 (C)
< 0x48 (H)
< 0x2e (.)
< 0x43 (C)
< 0x4e (N)
< 0xab («)

0x55 0xAA is prefix for responses with last byte also soke kind if crc

>   0x55 (U)
>   0xaa (ª)
>   0xa1 (¡)
>   0x00 ([NUL])
>   0x02 ([STX])
>   0x00 ([NUL])
>   0x73 (s)
>   0x13 ([DC3])
>   0x29 ())
nikitos1550 commented 2 years ago

Finally, this is readable dump from official WCH linux tool uart prog process:

Request
PREFIX 0x57 0xab
CMD 0xa1 0x12 0x00 0x00 0x00 0x4d 0x43 0x55 0x20 0x49 0x53 0x50 0x20 0x26 0x20 
CMD 0x57 0x43 0x48 0x2e 0x43 0x4e
CRC? 0xab
Response
PREFIX 0x55 0xaa
CMD 0xa1 0x00 0x02 0x00 0x73 0x13
CRC? 0x29

Request:
PREFIX 0x57 0xab
CMD 0xa7 0x02 0x00 0x1f 0x00
CRC? 0xc8
Response:
PREFIX 0x55 0xaa
CMD 0xa7 0x00 0x1a 0x00 0x1f 0x00 0xff 0xff 0xff 0xff 0xfe 0xff 0xff 0xff 0x4f 
CMD 0x3f 0x00 0x40 0x00 0x02 0x08 0x00 0x0b 0x5d 0xdc 0xe4 0xc2 0x84 0xa9 0xc6
CRC? 0x8c

Request:
PREFIX 0x57 0xab
CMD 0xa8 0x0e 0x00 0x07 0x00 0xff 0xff 0xff 0xff 0xfe 0xff 0xff 0xff 0x4f 0x3f 
CMD 0x00 0x00
CRC? 0x42
Response:
PREFIX 0x55 0xaa
CMD 0xa8 0x00 0x02 0x00 0x00 0x00
CRC? 0xaa

Request:
PREFIX 0x57 0xab
CMD 0xa3 0x2c 0x00 0x59 0x5a 0x59 0xf7 0x3f 0xf4 0x89 0x72 0x76 0xcb 0xc7 0xe5 
CMD 0x08 0x34 0x2b 0xa9 0x1e 0xcd 0xc2 0x33 0xc4 0x8a 0x9c 0x2a 0x50 0x43 0xa7 
CMD 0x79 0x91 0x77 0xef 0xea 0xd1 0x49 0xe2 0x11 0x3d 0x6b 0x83 0xb3 0x37 0x4a 
CMD 0x98 0x3f
CRC ?0xc8
Response:
PREFIX 0x55 0xaa
CMD 0xa3 0x00 0x02 0x00 0x4a 0x00
CRC? 0xef

Request:
PREFIX 0x57 0xab 
CMD 0xa4 0x01 0x00 0xc0
CRC? 0x65
Response:
PREFIX 0x55 0xaa
CMD 0xa4 0x00 0x02 0x00 0x00 0x00
CRC? 0xa6

//Write

Requst:
PREFIX 0x57 0xab
CMD 0xa5 0x3d 0x00 0x00 0x00 0x00 0x00 0x7f 0xe2 0xab 0xd4 0x86 0x1f 0x8d 0x32 
CMD 0x00 0x8d 0xab 0x54 0xe0 0x70 0x8d 0xb2 0x08 0xe2 0xab 0x14 0xfe 0x1f 0x8d 
CMD 0x32 0x00 0x8d 0xab 0x54 0xe0 0x1f 0x8d 0x32 0x00 0x8d 0xab 0x54 0xe0 0x1f 
CMD 0x8d 0x32 0x00 0x8d 0xab 0x54 0xe0 0x1f 0x8d 0x32 0x00 0x8d 0xab 0x54 0xe0 
CMD 0x70 0x8d 0x72 0x06
CRC? 0x85
Response:
PREFIX 0x55 0xaa
CMD 0xa5 0x00 0x02 0x00 0x00 0x00
CRC? 0xa7

Request:
PREFIX 0x57 0xab
CMD 0xa5 0x3d 0x00 0x38 0x00 0x00 0x00 0xc4 0x8d 0xab 0x54 0xe0 0x70 0x8d 0xd2 
CMD 0x05 0x8d 0xab 0x54 0xe0 0x70 0x8d 0xb2 0x05 0xe2 0xab 0x34 0xe5 0x70 0x8d
CMD 0x72 0x05 0xe2 0xab 0x74 0xe5 0x70 0x8d 0x32 0x05 0xe2 0xab 0xb4 0xe4 0x70
CMD 0x8d 0xf2 0x04 0x8d 0xab 0x54 0xe0 0x70 0x8d 0x52 0x04 0xe2 0xab 0x14 0xe4
CMD 0x70 0x8d 0x12 0x04
CRC? 0xe1
Response:
PREFIX 0x55 0xaa
CMD 0xa5 0x00 0x02 0x00 0x00 0x00
CRC? 0xa7

Request:
PREFIX 0x57 0xab
CMD 0xa5 0x3d 0x00 0x70 0x00 0x00 0x00 0xe9 0xe2 0xab 0x54 0xe4 0x70 0x8d 0xf2
CMD 0x1e 0xe2 0xab 0x94 0xe3 0x1f 0x8d 0x32 0x00 0xe2 0xab 0x34 0xe3 0x70 0x8d
CMD 0x72 0x03 0xe2 0xab 0x74 0xe3 0x70 0x8d 0x32 0x03 0xe2 0xab 0xb4 0xe2 0x1e
CMD 0x2d 0x33 0xa0 0x8c 0x0b 0x55 0x40 0x1e 0x2d 0x33 0xa0 0x8c 0x0b 0x55 0x40 
CMD 0x1e 0x2d 0x33 0xa0
CRC? 0xf0
Response:
PREFIX 0x55 0xaa
CMD 0xa5 0x00 0x02 0x00 0x00 0x00
CRC? 0xa7

[CUT]

Request:
PREFIX 0x57 0xab
CMD 0xa5 0x3d 0x00 0xf0 0xce 0x00 0x00 0xf6 0xb1 0x16 0x54 0xe0 0x23 0x30 0x32 
CMD 0x00 0xb1 0x16 0x54 0xe0 0x23 0x30 0x32 0x00 0x72 0x54 0xab 0x1f 0xe0 0x72 
CMD 0xcd 0xff 0x72 0x54 0xab 0x1f 0xe0 0x72 0x32 0x00 0x8c 0xab 0x15 0xb3 0x5c 
CMD 0xc4 0x7b 0x00 0x8d 0xab 0x54 0xe0 0x1f 0x8d 0x32 0x00 0x8d 0xab 0x54 0xe0 
CMD 0x1f 0x8d 0x32 0x00
CRC? 0x86
Response:
PREFIX 0x55 0xaa
CMD 0xa5 0x00 0x02 0x00 0x00 0x00
CRC? 0xa7

Request:
PREFIX 0x57 0xab
CMD 0xa5 0x3d 0x00 0x28 0xcf 0x00 0x00 0xc0 0x8d 0xab 0x54 0xe0 0x1f 0x8d 0x32
CMD 0x00 0x8d 0xab 0x15 0xb3 0x5c 0xc4 0x7b 0x00 0x8d 0xab 0x54 0xe0 0x1f 0x8d
CMD 0x32 0x00 0x8d 0xab 0x54 0xe0 0x1f 0x8d 0x32 0x00 0x8d 0xab 0x54 0xe0 0x1f
CMD 0x8d 0x32 0x00 0x8d 0xab 0x54 0xe0 0x1f 0x8d 0x32 0x00 0x8d 0xeb 0x54 0xc0
CMD 0xe0 0x72 0xcd 0xff
CRC? 0x50
Response:
PREFIX 0x55 0xaa
CMD 0xa5 0x00 0x02 0x00 0x00 0x00
CRC? 0xa7

Request:
PREFIX x57 0xab
CMD 0xa5 0x0d 0x00 0x60 0xcf 0x00 0x00 0xba 0x8d 0xab 0x56 0xe0 0x1f 0x8d 0x32 
CMD 0x00
CRC? 0xe7
Response:
PREFIX 0x55 0xaa
CMD 0xa5 0x00 0x02 0x00 0x00 0x00
CRC 0xa7

//Another one key(wtf???)

Request:
PREFIX 0x57 0xab
CMD 0xa3 0x39 0x00 0xde 0x67 0x26 0x67 0x03 0xfd 0x6d 0x87 0x27 0x27 0x08 0x44 
CMD 0x2c 0x84 0xdc 0xdc 0x95 0x2d 0xfc 0x31 0xe2 0xb8 0x93 0x5c 0x22 0x84 0x2f
CMD 0x60 0x5c 0xb2 0x7d 0x3a 0x19 0xa3 0xa1 0x1c 0xa0 0x0f 0xa3 0xc7 0x36 0xab
CMD 0x0c 0x62 0x2f 0xe8 0x3e 0xc4 0x16 0x3a 0xf6 0xf8 0xf2 0x89 0x55 0x15 0x0d 
CRC? 0x40
Response:
PREFIX 0x55 0xaa
CMD 0xa3 0x00 0x02 0x00 0xc1 0x00
CRC? 0x66

//Verify

Request:
PREFIX 0x57 0xab
CMD 0xa6 0x3d 0x00 0x00 0x00 0x00 0x00 0x84 0xab 0x99 0x7a 0xad 0xff 0x7e 0xeb
CMD 0x37 0xc4 0x99 0xfa 0xcb 0x90 0x7e 0x6b 0x3f 0xab 0x99 0xba 0xd5 0xff 0x7e
CMD 0xeb 0x37 0xc4 0x99 0xfa 0xcb 0xff 0x7e 0xeb 0x37 0xc4 0x99 0xfa 0xcb 0xff 
CMD 0x7e 0xeb 0x37 0xc4 0x99 0xfa 0xcb 0xff 0x7e 0xeb 0x37 0xc4 0x99 0xfa 0xcb
CMD 0x90 0x7e 0xab 0x31
CRC? 0x0c
Response:
PREFIX 0x55 0xaa
CMD 0xa6 0x00 0x02 0x00 0x00 0x00
CRC? 0xa8 (š)

Request:
PREFIX 0x57 0xab
CMD 0xa6 0x3d 0x00 0x38 0x00 0x00 0x00 0x75 0xc4 0x99 0xfa 0xcb 0x90 0x7e 0x0b 
CMD 0x32 0xc4 0x99 0xfa 0xcb 0x90 0x7e 0x6b 0x32 0xab 0x99 0x9a 0xce 0x90 0x7e
CMD 0xab 0x32 0xab 0x99 0xda 0xce 0x90 0x7e 0xeb 0x32 0xab 0x99 0x1a 0xcf 0x90
CMD 0x7e 0x2b 0x33 0xc4 0x99 0xfa 0xcb 0x90 0x7e 0x8b 0x33 0xab 0x99 0xba 0xcf
CMD 0x90 0x7e 0xcb 0x33
CRC? 0xd8
Response:
PREFIX 0x55 0xaa
CMD 0xa6 0x00 0x02 0x00 0x00 0x00
CRC? 0xa8

Request:
PREFIX 0x57 0xab
CMD 0xa6 0x3d 0x00 0x70 0x00 0x00 0x00 0x69 0xab 0x99 0xfa 0xcf 0x90 0x7e 0x2b
CMD 0x29 0xab 0x99 0x3a 0xc8 0xff 0x7e 0xeb 0x37 0xab 0x99 0x9a 0xc8 0x90 0x7e
CMD 0xab 0x34 0xab 0x99 0xda 0xc8 0x90 0x7e 0xeb 0x34 0xab 0x99 0x1a 0xc9 0xfe
CMD 0xde 0xea 0x97 0xc5 0x39 0xfb 0x6b 0xfe 0xde 0xea 0x97 0xc5 0x39 0xfb 0x6b
CMD 0xfe 0xde 0xea 0x97
CRC? 0xbc
Response:
PREFIX 0x55 0xaa
CMD 0xa6 0x00 0x02 0x00 0x00 0x00
CRC? 0xa8S

[CUT]

Request:
PREFIX 0x57 0xab
CMD 0xa6 0x3d 0x00 0xf0 0xce 0x00 0x00 0x6e 0xf8 0x24 0xfa 0xcb 0xc3 0xc3 0xeb
CMD 0x37 0xf8 0x24 0xfa 0xcb 0xc3 0xc3 0xeb 0x37 0x3b 0x66 0x05 0x34 0x00 0x81
CMD 0x14 0xc8 0x3b 0x66 0x05 0x34 0x00 0x81 0xeb 0x37 0xc5 0x99 0xbb 0x98 0xbc
CMD 0x37 0xa2 0x37 0xc4 0x99 0xfa 0xcb 0xff 0x7e 0xeb 0x37 0xc4 0x99 0xfa 0xcb
CMD 0xff 0x7e 0xeb 0x37
CRC? 0xd4
Response:
PREFIX 0x55 0xaa (ª)
CMD 0xa6 0x00 0x02 0x00 0x00 0x00 ([NUL])
CRC? 0xa8

Request:
PREFIX 0x57 0xab
CMD 0xa6 0x3d 0x00 0x28 0xcf 0x00 0x00 0x16 0xc4 0x99 0xfa 0xcb 0xff 0x7e 0xeb
CMD 0x37 0xc4 0x99 0xbb 0x98 0xbc 0x37 0xa2 0x37 0xc4 0x99 0xfa 0xcb 0xff 0x7e
CMD 0xeb 0x37 0xc4 0x99 0xfa 0xcb 0xff 0x7e 0xeb 0x37 0xc4 0x99 0xfa 0xcb 0xff
CMD 0x7e 0xeb 0x37 0xc4 0x99 0xfa 0xcb 0xff 0x7e 0xeb 0x37 0xc4 0xd9 0xfa 0xeb
CMD 0x00 0x81 0x14 0xc8 
CRC? 0x10
Response:
PREFIX 0x55 0xaa
CMD 0xa6 0x00 0x02 0x00 0x00 0x00
CRC? 0xa8

Request:
PREFIX 0x57 0xab
CMD 0xa6 0x0d 0x00 0x60 0xcf 0x00 0x00 0x0c 0xc4 0x99 0xf8 0xcb 0xff 0x7e 0xeb 
CMD 0x37
CRC? 0xad 
Response:
PREFIX 0x55 0xaa
CMD 0xa6 0x00 0x02 0x00 0x00 0x00
CRC? 0xa8

//Reboot?

Request:
PREFIX 0x57 0xab
CMD 0xa2 0x01 0x00 0x01
CRC? 0xa4
Response:
PREFIX 0x55 0xaa
CMD 0xa2 0x00 0x02 0x00 0x00 0x00
CRC? 0xa4

Seems issue is here

0xa5 0x3d 0x00 0x00 0x00 0x00 0x00 0x7f
                                                              ^^^^

It should be calculated somehow, but I have no idea how. I changed _u1 to 0x77 and it allow me code fw, but not validate it.

nikitos1550 commented 2 years ago

I rolled back my changes to your last master and it works ok now, LOL. Maybe something about config, after I flashed chip via original app, it changed config somehow.

Before

0xa8 0x0e 0x00 0x07 0x00 0xa5 0x5a 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x3f 0xff 0x6f 

Now

0xa8 0x0e 0x00 0x07 0x00 0xff 0xff 0xff 0xff 0xfe 0xff 0xff 0xff 0x4f 0x3f 0x00 0x00
frank-zago commented 2 years ago

Thanks. I've committed your change. I might look at the options too. My CH32F103 had a similar issue (see need_remove_wp), but the 0xff had to be changed into a 0x5a, which is the opposite of what you have. Go figure.

nikitos1550 commented 2 years ago

Ok. I think this issue can be closed. I will do research about config bits and if anything will be needed, then open new issue.