[ESP32-H2] Can't use SPI with zigbee

eitell
Posts: 5
Joined: Tue Sep 12, 2023 3:49 pm

[ESP32-H2] Can't use SPI with zigbee

Postby eitell » Thu Feb 22, 2024 7:09 pm

Hi, I have a ESP-Thread BR & Zigbee GW development board that I'm using for a Zigbee project (it has a ESP32-H2 and a ESP32-S3).

I'm using the SPI connections already on the board to make the two SoCs communicate. The communication works fine, until I hit the part of the code where I start Zigbee. After that I get the following SPI-related error and the H2 resets:
assert failed: spi_slave_transmit spi_slave.c:432 (ret_trans == trans_desc)
AFAIK this is related to conflicts in the SPI queue and I know that Zigbee uses the flash, but shouldn't SPI0, SPI1 and SPI2 run independently?

I'm using this piece of code from ESP-IDF examples to initialize the SPI as slave on H2:

Code: Select all

    //Configuration for the SPI bus
    spi_bus_config_t buscfg;
    memset(&buscfg, 0, sizeof(buscfg));
    buscfg.mosi_io_num = GPIO_MOSI;
    buscfg.miso_io_num = GPIO_MISO;
    buscfg.sclk_io_num = GPIO_SCLK;
    buscfg.quadwp_io_num = -1;
    buscfg.quadhd_io_num = -1;
    buscfg.max_transfer_sz = 50000;

    //Configuration for the SPI slave interface
    spi_slave_interface_config_t slvcfg;
    memset(&slvcfg, 0, sizeof(slvcfg));
    slvcfg.spics_io_num = GPIO_CS;
    slvcfg.flags = 0;
    slvcfg.queue_size = 3;
    slvcfg.mode = 0;
    slvcfg.post_setup_cb = nullptr;
    slvcfg.post_trans_cb = nullptr;

    //Initialize SPI slave interface
    auto ret = spi_slave_initialize(SPI2_HOST, &buscfg, &slvcfg, SPI_DMA_CH_AUTO);
And later:

Code: Select all

    WORD_ALIGNED_ATTR uint8_t recvbuf[size];
    memset(recvbuf, 0, size);

    spi_slave_transaction_t t;
    memset(&t, 0, sizeof(t));

    t.length = sizeof(recvbuf) * 8;
    t.tx_buffer = nullptr;
    t.rx_buffer = recvbuf;

    auto timeout_ticks = timeout_ms / portTICK_PERIOD_MS;
    auto ret = spi_slave_transmit(SPI2_HOST, &t, timeout_ticks);
What am I missing here?

ESP_Sprite
Posts: 9589
Joined: Thu Nov 26, 2015 4:08 am

Re: [ESP32-H2] Can't use SPI with zigbee

Postby ESP_Sprite » Fri Feb 23, 2024 2:34 am

Any possible concurrency issues? As in, is it possible for spi_slave_transmit to be simultaneously called in two tasks? (Eg. one in your main task, one in some Zigbee-related callback?)

eitell
Posts: 5
Joined: Tue Sep 12, 2023 3:49 pm

Re: [ESP32-H2] Can't use SPI with zigbee

Postby eitell » Fri Feb 23, 2024 7:05 pm

No, I only have a single task using SPI. I double checked my callbacks and they seem to be fine. Right now they are pretty much a copy of the HA examples from ESP-IDF

ESP_Sprite
Posts: 9589
Joined: Thu Nov 26, 2015 4:08 am

Re: [ESP32-H2] Can't use SPI with zigbee

Postby ESP_Sprite » Sat Feb 24, 2024 12:32 am

Any chance you can post your full code?

Who is online

Users browsing this forum: No registered users and 110 guests