stcgal icon indicating copy to clipboard operation
stcgal copied to clipboard

Doesn't work with STC89C52, firmware version 7.2.5C

Open rgwan opened this issue 5 years ago • 10 comments

stcgal's stc89 mode only works with STC89C52 4.3C version. STC89C52 's recent version can't be recognized by stcgal, it shows up an error message:

Waiting for MCU, please cycle power: done Protocol detected: stc89 Protocol error: packet checksum mismatch Disconnected!

The new STC89 protocol seems to uses 8E1 line coding to transmit data.

rgwan avatar May 05 '19 04:05 rgwan

I met the some problem too... Have you solved it yet?

Yuns-Wang avatar May 29 '19 15:05 Yuns-Wang

@rgwan i am in the same trouble~have you solved it?

joephon avatar Jun 25 '19 19:06 joephon

As luck i have two STC, one is STC89C52 7.2.5C, another is STC90C516RD+ 4.3C. the experiment show that STC90C516RD+ is all right, the STC89C52 show the same error. the os is macOS High Sierra 10.13.6.

histriver avatar Jul 20 '19 09:07 histriver

Yeah I've met the same problem and I don't know how to solve that.

ChunjieShan avatar Jan 22 '20 13:01 ChunjieShan

It's work to change extract_payload function in protocols.py. form

packet_csum = packet[-2]
calc_csum = sum(packet[2:-2]) & 0xff

to

packet_csum = packet[-2] + (packet[-3] << 8)
calc_csum = sum(packet[2:-3]) & 0xffff

refer to: https://github.com/azman/my1stcflash/blob/master/src/my1stc.c

and use

stcgal.py -P stc12 -p /dev/tty.wchusbserial14310 -D 

is work too

soory for my poor english

yuangu avatar Feb 25 '20 11:02 yuangu

Both of these snippets are the same, but I think I know what you mean. :) It should be easy enough to add a special case for newer bootloader versions. Feel free to submit a PR. If I have some free time, I might be able to do it as well, but I cannot test it.

grigorig avatar Feb 25 '20 12:02 grigorig

I can confirm that using -P stc12 for the 89C52 I got on my development board described in https://github.com/kenyapcomau/QX-mini51 is a valid workaround. Hope this can be automatically detected in future.

kenyapcomau avatar Apr 29 '20 10:04 kenyapcomau

@grigorig Only changing extract_payload will not work, 7.2.5C and the old version of the communication protocol are completely different

nrife avatar Jan 09 '21 06:01 nrife

Yes, that is why I reverted it for now. It looks like newer STC89C52 use an stc12-like protocol and I'd like to avoid the code duplication if possible. I ordered some chips and hopefully I'll get these new ones.

grigorig avatar Jan 09 '21 11:01 grigorig

@grigorig I uploaded the original communication data of 7.2.5c in the fork

nrife avatar Jan 09 '21 11:01 nrife

Fixed (merged nrife's patch).

area-8051 avatar Jun 01 '23 17:06 area-8051