Skip to content

ImportError: gpio_deep_sleep_hold on MicroPython 1.29 (ESP32-S3) breaks every import of walter_modem #73

Description

@bmeares

Summary

On MicroPython 1.29.0, import walter_modem fails on an ESP32-S3 (Walter) with:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lib/walter_modem/__init__.py", line 1, in <module>
  File "/lib/walter_modem/modem.py", line 3, in <module>
  File "/lib/walter_modem/core.py", line 6, in <module>
ImportError: can't import name gpio_deep_sleep_hold

core.py imports the symbol at module scope:

from esp32 import gpio_deep_sleep_hold  # core.py:6

so the failure is not confined to deep-sleep users — it takes down every import of the library, and with it any application module that imports it at startup.

Cause

ports/esp32/modesp32.c has guarded this function for several releases:

#if SOC_GPIO_SUPPORT_HOLD_IO_IN_DSLP && !SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP

The guard is unchanged between v1.28.0 and v1.29.0. What changed is the IDF underneath it: 1.29 builds against ESP-IDF v5.5.2, which sets SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP for the ESP32-S3. The whole-GPIO-bank hold is therefore compiled out on the S3, leaving only per-IO hold (Pin(..., hold=True) / gpio_hold_en()).

Reproduce

  1. Flash ESP32_GENERIC_S3-20260824-v1.29.0.bin to a Walter.
  2. Install walter_modem (any version through current main).
  3. import walter_modem.

Works on v1.28.0, fails on v1.29.0.

Suggested fix

Guard the import, since ModemCore.__init__ is the only caller:

try:
    from esp32 import gpio_deep_sleep_hold
except ImportError:
    def gpio_deep_sleep_hold(_enable):
        pass

Or, if the intent is to preserve pin state across deep sleep on newer builds, call gpio_hold_en() per pin (via Pin(..., hold=True)) where the bank hold is unavailable — the S3 supports the per-IO form.

Happy to send a PR for the guarded-import version if that's the direction you'd prefer.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions