1 Commits
v1.2 ... stc12b

Author SHA1 Message Date
b070346e70 WIP: refactor and add STC12B support
This adds support for a new protocol variant called STC12B for
STC12xx52/56 and possibly others. It is STC12 but with a different
option packet. The current implementation uses mix-ins, but I am not
sure yet if I like the modified architecture.
2016-05-19 08:23:44 +02:00
6 changed files with 21 additions and 32 deletions

View File

@ -111,18 +111,18 @@ Most importantly, ```-p``` sets the serial port to be used for programming.
### Protocols ### Protocols
STC MCUs use a variety of related but incompatible protocols for the STC MCUs use a variety of related but incompatible protocols for the
BSL. The protocol can be specified with the ```-P``` flag. By default BSL. The protocol can be specified with the ```-P``` flag. Optionally,
UART protocol autodetection is used. The mapping between protocols experimental protocol autodetection can be used. The mapping between
and MCU series is as follows: protocols and MCU series is as follows:
* ```stc89``` STC89/90 series * ```stc89``` STC 89/90 series
* ```stc12a``` STC12x052 series and possibly others * ```stc12a``` STC12Cx052AD and possibly others
* ```stc12b``` STC12x52 series, STC12x56 series and possibly others * ```stc12b``` STC12x52xx series, STC12x56xx series and possibly others
* ```stc12``` Most STC10/11/12 series * ```stc12``` Most STC10/11/12 series (default)
* ```stc15a``` STC15x104E and STC15x204E(A) series * ```stc15a``` STC15x104E and STC15x204E(A) series
* ```stc15``` Most STC15 series * ```stc15``` Most STC15 series
* ```usb15``` USB support on STC15W4 series * ```usb15``` USB support on STC15W4 series
* ```auto``` Automatic detection of UART based protocols (default) * ```auto``` Automatic detection of UART based protocols
The text files in the doc/ subdirectory provide an overview over The text files in the doc/ subdirectory provide an overview over
the reverse engineered protocols used by the BSLs. For more details, the reverse engineered protocols used by the BSLs. For more details,

7
debian/changelog vendored
View File

@ -1,10 +1,3 @@
stcgal (1.2) unstable; urgency=low
* Update to 1.2
* Add optional python3-usb dependency
-- Grigori Goronzy <greg@chown.ath.cx> Fri, 20 May 2016 03:21:25 +0200
stcgal (1.0git) unstable; urgency=low stcgal (1.0git) unstable; urgency=low
* Initial Debianized Release * Initial Debianized Release

18
debian/control vendored
View File

@ -10,17 +10,17 @@ X-Python3-Version: >= 3.2
Package: stcgal Package: stcgal
Architecture: all Architecture: all
Depends: ${misc:Depends}, python3, python3-serial Depends: ${misc:Depends}, python3, python3-serial
Recommends: python3-usb (>= 1.0.0~b2)
Description: STC MCU ISP flash tool Description: STC MCU ISP flash tool
stcgal is a command line flash programming tool for STC MCU Ltd. stcgal is a command line flash programming tool for STC MCU Ltd. 8051
8051 compatible microcontrollers. The name was inspired by avrdude. compatible microcontrollers. The name was inspired by avrdude.
. .
STC microcontrollers have an UART/USB based boot strap loader (BSL). It STC microcontrollers have a UART based boot strap loader (BSL). It
utilizes a packet-based protocol to flash the code memory and IAP utilizes a packet-based protocol to flash the code memory and
memory over a serial link. This is referred to as in-system programming IAP memory over a serial link. This is referred to as in-system
(ISP). The BSL is also used to configure various (fuse-like) device programming (ISP). The BSL is also used to configure various
options. Unfortunately, this protocol is not publicly documented and (fuse-like) device options. Unfortunately, this protocol is not
STC only provide a (crude) Windows GUI application for programming. publicly documented and STC only provide a (crude) Windows GUI
application for programming.
. .
stcgal is a full-featured Open Source replacement for STC's Windows stcgal is a full-featured Open Source replacement for STC's Windows
software; it supports a wide range of MCUs, it is very portable and software; it supports a wide range of MCUs, it is very portable and

View File

@ -1 +1 @@
__version__ = "1.2" __version__ = "1.0"

View File

@ -196,7 +196,7 @@ def cli():
parser.add_argument("code_image", help="code segment file to flash (BIN/HEX)", type=argparse.FileType("rb"), nargs='?') parser.add_argument("code_image", help="code segment file to flash (BIN/HEX)", type=argparse.FileType("rb"), nargs='?')
parser.add_argument("eeprom_image", help="eeprom segment file to flash (BIN/HEX)", type=argparse.FileType("rb"), nargs='?') parser.add_argument("eeprom_image", help="eeprom segment file to flash (BIN/HEX)", type=argparse.FileType("rb"), nargs='?')
parser.add_argument("-a", "--autoreset", help="cycle power automatically by asserting DTR", action="store_true") parser.add_argument("-a", "--autoreset", help="cycle power automatically by asserting DTR", action="store_true")
parser.add_argument("-P", "--protocol", help="protocol version (default: auto)", choices=["stc89", "stc12a", "stc12b", "stc12", "stc15a", "stc15", "usb15", "auto"], default="auto") parser.add_argument("-P", "--protocol", help="protocol version", choices=["stc89", "stc12a", "stc12b", "stc12", "stc15a", "stc15", "usb15", "auto"], default="stc12")
parser.add_argument("-p", "--port", help="serial port device", default="/dev/ttyUSB0") parser.add_argument("-p", "--port", help="serial port device", default="/dev/ttyUSB0")
parser.add_argument("-b", "--baud", help="transfer baud rate (default: 19200)", type=BaudType(), default=19200) parser.add_argument("-b", "--baud", help="transfer baud rate (default: 19200)", type=BaudType(), default=19200)
parser.add_argument("-l", "--handshake", help="handshake baud rate (default: 2400)", type=BaudType(), default=2400) parser.add_argument("-l", "--handshake", help="handshake baud rate (default: 2400)", type=BaudType(), default=2400)

View File

@ -21,7 +21,7 @@
# #
import serial import serial
import sys, os, time, struct, re, errno import sys, os, time, struct, re
import argparse import argparse
import collections import collections
from stcgal.models import MCUModelDatabase from stcgal.models import MCUModelDatabase
@ -1528,11 +1528,7 @@ class StcUsb15Protocol(Stc15Protocol):
self.status_packet = None self.status_packet = None
raise StcFramingException raise StcFramingException
else: raise StcFramingException else: raise StcFramingException
except StcFramingException: except (StcFramingException, usb.core.USBError): time.sleep(0.5)
time.sleep(0.5)
except usb.core.USBError as err:
if err.errno == errno.EACCES:
raise IOError(err.strerror)
self.initialize_model() self.initialize_model()
print("done") print("done")