Commit Graph

146 Commits

Author SHA1 Message Date
Grigori Goronzy
3c180ff8dc Add image and cache 2017-09-18 16:06:12 +02:00
Grigori Goronzy
0dbca5c163 Add additional Python version 2017-09-18 15:59:54 +02:00
Grigori Goronzy
079affc4f3 Add basic Travis CI configuration 2017-09-18 15:53:26 +02:00
Grigori Goronzy
532363d97b Exclude test directory from build 2017-09-18 15:42:08 +02:00
Grigori Goronzy
5865b06f7f Add STC15W4K56S4 programming test 2017-09-02 10:23:06 +02:00
Grigori Goronzy
1b69257cd3 Add missing STC15F104E trace
Currently broken, needs retracing.
2017-09-02 10:12:14 +02:00
Grigori Goronzy
38ac5f0788 Add STC15L104W programming test 2017-09-02 08:05:13 +02:00
Grigori Goronzy
6dccf13fb6 Add missing test dependency
PyYAML is needed to parse the programming simulation data.
2017-09-02 00:08:28 +02:00
Grigori Goronzy
0ca8b2ea2d Ensure hexstr helper actually received a list of bytes
Otherwise, the formatted output is rather bogus. Found with a test case.
2017-09-02 00:00:27 +02:00
Grigori Goronzy
53184b549e Handle None in to_bool utility
None is commonly used, so we want to be able to handle it with this helper.
Found with a test case.
2017-09-01 23:59:05 +02:00
Grigori Goronzy
cf68e3c6dc Add initial tests
This adds various tests, integrated into setuptools. These use "monkey
patching" where needed to mock the pyserial and packet reader/writer
functionality to allow for testing with no changes.

The code should be refactored to simplify testing, but this is good enough
to stop regressions for now.
2017-09-01 23:55:46 +02:00
Grigori Goronzy
5d10c06f1e Add Visual Studio Code to gitignore 2017-08-31 21:08:57 +02:00
Grigori Goronzy
7e84b8e0fb Fix some additional code smells
No functional change intended.
2017-08-31 21:07:56 +02:00
Grigori Goronzy
f34ba6644f Fix option error handling for STC12A LVD 2017-06-16 10:22:24 +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
2e822375e0 Update Debian packaging scripts for 1.3 2017-06-10 10:02:53 +02:00
Grigori Goronzy
7d6e8e9bfd Update version to 1.3 2017-06-10 09:55:38 +02:00
Grigori Goronzy
506289b8ee Add __main__ module
This allows stcgal to be started with "python3 -m stcgal" or similar.
Addresses stcgal#24.
2017-06-09 21:03:07 +02:00
Grigori Goronzy
f417b6eed5 Add new compatibility report
Closes #20.
2016-11-22 10:23:47 +01:00
Grigori Goronzy
86e289b65c usb15: add basic protocol information
These are just my notes from reverse engineering.
2016-06-10 21:12:17 +02:00
Grigori Goronzy
53f9544281 stc15: fix RC oscillator baudrate switch packet
It looks like it wasn't correct. The last value sent is probably
supposed to be the trim value for the chosen trim frequency.

Found while investigating grigorig/stcgal#16.
2016-06-10 12:45:58 +02:00
Grigori Goronzy
65a7759647 stc12+: drop checksum verification for flashing
It's not needed on STC12 and up. All transfers are error checked with
parity and a 16-bit modular sum already. STC15 dropped the verification
checksum on the protocol level, it's not sent with the write status
packet, which is a testament to this not being needed.

Some parts store the UID in the last bytes of flash memory and this
verification actually caused incorrect verification failures because
of the verification, which apparently read the UID on verification
readback.

Fixes grigorig/stcgal#15.
2016-05-28 11:25:44 +02:00
Grigori Goronzy
8ad77586d4 Update version to 1.2 2016-05-20 03:22:24 +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
26ef34991b usb15: abort if permission denied
Don't ignore permission denied when looking for a suitable USB device.
Otherwise users don't notice what the problem is, stcgal will just
keep waiting on the prompt.
2016-05-20 02:55:23 +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
d6ef028dc7 Extract mix-ins for STC12 and STC12A options
This simplifies code down the line. No functional change intended.
2016-05-20 02:44:50 +02:00
Grigori Goronzy
979d7f513f Get rid of USB bmRequestType constants
These constants were calculated on class loading, which didn't work
without pyusb. USB support is going to remain optional.
2016-05-18 16:40:09 +02:00
Grigori Goronzy
fce2f01232 Extract option classes into separate file 2016-05-18 02:38:13 +02:00
Grigori Goronzy
854f36100b stc12: fix option handling
MCS3 index was wrong. Also, write MCS3 to two possible indices in
the option set packet.

Addresses grigorig/stcgal#14.
2016-05-18 02:14:02 +02:00
Grigori Goronzy
92f4def11a stc12a: revamp option handling
Completely revamp option handling. This fixes a wrong index of MCS4,
which is now renamed to MCS3. Now programming should be exactly
similar to STC-ISP 6.85M.

This also renames the values of the low_voltage_reset option for
clarity.

Also update the documentation and clarity the meaning of the option
according to protocol family.

Addresses grigorig/stcgal#14.
2016-05-18 01:40:08 +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
366a3a5bd3 Fix EEPROM size of STC12x54 series in MCU database 2016-05-15 02:39:51 +02:00
Grigori Goronzy
c046e886e3 usb15: add protocol notes 2016-05-15 02:31:36 +02:00
Grigori Goronzy
7ba95eab68 stc15/usb15: add password feature notes
I'm not going to implement this right now as it is rather dangerous.
2016-05-15 02:30:25 +02:00
Grigori Goronzy
61a4fa0e4f stc89: add missing output flush 2016-05-14 21:37:27 +02:00
Grigori Goronzy
da5f6678c5 usb15: sanity check on status packet reads
If a previous stcgal invocation is aborted, we can be in a bad state
upon connect. Add a simple sanity check based on packet length to
detect this and drop unsuitable packets.
2016-05-14 21:03:07 +02:00
Grigori Goronzy
a8f141584d Merge branch 'usbisp'
It is still experimental, but the changes are not very invasive, so why
not include it right now. Closes grigorig/stcgal#10.
2016-05-14 13:26:57 +02:00
Grigori Goronzy
adcb8d8ced README: add details of usb15 protocol mode 2016-05-14 13:21:43 +02:00
Grigori Goronzy
81c890337e usb15: make USB support optional 2016-05-14 13:03:03 +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
2738118e8f stc15: extract build_options method
This will allow use to reuse code for upcoming USB-ISP support.
2016-05-14 12:43:15 +02:00
Grigori Goronzy
eedf9169a7 stc15: add error reporting for locked MCUs
It is possible to lock devices with a password against flashing. This
feature is not currently supported by stcgal, so at least output a
sensible message.
2016-05-13 02:54:43 +02:00
Grigori Goronzy
cb739e6f94 Add exit status to documentation 2016-05-12 01:48:02 +02:00
Grigori Goronzy
2a770bb37f Add missing license header 2016-05-12 01:25:22 +02:00
Grigori Goronzy
8fe94e001f Update list of compatible MCUs 2016-05-12 01:19:31 +02:00
Grigori Goronzy
b1ed017137 Add protocol detection to documentation 2016-05-12 01:07:27 +02:00
Grigori Goronzy
678d001ec5 Print informational message after protocol detection 2016-05-12 01:04:34 +02:00
Grigori Goronzy
f8e8d66baa Merge pull request #13 from laborer/master
Add automatic protocol detection
2016-05-12 00:11:10 +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