code: def init(self):
          
  
          self.target.halt()
          self.target.reset_and_halt()
  
          # update core register to execute the init subroutine
  
          result = self._call_function_and_wait(self.flash_algo['pc_init'], init=True)
  
          # check the return code
          if result != 0:
              logging.error('init error: %i', result)
  
          # erase the cookie which take up one page
          self.erase_sector(0x01000000)
          time.sleep(.5)
  
          #do a hardware reset which will put the pc looping in rom
          self.target.dp.reset()
          time.sleep(1.3)
  
          # reconnect to the board
          self.target.dp.init()
          self.target.dp.power_up_debug()
  
          self.target.halt()
          self.target.reset_and_halt()
  
          # update core register to execute the init subroutine
          result = self._call_function_and_wait(self.flash_algo['pc_init'], init=True)
  
          # check the return code
          if result != 0:
              logging.error('init error: %i', result)
docs: Download the flash algorithm in RAM