laborer / stcflash Goto Github PK
View Code? Open in Web Editor NEWA command line programmer for STC 8051 microcontroller
License: GNU General Public License v3.0
A command line programmer for STC 8051 microcontroller
License: GNU General Public License v3.0
Traceback (most recent call last):
File "stcflash.py", line 637, in
main()
File "stcflash.py", line 610, in main
aispbaud = int(a)
ValueError: invalid literal for int() with base 10: './test.bin'
stcflash is a great project, thank you for your work!
But when I try to use it dowmload program for stc89c52 mcu, it doesn't work, blocking at "Detecting target...".
I want know why stcflash doesn't support stc89c52, Is it possible to support stc89c52?
And my second question is how do you find the protocols for these mcu?
Would you add support to erase eeprom?
Thank you.
Hi!
It seems like currently there is no way to read flash from the device (this feature is not available even in their own tool).
However, I really need this feature for one of the projects I'm working on.
Perhaps there is a way to implement it? E.g. maybe the verify sequence can be abused to get the data?
INFO: [2591] Model ID: F0 02
INFO: [2591] Model name: STC89C52RC
INFO: [2591] ROM size: 8
INFO: [2591] Protocol ID: 89
INFO: [2591] Checksum mode: 1
INFO: [2591] UART Parity: NONE
INFO: [2591] Info string [0]: 66 43 FD F0 02 82 00 00 00 00 00 00 00 00 00 00
INFO: [2591] Info string [1]: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
INFO: [2592] Info string [2]: 00 00 00 01
done
FOSC: 1.012MHz
Model: STC89C52RC (ver6.6C)
ROM: 8KB
Baudrate: INFO: [2592] Test baudrate 2400 (accuracy 0.0135) using config FF F3 00 1A 28
INFO: [2592] Waiting time config 83
DEBUG: [2592] send: 46 B9 6A 00 0C 8F FF F3 00 1A 28 83 BC 16
DEBUG: [2592] baud: 2400
DEBUG: [2793] recv: 46 B9 68
DEBUG: [2794] recv: 00 0C
DEBUG: [2794] recv: 8F FF F3 00 1A 28 83 BA 16
DEBUG: [2794] baud: 2400
INFO: [2794] Change baudrate to 2400
DEBUG: [2794] send: 46 B9 6A 00 0B 8E FF F3 00 1A 28 37 16
DEBUG: [2794] baud: 2400
DEBUG: [2995] recv: 46 B9 68
DEBUG: [2996] recv: 00 0B
DEBUG: [2996] recv: 8E FF F3 00 1A 28 35 16
2400
INFO: [2996] Send unknown packet (80 00 00 36 01 ...)
DEBUG: [2997] send: 46 B9 6A 00 0C 80 00 00 36 01 F0 02 1F 16
DEBUG: [3023] recv: 46 B9 68
DEBUG: [3023] recv: 00 06
DEBUG: [3024] recv: 80 EE 16
INFO: [3024] Send unknown packet (80 00 00 36 01 ...)
DEBUG: [3024] send: 46 B9 6A 00 0C 80 00 00 36 01 F0 02 1F 16
DEBUG: [3050] recv: 46 B9 68
DEBUG: [3050] recv: 00 06
DEBUG: [3051] recv: 80 EE 16
INFO: [3051] Send unknown packet (80 00 00 36 01 ...)
DEBUG: [3051] send: 46 B9 6A 00 0C 80 00 00 36 01 F0 02 1F 16
DEBUG: [3077] recv: 46 B9 68
DEBUG: [3077] recv: 00 06
DEBUG: [3078] recv: 80 EE 16
INFO: [3078] Send unknown packet (80 00 00 36 01 ...)
DEBUG: [3078] send: 46 B9 6A 00 0C 80 00 00 36 01 F0 02 1F 16
DEBUG: [3104] recv: 46 B9 68
DEBUG: [3104] recv: 00 06
DEBUG: [3105] recv: 80 EE 16
INFO: [3105] Send unknown packet (80 00 00 36 01 ...)
DEBUG: [3105] send: 46 B9 6A 00 0C 80 00 00 36 01 F0 02 1F 16
DEBUG: [3131] recv: 46 B9 68
DEBUG: [3131] recv: 00 06
DEBUG: [3132] recv: 80 EE 16
Erasing target...INFO: [3132] Erase
DEBUG: [3132] send: 46 B9 6A 00 0D 84 01 33 33 33 33 33 33 2E 16
DEBUG: [3183] recv:
DEBUG: [3233] recv:
DEBUG: [3284] recv:
DEBUG: [3335] recv:
DEBUG: [3385] recv:
DEBUG: [3436] recv:
DEBUG: [3486] recv:
DEBUG: [3537] recv:
DEBUG: [3587] recv:
DEBUG: [3638] recv:
DEBUG: [3688] recv:
DEBUG: [3739] recv:
DEBUG: [3789] recv:
DEBUG: [3840] recv:
DEBUG: [3890] recv:
DEBUG: [3941] recv:
DEBUG: [3992] recv:
DEBUG: [4042] recv:
DEBUG: [4093] recv:
DEBUG: [4143] recv:
DEBUG: [4194] recv:
DEBUG: [4244] recv:
DEBUG: [4295] recv:
DEBUG: [4345] recv:
DEBUG: [4396] recv:
DEBUG: [4447] recv:
DEBUG: [4497] recv:
DEBUG: [4547] recv:
DEBUG: [4598] recv:
DEBUG: [4649] recv:
DEBUG: [4699] recv:
DEBUG: [4750] recv:
DEBUG: [4800] recv:
DEBUG: [4816] recv: 46 B9 68
DEBUG: [4816] recv: 00 0D
DEBUG: [4817] recv: 80 F0 02 01 35 00 14 9A CB 16
Traceback (most recent call last):
File "stcflash.py", line 583, in
main()
File "stcflash.py", line 579, in main
program(Programmer(conn, protocol), code)
File "stcflash.py", line 460, in program
prog.erase()
File "stcflash.py", line 360, in erase
assert cmd == 0x80 and not dat
AssertionError
I have been trying to use stcflash to program the STC12C5A60S2's I have here and they appear to be ever so slightly incompatible. Do you have any ideas on how to adjust stcflash to work with this mcu?
$ python2.7 stcflash.py --port /dev/tty.usbserial-A703BXNC --protocol 12 --lowbaud 115200 --aispbaud 115200 --verbose program.bin
Connect to /dev/tty.usbserial-A703BXNC at baudrate 115200
Detecting target...INFO: [5045] Model ID: F4 88
INFO: [5046] Model name: Unknown F4 88
INFO: [5046] ROM size: None
INFO: [5046] Protocol ID: 12
INFO: [5046] Checksum mode: 2
INFO: [5046] UART Parity: EVEN
INFO: [5046] Info string [0]: 72 53 00 F4 88 01 06 70 A2 02 12 17 1B 1D 1F 00
INFO: [5046] Info string [1]: F4 F0 04 CF FF 7B 7F FF FF 14 09 04 60
done
FOSC: 5413.651MHz
Model: Unknown F4 88 (ver7.2S)
Traceback (most recent call last):
File "stcflash.py", line 582, in <module>
main()
File "stcflash.py", line 578, in main
program(Programmer(conn, protocol), code)
File "stcflash.py", line 438, in program
cmd, dat = prog.recv()
File "stcflash.py", line 185, in recv
raise IOError()
IOError
And with debug logging turned on ...
$ python2.7 stcflash.py --port /dev/tty.usbserial-A703BXNC --protocol 12 --lowbaud 115200 --aispbaud 115200 --verbose --debug program.bin
Connect to /dev/tty.usbserial-A703BXNC at baudrate 115200
Detecting target...DEBUG: [10] send: 7F 7F
DEBUG: [62] recv:
DEBUG: [62] recv(..): timeout
DEBUG: [62] send: 7F 7F
DEBUG: [115] recv:
DEBUG: [115] recv(..): timeout
DEBUG: [115] send: 7F 7F
DEBUG: [167] recv:
DEBUG: [167] recv(..): timeout
DEBUG: [167] send: 7F 7F
DEBUG: [222] recv:
DEBUG: [222] recv(..): timeout
DEBUG: [222] send: 7F 7F
DEBUG: [275] recv:
DEBUG: [275] recv(..): timeout
DEBUG: [275] send: 7F 7F
...
DEBUG: [4381] recv(..): timeout
DEBUG: [4381] send: 7F 7F
DEBUG: [4385] recv: 46
DEBUG: [4385] recv: B9
DEBUG: [4385] recv: 68
DEBUG: [4385] recv: 00 34
DEBUG: [4401] recv: 50 68 63 83 A2 F7 BA 9F 01 50 9F 00 FD 00 D5 FF FF 72 53 00 F4 88 01 06 70 A2 02 12 17 1B 1D 1F 00 F4 F0 04 CF FF 7B 7F FF FF 14 09 04 60 14 F7 16
INFO: [4401] Model ID: F4 88
INFO: [4401] Model name: Unknown F4 88
INFO: [4401] ROM size: None
INFO: [4401] Protocol ID: 12
INFO: [4401] Checksum mode: 2
INFO: [4401] UART Parity: EVEN
INFO: [4402] Info string [0]: 72 53 00 F4 88 01 06 70 A2 02 12 17 1B 1D 1F 00
INFO: [4402] Info string [1]: F4 F0 04 CF FF 7B 7F FF FF 14 09 04 60
done
FOSC: 6225.837MHz
Model: Unknown F4 88 (ver7.2S)
DEBUG: [4402] send: 46 B9 6A 00 0D 50 00 00 36 01 F4 88 02 7A 16
DEBUG: [4456] recv:
DEBUG: [4509] recv:
DEBUG: [4564] recv:
DEBUG: [4618] recv:
DEBUG: [4672] recv:
DEBUG: [4724] recv:
DEBUG: [4778] recv:
DEBUG: [4832] recv:
DEBUG: [4886] recv:
DEBUG: [4898] recv: 00 00 E6
DEBUG: [4898] recv: 9E 0C CF
DEBUG: [4968] recv: 00 00
DEBUG: [5022] recv:
DEBUG: [5074] recv:
DEBUG: [5128] recv:
DEBUG: [5181] recv:
DEBUG: [5234] recv:
DEBUG: [5289] recv:
DEBUG: [5344] recv:
DEBUG: [5399] recv:
DEBUG: [5454] recv:
DEBUG: [5454] recv(..): timeout
Traceback (most recent call last):
File "stcflash.py", line 582, in <module>
main()
File "stcflash.py", line 578, in main
program(Programmer(conn, protocol), code)
File "stcflash.py", line 438, in program
cmd, dat = prog.recv()
File "stcflash.py", line 185, in recv
raise IOError()
IOError
I have these error:
Programming: #################### done
Setting options...Traceback (most recent call last):
File "/home/max/tools/stcflash", line 700, in <module>
main()
File "/home/max/tools/stcflash", line 696, in main
program(Programmer(conn, opts.protocol), code, opts.erase_eeprom)
File "/home/max/tools/stcflash", line 558, in program
if prog.options(erase_eeprom=erase_eeprom):
File "/home/max/tools/stcflash", line 457, in options
self.send(0x8D, dat)
File "/home/max/tools/stcflash", line 226, in send
chksum = sum(buf[2:])
TypeError: unsupported operand type(s) for +: 'int' and 'str'
使用stcflash可以正常读出芯片数据
$ python stcflash.py
Connect to /dev/ttyUSB0 at baudrate 2400
Detecting target... done
FOSC: 12.056MHz
Model: STC12C5A60S2 (ver6.2I)
ROM: 60KB
可是在烧录程序时候却发生如下错误
$ python stcflash.py foo.bin
Connect to /dev/ttyUSB0 at baudrate 2400
Detecting target... done
FOSC: 12.052MHz
Model: STC12C5A60S2 (ver6.2I)
ROM: 60KB
Baudrate: 57600
Erasing target...Traceback (most recent call last):
File "stcflash.py", line 578, in
main()
File "stcflash.py", line 574, in main
program(Programmer(conn, protocol), code)
File "stcflash.py", line 455, in program
prog.erase()
File "stcflash.py", line 362, in erase
cmd, dat = self.recv()
File "stcflash.py", line 180, in recv
raise IOError()
IOError
经查,是因为本款芯片ROM过大导致,而原程序timeout时间为1s,擦写时间不足,所以引发报错。
解决方案:
修改源程序第170行,增加timeout时间,这里设置为5s
170 def recv(self, timeout = 5, start = [0x46, 0xB9, 0x68]):
171 timeout += time.time()
172 while time.time() < timeout:
173 .............................................................................
I want to burn a 8051chip use a raspberry without usb adapter
It is possible?
thanks!
STC12C5A60S2无法下载,使用的命令是
stcflash -l 1200 -a 19200 -r 12 -d ./test.bin
波特率怎么改都不行
DEBUG: [2774] send: 7F 7F
DEBUG: [2825] recv:
DEBUG: [2825] send: 7F 7F
DEBUG: [2853] recv: 46
DEBUG: [2853] send: 7F 7F
DEBUG: [2863] recv: B9
DEBUG: [2872] recv: 68
DEBUG: [2889] recv: 00 72
DEBUG: [2890] send: 7F 7F
DEBUG: [2898] recv: 41
DEBUG: [2906] recv: AA
DEBUG: [2906] send: 7F 7F
DEBUG: [2914] recv: 46
DEBUG: [2922] recv: 58
DEBUG: [2922] send: 7F 7F
DEBUG: [2930] recv: B1
DEBUG: [2939] recv: 40
DEBUG: [2939] send: 7F 7F
DEBUG: [2946] recv: C5
DEBUG: [2955] recv: 08
DEBUG: [2955] send: 7F 7F
DEBUG: [2964] recv: 15
DEBUG: [2973] recv: 05
DEBUG: [2974] send: 7F 7F
DEBUG: [2982] recv: 15
DEBUG: [2991] recv: 08
DEBUG: [2991] send: 7F 7F
DEBUG: [3000] recv: 15
DEBUG: [3009] recv: 04
DEBUG: [3009] send: 7F 7F
DEBUG: [3019] recv: 15
DEBUG: [3028] recv: 08
DEBUG: [3028] send: 7F 7F
DEBUG: [3037] recv: 15
DEBUG: [3046] recv: 04
DEBUG: [3046] send: 7F 7F
DEBUG: [3055] recv: 65
DEBUG: [3064] recv: 49
DEBUG: [3064] send: 7F 7F
DEBUG: [3073] recv: 00
DEBUG: [3082] recv: A2
DEBUG: [3082] send: 7F 7F
DEBUG: [3090] recv: F9
DEBUG: [3098] recv: 62
DEBUG: [3098] send: 7F 7F
DEBUG: [3106] recv: F7
DEBUG: [3118] recv: FD
DEBUG: [3118] send: 7F 7F
DEBUG: [3126] recv: BB
DEBUG: [3137] recv: FF
DEBUG: [3137] send: 7F 7F
DEBUG: [3147] recv: FD
DEBUG: [3156] recv: FF
DEBUG: [3156] send: 7F 7F
DEBUG: [3164] recv: 01
DEBUG: [3172] recv: 02
DEBUG: [3172] send: 7F 7F
DEBUG: [3180] recv: 08
DEBUG: [3188] recv: 10
DEBUG: [3188] send: 7F 7F
DEBUG: [3195] recv: 20
DEBUG: [3203] recv: 80
DEBUG: [3211] recv: 00
DEBUG: [3211] send: 7F 7F
DEBUG: [3220] recv: 00
DEBUG: [3229] recv: 00
DEBUG: [3229] send: 7F 7F
DEBUG: [3238] recv: 00
DEBUG: [3246] recv: 01
DEBUG: [3246] send: 7F 7F
DEBUG: [3254] recv: 04
DEBUG: [3262] recv: 08
DEBUG: [3262] send: 7F 7F
DEBUG: [3270] recv: 10
DEBUG: [3277] recv: 40
DEBUG: [3285] recv: 80
DEBUG: [3286] send: 7F 7F
DEBUG: [3293] recv: 00
DEBUG: [3302] recv: BD
DEBUG: [3302] send: 7F 7F
DEBUG: [3310] recv: 85
DEBUG: [3321] recv: 00
DEBUG: [3321] send: 7F 7F
DEBUG: [3329] recv: 00
DEBUG: [3337] recv: F5
DEBUG: [3338] send: 7F 7F
DEBUG: [3346] recv: 85
DEBUG: [3354] recv: 07
DEBUG: [3355] send: 7F 7F
DEBUG: [3362] recv: 88
DEBUG: [3371] recv: 90
DEBUG: [3371] send: 7F 7F
DEBUG: [3380] recv: 37
DEBUG: [3389] recv: F1
DEBUG: [3389] send: 7F 7F
DEBUG: [3439] recv:
DEBUG: [3439] send: 7F 7F
DEBUG: [3489] recv:
DEBUG: [3489] send: 7F 7F
DEBUG: [3540] recv:
DEBUG: [3540] send: 7F 7F
I just want to detect some info of my 89c52, but always raise an IOError.
it's my steps to use this script.
1st,python stcflash.py
;
2nd,turn off the power;
3rd, turn on the power.then wait.then raise error.
why...
Althought it work fine for stc89,stc90,stc12 .Is this also work for the lastest mcu ,like 'stc15' or 'stc8'?
to be honest for anyone wants to flash code into 8051, linux is great option for studying hardware, thus it is worth to update it to python3, as long as related modules
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.