#NEWLINE# def _compute_page_erase_pages_and_weight_crc32( self , assume_estimate_correct = False ) : #NEWLINE# #INDENT# '\n        Estimate how many pages are the same.\n\n        Quickly estimate how many pages are the same.  These estimates are used\n        by page_erase_program so it is recommended to call this before beginning programming\n        This is done automatically by smart_program.\n\n        If assume_estimate_correct is set to True, then pages with matching CRCs\n        will be marked as the same.  There is a small chance that the CRCs match even though the\n        data is different, but the odds of this happing are low: ~1/(2^32) = ~2.33*10^-8%.\n        ' #NEWLINE# sector_list = [ ] #NEWLINE# page_list = [ ] #NEWLINE# for page in self . page_list : #NEWLINE# #INDENT# if ( page . same is None ) : #NEWLINE# #INDENT# sector_list . append ( ( page . addr , page . size ) ) #NEWLINE# page_list . append ( page ) #NEWLINE# data = list ( page . data ) #NEWLINE# pad_size = ( page . size - len ( page . data ) ) #NEWLINE# if ( pad_size > 0 ) : #NEWLINE# #INDENT# data . extend ( ( [ 255 ] * pad_size ) ) #NEWLINE# #UNINDENT# page . crc = ( crc32 ( bytearray ( data ) ) & 4294967295 ) #NEWLINE# #UNINDENT# #UNINDENT# page_erase_count = 0 #NEWLINE# page_erase_weight = 0 #NEWLINE# if ( len ( page_list ) > 0 ) : #NEWLINE# #INDENT# crc_list = self . flash . computeCrcs ( sector_list ) #NEWLINE# for ( page , crc ) in zip ( page_list , crc_list ) : #NEWLINE# #INDENT# page_same = ( page . crc == crc ) #NEWLINE# if assume_estimate_correct : #NEWLINE# #INDENT# page . same = page_same #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( page_same is False ) : #NEWLINE# #INDENT# page . same = False #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for page in self . page_list : #NEWLINE# #INDENT# if ( page . same is False ) : #NEWLINE# #INDENT# page_erase_count += 1 #NEWLINE# page_erase_weight += page . getEraseProgramWeight ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( page . same is None ) : #NEWLINE# #INDENT# page_erase_weight += page . getVerifyWeight ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( page . same is True ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# self . page_erase_count = page_erase_count #NEWLINE# self . page_erase_weight = page_erase_weight #NEWLINE# return ( page_erase_count , page_erase_weight )