summaryrefslogtreecommitdiff
path: root/downloader
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-07-07 02:46:24 +0000
committerChristian Pointner <equinox@spreadspace.org>2013-07-07 02:46:24 +0000
commit82c90d70279c9522520f864daa72156fdacf38b1 (patch)
treeb245570d048459da45e0f3bab27188f33104d9d7 /downloader
parentadded length field for messages (diff)
bootloader now checks csum
git-svn-id: https://svn.spreadspace.org/pic/trunk@47 a09c6847-51d9-44de-8ef2-e725cf50f3c7
Diffstat (limited to 'downloader')
-rwxr-xr-xdownloader/downloader.py6
-rw-r--r--downloader/proto.txt4
2 files changed, 6 insertions, 4 deletions
diff --git a/downloader/downloader.py b/downloader/downloader.py
index f90eced..b85326f 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()
diff --git a/downloader/proto.txt b/downloader/proto.txt
index 17dec93..98beebe 100644
--- a/downloader/proto.txt
+++ b/downloader/proto.txt
@@ -157,12 +157,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.