micropython / micropython/micropython

if uart receives 0xf0 byte then mcu after entering lightsleep never wakes up

Open
#15,129 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug unicode
Dominant language
C
Stars
22.1k
Forks
9k
Avg merge
6d 4h
Merged PRs (30d)
16

Description

Checks
  • I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.

  • I've searched for existing issues matching this bug, and didn't find any.

Port, board and/or hardware

RP2, STM32L4, STM32H7

MicroPython version

MicroPython v1.22.2 on 2024-02-22; Raspberry Pi Pico with RP2040

Reproduction

Example for Rpi Pico:

from machine import Pin, UART, lightsleep
from time import sleep

uart = UART(0, baudrate=115200, bits=8, tx=Pin(0), rx=Pin(1), parity=None, stop = 1, timeout=2000)

## Main Loop ##
uart.write("Start \n")

while True:
    sleep(1)
    buff=bytearray()
    while uart.any():
        buff.extend(bytearray(uart.read(uart.any())))
    # to exit program send '9'
    if buff.find(b"9")>=0:
        break 
    
    if len(buff)>0:
        buff.append(10)
        uart.write(buff)
    uart.write("before lightsleep \n")
    lightsleep(100)
    sleep(0.05)
    uart.write("after lightsleep\n")
Expected behaviour

No response

Observed behaviour

If uart receives 0xf0 byte then mcu after entering lightsleep never wakes up.
If message doesn't have 0xf0 byte then it continues working ok.

I tried it on RPi Pico, and STM32 boards they have same behavior.

Additional Information

No, I've provided everything above.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with machine.UART and lightsleep using the provided Raspberry Pi Pico example, then compare behavior on the listed RP2, STM32L4, and STM32H7 ports. Trace the UART receive and lightsleep entry points; done means the MCU wakes and continues after receiving 0xf0, while existing behavior remains intact for other bytes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.