Here is a code I used to reproduce it separately, it works on ESP32, but freezes on ESP32-S3.
It only freezes when the transaction length is set to 1.
Code: Select all
static spi_device_handle_t deviceSPI;
spi_bus_config_t buscfg = {
.mosi_io_num = GPIO_NUM_2, // SWD I/O
.miso_io_num = -1, // not connected
.sclk_io_num = GPIO_NUM_1, // SWD CLK
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.max_transfer_sz = 0
};
spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_DISABLED);
spi_device_interface_config_t devcfg = {
.command_bits = 0,
.address_bits = 0,
.dummy_bits = 0,
.mode = 0,
.duty_cycle_pos = 0,
.cs_ena_pretrans = 0,
.cs_ena_posttrans = 0,
.clock_speed_hz = 100000,
.spics_io_num = -1,
.flags = SPI_DEVICE_3WIRE | SPI_DEVICE_HALFDUPLEX | SPI_DEVICE_BIT_LSBFIRST,
.queue_size = 24,
.pre_cb = NULL,
.post_cb = NULL
};
spi_bus_add_device(SPI2_HOST, &devcfg, &deviceSPI)
spi_transaction_t transSPI;
memset(&transSPI, 0, sizeof(spi_transaction_t));
// simulated transaction from libswd
transSPI.flags = SPI_TRANS_USE_TXDATA;
transSPI.cmd = 0;
transSPI.addr = 0;
transSPI.length = 1;
transSPI.rxlength = 0;
transSPI.tx_data[0] = 0;
transSPI.tx_data[1] = 0;
transSPI.tx_data[2] = 0;
transSPI.tx_data[3] = 0;
spi_device_transmit(deviceSPI, &transSPI); // <=== FREEZE HERE
I stepped deeper into the ESP-IDF code and the processor is freezing here in spi_device_get_trans_result():
Code: Select all
r = xQueueReceive(handle->ret_queue, (void*)&trans_buf, ticks_to_wait);
Is this a bug and how could I bypass it?