/* if (to_qio == true) { spi_flash_switch_to_qio_raw(); } } Low level SPI flash write. Write block of data up to 64 bytes.  */
static void IRAM spi_write_data(sdk_flashchip_t *chip, uint32_t addr, uint8_t *buf, uint32_t size)
/* if (to_qio == true) { spi_flash_switch_to_qio_raw(); } } Low level SPI flash write. Write block of data up to 64 bytes.  */
static void IRAM spi_write_data(sdk_flashchip_t *chip, uint32_t addr, uint8_t *buf, uint32_t size)
{
    uint32_t words = size >> 2;
    if (size & 0b11) {
        words++;
    }
    Wait_SPI_Idle(chip);
    SPI(0).ADDR = (addr & 0x00FFFFFF) | (size << 24);
    memcpy((void*)SPI(0).W, buf, words<<2);
    __asm__ volatile("memw");
    SPI_write_enable(chip);
    SPI(0).CMD = SPI_CMD_PP;
    while (SPI(0).CMD) {}
}