'Read up to 24 bits (num_bytes) of SPI flash status register contents
via RDSR, RDSR2, RDSR3 commands
Not all SPI flash supports all three commands. The upper 1 or 2
bytes may be 0xFF.'

def read_status(self, num_bytes=2):

    SPIFLASH_RDSR = 5
    SPIFLASH_RDSR2 = 53
    SPIFLASH_RDSR3 = 21
    status = 0
    shift = 0
    for cmd in [SPIFLASH_RDSR, SPIFLASH_RDSR2, SPIFLASH_RDSR3][0:num_bytes]:
        status += (self.run_spiflash_command(cmd, read_bits=8) << shift)
        shift += 8
    return status
