Commit Graph

40 Commits

Author SHA1 Message Date
Vincent DEFERT
6254494f92 Updated documentation and fixed a few details 2023-06-02 09:55:36 +02:00
Vincent DEFERT
4894e8f219 Added protocol stc89a (BSL 7.2.5c) PR#64 2023-06-01 18:34:44 +02:00
Vincent DEFERT
1468d60005 Minor corrections after review 2023-06-01 08:50:30 +02:00
Vincent DEFERT
20ae770f8f Added support for all STC8 and STC32 series 2023-05-29 09:15:07 +02:00
Grigori Goronzy
761c68e469 frontend: fix disconnect when autodetection fails
We don't know the protocol version so we can't actually disconnect,
just skip it.
2021-01-09 16:50:08 +01:00
Grigori Goronzy
c2fd3ab710 Add -e/--erase option
Erases the flash memory without any programming. Mutually exclusive with
providing a file to flash.
2021-01-03 19:57:50 +01:00
Grigori Goronzy
1ec855e6a1 Revert "Add "stc89a" protocol"
This reverts commit c5d509d1fa.
2021-01-03 18:36:05 +01:00
Grigori Goronzy
c5d509d1fa Add "stc89a" protocol
This protocol variant is designed for newer STC89 series chips with BSL
version 7.x.x. The new firmware uses framing
with 16-bit checksum.

This protocol variant is currently untested because I don't have any
hardware at hand.

Addresses #50, #40.
2021-01-03 16:41:05 +01:00
Grigori Goronzy
eaeab65044 frontend: fix flash/eeprom padding
Fill space with 0xFF instead of 0x00.  Addresses #58.
2021-01-02 18:26:21 +01:00
Grigori Goronzy
1c062ed0c7 Update documentation
Minor updates and improvements to the documentation.
2018-09-24 22:51:57 +02:00
Grigori Goronzy
bc829ce54c frontend: catch unknown errors
Catch unknown error types in the first stage (connect/initialize).
Sometimes we unfortunately see unexpected exceptions, for instance
pyserial might throw termios.error. See #39 for more details.
2018-09-24 00:43:27 +02:00
Grigori Goronzy
97d0d1123b frontend: add -V/--version flag
Add a new CLI flag to print version info and exit, like it is common.
2018-09-23 23:41:44 +02:00
Grigori Goronzy
4cc0deb8e9 Prepare for v1.5 2018-09-23 20:42:06 +02:00
Grigori Goronzy
8bc9d89257 Add preliminary STC8 support
What works:
* Frequency calibration of internal RC oscillator
* Flash/EEPROM programming

What doesn't work yet:
* Everything else
2018-06-27 01:05:06 +02:00
Grigori Goronzy
b47092093e Fix frontend argument parser
Refactoring sneaked in an issue with the string formatting.
2018-06-27 01:03:22 +02:00
Grigori Goronzy
d9e71a8694 Misc style and consistency fixes (NFC)
Various style, naming and other changes as recommended by pep8,
pyflakes and pylint.
2018-06-27 00:05:16 +02:00
Grigori Goronzy
4dcde5cc49 Clean up imports (NFC) 2018-06-27 00:05:16 +02:00
Grigori Goronzy
030497beb0 Extract StcAutoProtocol class, fix autodetection
With the introduction of real abstract classes, it is not possible
anymore to instantiate StcBaseProtocol. Instead, extract some of the
code for autodetection into the new class StcAutoProtocol and use
that for autodetection.
2017-10-12 23:02:02 +02:00
Andrew Andrianov
c131a9d901 frontend: Use command instead of cmd in description
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-08 23:19:55 +03:00
Andrew Andrianov
ba4faf9c43 Implement power-cycling via custom shell command
Sometimes instead of DTR line some custom way (e.g SoC gpio line)
may be used to reset the device. This commit implements
automated power-cycling using a a custom shell command that can
be specified via -r option

Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-07 22:41:49 +03:00
Grigori Goronzy
7e84b8e0fb Fix some additional code smells
No functional change intended.
2017-08-31 21:07:56 +02:00
Grigori Goronzy
f15b64f4f7 Fix some minor code smells reported by pylint
No functional change intended.
2017-06-16 10:21:43 +02:00
Grigori Goronzy
7d6e8e9bfd Update version to 1.3 2017-06-10 09:55:38 +02:00
Grigori Goronzy
276c696fa4 frontend: enable protocol autodetection by default
It seems to work rather well after some extended testing. Also clean
up and update the protocol documentation while at it.
2016-05-20 02:59:35 +02:00
Grigori Goronzy
f90fe4152b Add STC12B protocol variant
This is just like STC12, but with the STC12A option packet. Used by
STC12xx52 series, STC12xx56 series and possibly others.

Fixes grigorig/stcgal#14.
2016-05-20 02:54:57 +02:00
Grigori Goronzy
6c0af88551 frontend: always pad to 512 bytes, fill with 0xff
This seems to be the default of STC-ISP, so let's use it for possibly
improved compatibility.
2016-05-18 00:56:16 +02:00
Grigori Goronzy
9af984a191 Add USB-ISP support for STC15W4 series
The STC15W4 series have an additional USB BSL mode which kind of wraps
the serial protocol. It just uses basic USB control transfers. This
adds support for this mode, based on the existing STC15 code. pyusb is
required as an additional dependency. The new protocol mode is called
"usb15". There are some shortcomings, for instance timing of erase
and programming operations is problematic and right now only delays
are used. Also, only a single USB-ISP device is supported and the
first one found is always used.

Flash programming and setting options has been mildly tested on an
STC15W4K56S4 MCU.
2016-05-14 12:50:14 +02:00
Grigori Goronzy
678d001ec5 Print informational message after protocol detection 2016-05-12 01:04:34 +02:00
laborer
afba6c6805 Add automatic protocol detection
The model of the target MCU and its protocol is detected using model ID provided in the first packet (status packet) from the MCU.

Tested working models include,
IAP15F2K61S2 (BSL version: 7.1.4S, protocol: stc15)
STC15F104W (BSL version: 7.1.4Q, protocol: stc15)
TC11F02E (BSL version: 6.5K, protocol: stc12)
STC10F04XE (BSL version: 6.5J, protocol: stc12)
STC12C5A16S2 (BSL version: 6.2I, protocol: stc12)
STC12C5608AD (BSL version: 6.0G, protocol: stc12)
STC12C2052 (BSL version: 5.8D, protocol: stc12a)
STC90C52RC (BSL version: 4.3C, protocol: stc89)
STC89C52RC (BSL version: 4.3C, protocol: stc89)
STC89C54RD+ (BSL version: 4.3C, protocol: stc89)
STC15F104E (BSL version: 6.7Q, protocol: stc15a)

STC15F104E uses a different status packet protocol than other MCUs; it waits for an ACK packet before sending out the status packet.  Another problem is that STC15F104E shares the same model magic with STC15F104W.  Fortunately, these two models can be differentiated by their BSL version numbers.
2016-05-11 15:14:13 -04:00
Grigori Goronzy
d1f464c387 Raise default handshake baudrate to 2400
See grigorig/stcgal#12 for more information.
2016-04-15 11:13:54 +02:00
Grigori Goronzy
372f854c77 Add autoreset feature via DTR control line
This is inspired by Arduino.  Directly before connect, DTR is asserted
for 0.5 seconds and then deasserted again.  With a small external
circuit, the MCU can be power-cycled with this control signal.
In case the MCU draws very little power, it may even be possible to
supply power directly from the DTR pin.
2016-04-02 23:00:07 +02:00
Grigori Goronzy
41cabb587b frontend: also catch I/O errors in pulse phase 2016-01-17 15:16:43 +01:00
Grigori Goronzy
f5574f30e3 frontend: rename code_binary/eeprom_binary
We don't accept binary only anymore.
2015-12-11 01:49:45 +01:00
Grigori Goronzy
bc6f9da03e frontend: nicer description 2015-12-11 01:38:46 +01:00
Grigori Goronzy
3a81844a17 frontend: prefer to catch SerialException
It's a subclass of IOError, which we were catching first.
2015-11-24 01:42:53 +01:00
Grigori Goronzy
63327e3498 frontend: add Intel HEX support
Add Intel HEX support with the help of the IHex library. IHex needed
some modifications to make it work with Python 3.

Intel HEX files are autodetected, based on file extension (.hex,
.ihx or .ihex).
2015-11-24 00:36:44 +01:00
Grigori Goronzy
f452ca226e frontend: return instead of exit 2015-11-23 23:48:58 +01:00
Grigori Goronzy
7317f9e3a7 frontend: use 1200 BPS for handshake by default
It's not much slower but makes frequency measurement and calibration
more reliable.
2015-11-23 23:44:50 +01:00
Grigori Goronzy
b96bc39948 setup: use version from package 2015-11-23 22:19:21 +01:00
Grigori Goronzy
bc242390e7 Add packaging infrastructure
Split up single script into a package with multiple modules.
Also add a setuptools control file. With this, stcgal can be
installed like any other program. It's still possible to launch
from the sources directly. stcgal.py has been converted into a
simple launcher.

v2: fix imports
2015-11-23 22:19:06 +01:00