Skip to content

StamPLC: boot_option=2 ("only network setup") never connects Wi-Fi because PoEStamPLC() is created unconditionally #116

Open

Description

@wrpro

Environment

  • Board: M5Stack StamPLC (K141), no PoE module attached (Wi-Fi only, net_mode = "WIFI")
  • Firmware: uiflow-50e4407-esp32s3-8mb-stamplc-v2.5.3-20260911.bin (UIFlow2 v2.5.3, commit 50e4407). The code on master (2026-10-09) is the same.
  • uiflow NVS: boot_option = 2, net_mode = "WIFI", ssid0 / pswd0 set (the same credentials connect fine from the startup menu and from user code).

Steps to reproduce

  1. Set boot_option to 2 (e.g. esp32.NVS("uiflow").set_u8("boot_option", 2)), reboot.
  2. Wait 40 s. network.WLAN(network.STA_IF).isconnected() is still False.
  3. Calling the same path from the REPL shows the cause:
>>> import startup
>>> startup.startup(2, 60)
Startup with network type: WIFI
WiFi initialized
hw_spi: SPI bus already initialized
esp_eth_driver_install failed with error code 263
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "startup/__init__.py", line 1, in startup
  File "startup/__init__.py", line 1, in _connect_network_only
  File "stamplc/poe.py", line 43, in __new__
OSError: esp_eth_driver_install failed

Cause

In m5stack/modules/startup/__init__.py, _connect_network_only() instantiates the PoE Ethernet driver for StamPLC regardless of net_mode:

def _connect_network_only(board_id, net_mode, ssid, pswd):
    startup = Startup(network_type=net_mode)
    lan_if = None
    if board_id == M5.BOARD.M5Unit_PoEP4:
        from driver.ip101gri import IP101GRI
        lan_if = IP101GRI(mdc_pin=31, mdio_pin=52, power_pin=51)
    elif board_id == M5.BOARD.M5StamPLC:
        from stamplc import PoEStamPLC
        lan_if = PoEStamPLC()          # raises OSError when the PoE module is absent
    startup.connect_network(ssid, pswd, lan_if)

Without the PoE module, PoEStamPLC() fails with esp_eth_driver_install failed (263 = ESP_ERR_TIMEOUT) and the exception propagates before connect_network() is reached, so Wi-Fi is never started. The startup menu path (boot_option = 1, startup/stamplc/__init__.py) only creates PoEStamPLC() when net_mode == "ETH", so it is not affected.

Expected

With net_mode = "WIFI", boot_option = 2 should start the Wi-Fi connection exactly like the startup menu does, whether or not a PoE module is attached.

Proposed fix

Create the PoE interface only when Ethernet is selected, matching the StamPLC startup menu:

     elif board_id == M5.BOARD.M5StamPLC:
-        from stamplc import PoEStamPLC
-        lan_if = PoEStamPLC()
+        if net_mode == "ETH":
+            from stamplc import PoEStamPLC
+            lan_if = PoEStamPLC()
     startup.connect_network(ssid, pswd, lan_if)

(Alternatively wrap PoEStamPLC() in try/except OSError and fall back to Wi-Fi.)

Workaround used meanwhile

Keep boot_option = 0 and start the connection from user code with the firmware's own class:

from startup import Startup
Startup(network_type="WIFI").connect_network(ssid, pswd)

This connects in about 2 s on the same device.

Activity

  1. m5agent commented on Oct 10, 2026

    @m5agent
    Contributor

    Thanks for the detailed reproduction and proposed fix. I confirmed the control-flow failure against the real startup/__init__.py and opened #118.

    The fix keeps PoEStamPLC() only for net_mode == "ETH", so the WIFI path reaches connect_network() instead of aborting before it.

    Verification record:
    https://github.com/m5agent/agent-work-logs/blob/6367ac3cf17d3978ae18ca3aebf0c633b8f76b32/records/m5stack-github/2026-10-10-uiflow-issue-116-stamplc-wifi/README.md

    Status: host reproducer PASS, M5STACK_StamPLC firmware build PASS. No StamPLC test slot was available, so real-device boot_option=2 verification is NOT RUN.

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

Metadata

Metadata

Assignees

No one assigned

    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