#NEWLINE# def _chip_erase_program_double_buffer( self , progress_cb = _stub_progress ) : #NEWLINE# #INDENT# '\n        Program by first performing a chip erase.\n        ' #NEWLINE# logging . debug ( 'Smart chip erase' ) #NEWLINE# logging . debug ( '%i of %i pages already erased' , ( len ( self . page_list ) - self . chip_erase_count ) , len ( self . page_list ) ) #NEWLINE# progress_cb ( 0.0 ) #NEWLINE# progress = 0 #NEWLINE# self . flash . eraseAll ( ) #NEWLINE# progress += self . flash . getFlashInfo ( ) . erase_weight #NEWLINE# error_count = 0 #NEWLINE# current_buf = 0 #NEWLINE# next_buf = 1 #NEWLINE# ( page , i ) = self . _next_unerased_page ( 0 ) #NEWLINE# assert ( page is not None ) #NEWLINE# self . flash . loadPageBuffer ( current_buf , page . addr , page . data ) #NEWLINE# while ( page is not None ) : #NEWLINE# #INDENT# current_addr = page . addr #NEWLINE# current_weight = page . getProgramWeight ( ) #NEWLINE# self . flash . startProgramPageWithBuffer ( current_buf , current_addr ) #NEWLINE# ( page , i ) = self . _next_unerased_page ( i ) #NEWLINE# if ( page is not None ) : #NEWLINE# #INDENT# self . flash . loadPageBuffer ( next_buf , page . addr , page . data ) #NEWLINE# #UNINDENT# result = self . flash . waitForCompletion ( ) #NEWLINE# if ( result != 0 ) : #NEWLINE# #INDENT# logging . error ( 'programPage(0x%x) error: %i' , current_addr , result ) #NEWLINE# error_count += 1 #NEWLINE# if ( error_count > self . max_errors ) : #NEWLINE# #INDENT# logging . error ( 'Too many page programming errors, aborting program operation' ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# temp = current_buf #NEWLINE# current_buf = next_buf #NEWLINE# next_buf = temp #NEWLINE# progress += current_weight #NEWLINE# progress_cb ( ( float ( progress ) / float ( self . chip_erase_weight ) ) ) #NEWLINE# #UNINDENT# progress_cb ( 1.0 ) #NEWLINE# return FlashBuilder . FLASH_CHIP_ERASE