-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: i2c_nrfx_twim: Fix write transaction issues #38678
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
drivers: i2c_nrfx_twim: Fix write transaction issues #38678
Conversation
Issue an error logging message when the i2c_nrfx_twim driver lacks a concatenation buffer big enough to properly handle a call to i2c_burst_write() function, to give the user a hint what is wrong. Also use by default a 16-bytes long concatenation buffer for every instance of the i2c_nrfx_twim driver. Such value should cover most of the simple uses of the i2c_burst_write() function, like those in the stmemsc sensor drivers, and when a longer buffer is needed, the user will be provided with the above message pointing to the property that should be adjusted. Signed-off-by: Andrzej Głąbek <[email protected]>
TWIM peripherals cannot perform write transactions from buffers located in flash. The content of such buffers needs to be copied to RAM before the actual transfer can be requested. This commits adds a new property (zephyr,flash-buf-max-size) that informs the driver how much space in RAM needs to be reserved for such copying and adds proper handling of buffers located in flash. This fixes an issue that caused that e.g. the DPS310 sensor driver did not work on nRF SoCs that only have TWIM, not TWI peripherals. Signed-off-by: Andrzej Głąbek <[email protected]>
ff102b3 to
0a1751c
Compare
|
Rebased. |
drivers/i2c/i2c_nrfx_twim.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[00:00:16.188,903] <err> i2c_nrfx_twim: Need to use concatenation buffer and provided size is
insufficient (1 + 1024 > 16). Adjust the zephyr,concat-buf-size property in the "I2C_0" node.
I would make it shorter.
diff --git a/drivers/i2c/i2c_nrfx_twim.c b/drivers/i2c/i2c_nrfx_twim.c
index a00d9fad00..a477f8fe57 100644
--- a/drivers/i2c/i2c_nrfx_twim.c
+++ b/drivers/i2c/i2c_nrfx_twim.c
@@ -86,13 +86,11 @@ static int i2c_nrfx_twim_transfer(const struct device *dev,
*/
if (concat_next || (msg_buf_used != 0)) {
if ((msg_buf_used + msgs[i].len) > concat_buf_size) {
- LOG_ERR("Need to use concatenation buffer and "
- "provided size is insufficient "
- "(%u + %u > %u). "
- "Adjust the zephyr,concat-buf-size "
- "property in the \"%s\" node.",
+ LOG_ERR("Concatenation buffer is insufficient "
+ "(%u + %u > %u)",
msg_buf_used, msgs[i].len,
- concat_buf_size, dev->name);
+ concat_buf_size);
+ LOG_ERR("Adjust the zephyr,concat-buf-size");
ret = -ENOSPC;
break;
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I wanted to give the user a clear indication what is wrong and how to solve the problem. Hence such verbose message. But the message is not supposed to occur normally, as it indicates an invalid build configuration, so I think its length should not be a problem and I'd rather keep it as it is.
drivers: i2c_nrfx_twim: Use concatenation buffer by default
Issue an error logging message when the i2c_nrfx_twim driver lacks
a concatenation buffer big enough to properly handle a call to
i2c_burst_write() function, to give the user a hint what is wrong.
Also use by default a 16-bytes long concatenation buffer for every
instance of the i2c_nrfx_twim driver. Such value should cover most
of the simple uses of the i2c_burst_write() function, like those
in the stmemsc sensor drivers, and when a longer buffer is needed,
the user will be provided with the above message pointing to the
property that should be adjusted.
Fixes #33440.
drivers: i2c_nrfx_twim: Add handling of buffers located in flash
TWIM peripherals cannot perform write transactions from buffers
located in flash. The content of such buffers needs to be copied
to RAM before the actual transfer can be requested.
This commits adds a new property (zephyr,flash-buf-max-size) that
informs the driver how much space in RAM needs to be reserved for
such copying and adds proper handling of buffers located in flash.
This fixes an issue that caused that e.g. the DPS310 sensor driver
did not work on nRF SoCs that only have TWIM, not TWI peripherals.
Fixes #35550.