Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slave spi seems badly broken on 4.0 (IDFGH-3885) #5784

Closed
pgu-swir opened this issue Aug 25, 2020 · 2 comments
Closed

slave spi seems badly broken on 4.0 (IDFGH-3885) #5784

pgu-swir opened this issue Aug 25, 2020 · 2 comments

Comments

@pgu-swir
Copy link

pgu-swir commented Aug 25, 2020

No offense, but the slave SPI on v4.0 at least seems to be badly broken

  • trying to not use cs_pin (-1) ends up in a crash (not an assert) in spicommon_cs_initialize as the -1 is used to index gpio array
  • spi_slave_transmit produces random results in rx data or tx data if one rx_buffer or tx_buffer is not set (one left to NULL and data is incorrect 10% of time - doc says that one can be NULL)
  • at least in non-DMA mode, when sending data, if tx_buffer is not in DMA memory, incorrect data is sent
  • no other mode than SPI mode 0 seems to be supported
  • even when patched spi_common_cs_initialize to accept a cs = -1, received data is incorrect unless DMA is used
  • last one, but I assume it's normal but documentation is silent about it : when using non-DMA, callbacks are not activated
@github-actions github-actions bot changed the title slave spi seems badly broken on 4.0 slave spi seems badly broken on 4.0 (IDFGH-3885) Aug 25, 2020
@Icarus113
Copy link
Collaborator

Q1. Yes, thanks for the report. The crash problem will be fixed soon.
Q2. In CPU-controlled mode: if you don't prepare a tx_buffer, your data won't be copied into the hardware buffer; if no rx_buffer, the data in the hardware buffer will not be moved out. In DMA mode: if you don't prepare corresponding data buffer, the DMA will not start. Therefore, we strongly recommend you to prepare those buffers.
Q3. After checking, transactions under CPU-controlled mode work well.
Q4. After checking, all modes are correctly supported.
Q5. A CS signal is required by the Slave to be triggered. If the CS pin is not correctly set, it won't work as we expect.
Q6. After checking, callbacks work well under CPU-controlled mode.

Thank you very much.

espressif-bot pushed a commit that referenced this issue Nov 3, 2020
Setting cs num to -1 means cs pin is not connected. But passing the value -1 to the
spicommon_cs_initialize() will lead to program crash caused by "array index out
of bounds". We expect the driver to execute well but the driver should not be in
charge of users' behaviour, so this commit prevents the crash.

#5784
@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting, feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants