@@ -112,12 +112,12 @@ def read_framebuf_line(self, y):
112
112
chr (0 ) + # x1 (x1,y1) = tile's upper left corner
113
113
chr (y ) + # y1
114
114
chr (159 ) + # x2 (x2,y2) = tile's lower right corner
115
- chr (y ) # y2
115
+ chr (y ) # y2
116
116
)
117
117
self ._device .ctrl_transfer (0x21 , Request .DNLOAD , 1 , 0 , cmdstr )
118
118
self .get_status () # this changes state
119
119
status = self .get_status () # this gets the status
120
- # read 5-byte header (echo of cmdstr) followed by
120
+ # read 5-byte header (echo of cmdstr) followed by
121
121
# 160 pixels per line * 3 bytes per pixel (BLUE,GREEN,RED):
122
122
rd_result = self .upload (1 , 160 * 3 + 5 , 0 );
123
123
if rd_result [4 ] == y : # y2 ok -> got the expected response
@@ -282,8 +282,8 @@ def custom(self, cmd):
282
282
status = self .get_status () # this gets the status
283
283
284
284
def reboot_to_bootloader (self ):
285
- """Reboot into the bootloader with a DFU command.
286
- This will erase (part of) the firmware from flash,
285
+ """Reboot into the bootloader with a DFU command.
286
+ This will erase (part of) the firmware from flash,
287
287
so you must reprogram the firmware afterwards if you'd like a working radio.
288
288
"""
289
289
cmd = 0x86 # reboot_to_bootloader
@@ -427,8 +427,8 @@ def screenshot(dfu, filename="screenshot.bmp"):
427
427
with open (filename , 'wb' ) as f :
428
428
# Write a simple, hard-coded bitmap file header
429
429
# (14 byte "file header" + 40 byte "info block" + 3*160*128 byte "data",
430
- # total size = 0x0000F036 bytes. Here written in little endian format:
431
- f .write ( "BM" + chr (0x36 )+ chr (0xF0 )+ chr (0x00 )+ chr (0x00 )
430
+ # total size = 0x0000F036 bytes. Here written in little endian format:
431
+ f .write ( "BM" + chr (0x36 )+ chr (0xF0 )+ chr (0x00 )+ chr (0x00 )
432
432
+ chr (0x00 )+ chr (0x00 )+ chr (0x00 )+ chr (0x00 )
433
433
+ chr ( 54 )+ chr (0x00 )+ chr (0x00 )+ chr (0x00 ) )
434
434
# Next: Write the "bitmap info header". Keep it simple, use 40 bytes.
@@ -446,7 +446,7 @@ def screenshot(dfu, filename="screenshot.bmp"):
446
446
# Write image data with 160 pixels per line, 3 bytes per pixel.
447
447
# For a start, just dump the pixels to the file unmodified.
448
448
y = 127 ; # bmp files begin with the 'bottom line' (y=127)
449
- while y >= 0 :
449
+ while y >= 0 :
450
450
buf = dfu .read_framebuf_line (y )
451
451
f .write (buf )
452
452
y = y - 1 ;
@@ -751,7 +751,7 @@ def usage():
751
751
md380-tool readword <0xcafebabe>
752
752
Dump 1kB from arbitrary address
753
753
md380-tool dump <filename.bin> <address>
754
- Dump calibration data
754
+ Dump calibration data
755
755
md380-tool calibration
756
756
Reboot into the bootloader (erases application, you _must_ reflash firmware afterwards):
757
757
md380-tool reboot_to_bootloader
@@ -884,6 +884,11 @@ def main():
884
884
except RuntimeError as e :
885
885
print (e .args [0 ])
886
886
exit (1 )
887
+ except usb .core .USBError as ue :
888
+ print (ue )
889
+ if ue [0 ] == 32 :
890
+ print ('Make sure the device is already flashed with custom firmware and NOT in DFU mode' )
891
+ exit (1 )
887
892
except Exception as e :
888
893
print (e )
889
894
# print(dfu.get_status())
0 commit comments