Skip to content

alif: implement wake up sources for machine.lightsleep()#19210

Open
dpgeorge wants to merge 3 commits into
micropython:masterfrom
dpgeorge:alif-lightsleep-wakeup
Open

alif: implement wake up sources for machine.lightsleep()#19210
dpgeorge wants to merge 3 commits into
micropython:masterfrom
dpgeorge:alif-lightsleep-wakeup

Conversation

@dpgeorge
Copy link
Copy Markdown
Member

@dpgeorge dpgeorge commented May 11, 2026

Summary

This PR implements on alif the following wake-up sources for machine.lightsleep():

  • LPTIMER, for when a timeout argument is passed to machine.lightsleep(timeout_ms)
  • LPGPIO, enabled on OPENMV_AE3

Addresses #19190.

Testing

Tested on OPENMV_AE3:

  • calling machine.lightsleep(2_000) and machine.lightsleep(15_000), the device wakes after the specified time
  • calling machine.lightsleep(), then pressing the user button wakes the device

Generative AI

I did not use generative AI tools when creating this PR.

dpgeorge added 3 commits May 12, 2026 00:28
Passing in a millisecond timeout argument to `machine.lightslep()` will
configure the LPTIMER to wake the system.

Signed-off-by: Damien George <damien@micropython.org>
This allows the GPIO IRQ to be enabled even if a Python `Pin.irq()` is not
configured for that pin.

Signed-off-by: Damien George <damien@micropython.org>
Configure the P15_7 GPIO IRQ on the user button input so that the button
can wake the device from `machine.lightsleep()`.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge linked an issue May 11, 2026 that may be closed by this pull request
@dpgeorge
Copy link
Copy Markdown
Member Author

@kwagyeman @iabdalkader this should get lightsleep() working on alif.

I also tested waking via a message sent from HE to HP. That works (it wakes HP from lightsleep()) but only if you first create the endpoint on the HP side, because that enables the IRQ.

@kwagyeman
Copy link
Copy Markdown
Contributor

@dpgeorge what do you mean by first create the endpoint on the HP side. Do you mean that at least one message has to be received first before the HP can sleep? Please let me know what needs to be changed in the example I posted on the bug report.

@dpgeorge
Copy link
Copy Markdown
Member Author

what do you mean by first create the endpoint on the HP side

I'm not sure exactly how your code works when communicating with the second core (it's hidden behind the @openamp.async_remote decorator), but the ept.send(l) call on the HE must have an endpoint associated with it, and that endpoint must be opened on the HP, eg via openamp.Endpoint("<name of endpoint>"). From my testing on other examples, the endpoint must be opened on the HP for the HE to be able to wake it up.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OPENMV Bug: Alif lightsleep doesn't work anymore.

2 participants