Merge branch 'master' into feature/esp32s2beta_merge

This commit is contained in:
Angus Gratton
2019-09-19 21:17:31 +10:00
committed by Angus Gratton
129 changed files with 1751 additions and 1431 deletions

View File

@@ -385,7 +385,7 @@ menu "ESP32-specific"
config ESP32_DEBUG_STUBS_ENABLE
bool "OpenOCD debug stubs"
default COMPILER_OPTIMIZATION_LEVEL_DEBUG
default COMPILER_OPTIMIZATION_DEFAULT
depends on !ESP32_TRAX
help
Debug stubs are used by OpenOCD to execute pre-compiled onboard code which does some useful debugging,

View File

@@ -43,7 +43,7 @@
#include "sdkconfig.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#include "esp_flash.h"
#include "esp_flash_internal.h"
#include "nvs_flash.h"
#include "esp_event.h"
#include "esp_spi_flash.h"
@@ -395,20 +395,9 @@ void start_cpu0_default(void)
/* init default OS-aware flash access critical section */
spi_flash_guard_set(&g_flash_guard_default_ops);
#ifndef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
esp_flash_app_init();
esp_err_t flash_ret = esp_flash_init_default_chip();
assert(flash_ret == ESP_OK);
#endif
uint8_t revision = esp_efuse_get_chip_ver();
ESP_LOGI(TAG, "Chip Revision: %d", revision);
if (revision > CONFIG_ESP32_REV_MIN) {
ESP_LOGW(TAG, "Chip revision is higher than the one configured in menuconfig. Suggest to upgrade it.");
} else if(revision != CONFIG_ESP32_REV_MIN) {
ESP_LOGE(TAG, "ESP-IDF can't support this chip revision. Modify minimum supported revision in menuconfig");
abort();
}
#ifdef CONFIG_PM_ENABLE
esp_pm_impl_init();

View File

@@ -31,9 +31,7 @@ extern "C" {
* Pass a pointer to this structure as an argument to esp_pm_configure function.
*/
typedef struct {
rtc_cpu_freq_t max_cpu_freq __attribute__((deprecated)); /*!< Maximum CPU frequency to use. Deprecated, use max_freq_mhz instead. */
int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */
rtc_cpu_freq_t min_cpu_freq __attribute__((deprecated)); /*!< Minimum CPU frequency to use when no frequency locks are taken. Deprecated, use min_freq_mhz instead. */
int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */
bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */
} esp_pm_config_esp32_t;

View File

@@ -295,16 +295,6 @@ esp_err_t esp_light_sleep_start(void);
*/
void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn));
/**
* @brief Enter deep-sleep mode
*
* Function has been renamed to esp_deep_sleep.
* This name is deprecated and will be removed in a future version.
*
* @param time_in_us deep-sleep time, unit: microsecond
*/
void system_deep_sleep(uint64_t time_in_us) __attribute__((noreturn, deprecated));
/**
* @brief Get the wakeup source which caused wakeup from sleep

View File

@@ -182,15 +182,6 @@ esp_err_t esp_pm_configure(const void* vconfig)
int min_freq_mhz = config->min_freq_mhz;
int max_freq_mhz = config->max_freq_mhz;
if (min_freq_mhz == 0 && max_freq_mhz == 0) {
/* For compatibility, handle deprecated fields, min_cpu_freq and max_cpu_freq. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
min_freq_mhz = rtc_clk_cpu_freq_value(config->min_cpu_freq) / MHZ;
max_freq_mhz = rtc_clk_cpu_freq_value(config->max_cpu_freq) / MHZ;
#pragma GCC diagnostic pop
}
if (min_freq_mhz > max_freq_mhz) {
return ESP_ERR_INVALID_ARG;
}

View File

@@ -360,8 +360,6 @@ esp_err_t esp_light_sleep_start(void)
return err;
}
void system_deep_sleep(uint64_t) __attribute__((alias("esp_deep_sleep")));
esp_err_t esp_sleep_disable_wakeup_source(esp_sleep_source_t source)
{
// For most of sources it is enough to set trigger mask in local

View File

@@ -47,10 +47,6 @@ static uint8_t base_mac_addr[6] = { 0 };
#define SHUTDOWN_HANDLERS_NO 2
static shutdown_handler_t shutdown_handlers[SHUTDOWN_HANDLERS_NO];
void system_init(void)
{
}
esp_err_t esp_base_mac_addr_set(uint8_t *mac)
{
if (mac == NULL) {
@@ -122,9 +118,6 @@ esp_err_t esp_efuse_mac_get_default(uint8_t* mac)
return ESP_OK;
}
esp_err_t system_efuse_read_mac(uint8_t *mac) __attribute__((alias("esp_efuse_mac_get_default")));
esp_err_t esp_efuse_read_mac(uint8_t *mac) __attribute__((alias("esp_efuse_mac_get_default")));
esp_err_t esp_derive_local_mac(uint8_t* local_mac, const uint8_t* universal_mac)
{
uint8_t idx;
@@ -344,8 +337,6 @@ void IRAM_ATTR esp_restart_noos(void)
}
}
void system_restart(void) __attribute__((alias("esp_restart")));
uint32_t esp_get_free_heap_size( void )
{
return heap_caps_get_free_size( MALLOC_CAP_DEFAULT );
@@ -356,13 +347,6 @@ uint32_t esp_get_minimum_free_heap_size( void )
return heap_caps_get_minimum_free_size( MALLOC_CAP_DEFAULT );
}
uint32_t system_get_free_heap_size(void) __attribute__((alias("esp_get_free_heap_size")));
const char* system_get_sdk_version(void)
{
return "master";
}
const char* esp_get_idf_version(void)
{
return IDF_VER;

View File

@@ -387,46 +387,3 @@ esp_err_t esp_task_wdt_status(TaskHandle_t handle)
portEXIT_CRITICAL(&twdt_spinlock);
return ESP_ERR_NOT_FOUND;
}
void esp_task_wdt_feed(void)
{
portENTER_CRITICAL(&twdt_spinlock);
//Return immediately if TWDT has not been initialized
ASSERT_EXIT_CRIT_RETURN((twdt_config != NULL), VOID_RETURN);
//Check if task is on list
TaskHandle_t handle = xTaskGetCurrentTaskHandle();
bool all_reset;
twdt_task_t *target_task = find_task_in_twdt_list(handle, &all_reset);
//reset the task if it's on the list, then return
if(target_task != NULL){
target_task->has_reset = true;
if(all_reset){
reset_hw_timer(); //Reset hardware timer if all other tasks have reset
}
portEXIT_CRITICAL(&twdt_spinlock);
return;
}
//Add task if it's has not on list
target_task = calloc(1, sizeof(twdt_task_t));
ASSERT_EXIT_CRIT_RETURN((target_task != NULL), VOID_RETURN); //If calloc failed
target_task->task_handle = handle;
target_task->has_reset = true;
target_task->next = NULL;
if (twdt_config->list == NULL) { //Adding to empty list
twdt_config->list = target_task;
} else { //Adding to tail of list
twdt_task_t *task;
for (task = twdt_config->list; task->next != NULL; task = task->next){
; //point task to current tail of wdt task list
}
task->next = target_task;
}
portEXIT_CRITICAL(&twdt_spinlock);
}

View File

@@ -15,6 +15,8 @@
#include "esp32/ulp.h"
#include "soc/rtc_periph.h"
#define MHZ 1000000
TEST_CASE("Can dump power management lock stats", "[pm]")
{
esp_pm_dump_locks(stdout);
@@ -31,15 +33,15 @@ static void switch_freq(int mhz)
};
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
printf("Waiting for frequency to be set to %d MHz...\n", mhz);
while (esp_clk_cpu_freq() / 1000000 != mhz) {
while (esp_clk_cpu_freq() / MHZ != mhz) {
vTaskDelay(pdMS_TO_TICKS(200));
printf("Frequency is %d MHz\n", esp_clk_cpu_freq() / 1000000);
printf("Frequency is %d MHz\n", esp_clk_cpu_freq() / MHZ);
}
}
TEST_CASE("Can switch frequency using esp_pm_configure", "[pm]")
{
int orig_freq_mhz = esp_clk_cpu_freq() / 1000000;
int orig_freq_mhz = esp_clk_cpu_freq() / MHZ;
switch_freq(240);
switch_freq(40);
switch_freq(160);
@@ -60,9 +62,12 @@ TEST_CASE("Can switch frequency using esp_pm_configure", "[pm]")
static void light_sleep_enable(void)
{
int cur_freq_mhz = esp_clk_cpu_freq() / MHZ;
int xtal_freq = (int) rtc_clk_xtal_freq_get();
const esp_pm_config_esp32_t pm_config = {
.max_cpu_freq = rtc_clk_cpu_freq_get(),
.min_cpu_freq = RTC_CPU_FREQ_XTAL,
.max_freq_mhz = cur_freq_mhz,
.min_freq_mhz = xtal_freq,
.light_sleep_enable = true
};
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
@@ -70,9 +75,11 @@ static void light_sleep_enable(void)
static void light_sleep_disable(void)
{
int cur_freq_mhz = esp_clk_cpu_freq() / MHZ;
const esp_pm_config_esp32_t pm_config = {
.max_cpu_freq = rtc_clk_cpu_freq_get(),
.min_cpu_freq = rtc_clk_cpu_freq_get(),
.max_freq_mhz = cur_freq_mhz,
.min_freq_mhz = cur_freq_mhz,
};
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
}