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

i2c_write_blocking() hanging on SDK 2.1.0 #2128

Open
tjko opened this issue Dec 6, 2024 · 4 comments
Open

i2c_write_blocking() hanging on SDK 2.1.0 #2128

tjko opened this issue Dec 6, 2024 · 4 comments
Assignees

Comments

@tjko
Copy link
Contributor

tjko commented Dec 6, 2024

After switching from SDK 2.0.0 to 2.1.0, I noticed that ss_oled OLED panel library stopped working (it hangs when initializing the OLED panel).
This issue was clearly introduced in SDK 2.1.0, as issue is not present in 2.0.0 or 1.5.0.

I traced the hang to i2c_write_blocking() call:

ss_oled/BitBang_I2C.c(322):

 rc = i2c_write_blocking(i2c0, iAddr, &u8Register, 1, true); // true to keep master control of bus 

(at least on Pico W the i2c_write_blocking() call never returns)

Curiously, after I changed this line to following, that fixed the problem:

rc = i2c_write_timeout_us(pI2C->i2c, iAddr, &u8Register, 1, true, 100000); // true to keep master control of bus

(also its not timing out but succeeding normally, so blocking write should not hang either?)

@tjko tjko changed the title i2c_write_blocking() hanging on SDK2.1.0 (while works fine on 2.0.0 or earlier) i2c_write_blocking() hanging on SDK 2.1.0 Dec 6, 2024
@peterharperuk
Copy link
Contributor

@tjko If you're keen, you could try reverting a couple of changes? It would be helpful to know which caused the problem. My bet would be on the first. I have a SSD1306 but it'll be a couple of days before I can test it...

commit 68778b1
commit 3bc8663

@tjko
Copy link
Contributor Author

tjko commented Dec 7, 2024

@peterharperuk , I reverted the change 68778b1 and that fixed the hang as well.

I have two devices on the I2C bus:

0x38 AHT21 (Temperature/Pressure sensor)
0x3c SH1107 (1.5" 128x128 OLED Panel)

I also noticed that if I only have the OLED panel connected, I don't see the 'hang'...

@peterharperuk
Copy link
Contributor

Thanks. Do you know if the lockup occurs if you just have the AHT21 connected?

@tjko
Copy link
Contributor Author

tjko commented Dec 10, 2024

No, since lockup happens in the ss_oled library, and when there is no panel found in the bus it won't get far enough to initialize it...

I noticed that the sensor library uses 'non-blocking' functions (i2c_write_timeout_us(), i2c_read_timeout_us()), so new SDK didn't cause any issues with it.

I'm initializing I2C sensors first, before trying to initialize the OLED panel, maybe the condition is triggered by first accessing another device with "non-blocking" read/write calls and then trying to initialize OLED panel, where the library is using the "blocking" read/write calls...

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

2 participants