#NEWLINE# def flashOp( self , data ) : #NEWLINE# #INDENT# ops = data . split ( ':' ) [ 0 ] #NEWLINE# logging . debug ( 'flash op: %s' , ops ) #NEWLINE# if ( ops == 'FlashErase' ) : #NEWLINE# #INDENT# return self . createRSPPacket ( 'OK' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ops == 'FlashWrite' ) : #NEWLINE# #INDENT# write_addr = int ( data . split ( ':' ) [ 1 ] , 16 ) #NEWLINE# logging . debug ( 'flash write addr: 0x%x' , write_addr ) #NEWLINE# second_colon = 0 #NEWLINE# idx_begin = 0 #NEWLINE# while ( second_colon != 2 ) : #NEWLINE# #INDENT# if ( data [ idx_begin ] == ':' ) : #NEWLINE# #INDENT# second_colon += 1 #NEWLINE# #UNINDENT# idx_begin += 1 #NEWLINE# #UNINDENT# if ( self . flashBuilder == None ) : #NEWLINE# #INDENT# self . flashBuilder = self . flash . getFlashBuilder ( ) #NEWLINE# #UNINDENT# self . flashBuilder . addData ( write_addr , self . unescape ( data [ idx_begin : ( len ( data ) - 3 ) ] ) ) #NEWLINE# return self . createRSPPacket ( 'OK' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'FlashDone' in ops ) : #NEWLINE# #INDENT# def print_progress( progress ) : #NEWLINE# #INDENT# if ( progress == 0.0 ) : #NEWLINE# #INDENT# print_progress . done = False #NEWLINE# #UNINDENT# if ( not print_progress . done ) : #NEWLINE# #INDENT# sys . stdout . write ( '\r' ) #NEWLINE# i = int ( ( progress * 20.0 ) ) #NEWLINE# sys . stdout . write ( ( '[%-20s] %3d%%' % ( ( '=' * i ) , round ( ( progress * 100 ) ) ) ) ) #NEWLINE# sys . stdout . flush ( ) #NEWLINE# #UNINDENT# if ( progress >= 1.0 ) : #NEWLINE# #INDENT# if ( not print_progress . done ) : #NEWLINE# #INDENT# print_progress . done = True #NEWLINE# sys . stdout . write ( '\r\n' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if self . hide_programming_progress : #NEWLINE# #INDENT# progress_cb = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# progress_cb = print_progress #NEWLINE# #UNINDENT# self . flashBuilder . program ( chip_erase = self . chip_erase , progress_cb = progress_cb , fast_verify = self . fast_program ) #NEWLINE# self . flashBuilder = None #NEWLINE# return self . createRSPPacket ( 'OK' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return None