Skip to content

feat: deep sleep improvement for devkit2#3157

Merged
beastoin merged 5 commits into
BasedHardware:mainfrom
TuEmb:TuEmb/deep_sleep_improvement
Oct 14, 2025
Merged

feat: deep sleep improvement for devkit2#3157
beastoin merged 5 commits into
BasedHardware:mainfrom
TuEmb:TuEmb/deep_sleep_improvement

Conversation

@TuEmb
Copy link
Copy Markdown
Contributor

@TuEmb TuEmb commented Oct 9, 2025

This pull request aims to reduce deep sleep power consumption for the DevKit2 platform (and potentially for the OMI device as well). With these improvements, the power consumption decreases from approximately 1.2 mA to 7.8 µA.
As a result, with a 250 mAh battery, the device can operate in deep sleep mode for over three years.

QSPI Flash Deep Sleep

By default, the QSPI flash remains powered on without entering sleep mode.

Since the hardware is directly connected to the 3.3 V power source, we now initialize the flash and explicitly place it into deep sleep mode to minimize power consumption.

SD Card Power Management

Enhanced SD card power efficiency by suspending the SPI peripheral and disconnecting related GPIOs when the SD card is powered off, then restoring them upon reactivation.

Simply setting SD_EN = 0 does not completely power down the SD card — there is still potential current leakage through other connected pins. Therefore, all relevant GPIOs should also be disconnected to achieve true low-power operation.

MEASUREMENT RESULT

Before improvement:
image

After improvement:
image

@TuEmb TuEmb force-pushed the TuEmb/deep_sleep_improvement branch from 3434b9d to 0be9893 Compare October 9, 2025 09:39
@TuEmb TuEmb force-pushed the TuEmb/deep_sleep_improvement branch from 0be9893 to b3e6fff Compare October 9, 2025 09:40
@TuEmb TuEmb changed the title deep sleep improvement for devkit2 feat: deep sleep improvement for devkit2 Oct 9, 2025
@TuEmb
Copy link
Copy Markdown
Contributor Author

TuEmb commented Oct 9, 2025

Hi @beastoin,

Could you help me take a look at this PR ?

I’m really excited about this project! I recently ordered a DevKit2 to explore it further and noticed that the device runs out of battery after several days when using the latest firmware version.

After some investigation, I identified a few improvements that allow the device to enter deep sleep mode more effectively. Please correct me if I’m mistaken anywhere — I’m still new to this project and eager to learn and contribute more!

@beastoin
Copy link
Copy Markdown
Collaborator

beastoin commented Oct 9, 2025

that looks solid. will take a look then let you know.

btw, in the meantime, can you:

  • check the sdcard functions so we can make sure it works after these changes?
  • does zephyr have high-level apis support so you can use it instead of touching directly to nrf*?
  • ah, we also have .overlay. take a look at this - the more elegant way is to use overlay/label but do not recall the pin directly.

also, feel free to ping me @thinh http://discord.omi.me

@TuEmb

@aaravgarg
Copy link
Copy Markdown
Collaborator

Nice! @TuEmb, it would also be cool to try reducing the power consumption of the device when it's actually being used.

ofc only after youre done with this PR haha

@TuEmb TuEmb force-pushed the TuEmb/deep_sleep_improvement branch from 1dd9548 to ae026bd Compare October 10, 2025 07:43
@TuEmb
Copy link
Copy Markdown
Contributor Author

TuEmb commented Oct 10, 2025

Hi @beastoin , @aaravgarg ,

1. check the sdcard functions so we can make sure it works after these changes?
--> yes, the SD card functions work well after wakeup from deepsleep (button press)

2. does zephyr have high-level apis support so you can use it instead of touching directly to nrf*?

--> yes, you are right. The zephyr supports the high level APIs to config the power management for qspi_flash.
Step to set the qspi_flash into deepsleep:

  • Enable CONFIG_FLASH=y
  • then just push it to deepsleep by pm_device_action_run(flash_dev, PM_DEVICE_ACTION_SUSPEND);

But, it seems the qspi_flash is still in standby mode (still better than before). We can save more ~10uA if it goes into deepsleep correctly. I read through the zephyr code in nrf sdk v2.7.0, it seems there is a bug (not sure) inside that can't let the qspi_flash into deepsleep
image
image

3. ah, we also have .overlay. take a look at this - the more elegant way is to use overlay/label but do not recall the pin directly.
--> I assumed you mentioned about the SD card pins. Let me explain about that issue:

From the schematic, the power for SD card is handled by P0.19 pin (SD_END), I tried to turn it off but the power is still there that let the SD consumes power. So I think the SPI pins that let the current leakage in SD cards (maybe it's related to hardware design), we need to isolate all pins to let SD card going off.
image

@TuEmb
Copy link
Copy Markdown
Contributor Author

TuEmb commented Oct 10, 2025

Conclusion:

To prevent adding a lot of code or touching directly to nrf pins, I tried to use the API from zephyr as much as possible:

  • Added CONFIG_FLASH=y --> it will let the qspi_flash comes to standby mode (the current also reduces alot) --> still have a blocker that I need to investigate to push it into deepsleep mode (10uA saving).
  • isolated the SPI pins and turned off the P0.19 to cut off the total power for SD card in deepsleep

Result: The total current consumption was reduced from 1.2 mA to 17 µA in deep sleep mode, ensuring the device can operate for over one year in this state.

@beastoin beastoin merged commit d7e56b5 into BasedHardware:main Oct 14, 2025
@beastoin
Copy link
Copy Markdown
Collaborator

nice, lgtm @TuEmb

1 more thing, please create a new ticket that can help us save 10 uA more, but let it remain there.

@TuEmb TuEmb deleted the TuEmb/deep_sleep_improvement branch October 14, 2025 04:31
Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
* power off and disconnect all pins of SD card in deepsleep

* push qspi flash into deepsleep at beginning

* use the zephyr config instead of creating the APIs

* can't set qspi flash to deepsleep mode by zephyr API

* minimize the changes for the PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants