Thanks to visit codestin.com
Credit goes to github.com

Skip to content

RP2350 does not reset i2c peripheral upon reload #9703

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

Closed
bill88t opened this issue Oct 9, 2024 · 3 comments · Fixed by #9706
Closed

RP2350 does not reset i2c peripheral upon reload #9703

bill88t opened this issue Oct 9, 2024 · 3 comments · Fixed by #9706
Assignees
Milestone

Comments

@bill88t
Copy link

bill88t commented Oct 9, 2024

CircuitPython version

Adafruit CircuitPython 9.2.0-beta.0-25-g7f14b9c49a on 2024-10-04; Raspberry Pi Pico 2 with rp2350a

Code/REPL

import time, board, busio, adafruit_ssd1306
from digitalio import DigitalInOut
i2c = busio.I2C(board.GP17, board.GP16)
display = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)

Behavior

SSD1306 display properly attached
First time works, then if we reload and run it again:

ValueError: I2C peripheral in use

Description

No response

Additional information

No response

@bill88t bill88t added the bug label Oct 9, 2024
@tannewt tannewt added the rp235x label Oct 9, 2024
@tannewt tannewt modified the milestones: 9.2.0, Support Oct 9, 2024
@tannewt
Copy link
Member

tannewt commented Oct 9, 2024

I don't think this is a bug. We keep I2C around when used by a display so that it can be used internally. Do displayio.release_displays() to release it.

@tannewt tannewt closed this as completed Oct 9, 2024
@bill88t
Copy link
Author

bill88t commented Oct 9, 2024

It's not a displayio display. I just stumbled upon the bug with it.
It can be repro'ed with just import board, busio; busio.I2C(board.GP17, board.GP16), reloading and running it again.

Adafruit CircuitPython 9.2.0-beta.0-25-g7f14b9c49a on 2024-10-04; Raspberry Pi Pico 2 with rp2350a
>>> import board, busio;busio.I2C(board.GP17, board.GP16)
<I2C>
>>> 
soft reboot

Auto-reload is off.
Running in safe mode! Not running saved code.

You are in safe mode because:
The `microcontroller` module was used to boot into safe mode.
Press reset to exit safe mode.

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 9.2.0-beta.0-25-g7f14b9c49a on 2024-10-04; Raspberry Pi Pico 2 with rp2350a
>>> import board, busio;busio.I2C(board.GP17, board.GP16)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: I2C peripheral in use
>>>

@tannewt tannewt modified the milestones: Support, 9.2.0 Oct 9, 2024
@tannewt tannewt reopened this Oct 9, 2024
@dhalbert
Copy link
Collaborator

dhalbert commented Oct 9, 2024

I tried latest main with a SAMD21 board, and I2C cleanup is acting flaky, though I haven't got a reproducer yet. I think this may be due to #9671, which removed i2c_reset() on various ports.

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

Successfully merging a pull request may close this issue.

3 participants