diff options
author | Christian Pointner <equinox@spreadspace.org> | 2013-07-07 21:41:29 +0000 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2013-07-07 21:41:29 +0000 |
commit | fcbcd99677cc864a0c8911c99a6e2a106f92567c (patch) | |
tree | 43456b86e3b747289af2273bdc76af07aed3ed9a /downloader | |
parent | switched back to name but only 3 bytes (diff) |
fixed new features
git-svn-id: https://svn.spreadspace.org/pic/trunk@51 a09c6847-51d9-44de-8ef2-e725cf50f3c7
Diffstat (limited to 'downloader')
-rwxr-xr-x | downloader/downloader.py | 13 | ||||
-rw-r--r-- | downloader/proto.txt | 14 |
2 files changed, 19 insertions, 8 deletions
diff --git a/downloader/downloader.py b/downloader/downloader.py index 653bd72..86a41c9 100755 --- a/downloader/downloader.py +++ b/downloader/downloader.py @@ -108,9 +108,11 @@ def exec_command(dev, cmd, param, answer): 5: "address invalid", 6: "address prohibited", 7: "value out of bounds" } - cstr = bytearray(struct.pack('<BB', cmd, 0) + param) + dev.flushInput() + dev.flushOutput() + + cstr = bytearray(struct.pack('<BB', cmd, len(param)+3) + param) cstr.extend(struct.pack("<B", calc_csum(cstr))) - cstr[1] = len(cstr) dev.write(cstr) astr = bytearray() @@ -156,9 +158,9 @@ def exec_command(dev, cmd, param, answer): ### Commands def identify(dev): - data = exec_command(dev, 1, '', '<BB3sHBBH') + data = exec_command(dev, 1, '', '<BB3sHHBHBH') id = { 'ver_min': data[0], 'ver_maj': data[1], 'name': data[2], 'devid': data[3], - 'fss': data[4], 'mess': data[5], 'supported': data[6] } + 'fs': data[4], 'fss': data[5], 'es': data[6], 'mess': data[7], 'supported': data[8] } if id['ver_maj'] != VERSION_MAJ: print "incompatible protocol version, expected: %d, got: %d" % (VERSION_MAJ, id['ver_maj']) @@ -167,7 +169,8 @@ def identify(dev): print "FSS value is 0 " sys.exit(4) - print "connected with Bootloader '%s' Version %d.%d, (ID=%04X, FSS=%d, MESS=%d)" % (id['name'], id['ver_maj'], id['ver_min'], id['devid'], id['fss'], id['mess']) + print "connected with Bootloader '%s' Version %d.%d, (ID=%04X, %d bytes Flash, FSS=%d, %d bytes EEPROM, MESS=%d)" % \ + (id['name'], id['ver_maj'], id['ver_min'], id['devid'], id['fs'], id['fss'], id['es'], id['mess']) return id def boot(dev): diff --git a/downloader/proto.txt b/downloader/proto.txt index 15caec7..0e35e1e 100644 --- a/downloader/proto.txt +++ b/downloader/proto.txt @@ -43,7 +43,7 @@ identify: 1 | len=3 | <csum> answer: - 1 | len=22 | <ret> | version | name | devid | fss | mess | supported | <csum> + 1 | len=19 | <ret> | version | name | devid | fs | fss | es | mess | supported | <csum> version: 2bytes, protocol version @@ -59,12 +59,20 @@ identify: 2bytes, device id of the PIC The downlaoder may use this id to check if it talks to the right bootloader + fs: + 2bytes, flash size + The size of the flash in code words. + fss: 1byte, flash segment size The number of words of one flash segment which has to be written at once. If less than <fss> should be updated the downloader has to perform a read operation first. + es: + 2bytes, eeprom size + The size of the eeprom in bytes. + mess: 1byte, maximum eeprom segment size This represents the maximum number of eeprom bytes which may be written or @@ -157,12 +165,12 @@ write eeprom: ~~~~~~~~~~~~~ command: - 7 | len=4+2<len(data) | addr | data | <csum> + 7 | len=4+len(data) | addr | data | <csum> answer: 7 | len=4 | <ret> | <csum> - The bootloader writes <data> (which has to contain exactly <len> bytes) to address + The bootloader writes <data> (which has to contain exactly <len>-4 bytes) to address <addr> inside the eeprom. len is 1byte long and the value must not exceed <mess> bytes. |