docs: def write_status(self, new_status, num_bytes=2, set_non_volatile=False):
          """Write up to 24 bits (num_bytes) of new status register
  
          num_bytes can be 1, 2 or 3.
  
          Not all flash supports the additional commands to write the
          second and third byte of the status register. When writing 2
          bytes, esptool also sends a 16-byte WRSR command (as some
          flash types use this instead of WRSR2.)
  
          If the set_non_volatile flag is set, non-volatile bits will
          be set as well as volatile ones (WREN used instead of WEVSR).
  
          """
          SPIFLASH_WRSR = 0x01
          SPIFLASH_WRSR2 = 0x31
          SPIFLASH_WRSR3 = 0x11
          SPIFLASH_WEVSR = 0x50
          SPIFLASH_WREN = 0x06
          SPIFLASH_WRDI = 0x04
  
          enable_cmd = SPIFLASH_WREN if set_non_volatile else SPIFLASH_WEVSR
  
          # try using a 16-bit WRSR (not supported by all chips)
          # this may be redundant, but shouldn't hurt
          if num_bytes == 2:
              self.run_spiflash_command(enable_cmd)
              self.run_spiflash_command(SPIFLASH_WRSR, struct.pack("<H", new_status))
  
          # also try using individual commands (also not supported by all chips for num_bytes 2 & 3)
          for cmd in [SPIFLASH_WRSR, SPIFLASH_WRSR2, SPIFLASH_WRSR3][0:num_bytes]:
              self.run_spiflash_command(enable_cmd)
              self.run_spiflash_command(cmd, struct.pack("B", new_status & 0xFF))
              new_status >>= 8
  
          self.run_spiflash_command(SPIFLASH_WRDI)