summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-07-07 14:39:52 +0000
committerChristian Pointner <equinox@spreadspace.org>2013-07-07 14:39:52 +0000
commit66e1493a741bee0ab916d74e7e55a76114fa822d (patch)
treebcefbb4d4e3667babdeb9eb59a5405e45b4f9093
parentremoved name for identify - now using userid (diff)
switched back to name but only 3 bytes
git-svn-id: https://svn.spreadspace.org/pic/trunk@50 a09c6847-51d9-44de-8ef2-e725cf50f3c7
-rw-r--r--bootloader/bootloader.asm13
-rwxr-xr-xdownloader/downloader.py15
-rw-r--r--downloader/proto.txt20
3 files changed, 20 insertions, 28 deletions
diff --git a/bootloader/bootloader.asm b/bootloader/bootloader.asm
index 164adb7..629b6f5 100644
--- a/bootloader/bootloader.asm
+++ b/bootloader/bootloader.asm
@@ -35,10 +35,11 @@ ISRVECT EQU USERVECT + H'4'
VERSION_MAJ EQU .0
VERSION_MIN EQU .1
-USERID_L EQU H'fe'
-USERID_H EQU H'ca'
-DEVID_H EQU H'20'
+NAME_0 EQU 'n'
+NAME_1 EQU 'i'
+NAME_2 EQU 'l'
DEVID_L EQU H'82'
+DEVID_H EQU H'20'
FLASH_SIZE_L EQU H'00'
FLASH_SIZE_H EQU H'20' ; 0x2000 -> 8192 Words of Flash
FSS EQU .16 ; writing is done 8 words at a time but 16 words get erased
@@ -292,9 +293,11 @@ cmd_identify
movlw VERSION_MAJ
call uart_tx_byte
- movlw USERID_L
+ movlw NAME_0
+ call uart_tx_byte
+ movlw NAME_1
call uart_tx_byte
- movlw USERID_H
+ movlw NAME_2
call uart_tx_byte
movlw DEVID_L
diff --git a/downloader/downloader.py b/downloader/downloader.py
index c0ce34f..653bd72 100755
--- a/downloader/downloader.py
+++ b/downloader/downloader.py
@@ -108,11 +108,9 @@ def exec_command(dev, cmd, param, answer):
5: "address invalid", 6: "address prohibited",
7: "value out of bounds" }
- dev.flushInput()
- dev.flushOutput()
-
- cstr = bytearray(struct.pack('<BB', cmd, len(param)+3) + param)
+ cstr = bytearray(struct.pack('<BB', cmd, 0) + param)
cstr.extend(struct.pack("<B", calc_csum(cstr)))
+ cstr[1] = len(cstr)
dev.write(cstr)
astr = bytearray()
@@ -158,9 +156,9 @@ def exec_command(dev, cmd, param, answer):
### Commands
def identify(dev):
- data = exec_command(dev, 1, '', '<BBHHHBHBH')
- id = { 'ver_min': data[0], 'ver_maj': data[1], 'userid': data[2], 'devid': data[3],
- 'fs': data[4], 'fss': data[5], 'es': data[6], 'mess': data[7], 'supported': data[8] }
+ data = exec_command(dev, 1, '', '<BB3sHBBH')
+ id = { 'ver_min': data[0], 'ver_maj': data[1], 'name': data[2], 'devid': data[3],
+ 'fss': data[4], 'mess': data[5], 'supported': data[6] }
if id['ver_maj'] != VERSION_MAJ:
print "incompatible protocol version, expected: %d, got: %d" % (VERSION_MAJ, id['ver_maj'])
@@ -169,8 +167,7 @@ def identify(dev):
print "FSS value is 0 "
sys.exit(4)
- print "connected with Bootloader '%04X' Version %d.%d, (ID=%04X, %d bytes Flash, FSS=%d, %d bytes EEPROM, MESS=%d)" % \
- (id['userid'], id['ver_maj'], id['ver_min'], id['devid'], id['fs'], id['fss'], id['es'], id['mess'])
+ 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'])
return id
def boot(dev):
diff --git a/downloader/proto.txt b/downloader/proto.txt
index af32584..15caec7 100644
--- a/downloader/proto.txt
+++ b/downloader/proto.txt
@@ -43,36 +43,28 @@ identify:
1 | len=3 | <csum>
answer:
- 1 | len=22 | <ret> | version | userid | devid | fs | fss | es | mess | supported | <csum>
+ 1 | len=22 | <ret> | version | name | devid | fss | mess | supported | <csum>
version:
2bytes, protocol version
It is an error if the major version (MSB) is different (hence any
protocol update must change the major version of the bootloader).
- userid:
- 2bytes, an id which determines the exact device
- The downloader has to compare this with the device id supplied
+ name:
+ 3bytes, a descriptive name of the device.
+ The downloader has to compare this name with the device name supplied
via commandline and stop in case they don't match
devid:
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
@@ -165,12 +157,12 @@ write eeprom:
~~~~~~~~~~~~~
command:
- 7 | len=4+len(data) | addr | data | <csum>
+ 7 | len=4+2<len(data) | addr | data | <csum>
answer:
7 | len=4 | <ret> | <csum>
- The bootloader writes <data> (which has to contain exactly <len>-4 bytes) to address
+ The bootloader writes <data> (which has to contain exactly <len> bytes) to address
<addr> inside the eeprom. len is 1byte long and the value must not exceed <mess> bytes.