/* Read SPI flash data. Data region doesn't need to be page aligned.  */
static bool IRAM read_data(sdk_flashchip_t *flashchip, uint32_t addr, uint8_t *dst, uint32_t size)
/* Read SPI flash data. Data region doesn't need to be page aligned.  */
static bool IRAM read_data(sdk_flashchip_t *flashchip, uint32_t addr, uint8_t *dst, uint32_t size)
{
    if (size < 1) {
        return true;
    }
    if ((addr + size) > flashchip->chip_size) {
        return false;
    }
    while (size >= SPI_READ_MAX_SIZE) {
        read_block(flashchip, addr, dst, SPI_READ_MAX_SIZE);
        dst += SPI_READ_MAX_SIZE;
        size -= SPI_READ_MAX_SIZE;
        addr += SPI_READ_MAX_SIZE;
    }
    if (size > 0) {
        read_block(flashchip, addr, dst, size);
    }
    return true;
}