Commit Graph

126 Commits

Author SHA1 Message Date
Grigori Goronzy
b4c7f34d39 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.

Addresses grigorig/stcgal#16.
2016-06-09 16:15:09 +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
Grigori Goronzy
d1f464c387 Raise default handshake baudrate to 2400
See grigorig/stcgal#12 for more information.
2016-04-15 11:13:54 +02:00
Jens J
e268b282cb Update dump-mcu.py for stc-isp 6.85K
v2: squash "Update model DB"
2016-04-14 18:53:45 +02:00
Grigori Goronzy
f9a19c927c Update README.md 2016-04-02 23:13:51 +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
6a38127c0d Fix regression with some STC15 parts
The cpu core voltage setting is only available on newer parts, so do not
try to support it on older ones. The option packet is too short on some
parts, which resulted in an assertion hit.

There may be a nicer solution, but this works for now.

Fixes grigorig/stcgal#6.
2016-01-05 07:03:59 +01:00
Grigori Goronzy
d3911870c3 Fix initialization with CH340 UARTs
Initialization is messed up on older Linux kernels and that results
in 9600 baud being used unconditionally in some cases. Setting the
baud rate separately seems to work around this successfully.

Fixes grigorig/stcgal#5.
2015-12-15 20:22:25 +01:00
Grigori Goronzy
293ce2c749 Add STC15W408AS to compatibility list
Tested and works fine.
2015-12-12 01:03:14 +01:00
Grigori Goronzy
f13650a352 stc15: remove extra space in output 2015-12-11 01:50:55 +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
6f0ee0387d serial: flush input on connect
Sometimes there's some garbage in the input buffer and we aren't
interested in that.
2015-12-11 01:21:06 +01:00
Grigori Goronzy
cc20c85ad0 Add STC15W4K56S4 dump 2015-12-11 01:14:51 +01:00
Grigori Goronzy
b71b6535c4 Add STC15W4K56S4 to compatibility list
Seems to work just fine for me now.
2015-12-11 01:13:35 +01:00
Grigori Goronzy
76b3418f0a stc15: add core voltage option (STC15W)
This is used on STC15W4 series and has no function on earlier MCUs.
There is no good way to filter options, unfortunately.
2015-12-11 01:11:53 +01:00
Grigori Goronzy
11b165c02c stc15a: set pulse timeout for handshake 2015-12-11 00:40:22 +01:00
Grigori Goronzy
9f42ef29f3 stc15: use generic/new sync sequence for handshake
Use the newer sync sequence. Refactor the pulse() function to make
it somewhat generic, so we can use it without worrying about writing
the exactly right number of bytes.

This seems to get STC15W4 series chips working.
2015-12-11 00:39:59 +01:00
Grigori Goronzy
432fed8af1 Add STC11F02E to compatibility list 2015-12-06 19:45:29 +01:00
Grigori Goronzy
7336673655 Add STC15L2K61S2 to README
See https://github.com/grigorig/stcgal/issues/3
2015-11-30 00:51:51 +01:00
Andrew Andrianov
0548582dd4 Add initial debian packaging info
v2 (Grigori Goronzy): Simplify with pybuild, fix some smaller issues,
license as MIT.

Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2015-11-25 23:03:25 +01:00