diff options
Diffstat (limited to 'downloader')
-rwxr-xr-x | downloader/downloader.py | 18 | ||||
-rw-r--r-- | downloader/proto.txt | 74 |
2 files changed, 47 insertions, 45 deletions
diff --git a/downloader/downloader.py b/downloader/downloader.py index 3a66f3b..b332271 100755 --- a/downloader/downloader.py +++ b/downloader/downloader.py @@ -160,7 +160,7 @@ def exec_command(dev, cmd, answer): ### Commands def identify(dev): - data = exec_command(dev, 'i', '<BB10sHBHH') + data = exec_command(dev, struct.pack('<B', 1), '<BB10sHBHH') id = { 'ver_min': data[0], 'ver_maj': data[1], 'name': data[2], 'devid': data[3], 'fss': data[4], 'mess': data[5], 'supported': data[6] } @@ -175,34 +175,34 @@ def identify(dev): return id def boot(dev): - exec_command(dev, 'b', '<') + exec_command(dev, struct.pack('<B', 2), '<') def reset(dev, id): - exec_command(dev, 'r', '<') + exec_command(dev, struct.pack('<B', 3), '<') def read_flash_segment(dev, id, addr): - cmd = struct.pack('<cH', 'f', addr) + cmd = struct.pack('<BH', 4, addr) return exec_command(dev, cmd, '<%dH' % id['fss']) def write_flash_segment(dev, id, addr, data): - cmd = struct.pack('<cH%dH' % id['fss'], 'F', addr, *data) + cmd = struct.pack('<BH%dH' % id['fss'], 5, addr, *data) return exec_command(dev, cmd, '<') def read_eeprom(dev, id, addr, len): - cmd = struct.pack('<cHH', 'e', addr, len) + cmd = struct.pack('<BHH', 6, addr, len) return exec_command(dev, cmd, '<%dB' % len) def write_eeprom(dev, id, addr, data): - cmd = struct.pack('<cHH%dB' % len(data), 'E', addr, len(data), *data) + cmd = struct.pack('<BHH%dB' % len(data), 7, addr, len(data), *data) return exec_command(dev, cmd, '<') def read_config(dev, id, nr): - cmd = struct.pack('<cB', 'c', nr) + cmd = struct.pack('<BB', 8, nr) data = exec_command(dev, cmd, '<H') return data[0] def write_config(dev, id, nr, word): - cmd = struct.pack('<cBH', 'C', nr, word) + cmd = struct.pack('<BBH', 9, nr, word) return exec_command(dev, cmd, '<') diff --git a/downloader/proto.txt b/downloader/proto.txt index 71b0774..f4f32c8 100644 --- a/downloader/proto.txt +++ b/downloader/proto.txt @@ -1,15 +1,17 @@ Command List: ============= -'i' ... identify -'b' ... boot -'r' ... reset -'f' ... read flash -'F' ... write flash -'e' ... read eeprom -'E' ... write eeprom -'c' ... read config -'C' ... write config + code | command + ------+------------ + 1 | identify + 2 | boot + 3 | reset + 4 | read flash + 5 | write flash + 6 | read eeprom + 7 | write eeprom + 8 | read config + 9 | write config Description: @@ -36,10 +38,10 @@ The return codes have the following meaning: identify: ~~~~~~~~~ command: - 'i' | <csum> (in this case <csum> will always be 'i') + 1 | <csum> (in this case <csum> will always be 1) answer: - 'i' | <ret> | version | name | devid | fss | mess | supported | <csum> + 1 | <ret> | version | name | devid | fss | mess | supported | <csum> version: 2bytes, protocol version @@ -53,7 +55,7 @@ identify: devid: 2bytes, device id of the PIC - The downlaoder may use this id to check if it talks to the right bootloader + The downlaoder may use this id to check if it talks to the right bootloader fss: 1byte, flash segment size @@ -87,10 +89,10 @@ boot: ~~~~~ command: - 'b' | <csum> (in this case <csum> will always be 'b') + 2 | <csum> (in this case <csum> will always be 2) answer: - 'b' | <ret> | <csum> + 2 | <ret> | <csum> This instucts the bootloader to boot to the user application directly (no reset) @@ -99,10 +101,10 @@ reset: ~~~~~~ command: - 'r' | <csum> (in this case <csum> will always be 'r') + 3 | <csum> (in this case <csum> will always be 3) answer: - 'r' | <ret> | <csum> + 3 | <ret> | <csum> The device performs a reboot. If the boot condition (i.e.: port pin) is not met this instructs the device to boot to the user application. @@ -112,10 +114,10 @@ read flash: ~~~~~~~~~~~ command: - 'f' | addr | <csum> + 4 | addr | <csum> answer: - 'f' | <ret> | data | <csum> + 4 | <ret> | data | <csum> The bootloader reads <fss> words from flash address <addr> and returns it as <data>. @@ -125,10 +127,10 @@ write flash: ~~~~~~~~~~~~ command: - 'F' | addr | data | <csum> + 5 | addr | data | <csum> answer: - 'F' | <ret> | <csum> + 5 | <ret> | <csum> The bootloader writes <data> (which has to contain exactly <fss> words) to address <addr> inside the flash. @@ -138,10 +140,10 @@ read eeprom: ~~~~~~~~~~~~ command: - 'e' | addr | len | <csum> + 6 | addr | len | <csum> answer: - 'e' | <ret> | data | <csum> + 6 | <ret> | data | <csum> The bootloader reads <len> bytes from eeprom at address <addr> and returns it as <data>. len is 2bytes long. @@ -151,10 +153,10 @@ write eeprom: ~~~~~~~~~~~~~ command: - 'E' | addr | len | data | <csum> + 7 | addr | len | data | <csum> answer: - 'E' | <ret> | <csum> + 7 | <ret> | <csum> The bootloader writes <data> (which has to contain exactly <len> bytes) to address <addr> inside the eeprom. len is 2bytes long and the value must not exceed <mess> bytes. @@ -163,24 +165,24 @@ write eeprom: read config: ~~~~~~~~~~~~ - command: - 'c' | nr | <csum> + command: + 8 | nr | <csum> - answer: - 'c' | <ret> | word | <csum> + answer: + 8 | <ret> | word | <csum> - The bootloader reads and returns the configuration word number <nr>. <nr> is one - byte long. + The bootloader reads and returns the configuration word number <nr>. <nr> is one + byte long. write config: ~~~~~~~~~~~~~ - command: - 'C' | nr | word | <csum> + command: + 9 | nr | word | <csum> - answer: - 'C' | <ret> | <csum> + answer: + 9 | <ret> | <csum> - The bootloader writes <word> onto configuration word number <nr>. <nr> is one - byte long + The bootloader writes <word> onto configuration word number <nr>. <nr> is one + byte long. |