code: def reset(mode):
      
      _board.enter_raw_repl()
      if mode == "SOFT":
          _board.exit_raw_repl()
          return
  
      _board.exec_(
          """if 1:
          def on_next_reset(x):
              try:
                  import microcontroller
              except:
                  if x == 'NORMAL': return ''
                  return 'Reset mode only supported on CircuitPython'
              try:
                  microcontroller.on_next_reset(getattr(microcontroller.RunMode, x))
              except ValueError as e:
                  return str(e)
              return ''
          def reset():
              try:
                  import microcontroller
              except:
                  import machine as microcontroller
              microcontroller.reset()
      """
      )
      r = _board.eval("on_next_reset({})".format(repr(mode)))
      print("here we are", repr(r))
      if r:
          click.echo(r, err=True)
          return
  
      try:
          _board.exec_("reset()")
      except serial.serialutil.SerialException as e:
          # An error is expected to occur, as the board should disconnect from
          # serial when restarted via microcontroller.reset()
          pass
docs: Perform soft reset/reboot of the board.
  
      Will connect to the board and perform a reset.  Depending on the board
      and firmware, several different types of reset may be supported.
  
        ampy --port /board/serial/port reset