You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2026/04/10 12:34:52 UTC
(nuttx) branch master updated (ad168fdf2db -> c97a7856e3f)
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from ad168fdf2db arch/xtensa/esp32: Add support for hardware accelerated PBKDF2
new 213a651509e arch/risc-v/esp32[-c3|-c6|-h2]: Add auto sleep
new 8cc3d49c347 boards/risc-v/esp32[-c3|-c6|-h2]: Add autopm defconfig
new c97a7856e3f Docs/risc-v/esp32[-c3|-c6|-h2]: Add autopm docs
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../risc-v/esp32c3/boards/esp32c3-devkit/index.rst | 12 +
.../esp32c6/boards/esp32c6-devkitc/index.rst | 12 +
.../risc-v/esp32h2/boards/esp32h2-devkit/index.rst | 6 +
arch/risc-v/src/common/espressif/CMakeLists.txt | 9 +-
arch/risc-v/src/common/espressif/Kconfig | 17 ++
arch/risc-v/src/common/espressif/Make.defs | 9 +-
.../risc-v/src/common/espressif/esp_allocateheap.c | 20 ++
.../risc-v/src/common/espressif/esp_extraheaps.c | 18 +-
arch/risc-v/src/common/espressif/esp_idle.c | 31 +-
arch/risc-v/src/common/espressif/esp_pm.c | 312 ++++++++++++++++++++-
arch/risc-v/src/common/espressif/esp_pm.h | 73 +++++
.../src/common/espressif/esp_retentionheap.c | 292 +++++++++++++++++++
.../src/common/espressif/esp_retentionheap.h} | 165 ++++++-----
arch/risc-v/src/common/espressif/esp_tickless.c | 2 +-
arch/risc-v/src/common/espressif/esp_tickless.h | 2 +-
arch/risc-v/src/esp32c3/hal_esp32c3.cmake | 14 +-
arch/risc-v/src/esp32c3/hal_esp32c3.mk | 7 +
arch/risc-v/src/esp32c6/hal_esp32c6.cmake | 7 +-
arch/risc-v/src/esp32c6/hal_esp32c6.mk | 4 +-
arch/risc-v/src/esp32h2/hal_esp32h2.cmake | 7 +-
arch/risc-v/src/esp32h2/hal_esp32h2.mk | 3 +
arch/risc-v/src/esp32p4/hal_esp32p4.cmake | 1 +
arch/risc-v/src/esp32p4/hal_esp32p4.mk | 1 +
arch/xtensa/src/esp32/Make.defs | 2 +-
arch/xtensa/src/esp32s2/Make.defs | 2 +-
arch/xtensa/src/esp32s3/Make.defs | 2 +-
.../configs/{wifi => autopm}/defconfig | 9 +-
.../esp32c3/esp32c3-devkit/src/esp32c3_bringup.c | 14 +
.../configs/autopm}/defconfig | 11 +-
.../esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c | 14 +
.../configs/{adc => autopm}/defconfig | 8 +-
.../esp32h2/esp32h2-devkit/src/esp32h2_bringup.c | 14 +
32 files changed, 967 insertions(+), 133 deletions(-)
copy libs/libm/libm/lib_llround.c => arch/risc-v/src/common/espressif/esp_extraheaps.c (84%)
create mode 100644 arch/risc-v/src/common/espressif/esp_retentionheap.c
copy arch/{xtensa/include/arch.h => risc-v/src/common/espressif/esp_retentionheap.h} (59%)
copy boards/risc-v/esp32c3/esp32c3-devkit/configs/{wifi => autopm}/defconfig (93%)
copy boards/risc-v/esp32c6/{esp32c6-devkitm/configs/sta_softap => esp32c6-devkitc/configs/autopm}/defconfig (91%)
copy boards/risc-v/esp32h2/esp32h2-devkit/configs/{adc => autopm}/defconfig (92%)
(nuttx) 03/03: Docs/risc-v/esp32[-c3|-c6|-h2]: Add autopm docs
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit c97a7856e3ffba10f66a75c8fc0edeb0cbb98733
Author: Eren Terzioglu <er...@espressif.com>
AuthorDate: Thu Nov 27 16:42:43 2025 +0100
Docs/risc-v/esp32[-c3|-c6|-h2]: Add autopm docs
Add autopm docs for risc-v based Espressif devices
Signed-off-by: Eren Terzioglu <er...@espressif.com>
---
.../platforms/risc-v/esp32c3/boards/esp32c3-devkit/index.rst | 12 ++++++++++++
.../risc-v/esp32c6/boards/esp32c6-devkitc/index.rst | 12 ++++++++++++
.../platforms/risc-v/esp32h2/boards/esp32h2-devkit/index.rst | 6 ++++++
3 files changed, 30 insertions(+)
diff --git a/Documentation/platforms/risc-v/esp32c3/boards/esp32c3-devkit/index.rst b/Documentation/platforms/risc-v/esp32c3/boards/esp32c3-devkit/index.rst
index 954dc18776c..b47ed4e8513 100644
--- a/Documentation/platforms/risc-v/esp32c3/boards/esp32c3-devkit/index.rst
+++ b/Documentation/platforms/risc-v/esp32c3/boards/esp32c3-devkit/index.rst
@@ -74,6 +74,18 @@ show in units of mV)::
3: channel: 2 value: 0
4: channel: 3 value: 0
+autopm
+------
+
+This configuration makes the device automatically enter the low power consumption mode
+when in the idle state, powering off the cpu and other peripherals.
+
+In minimum power save mode, the station wakes up every DTIM to receive a beacon. The broadcast
+data will not be lost because it is transmitted after DTIM. However, it can not save much more
+power if DTIM is short as the DTIM is determined by the access point.
+
+During ping operation power consumption should drop from 90-100mA to 40-50mA.
+
ble
---
diff --git a/Documentation/platforms/risc-v/esp32c6/boards/esp32c6-devkitc/index.rst b/Documentation/platforms/risc-v/esp32c6/boards/esp32c6-devkitc/index.rst
index 06c7e7f129d..0cfd58ae907 100644
--- a/Documentation/platforms/risc-v/esp32c6/boards/esp32c6-devkitc/index.rst
+++ b/Documentation/platforms/risc-v/esp32c6/boards/esp32c6-devkitc/index.rst
@@ -109,6 +109,18 @@ show in units of mV)::
3: channel: 2 value: 103
4: channel: 3 value: 104
+autopm
+------
+
+This configuration makes the device automatically enter the low power consumption mode
+when in the idle state, powering off the cpu and other peripherals.
+
+In minimum power save mode, the station wakes up every DTIM to receive a beacon. The broadcast
+data will not be lost because it is transmitted after DTIM. However, it can not save much more
+power if DTIM is short as the DTIM is determined by the access point.
+
+During ping operation power consumption should drop from 90-100mA to 30-40mA.
+
bmp180
------
diff --git a/Documentation/platforms/risc-v/esp32h2/boards/esp32h2-devkit/index.rst b/Documentation/platforms/risc-v/esp32h2/boards/esp32h2-devkit/index.rst
index 234a67c062f..a89b8589d76 100644
--- a/Documentation/platforms/risc-v/esp32h2/boards/esp32h2-devkit/index.rst
+++ b/Documentation/platforms/risc-v/esp32h2/boards/esp32h2-devkit/index.rst
@@ -108,6 +108,12 @@ show in units of mV)::
3: channel: 2 value: 1
4: channel: 3 value: 0
+autopm
+------
+
+This configuration makes the device automatically enter the low power consumption mode
+when in the idle state, powering off the cpu and other peripherals.
+
bmp180
------
(nuttx) 02/03: boards/risc-v/esp32[-c3|-c6|-h2]: Add autopm defconfig
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 8cc3d49c34766a4a49833a49ce78e6f1c9e9c6aa
Author: Eren Terzioglu <er...@espressif.com>
AuthorDate: Tue Nov 25 11:27:54 2025 +0100
boards/risc-v/esp32[-c3|-c6|-h2]: Add autopm defconfig
Add autopm defconfig for risc-v based Espressif devices
Signed-off-by: Eren Terzioglu <er...@espressif.com>
---
.../esp32c3-devkit/configs/autopm/defconfig | 83 ++++++++++++++++++++++
.../esp32c3/esp32c3-devkit/src/esp32c3_bringup.c | 4 ++
.../esp32c6-devkitc/configs/autopm/defconfig | 83 ++++++++++++++++++++++
.../esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c | 14 ++++
.../esp32h2-devkit/configs/autopm/defconfig | 53 ++++++++++++++
.../esp32h2/esp32h2-devkit/src/esp32h2_bringup.c | 14 ++++
6 files changed, 251 insertions(+)
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/configs/autopm/defconfig b/boards/risc-v/esp32c3/esp32c3-devkit/configs/autopm/defconfig
new file mode 100644
index 00000000000..d58386cfa69
--- /dev/null
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/configs/autopm/defconfig
@@ -0,0 +1,83 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_NDEBUG is not set
+# CONFIG_NSH_ARGCAT is not set
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+CONFIG_ALLOW_BSD_COMPONENTS=y
+CONFIG_ARCH="risc-v"
+CONFIG_ARCH_BOARD="esp32c3-devkit"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_ESP32C3_DEVKIT=y
+CONFIG_ARCH_CHIP="esp32c3"
+CONFIG_ARCH_CHIP_ESP32C3=y
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_IRQ_TO_NDX=y
+CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y
+CONFIG_ARCH_NUSER_INTERRUPTS=17
+CONFIG_ARCH_RISCV=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARD_LOOPSPERMSEC=15000
+CONFIG_BUILTIN=y
+CONFIG_DRIVERS_IEEE80211=y
+CONFIG_DRIVERS_WIRELESS=y
+CONFIG_ESPRESSIF_AUTO_SLEEP=y
+CONFIG_ESPRESSIF_POWER_SAVE_MAX_MODEM=y
+CONFIG_ESPRESSIF_SPIFLASH=y
+CONFIG_ESPRESSIF_SPIFLASH_SPIFFS=y
+CONFIG_ESPRESSIF_WIFI=y
+CONFIG_EXAMPLES_RANDOM=y
+CONFIG_FS_PROCFS=y
+CONFIG_IDLETHREAD_STACKSIZE=2048
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INIT_STACKSIZE=8192
+CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_BUFSIZE=128
+CONFIG_IOB_NBUFFERS=160
+CONFIG_IOB_THROTTLE=24
+CONFIG_LIBC_PERROR_STDOUT=y
+CONFIG_LIBC_STRERROR=y
+CONFIG_NETDB_DNSCLIENT=y
+CONFIG_NETDEV_LATEINIT=y
+CONFIG_NETDEV_PHY_IOCTL=y
+CONFIG_NETDEV_WIRELESS_IOCTL=y
+CONFIG_NETINIT_DHCPC=y
+CONFIG_NETUTILS_CJSON=y
+CONFIG_NET_BROADCAST=y
+CONFIG_NET_ETH_PKTSIZE=1514
+CONFIG_NET_ICMP_SOCKET=y
+CONFIG_NET_TCP=y
+CONFIG_NET_UDP=y
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_READLINE=y
+CONFIG_NSH_STRERROR=y
+CONFIG_PM_UART_WAKEUP=y
+CONFIG_PREALLOC_TIMERS=0
+CONFIG_PTHREAD_MUTEX_TYPES=y
+CONFIG_SCHED_BACKTRACE=y
+CONFIG_SCHED_LPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SIG_DEFAULT=y
+CONFIG_START_DAY=29
+CONFIG_START_MONTH=11
+CONFIG_START_YEAR=2019
+CONFIG_SYSTEM_DHCPC_RENEW=y
+CONFIG_SYSTEM_DUMPSTACK=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_PING=y
+CONFIG_TESTING_GETPRIME=y
+CONFIG_TESTING_OSTEST=y
+CONFIG_TLS_TASK_NELEM=4
+CONFIG_UART0_SERIAL_CONSOLE=y
+CONFIG_WIRELESS=y
+CONFIG_WIRELESS_WAPI=y
+CONFIG_WIRELESS_WAPI_CMDTOOL=y
+CONFIG_WIRELESS_WAPI_INITCONF=y
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
index f8f46763d6a..fa2db59a6fd 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
@@ -128,6 +128,10 @@
# include "espressif/esp_aes.h"
#endif
+#ifdef CONFIG_PM
+# include "espressif/esp_pm.h"
+#endif
+
#ifdef CONFIG_MMCSD_SPI
# include "esp_board_mmcsd.h"
#endif
diff --git a/boards/risc-v/esp32c6/esp32c6-devkitc/configs/autopm/defconfig b/boards/risc-v/esp32c6/esp32c6-devkitc/configs/autopm/defconfig
new file mode 100644
index 00000000000..0e5ab084830
--- /dev/null
+++ b/boards/risc-v/esp32c6/esp32c6-devkitc/configs/autopm/defconfig
@@ -0,0 +1,83 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_NSH_ARGCAT is not set
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+CONFIG_ALLOW_BSD_COMPONENTS=y
+CONFIG_ARCH="risc-v"
+CONFIG_ARCH_BOARD="esp32c6-devkitc"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_ESP32C6_DEVKITC=y
+CONFIG_ARCH_CHIP="esp32c6"
+CONFIG_ARCH_CHIP_ESP32C6=y
+CONFIG_ARCH_CHIP_ESP32C6WROOM1=y
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_IRQ_TO_NDX=y
+CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y
+CONFIG_ARCH_NUSER_INTERRUPTS=17
+CONFIG_ARCH_RISCV=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARD_LOOPSPERMSEC=15000
+CONFIG_BUILTIN=y
+CONFIG_DRIVERS_IEEE80211=y
+CONFIG_DRIVERS_WIRELESS=y
+CONFIG_ESPRESSIF_AUTO_SLEEP=y
+CONFIG_ESPRESSIF_POWER_SAVE_MAX_MODEM=y
+CONFIG_ESPRESSIF_SPIFLASH=y
+CONFIG_ESPRESSIF_SPIFLASH_SPIFFS=y
+CONFIG_ESPRESSIF_WIFI=y
+CONFIG_EXAMPLES_RANDOM=y
+CONFIG_FS_PROCFS=y
+CONFIG_IDLETHREAD_STACKSIZE=2048
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INIT_STACKSIZE=8192
+CONFIG_INTELHEX_BINARY=y
+CONFIG_IOB_BUFSIZE=128
+CONFIG_IOB_NBUFFERS=160
+CONFIG_IOB_THROTTLE=24
+CONFIG_LIBC_PERROR_STDOUT=y
+CONFIG_LIBC_STRERROR=y
+CONFIG_NETDB_DNSCLIENT=y
+CONFIG_NETDEV_LATEINIT=y
+CONFIG_NETDEV_PHY_IOCTL=y
+CONFIG_NETDEV_WIRELESS_IOCTL=y
+CONFIG_NETINIT_DHCPC=y
+CONFIG_NETUTILS_CJSON=y
+CONFIG_NET_BROADCAST=y
+CONFIG_NET_ETH_PKTSIZE=1514
+CONFIG_NET_ICMP_SOCKET=y
+CONFIG_NET_TCP=y
+CONFIG_NET_UDP=y
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_READLINE=y
+CONFIG_NSH_STRERROR=y
+CONFIG_PM_UART_WAKEUP=y
+CONFIG_PREALLOC_TIMERS=0
+CONFIG_PTHREAD_MUTEX_TYPES=y
+CONFIG_SCHED_BACKTRACE=y
+CONFIG_SCHED_LPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SIG_DEFAULT=y
+CONFIG_START_DAY=29
+CONFIG_START_MONTH=11
+CONFIG_START_YEAR=2019
+CONFIG_SYSTEM_DHCPC_RENEW=y
+CONFIG_SYSTEM_DUMPSTACK=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_PING=y
+CONFIG_TESTING_GETPRIME=y
+CONFIG_TESTING_OSTEST=y
+CONFIG_TLS_TASK_NELEM=4
+CONFIG_UART0_SERIAL_CONSOLE=y
+CONFIG_WIRELESS=y
+CONFIG_WIRELESS_WAPI=y
+CONFIG_WIRELESS_WAPI_CMDTOOL=y
+CONFIG_WIRELESS_WAPI_INITCONF=y
diff --git a/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c b/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c
index f3bac90e185..78c6668e2c6 100644
--- a/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c
+++ b/boards/risc-v/esp32c6/esp32c6-devkitc/src/esp32c6_bringup.c
@@ -135,6 +135,10 @@
# include "espressif/esp_aes.h"
#endif
+#ifdef CONFIG_PM
+# include "espressif/esp_pm.h"
+#endif
+
#ifdef CONFIG_NET_OA_TC6
# include "esp_board_oa_tc6.h"
#endif
@@ -505,6 +509,16 @@ int esp_bringup(void)
}
#endif
+#ifdef CONFIG_ESPRESSIF_AUTO_SLEEP
+ /* Configure PM */
+
+ ret = esp_pmconfigure();
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: esp_pmconfigure failed: %d\n", ret);
+ }
+#endif
+
#ifdef CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP_WO_TOOL
ret = esp_nxdiag_initialize();
if (ret < 0)
diff --git a/boards/risc-v/esp32h2/esp32h2-devkit/configs/autopm/defconfig b/boards/risc-v/esp32h2/esp32h2-devkit/configs/autopm/defconfig
new file mode 100644
index 00000000000..b8b61a0e5ee
--- /dev/null
+++ b/boards/risc-v/esp32h2/esp32h2-devkit/configs/autopm/defconfig
@@ -0,0 +1,53 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_NSH_ARGCAT is not set
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+CONFIG_ARCH="risc-v"
+CONFIG_ARCH_BOARD="esp32h2-devkit"
+CONFIG_ARCH_BOARD_COMMON=y
+CONFIG_ARCH_BOARD_ESP32H2_DEVKIT=y
+CONFIG_ARCH_CHIP="esp32h2"
+CONFIG_ARCH_CHIP_ESP32H2=y
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_IRQ_TO_NDX=y
+CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y
+CONFIG_ARCH_NUSER_INTERRUPTS=17
+CONFIG_ARCH_RISCV=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARD_LOOPSPERMSEC=15000
+CONFIG_BUILTIN=y
+CONFIG_ESPRESSIF_AUTO_SLEEP=y
+CONFIG_FS_PROCFS=y
+CONFIG_IDLETHREAD_STACKSIZE=2048
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INTELHEX_BINARY=y
+CONFIG_LIBC_PERROR_STDOUT=y
+CONFIG_LIBC_STRERROR=y
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_DISABLE_DATE=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_READLINE=y
+CONFIG_NSH_STRERROR=y
+CONFIG_PM_UART_WAKEUP=y
+CONFIG_PREALLOC_TIMERS=0
+CONFIG_RR_INTERVAL=200
+CONFIG_RTC=y
+CONFIG_RTC_DRIVER=y
+CONFIG_SCHED_BACKTRACE=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_START_DAY=29
+CONFIG_START_MONTH=11
+CONFIG_START_YEAR=2019
+CONFIG_SYSTEM_DUMPSTACK=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_TESTING_GETPRIME=y
+CONFIG_TESTING_OSTEST=y
+CONFIG_UART0_SERIAL_CONSOLE=y
diff --git a/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c b/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c
index ba670579ac5..8c4120eff80 100644
--- a/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c
+++ b/boards/risc-v/esp32h2/esp32h2-devkit/src/esp32h2_bringup.c
@@ -125,6 +125,10 @@
# include "espressif/esp_aes.h"
#endif
+#ifdef CONFIG_PM
+# include "espressif/esp_pm.h"
+#endif
+
#ifdef CONFIG_MMCSD_SPI
# include "esp_board_mmcsd.h"
#endif
@@ -447,6 +451,16 @@ int esp_bringup(void)
}
#endif
+#ifdef CONFIG_ESPRESSIF_AUTO_SLEEP
+ /* Configure PM */
+
+ ret = esp_pmconfigure();
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: esp_pmconfigure failed: %d\n", ret);
+ }
+#endif
+
#ifdef CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP_WO_TOOL
ret = esp_nxdiag_initialize();
if (ret < 0)
(nuttx) 01/03: arch/risc-v/esp32[-c3|-c6|-h2]: Add auto sleep
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 213a651509ef4bea658c19f13202267cb8a06639
Author: Tiago Medicci Serrano <ti...@espressif.com>
AuthorDate: Mon Mar 30 16:28:28 2026 -0300
arch/risc-v/esp32[-c3|-c6|-h2]: Add auto sleep
Add auto sleep for risc-v based Espressif devices
Signed-off-by: Eren Terzioglu <er...@espressif.com>
---
arch/risc-v/src/common/espressif/CMakeLists.txt | 9 +-
arch/risc-v/src/common/espressif/Kconfig | 17 ++
arch/risc-v/src/common/espressif/Make.defs | 9 +-
.../risc-v/src/common/espressif/esp_allocateheap.c | 20 ++
.../espressif/{esp_tickless.h => esp_extraheaps.c} | 52 +---
arch/risc-v/src/common/espressif/esp_idle.c | 31 +-
arch/risc-v/src/common/espressif/esp_pm.c | 312 ++++++++++++++++++++-
arch/risc-v/src/common/espressif/esp_pm.h | 73 +++++
.../src/common/espressif/esp_retentionheap.c | 292 +++++++++++++++++++
.../src/common/espressif/esp_retentionheap.h | 222 +++++++++++++++
arch/risc-v/src/common/espressif/esp_tickless.c | 2 +-
arch/risc-v/src/common/espressif/esp_tickless.h | 2 +-
arch/risc-v/src/esp32c3/hal_esp32c3.cmake | 14 +-
arch/risc-v/src/esp32c3/hal_esp32c3.mk | 7 +
arch/risc-v/src/esp32c6/hal_esp32c6.cmake | 7 +-
arch/risc-v/src/esp32c6/hal_esp32c6.mk | 4 +-
arch/risc-v/src/esp32h2/hal_esp32h2.cmake | 7 +-
arch/risc-v/src/esp32h2/hal_esp32h2.mk | 3 +
arch/risc-v/src/esp32p4/hal_esp32p4.cmake | 1 +
arch/risc-v/src/esp32p4/hal_esp32p4.mk | 1 +
arch/xtensa/src/esp32/Make.defs | 2 +-
arch/xtensa/src/esp32s2/Make.defs | 2 +-
arch/xtensa/src/esp32s3/Make.defs | 2 +-
.../esp32c3/esp32c3-devkit/src/esp32c3_bringup.c | 10 +
24 files changed, 1036 insertions(+), 65 deletions(-)
diff --git a/arch/risc-v/src/common/espressif/CMakeLists.txt b/arch/risc-v/src/common/espressif/CMakeLists.txt
index 067d5ba5916..3bbb0be67fa 100644
--- a/arch/risc-v/src/common/espressif/CMakeLists.txt
+++ b/arch/risc-v/src/common/espressif/CMakeLists.txt
@@ -34,6 +34,13 @@ list(APPEND SRCS esp_irq.c esp_gpio.c esp_rtc_gpio.c esp_libc_stubs.c)
list(APPEND SRCS esp_lowputc.c esp_serial.c)
list(APPEND SRCS esp_systemreset.c)
+if(CONFIG_ARCH_HAVE_EXTRA_HEAPS)
+ list(APPEND SRCS esp_extraheaps.c)
+ if(CONFIG_ESPRESSIF_RETENTION_HEAP)
+ list(APPEND SRCS esp_retentionheap.c)
+ endif()
+endif()
+
if(CONFIG_SCHED_TICKLESS)
list(APPEND SRCS esp_tickless.c)
else()
@@ -202,7 +209,7 @@ if(DEFINED ENV{ESP_HAL_3RDPARTY_VERSION})
CACHE STRING "ESP HAL 3rdparty version")
else()
set(ESP_HAL_3RDPARTY_VERSION
- 5d8324708f55d5a927329553cdceebf7eafbd8c6
+ b7e51db97a3f9dc82d3b3524d2bad298ba1e2647
CACHE STRING "ESP HAL 3rdparty version")
endif()
diff --git a/arch/risc-v/src/common/espressif/Kconfig b/arch/risc-v/src/common/espressif/Kconfig
index 4285a109a26..15ae7cc9025 100644
--- a/arch/risc-v/src/common/espressif/Kconfig
+++ b/arch/risc-v/src/common/espressif/Kconfig
@@ -469,6 +469,22 @@ endmenu # LP Core (Low-power core) Coprocessor Configuration
menu "PM Configuration"
+config ESPRESSIF_AUTO_SLEEP
+ bool "Auto-sleep"
+ default n
+ select PM
+ select ESPRESSIF_HR_TIMER
+ select ARCH_HAVE_EXTRA_HEAPS if ARCH_CHIP_ESP32C3
+ select ESPRESSIF_RETENTION_HEAP if ARCH_CHIP_ESP32C3
+ select SCHED_TICKLESS
+ ---help---
+ Enable Auto-sleep
+
+config ESPRESSIF_RETENTION_HEAP
+ bool "Use retention memory as a separate heap"
+ depends on ARCH_CHIP_ESP32C3
+ default n
+
if PM
config PM_EXT1_WAKEUP
@@ -615,6 +631,7 @@ config PM_ULP_WAKEUP
config PM_GPIO_WAKEUP
bool "PM GPIO Wakeup"
default n
+ depends on ARCH_CHIP_ESP32C3
---help---
Enable GPIO wakeup functionality.
This allows the system to wake up from PM_STANDBY
diff --git a/arch/risc-v/src/common/espressif/Make.defs b/arch/risc-v/src/common/espressif/Make.defs
index 660b7042088..d751aa63789 100644
--- a/arch/risc-v/src/common/espressif/Make.defs
+++ b/arch/risc-v/src/common/espressif/Make.defs
@@ -39,6 +39,13 @@ CHIP_CSRCS += esp_irq.c esp_gpio.c esp_rtc_gpio.c esp_libc_stubs.c
CHIP_CSRCS += esp_lowputc.c esp_serial.c
CHIP_CSRCS += esp_systemreset.c
+ifeq ($(CONFIG_ARCH_HAVE_EXTRA_HEAPS),y)
+ CHIP_CSRCS += esp_extraheaps.c
+ ifeq ($(CONFIG_ESPRESSIF_RETENTION_HEAP),y)
+ CHIP_CSRCS += esp_retentionheap.c
+ endif
+endif
+
ifeq ($(CONFIG_SCHED_TICKLESS),y)
CHIP_CSRCS += esp_tickless.c
else
@@ -210,7 +217,7 @@ endif
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
ifndef ESP_HAL_3RDPARTY_VERSION
- ESP_HAL_3RDPARTY_VERSION = 5d8324708f55d5a927329553cdceebf7eafbd8c6
+ ESP_HAL_3RDPARTY_VERSION = b7e51db97a3f9dc82d3b3524d2bad298ba1e2647
endif
ifndef ESP_HAL_3RDPARTY_URL
diff --git a/arch/risc-v/src/common/espressif/esp_allocateheap.c b/arch/risc-v/src/common/espressif/esp_allocateheap.c
index 8d27956d637..df06f360e47 100644
--- a/arch/risc-v/src/common/espressif/esp_allocateheap.c
+++ b/arch/risc-v/src/common/espressif/esp_allocateheap.c
@@ -36,11 +36,20 @@
#include "riscv_internal.h"
#include "rom/rom_layout.h"
+#ifdef CONFIG_ESPRESSIF_RETENTION_HEAP
+# include "esp_retentionheap.h"
+#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+uintptr_t _heap_start;
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -77,11 +86,22 @@ void up_allocate_heap(void **heap_start, size_t *heap_size)
* Check boards/risc-v/espressif.
*/
+#ifdef CONFIG_ESPRESSIF_RETENTION_HEAP
+ uintptr_t rstart;
+ uintptr_t rend;
+#endif
+
board_autoled_on(LED_HEAPALLOCATE);
*heap_start = (void *)g_idle_topstack;
+#ifdef CONFIG_ESPRESSIF_RETENTION_HEAP
+ esp_retentionheap_find_region(&rstart, &rend);
+ *heap_size = (uintptr_t) rstart - g_idle_topstack;
+#else
*heap_size = (uintptr_t)ets_rom_layout_p->dram0_rtos_reserved_start -
g_idle_topstack;
+#endif
+ _heap_start = g_idle_topstack;
}
/****************************************************************************
diff --git a/arch/risc-v/src/common/espressif/esp_tickless.h b/arch/risc-v/src/common/espressif/esp_extraheaps.c
similarity index 55%
copy from arch/risc-v/src/common/espressif/esp_tickless.h
copy to arch/risc-v/src/common/espressif/esp_extraheaps.c
index 93203b7f929..01442391254 100644
--- a/arch/risc-v/src/common/espressif/esp_tickless.h
+++ b/arch/risc-v/src/common/espressif/esp_extraheaps.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/risc-v/src/common/espressif/esp_tickless.h
+ * arch/risc-v/src/common/espressif/esp_extraheaps.c
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -20,52 +20,24 @@
*
****************************************************************************/
-#ifndef __ARCH_RISCV_SRC_COMMON_ESPRESSIF_ESP_TICKLESS_H
-#define __ARCH_RISCV_SRC_COMMON_ESPRESSIF_ESP_TICKLESS_H
-
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
+#include <nuttx/arch.h>
-#include <stdint.h>
+#ifdef CONFIG_ESPRESSIF_RETENTION_HEAP
+# include "esp_retentionheap.h"
+#endif
/****************************************************************************
- * Public Function Prototypes
+ * Public Functions
****************************************************************************/
-/****************************************************************************
- * Name: up_get_idletime
- *
- * Description:
- * This function returns the idle time.
- *
- * Input Parameters:
- * None.
- *
- * Returned Value:
- * The time in system ticks remaining for idle.
- * Zero means system is busy.
- *
- ****************************************************************************/
-
-uint32_t up_get_idletime(void);
-
-/****************************************************************************
- * Name: up_step_idletime
- *
- * Description:
- * Add system time by idletime_us.
- *
- * Input Parameters:
- * idletime_us - Idle time in microseconds.
- *
- * Returned Value:
- * None.
- *
- ****************************************************************************/
-
-void up_step_idletime(uint32_t idletime_us);
-
-#endif /* __ARCH_RISCV_SRC_COMMON_ESPRESSIF_ESP_TICKLESS_H */
+void up_extraheaps_init(void)
+{
+#ifdef CONFIG_ESPRESSIF_RETENTION_HEAP
+ esp_retentionheap_initialize();
+#endif
+}
diff --git a/arch/risc-v/src/common/espressif/esp_idle.c b/arch/risc-v/src/common/espressif/esp_idle.c
index b3d43d0c1bc..b09dc5bc51b 100644
--- a/arch/risc-v/src/common/espressif/esp_idle.c
+++ b/arch/risc-v/src/common/espressif/esp_idle.c
@@ -34,10 +34,26 @@
#include <nuttx/spinlock.h>
#include <nuttx/debug.h>
#include <nuttx/arch.h>
+#include <sys/param.h>
#include "riscv_internal.h"
#include "esp_pm.h"
+#ifdef CONFIG_ESPRESSIF_HR_TIMER
+#include "esp_hr_timer.h"
+#endif
+
+#ifdef CONFIG_SCHED_TICKLESS
+#include "esp_tickless.h"
+#endif
+
+#ifdef CONFIG_ESPRESSIF_AUTO_SLEEP
+#include "esp_private/pm_impl.h"
+#include "platform/os.h"
+#endif
+
+#include "esp_sleep.h"
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -87,6 +103,9 @@ static spinlock_t g_esp_idle_lock = SP_UNLOCKED;
static void up_idlepm(void)
{
irqstate_t flags;
+# ifdef CONFIG_ESPRESSIF_AUTO_SLEEP
+ esp_os_application_sleep();
+# else
static enum pm_state_e oldstate = PM_NORMAL;
enum pm_state_e newstate;
int ret;
@@ -169,16 +188,17 @@ static void up_idlepm(void)
}
else
{
-# ifdef CONFIG_WATCHDOG
+# ifdef CONFIG_WATCHDOG
/* Announce the power management state change to feed watchdog */
pm_changestate(PM_IDLE_DOMAIN, PM_NORMAL);
-# endif
+# endif
}
+# endif /* CONFIG_ESPRESSIF_AUTO_SLEEP */
}
#else
# define up_idlepm()
-#endif
+#endif /* CONFIG_PM */
/****************************************************************************
* Public Functions
@@ -216,7 +236,12 @@ void up_idle(void)
* sleep in a reduced power mode until an interrupt occurs to save power
*/
+#ifdef CONFIG_ESPRESSIF_AUTO_SLEEP
+ esp_pm_impl_idle_hook();
+ esp_pm_impl_waiti();
+#else
asm("WFI");
+#endif
/* Perform IDLE mode power management */
diff --git a/arch/risc-v/src/common/espressif/esp_pm.c b/arch/risc-v/src/common/espressif/esp_pm.c
index 67bbbf6ee0c..9501106cb2e 100644
--- a/arch/risc-v/src/common/espressif/esp_pm.c
+++ b/arch/risc-v/src/common/espressif/esp_pm.c
@@ -30,7 +30,10 @@
#include <nuttx/debug.h>
-#include "esp_pm.h"
+#include "include/esp_pm.h"
+#include "espressif/esp_pm.h"
+#include "esp_hr_timer.h"
+
#ifdef CONFIG_SCHED_TICKLESS
# include "esp_tickless.h"
#endif
@@ -38,6 +41,9 @@
#include "soc/rtc.h"
#include "esp_sleep_internal.h"
#include "esp_pmu.h"
+#include "esp_attr.h"
+#include "esp_private/pm_impl.h"
+
#ifdef CONFIG_PM_EXT1_WAKEUP
# include "driver/rtc_io.h"
#endif
@@ -57,7 +63,7 @@
* Pre-processor Definitions
****************************************************************************/
-#if defined(CONFIG_ARCH_CHIP_ESP32C3_GENERIC) || \
+#if defined(CONFIG_ARCH_CHIP_ESP32C3) || \
defined(CONFIG_ARCH_CHIP_ESP32C6)
# define CHECK_VDD_SPI 1
# if defined(CONFIG_ARCH_CHIP_ESP32C6)
@@ -69,6 +75,19 @@
# endif /* CONFIG_ARCH_CHIP_ESP32C6 */
#endif /* CONFIG_ARCH_CHIP_ESP32C3_GENERIC || CONFIG_ARCH_CHIP_ESP32C6 */
+#ifdef CONFIG_PM_EXT0_WAKEUP
+# define EXT0_WAIT_TIME_US 5000000
+#endif
+#ifdef CONFIG_PM_EXT1_WAKEUP
+# define EXT1_WAIT_TIME_US 5000000
+#endif
+#ifdef CONFIG_PM_GPIO_WAKEUP
+# define GPIO_WAIT_TIME_US 5000000
+#endif
+#ifdef CONFIG_PM_UART_WAKEUP
+# define UART_WAIT_TIME_US 5000000
+#endif
+
/****************************************************************************
* Private Data
****************************************************************************/
@@ -94,10 +113,41 @@ const char *g_wakeup_reasons[] =
""
};
+static esp_sleep_wakeup_cause_t g_last_wakeup_reason =
+ ESP_SLEEP_WAKEUP_UNDEFINED;
+static uint64_t g_last_wakeup_time = 0;
+
/****************************************************************************
* Private Functions
****************************************************************************/
+#ifdef CONFIG_PM_EXT0_WAKEUP
+/****************************************************************************
+ * Name: esp_pm_ext0_wakeup_prepare
+ *
+ * Description:
+ * Configure ext0 gpios to use as wakeup source.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void IRAM_ATTR esp_pm_ext0_wakeup_prepare(void)
+{
+ int pin = CONFIG_PM_EXT0_WAKEUP_GPIO;
+# ifdef CONFIG_PM_EXT0_WAKEUP_TRIGGER_LOW
+ int level_mode = 0;
+# else
+ int level_mode = 1;
+# endif /* CONFIG_PM_EXT0_WAKEUP */
+ esp_sleep_enable_ext0_wakeup(pin, level_mode);
+}
+#endif /* CONFIG_PM_EXT0_WAKEUP */
+
#ifdef CONFIG_PM_EXT1_WAKEUP
/****************************************************************************
* Name: esp_pm_get_ext1_io_mask
@@ -410,6 +460,163 @@ static void IRAM_ATTR esp_pm_uart_wakeup_prepare(void)
}
#endif /* CONFIG_PM_UART_WAKEUP */
+#ifdef CONFIG_ESPRESSIF_AUTO_SLEEP
+
+/****************************************************************************
+ * Name: esp_pm_skip_light_sleep
+ *
+ * Description:
+ * Callback for the power manager's "skip light sleep" hook. This function
+ * checks if the system should defer entering light sleep after waking up
+ * from any supported wakeup source (EXT0, EXT1, GPIO, UART). It compares
+ * the current time to the last wakeup time for each source. If the system
+ * is still within the configured guard window for any wakeup source, it
+ * returns true to skip light sleep and let peripheral activity finish. If
+ * the guard window has elapsed or there was no wakeup, it returns false
+ * and allows light sleep to proceed.
+ *
+ * Placed in IRAM because it runs in timing-critical power management
+ * decision paths.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * true - Skip light sleep (recent EXT0, EXT1, GPIO, or UART wakeup still
+ * within the configured guard window).
+ * false - Allow light sleep (no relevant wakeup or guard window elapsed).
+ *
+ ****************************************************************************/
+
+static bool IRAM_ATTR esp_pm_skip_light_sleep(void)
+{
+ bool skip = false;
+#if defined(CONFIG_PM_EXT0_WAKEUP) || \
+ defined(CONFIG_PM_EXT1_WAKEUP) || \
+ defined(CONFIG_PM_GPIO_WAKEUP) || \
+ defined(CONFIG_PM_UART_WAKEUP)
+ uint64_t current_time = esp_hr_timer_time_us();
+#endif
+
+#ifdef CONFIG_PM_EXT0_WAKEUP
+ if (g_last_wakeup_reason == ESP_SLEEP_WAKEUP_EXT0 &&
+ current_time < (g_last_wakeup_time + EXT0_WAIT_TIME_US))
+ {
+ pwrinfo("EXT0 wakeup still within guard window\n");
+ skip = true;
+ }
+#endif
+
+#ifdef CONFIG_PM_EXT1_WAKEUP
+ if (g_last_wakeup_reason == ESP_SLEEP_WAKEUP_EXT1 &&
+ current_time < (g_last_wakeup_time + EXT1_WAIT_TIME_US))
+ {
+ pwrinfo("EXT1 wakeup still within guard window\n");
+ skip = true;
+ }
+#endif
+
+#ifdef CONFIG_PM_GPIO_WAKEUP
+ if (g_last_wakeup_reason == ESP_SLEEP_WAKEUP_GPIO &&
+ current_time < (g_last_wakeup_time + GPIO_WAIT_TIME_US))
+ {
+ pwrinfo("GPIO wakeup still within guard window\n");
+ skip = true;
+ }
+#endif
+
+#ifdef CONFIG_PM_UART_WAKEUP
+ if (g_last_wakeup_reason == ESP_SLEEP_WAKEUP_UART &&
+ current_time < (g_last_wakeup_time + UART_WAIT_TIME_US))
+ {
+ pwrinfo("UART wakeup still within guard window\n");
+ skip = true;
+ }
+#endif
+
+ return skip;
+}
+
+/****************************************************************************
+ * Name: esp_pm_light_sleep_exit_cb
+ *
+ * Description:
+ * Store wakeup reason and timestamp on light sleep exit.
+ *
+ * Input Parameters:
+ * sleep_time_us - Actual sleep time in microseconds (unused).
+ * arg - User callback argument (unused).
+ *
+ * Returned Value:
+ * ESP_OK
+ *
+ ****************************************************************************/
+
+static esp_err_t IRAM_ATTR esp_pm_light_sleep_exit_cb(int64_t sleep_time_us,
+ void *arg)
+{
+ esp_sleep_wakeup_cause_t wc;
+ uint64_t tw;
+
+ UNUSED(sleep_time_us);
+ UNUSED(arg);
+
+ wc = esp_sleep_get_wakeup_cause();
+ tw = esp_hr_timer_time_us();
+
+ pwrinfo("Light sleep exit: %s, time: %lld\n", g_wakeup_reasons[wc], tw);
+
+ esp_pm_wakeup_set_last_reason((int32_t)wc);
+ esp_pm_wakeup_set_last_time(tw);
+
+ return ESP_OK;
+}
+#endif /* CONFIG_ESPRESSIF_AUTO_SLEEP */
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_pm_wakeup_set_last_reason
+ *
+ * Description:
+ * Store the sleep exit wakeup cause after light sleep.
+ *
+ * Input Parameters:
+ * reason - Value from esp_sleep_get_wakeup_cause().
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void esp_pm_wakeup_set_last_reason(int32_t reason)
+{
+ g_last_wakeup_reason = reason;
+}
+
+/****************************************************************************
+ * Name: esp_pm_wakeup_set_last_time
+ *
+ * Description:
+ * Store the high-resolution timestamp (microseconds) for the last light
+ * sleep exit, together with the cause from
+ * esp_pm_wakeup_set_last_reason().
+ *
+ * Input Parameters:
+ * time_us - Time from esp_hr_timer_time_us() at exit from light sleep.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void esp_pm_wakeup_set_last_time(uint64_t time_us)
+{
+ g_last_wakeup_time = time_us;
+}
+
/****************************************************************************
* Name: esp_pm_sleep_enable_timer_wakeup
*
@@ -424,15 +631,11 @@ static void IRAM_ATTR esp_pm_uart_wakeup_prepare(void)
*
****************************************************************************/
-static void esp_pm_sleep_enable_timer_wakeup(uint64_t time_in_us)
+void esp_pm_sleep_enable_timer_wakeup(uint64_t time_in_us)
{
esp_sleep_enable_timer_wakeup(time_in_us);
}
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
/****************************************************************************
* Name: esp_pm_light_sleep_start
*
@@ -510,6 +713,9 @@ void esp_pmstandby(uint64_t time_in_us)
#ifdef CONFIG_PM_GPIO_WAKEUP
int64_t gpio_mask;
#endif
+#ifdef CONFIG_PM_EXT0_WAKEUP
+ esp_pm_ext0_wakeup_prepare();
+#endif
#ifdef CONFIG_PM_EXT1_WAKEUP
int64_t ext1_mask;
esp_pm_ext1_wakeup_prepare();
@@ -518,6 +724,7 @@ void esp_pmstandby(uint64_t time_in_us)
esp_pm_gpio_wakeup_prepare();
#endif
#ifdef CONFIG_PM_ULP_WAKEUP
+ esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
esp_sleep_enable_ulp_wakeup();
#endif
#ifdef CONFIG_PM_UART_WAKEUP
@@ -579,3 +786,94 @@ void esp_pmsleep(uint64_t time_in_us)
esp_pm_sleep_enable_timer_wakeup(time_in_us);
esp_pm_deep_sleep_start();
}
+
+#ifdef CONFIG_ESPRESSIF_AUTO_SLEEP
+
+/****************************************************************************
+ * Name: esp_pmconfigure
+ *
+ * Description:
+ * Configure power manager.
+ *
+ * Input Parameters:
+ * None.
+ *
+ * Returned Value:
+ * Returns OK on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int esp_pmconfigure(void)
+{
+ int ret;
+ esp_err_t err = ESP_OK;
+#ifdef CONFIG_PM_EXT1_WAKEUP
+ int64_t ext1_mask;
+#endif
+#ifdef CONFIG_PM_GPIO_WAKEUP
+ int64_t gpio_mask;
+#endif
+ esp_pm_config_t pm_config =
+ {
+ .max_freq_mhz = CONFIG_ESPRESSIF_CPU_FREQ_MHZ,
+ .min_freq_mhz = CONFIG_ESPRESSIF_CPU_FREQ_MHZ,
+#ifdef CONFIG_ESPRESSIF_AUTO_SLEEP
+ .light_sleep_enable = true
+#endif
+ };
+
+ ret = esp_pm_configure(&pm_config);
+ if (ret != OK)
+ {
+ return ret;
+ }
+
+#ifdef CONFIG_PM_EXT0_WAKEUP
+ esp_pm_ext0_wakeup_prepare();
+#endif
+#ifdef CONFIG_PM_EXT1_WAKEUP
+ esp_pm_ext1_wakeup_prepare();
+#endif
+#ifdef CONFIG_PM_GPIO_WAKEUP
+ esp_pm_gpio_wakeup_prepare();
+#endif
+#ifdef CONFIG_PM_UART_WAKEUP
+ esp_pm_uart_wakeup_prepare();
+#endif /* CONFIG_PM_UART_WAKEUP */
+
+ err = esp_pm_register_skip_light_sleep_callback(
+ esp_pm_skip_light_sleep);
+ if (err != ESP_OK)
+ {
+ pwrerr("Failed to register skip light sleep callback: %d\n", err);
+ return -ENOMEM;
+ }
+
+ esp_pm_sleep_cbs_register_config_t sleep_cbs =
+ {
+ .enter_cb = NULL,
+ .exit_cb = esp_pm_light_sleep_exit_cb,
+ .enter_cb_user_arg = NULL,
+ .exit_cb_user_arg = NULL,
+ .enter_cb_prior = 0,
+ .exit_cb_prior = 0,
+ };
+
+ err = esp_pm_light_sleep_register_cbs(&sleep_cbs);
+ if (err != ESP_OK)
+ {
+ pwrerr("Failed to register light sleep callbacks: %d\n", err);
+ return -ENOMEM;
+ }
+
+ err =
+ esp_sleep_set_console_uart_handling_mode(ESP_SLEEP_ALWAYS_FLUSH_UART);
+ if (err != ESP_OK)
+ {
+ pwrerr("Failed to set console UART handling mode: %d\n", err);
+ return -ENOMEM;
+ }
+
+ return ret;
+}
+#endif /* CONFIG_ESPRESSIF_AUTO_SLEEP */
diff --git a/arch/risc-v/src/common/espressif/esp_pm.h b/arch/risc-v/src/common/espressif/esp_pm.h
index 892278ad4f7..596c7083f88 100644
--- a/arch/risc-v/src/common/espressif/esp_pm.h
+++ b/arch/risc-v/src/common/espressif/esp_pm.h
@@ -44,11 +44,32 @@ extern "C"
#endif
#ifdef CONFIG_PM
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+typedef bool (*skip_light_sleep_cb_t)(void);
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
+/****************************************************************************
+ * Name: esp_pm_sleep_enable_timer_wakeup
+ *
+ * Description:
+ * Configure wakeup interval
+ *
+ * Input Parameters:
+ * time_in_us - Sleep duration in microseconds.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void esp_pm_sleep_enable_timer_wakeup(uint64_t time_in_us);
+
/****************************************************************************
* Name: esp_pm_light_sleep_start
*
@@ -114,6 +135,58 @@ void esp_pmstandby(uint64_t time_in_us);
void esp_pmsleep(uint64_t time_in_us);
+/****************************************************************************
+ * Name: esp_pmconfigure
+ *
+ * Description:
+ * Configure power manager.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * Returns OK on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+#ifdef CONFIG_ESPRESSIF_AUTO_SLEEP
+int esp_pmconfigure(void);
+#endif
+
+/****************************************************************************
+ * Name: esp_pm_wakeup_set_last_reason
+ *
+ * Description:
+ * Store the sleep exit wakeup cause after light sleep. Used with
+ * esp_pm_wakeup_set_last_time() so the skip-light-sleep hook can
+ * detect a recent UART wakeup.
+ *
+ * Input Parameters:
+ * reason - Value from esp_sleep_get_wakeup_cause().
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void esp_pm_wakeup_set_last_reason(int32_t reason);
+
+/****************************************************************************
+ * Name: esp_pm_wakeup_set_last_time
+ *
+ * Description:
+ * Store the high-resolution timestamp (microseconds) aligned with
+ * the wakeup cause set by esp_pm_wakeup_set_last_reason().
+ *
+ * Input Parameters:
+ * time_us - Time from esp_hr_timer_time_us() at exit from light sleep.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void esp_pm_wakeup_set_last_time(uint64_t time_us);
+
#endif /* CONFIG_PM */
#ifdef __cplusplus
diff --git a/arch/risc-v/src/common/espressif/esp_retentionheap.c b/arch/risc-v/src/common/espressif/esp_retentionheap.c
new file mode 100644
index 00000000000..bbf31911f4d
--- /dev/null
+++ b/arch/risc-v/src/common/espressif/esp_retentionheap.c
@@ -0,0 +1,292 @@
+/****************************************************************************
+ * arch/risc-v/src/common/espressif/esp_retentionheap.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#ifdef CONFIG_ESPRESSIF_RETENTION_HEAP
+
+#include <debug.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <nuttx/mm/mm.h>
+
+#include "esp_retentionheap.h"
+#include "soc/soc.h"
+#include "heap_memory_layout.h"
+#include "esp_heap_caps.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define APP_USABLE_DRAM_END (SOC_ROM_STACK_START - SOC_ROM_STACK_SIZE)
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct mm_heap_s *g_retentionheap;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_retentionheap_find_region
+ *
+ * Description:
+ * Find address of retention heap.
+ *
+ * Input Parameters:
+ * rstart - Starting address of the region
+ * rend - Ending address of the region
+ *
+ * Returned Value:
+ * True if region found; false otherwise
+ *
+ ****************************************************************************/
+
+bool esp_retentionheap_find_region(uintptr_t *rstart, uintptr_t *rend)
+{
+ for (size_t i = 0; i < soc_memory_region_count; i++)
+ {
+ const soc_memory_region_t *reg = &soc_memory_regions[i];
+ if ((soc_memory_types[reg->type].caps[0] & MALLOC_CAP_RETENTION) != 0
+ && (reg->startup_stack == false))
+ {
+ *rstart = (uintptr_t)reg->start;
+ *rend = *rstart + reg->size;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/****************************************************************************
+ * Name: esp_retentionheap_initialize
+ *
+ * Description:
+ * Initialize the retention heap.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void esp_retentionheap_initialize(void)
+{
+ size_t sz;
+ uintptr_t rstart;
+ uintptr_t rend;
+
+ if (!esp_retentionheap_find_region(&rstart, &rend))
+ {
+ _warn("MALLOC_CAP_RETENTION region did not find\n");
+ return;
+ }
+
+ if (rend <= rstart)
+ {
+ return;
+ }
+
+ sz = (size_t)(rend - rstart);
+ g_retentionheap = mm_initialize("retention", (void *)rstart, sz);
+ if (g_retentionheap == NULL)
+ {
+ _err("retention heap mm_initialize failed size=%zu\n", sz);
+ }
+}
+
+/****************************************************************************
+ * Name: esp_retentionheap_malloc
+ *
+ * Description:
+ * Allocate memory from the retention heap.
+ *
+ * Input Parameters:
+ * size - Size to allocate memory in bytes
+ *
+ * Returned Value:
+ * Valid address reference on success; NULL, otherwise.
+ *
+ ****************************************************************************/
+
+void *esp_retentionheap_malloc(size_t size)
+{
+ if (g_retentionheap == NULL)
+ {
+ return NULL;
+ }
+
+ return mm_malloc(g_retentionheap, size);
+}
+
+/****************************************************************************
+ * Name: esp_retentionheap_calloc
+ *
+ * Description:
+ * Calculates the size of the allocation and allocate memory from
+ * the retention heap.
+ *
+ * Input Parameters:
+ * n - Number of elements to allocate.
+ * elem_size - Size of each element, in bytes.
+ *
+ * Returned Value:
+ * Valid address reference on success; NULL, otherwise.
+ *
+ ****************************************************************************/
+
+void *esp_retentionheap_calloc(size_t n, size_t elem_size)
+{
+ if (g_retentionheap == NULL)
+ {
+ return NULL;
+ }
+
+ return mm_calloc(g_retentionheap, n, elem_size);
+}
+
+/****************************************************************************
+ * Name: esp_retentionheap_memalign
+ *
+ * Description:
+ * memalign requests more than enough space from malloc, finds a region
+ * within that chunk that meets the alignment request and then frees any
+ * leading or trailing space.
+ *
+ * The alignment argument must be a power of two (not checked). 8-byte
+ * alignment is guaranteed by normal malloc calls.
+ *
+ * Input Parameters:
+ * alignment - Required byte alignment; must be a power of two and usually
+ * at least sizeof(void *).
+ * size - Number of bytes to allocate.
+ *
+ * Returned Value:
+ * Valid address reference on success; NULL, otherwise.
+ *
+ ****************************************************************************/
+
+void *esp_retentionheap_memalign(size_t alignment, size_t size)
+{
+ if (g_retentionheap == NULL)
+ {
+ return NULL;
+ }
+
+ return mm_memalign(g_retentionheap, alignment, size);
+}
+
+/****************************************************************************
+ * Name: esp_retentionheap_realloc
+ *
+ * Description:
+ * Reallocate memory from the retention heap.
+ *
+ * Input Parameters:
+ * mem - The address to reallocate
+ * size - New requested size
+ *
+ * Returned Value:
+ * Valid address reference on success; NULL, otherwise.
+ *
+ ****************************************************************************/
+
+void *esp_retentionheap_realloc(void *ptr, size_t size)
+{
+ if (g_retentionheap == NULL)
+ {
+ return NULL;
+ }
+
+ return mm_realloc(g_retentionheap, ptr, size);
+}
+
+/****************************************************************************
+ * Name: esp_retentionheap_free
+ *
+ * Description:
+ * Free memory from the retention heap.
+ *
+ * Input Parameters:
+ * mem - The address to free
+ *
+ * Returned Value:
+ * None.
+ *
+ ****************************************************************************/
+
+void esp_retentionheap_free(void *mem)
+{
+ if (g_retentionheap == NULL || mem == NULL)
+ {
+ return;
+ }
+
+ mm_free(g_retentionheap, mem);
+}
+
+/****************************************************************************
+ * Name: esp_retentionheap_heapmember
+ *
+ * Description:
+ * Check if an address lies in the retention heap.
+ *
+ * Parameters:
+ * mem - The address to check
+ *
+ * Return Value:
+ * True if the address is in the retention heap; false if not.
+ *
+ ****************************************************************************/
+
+bool esp_retentionheap_heapmember(void *mem)
+{
+ if (g_retentionheap == NULL || mem == NULL)
+ {
+ return false;
+ }
+
+ return mm_heapmember(g_retentionheap, mem);
+}
+
+/****************************************************************************
+ * Name: esp_retentionheap_malloc_size
+ *
+ * Description:
+ * Get size of the allocated space in retention heap
+ *
+ * Input Parameters:
+ * mem - The address to check
+ *
+ * Returned Value:
+ * Size of allocated space related to address.
+ *
+ ****************************************************************************/
+
+size_t esp_retentionheap_malloc_size(void *mem)
+{
+ if (g_retentionheap == NULL || mem == NULL)
+ {
+ return 0;
+ }
+
+ return mm_malloc_size(g_retentionheap, mem);
+}
+
+#endif /* CONFIG_ESPRESSIF_RETENTION_HEAP */
diff --git a/arch/risc-v/src/common/espressif/esp_retentionheap.h b/arch/risc-v/src/common/espressif/esp_retentionheap.h
new file mode 100644
index 00000000000..d8464175ae2
--- /dev/null
+++ b/arch/risc-v/src/common/espressif/esp_retentionheap.h
@@ -0,0 +1,222 @@
+/****************************************************************************
+ * arch/risc-v/src/common/espressif/esp_retentionheap.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_RETENTIONHEAP_H
+#define __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_RETENTIONHEAP_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/****************************************************************************
+ * Public Functions Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#if defined(CONFIG_ESPRESSIF_RETENTION_HEAP)
+
+/****************************************************************************
+ * Name: esp_retentionheap_find_region
+ *
+ * Description:
+ * Find address of retention heap.
+ *
+ * Input Parameters:
+ * rstart - Starting address of the region
+ * rend - Ending address of the region
+ *
+ * Returned Value:
+ * True if region found; false otherwise
+ *
+ ****************************************************************************/
+
+bool esp_retentionheap_find_region(uintptr_t *rstart, uintptr_t *rend);
+
+/****************************************************************************
+ * Name: esp_retentionheap_initialize
+ *
+ * Description:
+ * Initialize the retention heap.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void esp_retentionheap_initialize(void);
+
+/****************************************************************************
+ * Name: esp_retentionheap_malloc
+ *
+ * Description:
+ * Allocate memory from the retention heap.
+ *
+ * Input Parameters:
+ * size - Size to allocate memory in bytes
+ *
+ * Returned Value:
+ * Valid address reference on success; NULL, otherwise.
+ *
+ ****************************************************************************/
+
+void *esp_retentionheap_malloc(size_t size);
+
+/****************************************************************************
+ * Name: esp_retentionheap_calloc
+ *
+ * Description:
+ * Calculates the size of the allocation and allocate memory from
+ * the retention heap.
+ *
+ * Input Parameters:
+ * n - Number of elements to allocate.
+ * elem_size - Size of each element, in bytes.
+ *
+ * Returned Value:
+ * Valid address reference on success; NULL, otherwise.
+ *
+ ****************************************************************************/
+
+void *esp_retentionheap_calloc(size_t n, size_t elem_size);
+
+/****************************************************************************
+ * Name: esp_retentionheap_memalign
+ *
+ * Description:
+ * memalign requests more than enough space from malloc, finds a region
+ * within that chunk that meets the alignment request and then frees any
+ * leading or trailing space.
+ *
+ * The alignment argument must be a power of two (not checked). 8-byte
+ * alignment is guaranteed by normal malloc calls.
+ *
+ * Input Parameters:
+ * alignment - Required byte alignment; must be a power of two and usually
+ * at least sizeof(void *).
+ * size - Number of bytes to allocate.
+ *
+ * Returned Value:
+ * Valid address reference on success; NULL, otherwise.
+ *
+ ****************************************************************************/
+
+void *esp_retentionheap_memalign(size_t alignment, size_t size);
+
+/****************************************************************************
+ * Name: esp_retentionheap_realloc
+ *
+ * Description:
+ * Reallocate memory from the retention heap.
+ *
+ * Input Parameters:
+ * mem - The address to reallocate
+ * size - New requested size
+ *
+ * Returned Value:
+ * Valid address reference on success; NULL, otherwise.
+ *
+ ****************************************************************************/
+
+void *esp_retentionheap_realloc(void *ptr, size_t size);
+
+/****************************************************************************
+ * Name: esp_retentionheap_free
+ *
+ * Description:
+ * Free memory from the retention heap.
+ *
+ * Input Parameters:
+ * mem - The address to free
+ *
+ * Returned Value:
+ * None.
+ *
+ ****************************************************************************/
+
+void esp_retentionheap_free(void *mem);
+
+/****************************************************************************
+ * Name: esp_retentionheap_heapmember
+ *
+ * Description:
+ * Check if an address lies in the retention heap.
+ *
+ * Parameters:
+ * mem - The address to check
+ *
+ * Return Value:
+ * True if the address is a member of the RTC heap. false if not
+ *
+ ****************************************************************************/
+
+bool esp_retentionheap_heapmember(void *mem);
+
+/****************************************************************************
+ * Name: esp_retentionheap_malloc_size
+ *
+ * Description:
+ * Get size of the allocated space in retention heap
+ *
+ * Input Parameters:
+ * mem - The address to check
+ *
+ * Returned Value:
+ * Size of allocated space related to address.
+ *
+ ****************************************************************************/
+
+size_t esp_retentionheap_malloc_size(void *mem);
+
+#endif /* CONFIG_ESPRESSIF_RETENTION_HEAP */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ARCH_RISC_V_SRC_COMMON_ESPRESSIF_ESP_RETENTIONHEAP_H */
diff --git a/arch/risc-v/src/common/espressif/esp_tickless.c b/arch/risc-v/src/common/espressif/esp_tickless.c
index 7d76fb6711d..fa6769f38f0 100644
--- a/arch/risc-v/src/common/espressif/esp_tickless.c
+++ b/arch/risc-v/src/common/espressif/esp_tickless.c
@@ -117,7 +117,7 @@ static int esp_tickless_isr(int irq, void *context, void *arg)
*
* Returned Value:
* The time in system ticks remaining for idle.
- * Zero means system is busy.
+ * Zero means that the system is in idle mode without any timer running.
*
****************************************************************************/
diff --git a/arch/risc-v/src/common/espressif/esp_tickless.h b/arch/risc-v/src/common/espressif/esp_tickless.h
index 93203b7f929..6c4cc25b96f 100644
--- a/arch/risc-v/src/common/espressif/esp_tickless.h
+++ b/arch/risc-v/src/common/espressif/esp_tickless.h
@@ -46,7 +46,7 @@
*
* Returned Value:
* The time in system ticks remaining for idle.
- * Zero means system is busy.
+ * Zero means that the system is in idle mode without any timer running.
*
****************************************************************************/
diff --git a/arch/risc-v/src/esp32c3/hal_esp32c3.cmake b/arch/risc-v/src/esp32c3/hal_esp32c3.cmake
index c537ba0263d..3ed2ce93a4b 100644
--- a/arch/risc-v/src/esp32c3/hal_esp32c3.cmake
+++ b/arch/risc-v/src/esp32c3/hal_esp32c3.cmake
@@ -64,6 +64,7 @@ target_include_directories(
${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_gpio/include
${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_rmt/include
${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_rmt/src
+ ${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_uart/include
# ESP HAL RMT (hal/rmt_hal.h)
${ESP_HAL_3RDPARTY_REPO}/components/esp_hal_rmt/include
${ESP_HAL_3RDPARTY_REPO}/components/esp_hal_rmt/${CHIP_SERIES}/include
@@ -89,6 +90,7 @@ target_include_directories(
${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/${CHIP_SERIES}/include
${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/include
# ESP PM
+ ${ESP_HAL_3RDPARTY_REPO}/components/esp_pm
${ESP_HAL_3RDPARTY_REPO}/components/esp_pm/include
# ESP ROM
${ESP_HAL_3RDPARTY_REPO}/components/esp_rom
@@ -302,7 +304,7 @@ list(
${ESP_HAL_3RDPARTY_REPO}/components/esp_mm/esp_mmu_map.c
${ESP_HAL_3RDPARTY_REPO}/components/esp_mm/esp_cache_utils.c
${ESP_HAL_3RDPARTY_REPO}/components/esp_mm/port/${CHIP_SERIES}/ext_mem_layout.c
-)
+ ${ESP_HAL_3RDPARTY_REPO}/components/heap/port/${CHIP_SERIES}/memory_layout.c)
# ESP PHY sources
list(
@@ -313,6 +315,10 @@ list(
${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/src/phy_init.c
${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/${CHIP_SERIES}/phy_init_data.c)
+# ESP PM sources
+list(APPEND HAL_SRCS ${ESP_HAL_3RDPARTY_REPO}/components/esp_pm/pm_locks.c
+ ${ESP_HAL_3RDPARTY_REPO}/components/esp_pm/pm_impl.c)
+
# ESP ROM sources
list(
APPEND
@@ -408,7 +414,8 @@ list(
HAL_SRCS
${ESP_HAL_3RDPARTY_REPO}/components/riscv/instruction_decode.c
${ESP_HAL_3RDPARTY_REPO}/components/riscv/interrupt.c
- ${ESP_HAL_3RDPARTY_REPO}/components/riscv/interrupt_intc.c)
+ ${ESP_HAL_3RDPARTY_REPO}/components/riscv/interrupt_intc.c
+ ${ESP_HAL_3RDPARTY_REPO}/components/riscv/rv_utils.c)
# SPI Flash sources
list(
@@ -478,7 +485,8 @@ list(
${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_rmt/src/rmt_encoder_copy.c
${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_rmt/src/rmt_encoder_simple.c
${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_rmt/src/rmt_rx.c
- ${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_rmt/src/rmt_tx.c)
+ ${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_rmt/src/rmt_tx.c
+ ${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_uart/src/uart_wakeup.c)
# Bootloader flash encrypt source
list(APPEND HAL_SRCS
diff --git a/arch/risc-v/src/esp32c3/hal_esp32c3.mk b/arch/risc-v/src/esp32c3/hal_esp32c3.mk
index bfd250f5596..2ac5e04f16a 100644
--- a/arch/risc-v/src/esp32c3/hal_esp32c3.mk
+++ b/arch/risc-v/src/esp32c3/hal_esp32c3.mk
@@ -104,6 +104,7 @@ INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_mm$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)$(CHIP_SERIES)$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)include
@@ -145,6 +146,7 @@ INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_gpio$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_rmt$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_rmt$(DELIM)src
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_uart$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)src$(DELIM)components$(DELIM)esp_libc$(DELIM)platform_include
ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y)
@@ -225,6 +227,8 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)src$(DELIM)phy_common.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)src$(DELIM)phy_init.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)$(CHIP_SERIES)$(DELIM)phy_init_data.c
+CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm$(DELIM)pm_locks.c
+CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm$(DELIM)pm_impl.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)patches$(DELIM)esp_rom_sys.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)patches$(DELIM)esp_rom_print.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)patches$(DELIM)esp_rom_crc.c
@@ -280,6 +284,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hal_wdt$(DELIM)xt_wdt_hal.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hal_clock$(DELIM)$(CHIP_SERIES)$(DELIM)clk_tree_hal.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)hal$(DELIM)$(CHIP_SERIES)$(DELIM)efuse_hal.c
+CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)heap$(DELIM)port$(DELIM)${CHIP_SERIES}$(DELIM)memory_layout.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log$(DELIM)src$(DELIM)log.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log$(DELIM)src$(DELIM)log_level$(DELIM)log_level.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)log$(DELIM)src$(DELIM)log_level$(DELIM)tag_log_level$(DELIM)tag_log_level.c
@@ -309,6 +314,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)spi_
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)spi_flash$(DELIM)flash_mmap.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)spi_flash$(DELIM)flash_brownout_hook.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)spi_flash$(DELIM)cache_utils.c
+CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)riscv$(DELIM)rv_utils.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)lldesc.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hal_ana_conv$(DELIM)$(CHIP_SERIES)$(DELIM)adc_periph.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hal_gpio$(DELIM)$(CHIP_SERIES)$(DELIM)dedic_gpio_periph.c
@@ -341,6 +347,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)uppe
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_rmt$(DELIM)src$(DELIM)rmt_encoder_simple.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_rmt$(DELIM)src$(DELIM)rmt_rx.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_rmt$(DELIM)src$(DELIM)rmt_tx.c
+CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_uart$(DELIM)src$(DELIM)uart_wakeup.c
# Bootloader files
diff --git a/arch/risc-v/src/esp32c6/hal_esp32c6.cmake b/arch/risc-v/src/esp32c6/hal_esp32c6.cmake
index 009462aca60..980be2254f5 100644
--- a/arch/risc-v/src/esp32c6/hal_esp32c6.cmake
+++ b/arch/risc-v/src/esp32c6/hal_esp32c6.cmake
@@ -112,6 +112,7 @@ target_include_directories(
${ESP_HAL_3RDPARTY_REPO}/components/esp_mm/include
${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/${CHIP_SERIES}/include
${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/include
+ ${ESP_HAL_3RDPARTY_REPO}/components/esp_pm
${ESP_HAL_3RDPARTY_REPO}/components/esp_pm/include
${ESP_HAL_3RDPARTY_REPO}/components/esp_rom
${ESP_HAL_3RDPARTY_REPO}/components/esp_rom/include
@@ -317,7 +318,8 @@ list(
${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/${CHIP_SERIES}/phy_init_data.c)
# ESP PM
-list(APPEND HAL_SRCS ${ESP_HAL_3RDPARTY_REPO}/components/esp_pm/pm_impl.c)
+list(APPEND HAL_SRCS ${ESP_HAL_3RDPARTY_REPO}/components/esp_pm/pm_locks.c
+ ${ESP_HAL_3RDPARTY_REPO}/components/esp_pm/pm_impl.c)
# ESP ROM
list(
@@ -497,7 +499,8 @@ list(
${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_rmt/src/rmt_rx.c
${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_rmt/src/rmt_tx.c
${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_gpio/src/gpio.c
- ${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_gpio/src/rtc_io.c)
+ ${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_gpio/src/rtc_io.c
+ ${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_uart/src/uart_wakeup.c)
# Sleep ASM
list(
diff --git a/arch/risc-v/src/esp32c6/hal_esp32c6.mk b/arch/risc-v/src/esp32c6/hal_esp32c6.mk
index 6b424c69153..578c936a747 100644
--- a/arch/risc-v/src/esp32c6/hal_esp32c6.mk
+++ b/arch/risc-v/src/esp32c6/hal_esp32c6.mk
@@ -100,6 +100,7 @@ INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_mm$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)$(CHIP_SERIES)$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)include
@@ -250,6 +251,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)src$(DELIM)phy_common.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)src$(DELIM)phy_init.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)$(CHIP_SERIES)$(DELIM)phy_init_data.c
+CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm$(DELIM)pm_locks.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm$(DELIM)pm_impl.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)patches$(DELIM)esp_rom_sys.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)patches$(DELIM)esp_rom_print.c
@@ -373,9 +375,9 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)uppe
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_rmt$(DELIM)src$(DELIM)rmt_tx.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_gpio$(DELIM)src$(DELIM)gpio.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_gpio$(DELIM)src$(DELIM)rtc_io.c
+CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)upper_hal_uart$(DELIM)src$(DELIM)uart_wakeup.c
CHIP_ASRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)lowpower$(DELIM)port$(DELIM)esp32c6$(DELIM)sleep_cpu_asm.S
-
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)src$(DELIM)platform$(DELIM)os.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)src$(DELIM)heap_caps.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)src$(DELIM)components$(DELIM)newlib$(DELIM)newlib$(DELIM)libc$(DELIM)misc$(DELIM)init.c
diff --git a/arch/risc-v/src/esp32h2/hal_esp32h2.cmake b/arch/risc-v/src/esp32h2/hal_esp32h2.cmake
index d3e0ae94762..9794b785892 100644
--- a/arch/risc-v/src/esp32h2/hal_esp32h2.cmake
+++ b/arch/risc-v/src/esp32h2/hal_esp32h2.cmake
@@ -111,6 +111,7 @@ target_include_directories(
${ESP_HAL_3RDPARTY_REPO}/components/esp_hw_support/port/${CHIP_SERIES}/private_include
${ESP_HAL_3RDPARTY_REPO}/components/esp_hw_support/power_supply/include
${ESP_HAL_3RDPARTY_REPO}/components/esp_mm/include
+ ${ESP_HAL_3RDPARTY_REPO}/components/esp_pm
${ESP_HAL_3RDPARTY_REPO}/components/esp_pm/include
${ESP_HAL_3RDPARTY_REPO}/components/esp_rom
${ESP_HAL_3RDPARTY_REPO}/components/esp_rom/include
@@ -304,7 +305,8 @@ list(
)
# ESP PM
-list(APPEND HAL_SRCS ${ESP_HAL_3RDPARTY_REPO}/components/esp_pm/pm_impl.c)
+list(APPEND HAL_SRCS ${ESP_HAL_3RDPARTY_REPO}/components/esp_pm/pm_locks.c
+ ${ESP_HAL_3RDPARTY_REPO}/components/esp_pm/pm_impl.c)
# ESP ROM
list(
@@ -474,7 +476,8 @@ list(
${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_rmt/src/rmt_rx.c
${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_rmt/src/rmt_tx.c
${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_gpio/src/gpio.c
- ${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_gpio/src/rtc_io.c)
+ ${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_gpio/src/rtc_io.c
+ ${ESP_HAL_3RDPARTY_REPO}/components/upper_hal_uart/src/uart_wakeup.c)
# Sleep ASM
list(
diff --git a/arch/risc-v/src/esp32h2/hal_esp32h2.mk b/arch/risc-v/src/esp32h2/hal_esp32h2.mk
index dcbc41f1cab..8888da1aad0 100644
--- a/arch/risc-v/src/esp32h2/hal_esp32h2.mk
+++ b/arch/risc-v/src/esp32h2/hal_esp32h2.mk
@@ -98,6 +98,7 @@ INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)port$(DELIM)$(CHIP_SERIES)$(DELIM)private_include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)power_supply$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_mm$(DELIM)include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)include
@@ -231,6 +232,8 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_mm$(DELIM)esp_mmu_map.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_mm$(DELIM)esp_cache_utils.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_mm$(DELIM)port$(DELIM)$(CHIP_SERIES)$(DELIM)ext_mem_layout.c
+CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm$(DELIM)pm_locks.c
+CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm$(DELIM)pm_impl.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)patches$(DELIM)esp_rom_sys.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)patches$(DELIM)esp_rom_print.c
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)patches$(DELIM)esp_rom_crc.c
diff --git a/arch/risc-v/src/esp32p4/hal_esp32p4.cmake b/arch/risc-v/src/esp32p4/hal_esp32p4.cmake
index 93e492540a7..3dc54744188 100644
--- a/arch/risc-v/src/esp32p4/hal_esp32p4.cmake
+++ b/arch/risc-v/src/esp32p4/hal_esp32p4.cmake
@@ -116,6 +116,7 @@ set(ESP32P4_INCLUDES
${ESP_HAL_3RDPARTY_REPO}/components/esp_hw_support/power_supply/include
${ESP_HAL_3RDPARTY_REPO}/components/esp_libc/priv_include
${ESP_HAL_3RDPARTY_REPO}/components/esp_mm/include
+ ${ESP_HAL_3RDPARTY_REPO}/components/esp_pm
${ESP_HAL_3RDPARTY_REPO}/components/esp_pm/include
${ESP_HAL_3RDPARTY_REPO}/components/esp_rom/${CHIP_SERIES}
${ESP_HAL_3RDPARTY_REPO}/components/esp_rom/${CHIP_SERIES}/include
diff --git a/arch/risc-v/src/esp32p4/hal_esp32p4.mk b/arch/risc-v/src/esp32p4/hal_esp32p4.mk
index eb78122edb7..5fa42d34cc5 100644
--- a/arch/risc-v/src/esp32p4/hal_esp32p4.mk
+++ b/arch/risc-v/src/esp32p4/hal_esp32p4.mk
@@ -106,6 +106,7 @@ INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)power_supply$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_libc$(DELIM)priv_include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_mm$(DELIM)include
+INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_pm$(DELIM)include
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)$(CHIP_SERIES)
INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_rom$(DELIM)$(CHIP_SERIES)$(DELIM)include
diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs
index 807f7de0ed2..e072a06322b 100644
--- a/arch/xtensa/src/esp32/Make.defs
+++ b/arch/xtensa/src/esp32/Make.defs
@@ -194,7 +194,7 @@ endif
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
ifndef ESP_HAL_3RDPARTY_VERSION
- ESP_HAL_3RDPARTY_VERSION = 6c272b562a73107a852d44b9c6fb5df57245cbd7
+ ESP_HAL_3RDPARTY_VERSION = b7e51db97a3f9dc82d3b3524d2bad298ba1e2647
endif
ifndef ESP_HAL_3RDPARTY_URL
diff --git a/arch/xtensa/src/esp32s2/Make.defs b/arch/xtensa/src/esp32s2/Make.defs
index 91e982e226d..cf75d566028 100644
--- a/arch/xtensa/src/esp32s2/Make.defs
+++ b/arch/xtensa/src/esp32s2/Make.defs
@@ -127,7 +127,7 @@ endif
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
ifndef ESP_HAL_3RDPARTY_VERSION
- ESP_HAL_3RDPARTY_VERSION = 6c272b562a73107a852d44b9c6fb5df57245cbd7
+ ESP_HAL_3RDPARTY_VERSION = b7e51db97a3f9dc82d3b3524d2bad298ba1e2647
endif
ifndef ESP_HAL_3RDPARTY_URL
diff --git a/arch/xtensa/src/esp32s3/Make.defs b/arch/xtensa/src/esp32s3/Make.defs
index 2805b639792..3e0355ceaef 100644
--- a/arch/xtensa/src/esp32s3/Make.defs
+++ b/arch/xtensa/src/esp32s3/Make.defs
@@ -192,7 +192,7 @@ endif
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
ifndef ESP_HAL_3RDPARTY_VERSION
- ESP_HAL_3RDPARTY_VERSION = 6c272b562a73107a852d44b9c6fb5df57245cbd7
+ ESP_HAL_3RDPARTY_VERSION = b7e51db97a3f9dc82d3b3524d2bad298ba1e2647
endif
ifndef ESP_HAL_3RDPARTY_URL
diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
index 3b7b5e7db69..f8f46763d6a 100644
--- a/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
+++ b/boards/risc-v/esp32c3/esp32c3-devkit/src/esp32c3_bringup.c
@@ -457,6 +457,16 @@ int esp_bringup(void)
}
#endif /* CONFIG_ESPRESSIF_LEDC */
+#ifdef CONFIG_ESPRESSIF_AUTO_SLEEP
+ /* Configure PM */
+
+ ret = esp_pmconfigure();
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: esp_pmconfigure failed: %d\n", ret);
+ }
+#endif
+
#ifdef CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP_WO_TOOL
ret = esp_nxdiag_initialize();
if (ret < 0)