Skip to content

StackChan: boot hangs forever at servo calibration — time.delay_ms() does not exist #104

Description

@slagathor34

Summary

On the StackChan CoreS3 firmware (UIFlow2 v2.4.8, also present in current master), a fresh device (no servo zero data in NVS) hangs forever on the head-calibration screen at boot, and the REPL is unreachable. The device appears bricked.

Root cause

m5stack/modules/startup/stackchan/__init__.py, in _run_servo_zero_calibration_if_needed():

stackchan = StackChan(i2c=1, uart=1)
stackchan.set_servo_power(enable=True)
time.delay_ms(500)   # <-- AttributeError: no time.delay_ms in MicroPython

time.delay_ms does not exist in MicroPython (should be time.sleep_ms). The AttributeError is caught by the surrounding except, which prints:

[StackChan] servo calibration init failed: 'module' object has no attribute 'delay_ms'

and leaves stackchan = None. The calibration loop that follows then can never succeed — holding the on-screen confirm box for 3 s hits the stackchan is None branch ("servo calibration is unavailable") and the loop repeats forever. Because this runs from boot.py, the raw REPL is also blocked, so the device can't be recovered with mpremote without manually interrupting over serial.

Steps to reproduce

  1. Flash UIFlow2 StackChan v2.4.8 to a CoreS3-based StackChan (full 16 MB image at 0x0), or erase NVS on an already-flashed unit.
  2. Boot. Console shows the servo calibration init failed: 'module' object has no attribute 'delay_ms' message and the calibration screen never completes.

Fix

Replace time.delay_ms(500) with time.sleep_ms(500).

Workaround for stuck devices

Interrupt boot with Ctrl-C over USB serial, then write servo zero defaults so calibration is skipped:

import esp32
nvs = esp32.NVS("servo")
nvs.set_i32("zero_pos_1", 450)
nvs.set_i32("zero_pos_2", 125)
nvs.commit()

Firmware: UIFlow2 StackChan v2.4.8 (MicroPython v1.27.0), machine "M5STACK StackChan with ESP32S3".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions