Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
------

Expand Down
9 changes: 8 additions & 1 deletion arch/risc-v/src/common/espressif/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -199,7 +206,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()

Expand Down
17 changes: 17 additions & 0 deletions arch/risc-v/src/common/espressif/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion arch/risc-v/src/common/espressif/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions arch/risc-v/src/common/espressif/esp_allocateheap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down Expand Up @@ -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;
}

/****************************************************************************
Expand Down
43 changes: 43 additions & 0 deletions arch/risc-v/src/common/espressif/esp_extraheaps.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/****************************************************************************
* arch/risc-v/src/common/espressif/esp_extraheaps.c
*
* 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.
*
****************************************************************************/

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>
#include <nuttx/arch.h>

#ifdef CONFIG_ESPRESSIF_RETENTION_HEAP
# include "esp_retentionheap.h"
#endif

/****************************************************************************
* Public Functions
****************************************************************************/

void up_extraheaps_init(void)
{
#ifdef CONFIG_ESPRESSIF_RETENTION_HEAP
esp_retentionheap_initialize();
#endif
}
31 changes: 28 additions & 3 deletions arch/risc-v/src/common/espressif/esp_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
****************************************************************************/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */

Expand Down
Loading
Loading