espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.38k stars 7.22k forks source link

SPI: QSPI failed (IDFGH-3763) #5684

Open mcerveny opened 4 years ago

mcerveny commented 4 years ago

Environment

Problem Description

QSPI address is sent as standard (1-bit) SPI when there is no data to send. I am using address as command to achieve QSPI for command. I am using workaround in code now - if there is no data, do not send address ( .address_bits = 0) and use data ( .tx_buffer) as pointer to command and set transfer size (.length) to 8bit.

Expected Behavior

Send address as QSPI.

Actual Behavior

Without data standard SPI is used.

Steps to reproduce

Code to reproduce this issue

code snippet:

uint8_t test_data[] = { 0x55, 0xaa };

spi_transaction_ext_t qspi_ok = {
    .base = {
        .tx_buffer = test_data,
        .length = sizeof(test_data) * 8,
        .addr = 0x81,
        .flags = SPI_TRANS_MODE_QIO | SPI_TRANS_MODE_DIOQIO_ADDR | SPI_TRANS_VARIABLE_ADDR
    },
    .address_bits = 8
};

spi_transaction_ext_t qspi_failed = {
    .base = {
        .addr = 0x81,
        .flags = SPI_TRANS_MODE_QIO | SPI_TRANS_MODE_DIOQIO_ADDR | SPI_TRANS_VARIABLE_ADDR
    },
    .address_bits = 8
};

...
    ESP_ERROR_CHECK(spi_device_acquire_bus(spi, portMAX_DELAY));
    while (1) {
        ESP_ERROR_CHECK(spi_device_polling_transmit(spi, (spi_transaction_t *)&qspi_ok)); 
        ESP_ERROR_CHECK(spi_device_polling_transmit(spi, (spi_transaction_t *)&qspi_failed)); 
        vTaskDelay(100 / portTICK_RATE_MS);
    }
    spi_device_release_bus(spi);

See OLS output: qspi_failed

Alvin1Zhang commented 4 years ago

Thanks for the detailed report and letting us know, we will look into.