-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Labels
bugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugplatform: Bouffalo Lab
Description
Describe the bug
When using the bouffalolab I2C driver, failings will appear and break the driver's functionality.
Facts list:
- Driver never has failed when using -DCONFIG_NO_OPTIMIZATIONS=y, this is related to optimization
- Failure propagates: the specific failure will appear out of the driver, such as with PR drivers: display: ssd1306: remove i2c_burst_write usage #100686, this subtle change will add or remove failure with the driver version ae9f04b:
static int ssd1306_write_bus_i2c(const struct device *dev, uint8_t *buf, size_t len, bool command)
{
const struct ssd1306_config *config = dev->config;
const uint8_t control =
command ? SSD1306_CONTROL_ALL_BYTES_CMD : SSD1306_CONTROL_ALL_BYTES_DATA;
static uint8_t tmp[SSD1306_I2C_CHUNK_SIZE + 1];
int ret = 0;
if (len == 0U) {
return 0;
}
k_mutex_lock(&ssd1306_i2c_buffer_lock, K_FOREVER);
size_t off = 0;
while (off < len) {
size_t this_len = MIN(SSD1306_I2C_CHUNK_SIZE, len - off);
LOG_ERR("WHAT THE FUCK IS WRONG WITH YOU DUMBASS");
tmp[0] = control;
memcpy(&tmp[1], &buf[off], this_len);
ret = i2c_write_dt(&config->bus.i2c, tmp, this_len + 1);
if (ret < 0) {
k_mutex_unlock(&ssd1306_i2c_buffer_lock);
return ret;
}
off += this_len;
}
k_mutex_unlock(&ssd1306_i2c_buffer_lock);
return ret;
}This does not work
static int ssd1306_write_bus_i2c(const struct device *dev, uint8_t *buf, size_t len, bool command)
{
const struct ssd1306_config *config = dev->config;
const uint8_t control =
command ? SSD1306_CONTROL_ALL_BYTES_CMD : SSD1306_CONTROL_ALL_BYTES_DATA;
static uint8_t tmp[SSD1306_I2C_CHUNK_SIZE + 1];
int ret = 0;
if (len == 0U) {
return 0;
}
k_mutex_lock(&ssd1306_i2c_buffer_lock, K_FOREVER);
size_t off = 0;
while (off < len) {
size_t this_len = MIN(SSD1306_I2C_CHUNK_SIZE, len - off);
LOG_ERR("WHAT THE FUCK IS WRONG WITH YOU DUMBASS %d", this_len);
tmp[0] = control;
memcpy(&tmp[1], &buf[off], this_len);
ret = i2c_write_dt(&config->bus.i2c, tmp, this_len + 1);
if (ret < 0) {
k_mutex_unlock(&ssd1306_i2c_buffer_lock);
return ret;
}
off += this_len;
}
k_mutex_unlock(&ssd1306_i2c_buffer_lock);
return ret;
}This works.
- Failure may or may not show up depending on subtle conditions, see previous or drivers: display: ssd1306: remove i2c_burst_write usage #100686 (comment) where switching the specific binding (and so a bit of code) changed the behavior of the driver completly
- This may be related to timepoints and timeouts, as changing calls to this areas significiantly affects the resulting behavior, and similar issues have been observed out of the I2C driver entirely: drivers: i2c: bflb: Fix I2C again #101298 (comment)
Regression
- This is a regression.
Steps to reproduce
Switch between ssd1306 driver versions (current and PR mentionned) and see it starts failing for no reasons.
Relevant log output
Impact
Major – Severely degrades functionality; workaround is difficult or unavailable.
Environment
- OS: Linux x86_64
- Toolchain: SDK 17.4
- Commits: various
Additional Context
No response
Mitigations:
- Fix with limits of current drivers: i2c: Fix BFLB I2C again again #102033
- Find some way to reliably test or identify root cause of issue.
Metadata
Metadata
Assignees
Labels
bugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugplatform: Bouffalo Lab