code: def _fill_unwritten_sector_pages(self):
          
          for sector in self.sector_list:
              sector_page_number = 0
              sector_page_addr = sector.addr
  
              def add_page_with_existing_data():
                  page_info = self.flash.get_page_info(sector_page_addr)
                  if page_info is None:
                      raise FlashFailure("Attempt to program flash at invalid address 0x%08x" % sector_page_addr)
                  new_page = _FlashPage(page_info)
                  self._enable_read_access()
                  new_page.data = self.flash.target.read_memory_block8(new_page.addr, new_page.size)
                  new_page.same = True
                  sector.add_page(new_page)
                  self.page_list.append(new_page)
                  self.program_byte_count += len(new_page.data)
                  return new_page
          
              # Iterate over pages defined for the sector. If a gap is found, a new page is inserted
              # with the current contents of target memory.
              while sector_page_number < len(sector.page_list):
                  page = sector.page_list[sector_page_number]
              
                  if page.addr != sector_page_addr:
                      page = add_page_with_existing_data()
              
                  sector_page_number += 1
                  sector_page_addr += page.size
          
              # Add missing pages at the end of the sector.
              while sector_page_addr < sector.addr + sector.size:
                  page = add_page_with_existing_data()
                  sector_page_addr += page.size
docs: ! @brief Fill in missing pages from sectors we are going to modify.