Skip to content

Release leftover low power routing when a software I2C port is initialized - #239

Merged
lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:soft_i2c_lp_pad
Aug 7, 2026
Merged

Release leftover low power routing when a software I2C port is initialized#239
lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:soft_i2c_lp_pad

Conversation

@ainyan03

@ainyan03 ainyan03 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

A pin routed to the low power I2C keeps that routing across a reset, because it is held in the low power domain rather than by the CPU. set_pin() already hands such pins back before taking them for a hardware port, but the software port path did not: the bit-banged lines stayed bound to the low power peripheral and never reached the pads.

On boards whose autodetect probes the internal bus with a software port (e.g. ToughC5), this made the probe fail on every warm boot - after flashing, after a reset, and after waking from deep sleep - while a cold boot (power cycle) worked, because only a power cycle resets the routing.

This change releases the pads in init() for a software port as well, the same way the hardware port path does.

Verified on ToughC5: board autodetect now succeeds right after flashing and after waking from deep sleep.

…lized

A pin routed to the low power I2C keeps that routing across a reset,
because it is held in the low power domain rather than by the CPU.
set_pin() already hands such pins back before taking them for a hardware
port, but the software port path did not: the bit-banged lines stayed
bound to the low power peripheral and never reached the pads, so the
board autodetect probe (which runs on a software port) failed on every
warm boot until a power cycle reset the routing.

Release the pads in init() for a software port as well, the same way
the hardware port path does.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes warm-boot / deep-sleep-wake I2C failures on ESP32 targets where a GPIO previously routed to the low-power (LP) I2C peripheral stays bound across reset. It aligns the software (bit-banged) I2C initialization path with the existing hardware-port behavior by explicitly releasing any lingering LP pad routing before the software port starts using the pins.

Changes:

  • In init(), when initializing a software I2C port, release LP-domain pad routing for the configured SDA/SCL pins (when applicable) before calling soft_i2c_init().
  • Guard the LP pad release with the same build-time conditions used elsewhere (LGFX_LP_I2C_NUM > 0 && SOC_RTCIO_PIN_COUNT > 0) and ensure the port number is valid before accessing the soft I2C context.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lovyan03
lovyan03 merged commit 7e4dff1 into m5stack:develop Aug 7, 2026
23 checks passed
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

Successfully merging this pull request may close these issues.

3 participants