Commit Graph

169 Commits

Author SHA1 Message Date
Andrew Andrianov
1a5cf18590 debian: Update Build-Depends and Depends
This closes #32

Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-25 21:31:14 +03:00
Grigori Goronzy
a5e1cc26ee Merge pull request #31 from nekromant/progressbar
Implement progress callback and tqdm progressbar
2017-10-22 15:55:45 +02:00
Andrew Andrianov
b77157bc40 .travis.yml: Install tqdm to make ci happy
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-19 11:26:42 +03:00
Andrew Andrianov
092fbdc842 protocols.py: Implement progress callback and tqdm progressbar
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-19 11:26:27 +03:00
Grigori Goronzy
e0bda73fed Merge pull request #29 from grigorig/advanced-tests
Advanced tests
2017-10-18 23:22:40 +02:00
Grigori Goronzy
57100062af Rename test/ to tests/ 2017-10-12 23:02:02 +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
Grigori Goronzy
fd923f3a92 Cleanup utils
Just a tiny simplification, found by pylint.
2017-10-12 23:02:02 +02:00
Grigori Goronzy
b145fb364a Remove unneeded include 2017-10-12 23:02:02 +02:00
Grigori Goronzy
a29c9bf42e Add fuzzing programming cycle tests 2017-10-12 23:02:02 +02:00
Grigori Goronzy
1cde6da007 stc15: check that a UID has been received
Found by fuzzing. In some cases it's possible that we end up without
a valid UID. Detect and workaround.
2017-10-12 23:02:02 +02:00
Grigori Goronzy
ca30a508aa Fix various issues in frequency trimming
Found by fuzzing. The frequency trimming functions did a bad job of
checking for possible out of bounds accesses and didn't handle various
failure cases correctly. Add suitable checks to fix the issues found.

v2: fix one check, add several new ones
2017-10-12 23:01:50 +02:00
Grigori Goronzy
b9208c4772 Add length checks for status packets
Fuzzing found a number of issues when status packets are cut short.
Introduce checks on the length of status packets to fix these issues.
2017-10-11 23:20:20 +02:00
Grigori Goronzy
ad5a89297f Check length of responses
Fuzzing found lots of issues when packets are cut short. This should
rarely happen, but stcgal should be able to handle it without crashing.

This adds length checks when checking the magic of packets or when
checking checksums.
2017-10-11 23:20:20 +02:00
Grigori Goronzy
0cb56f4919 Use abc for StcBaseProtocol
Use the abc module to declare StcBaseProtocol as an abstract base
class and clean up imports while at it.
2017-10-11 23:20:20 +02:00
Grigori Goronzy
f195258eb5 Clean up options utilities
Use abc to declare an abstract base class and add some documentation.
2017-10-11 23:20:20 +02:00
Grigori Goronzy
ff9530833d Update gitignore 2017-10-11 23:19:11 +02:00
Grigori Goronzy
8b0fdcb42a Clean up Intel HEX utilities
No functional change intended.
2017-10-11 23:18:59 +02:00
Grigori Goronzy
ebcfeb467c Merge pull request #27 from nekromant/fixes
Implement power-cycling via a custom shell cmd, update models.py
2017-10-09 00:05:55 +02:00
Andrew Andrianov
d7e226df6b README.md: Document -r option properly
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-08 23:58:31 +03:00
Andrew Andrianov
191a580469 protocols: Move device reset logic to a separate method
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-08 23:20:17 +03: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
3f4263e8fe models.py: Add some STC15xxx definitions from stcdude's mcudb
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-07 23:30:03 +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
f1bafb1e0d Update version to 1.4 2017-09-19 18:00:02 +02:00
Grigori Goronzy
fdd6707d2d Add Travis CI for CI and CD
Run tests for each commit and deploy packages (deb/rpm) for each
release tag.
2017-09-19 17:54: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