-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
I2S: Wrong return codes for partial data transfers to/from DMA memory (IDFGH-6464) #8121
Comments
Hi @miketeachman , thank you for your feedback! We add this error code because i2s reading and writing functions could never return an error code before, it means even the operation failed (i.e. 0 byte is read or written), it would still return But yes, in the case you mentioned, we can't just return |
Hi @L-KAYA, thank you for looking at this issue. I looked at the proposed change you suggested. I have some concerns with this change. 0 bytes written or read does not seem like a failure - it just means that all DMA buffers were full (i2s_write) or empty (i2s_read) during the specified timeout period. This will be a normal situation with I2S. The write and read functions return with either Why do you consider 0 bytes written or read to be a failed operation? I'm struggling to understand this. |
Hi @miketeachman , from my consideration, if 0 byte is not a failure, how do users know their configuration is not working? For the case that no data to receive or write, just set the timeout ticks to the maximum value, it will be blocked here. And if the app needs to work in non-block mode (i.e. a short timeout period), the app needs to be able to know that there is a timeout event while receiving message from DMA queue, but the app can also choose to ignore this error code if it doesn't need this. Therefore, instead of only receiving ESP_OK, the app now can receive the timeout event and decide whether to use this information. Looking forward to your reply! |
I'm curious on the motivation to change the existing I2S API -- was this user driven? There must be a really good reason given that this is a breaking change (now returns an error code when previously ESP_OK was returned). I wonder how many other existing implementations will be affected by this breaking change. |
- Add default values for I2S features added in ESP-IDF 4.4. - Add workaround for bug introduced in ESP-IDF 4.4 (espressif/esp-idf#8121).
//ret = ESP_ERR_TIMEOUT; // espressif#8121
Revert "//ret = ESP_ERR_TIMEOUT; // espressif#8121"
Closes espressif#8121 Revert reading/writing return ESP_ERR_TIMEOUT introduced in commit b26da6f
Closes espressif#8121 Revert reading/writing return ESP_ERR_TIMEOUT introduced in commit b26da6f
- Add default values for I2S features added in ESP-IDF 4.4. - Add workaround for bug introduced in ESP-IDF 4.4 (espressif/esp-idf#8121).
Environment
Problem Description
A bug has been introduced in ESP-IDF v4.4-beta1 release that changes the behaviour of some I2S functions. The
i2s_write()
routine now returns anESP_ERR_TIMEOUT
error when the transmit buffer has become full, after a portion of the supplied data has been written. Here is the problem: a partial data transfer is NOT an error situation and should returnESP_OK
-- partial data transfers are expected behaviour and are described in the I2S API documentation. Similar problems exist in functionsi2s_write_expand()
andi2s_read()
.Expected Behavior
i2s_write() returns ERR_OK when any amount of data (even 0 bytes) has been copied to the transmit buffer. This is the API behaviour prior to ESP-IDF v4.4-beta1.
Actual Behavior
i2s_write() returns ESP_ERR_TIMEOUT. This behaviour is introduced in ESP-IDF v4.4-beta1.
Steps to reproduce
Code to reproduce this issue
rather than show code to reproduce the issue it's easiest to identify the code that was added which produces this bug.
By inspecting this code I think the bug will be obvious. The bug is found in the I2S driver file
i2s.c
in the functionsi2s_write
,i2s_write_expand()
, andi2s_read()
. The bug was introduced in commits b26da6f (for the write functions) andcommit 3c57a6a (for i2s_read())
Here is a code sample from i2s_write(), showing the problem line:
Debug Logs
Debug information comes from MicroPython
Other items if possible
The text was updated successfully, but these errors were encountered: