mirror of
https://github.com/espressif/esp-idf.git
synced 2026-05-05 12:25:03 +02:00
esp32: move brownout and cache err int setup
This commit is contained in:
@@ -12,7 +12,6 @@ if(BOOTLOADER_BUILD)
|
||||
else()
|
||||
# Regular app build
|
||||
set(srcs
|
||||
"cache_err_int.c"
|
||||
"cache_sram_mmu.c"
|
||||
"clk.c"
|
||||
"crosscore_int.c"
|
||||
|
||||
@@ -487,18 +487,6 @@ menu "ESP32-specific"
|
||||
default 6 if ESP32_BROWNOUT_DET_LVL_SEL_6
|
||||
default 7 if ESP32_BROWNOUT_DET_LVL_SEL_7
|
||||
|
||||
|
||||
#Reduce PHY TX power when brownout reset
|
||||
config ESP32_REDUCE_PHY_TX_POWER
|
||||
bool "Reduce PHY TX power when brownout reset"
|
||||
depends on ESP32_BROWNOUT_DET
|
||||
default y
|
||||
help
|
||||
When brownout reset occurs, reduce PHY TX power to keep the code running
|
||||
|
||||
# Note about the use of "FRC1" name: currently FRC1 timer is not used for
|
||||
# high resolution timekeeping anymore. Instead the esp_timer API is used.
|
||||
# FRC1 name in the option name is kept for compatibility.
|
||||
choice ESP32_TIME_SYSCALL
|
||||
prompt "Timers used for gettimeofday function"
|
||||
default ESP32_TIME_SYSCALL_USE_RTC_FRC1
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed 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.
|
||||
|
||||
/*
|
||||
The cache has an interrupt that can be raised as soon as an access to a cached
|
||||
region (flash, psram) is done without the cache being enabled. We use that here
|
||||
to panic the CPU, which from a debugging perspective is better than grabbing bad
|
||||
data from the bus.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "hal/cpu_hal.h"
|
||||
|
||||
#include "esp32/dport_access.h"
|
||||
#include "esp32/rom/ets_sys.h" // for intr_matrix_set
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
void esp_cache_err_int_init(void)
|
||||
{
|
||||
uint32_t core_id = cpu_hal_get_core_id();
|
||||
ESP_INTR_DISABLE(ETS_MEMACCESS_ERR_INUM);
|
||||
|
||||
// We do not register a handler for the interrupt because it is interrupt
|
||||
// level 4 which is not serviceable from C. Instead, xtensa_vectors.S has
|
||||
// a call to the panic handler for
|
||||
// this interrupt.
|
||||
intr_matrix_set(core_id, ETS_CACHE_IA_INTR_SOURCE, ETS_MEMACCESS_ERR_INUM);
|
||||
|
||||
// Enable invalid cache access interrupt when the cache is disabled.
|
||||
// When the interrupt happens, we can not determine the CPU where the
|
||||
// invalid cache access has occurred. We enable the interrupt to catch
|
||||
// invalid access on both CPUs, but the interrupt is connected to the
|
||||
// CPU which happens to call this function.
|
||||
// For this reason, panic handler backtrace will not be correct if the
|
||||
// interrupt is connected to PRO CPU and invalid access happens on the APP
|
||||
// CPU.
|
||||
|
||||
if (core_id == PRO_CPU_NUM) {
|
||||
DPORT_SET_PERI_REG_MASK(DPORT_CACHE_IA_INT_EN_REG,
|
||||
DPORT_CACHE_IA_INT_PRO_OPPOSITE |
|
||||
DPORT_CACHE_IA_INT_PRO_DRAM1 |
|
||||
DPORT_CACHE_IA_INT_PRO_DROM0 |
|
||||
DPORT_CACHE_IA_INT_PRO_IROM0 |
|
||||
DPORT_CACHE_IA_INT_PRO_IRAM0 |
|
||||
DPORT_CACHE_IA_INT_PRO_IRAM1);
|
||||
} else {
|
||||
DPORT_SET_PERI_REG_MASK(DPORT_CACHE_IA_INT_EN_REG,
|
||||
DPORT_CACHE_IA_INT_APP_OPPOSITE |
|
||||
DPORT_CACHE_IA_INT_APP_DRAM1 |
|
||||
DPORT_CACHE_IA_INT_APP_DROM0 |
|
||||
DPORT_CACHE_IA_INT_APP_IROM0 |
|
||||
DPORT_CACHE_IA_INT_APP_IRAM0 |
|
||||
DPORT_CACHE_IA_INT_APP_IRAM1);
|
||||
}
|
||||
ESP_INTR_ENABLE(ETS_MEMACCESS_ERR_INUM);
|
||||
}
|
||||
|
||||
int IRAM_ATTR esp_cache_err_get_cpuid(void)
|
||||
{
|
||||
const uint32_t pro_mask =
|
||||
DPORT_PRO_CPU_DISABLED_CACHE_IA_DRAM1 |
|
||||
DPORT_PRO_CPU_DISABLED_CACHE_IA_DROM0 |
|
||||
DPORT_PRO_CPU_DISABLED_CACHE_IA_IROM0 |
|
||||
DPORT_PRO_CPU_DISABLED_CACHE_IA_IRAM0 |
|
||||
DPORT_PRO_CPU_DISABLED_CACHE_IA_IRAM1 |
|
||||
DPORT_APP_CPU_DISABLED_CACHE_IA_OPPOSITE;
|
||||
|
||||
if (DPORT_GET_PERI_REG_MASK(DPORT_PRO_DCACHE_DBUG3_REG, pro_mask)) {
|
||||
return PRO_CPU_NUM;
|
||||
}
|
||||
|
||||
const uint32_t app_mask =
|
||||
DPORT_APP_CPU_DISABLED_CACHE_IA_DRAM1 |
|
||||
DPORT_APP_CPU_DISABLED_CACHE_IA_DROM0 |
|
||||
DPORT_APP_CPU_DISABLED_CACHE_IA_IROM0 |
|
||||
DPORT_APP_CPU_DISABLED_CACHE_IA_IRAM0 |
|
||||
DPORT_APP_CPU_DISABLED_CACHE_IA_IRAM1 |
|
||||
DPORT_PRO_CPU_DISABLED_CACHE_IA_OPPOSITE;
|
||||
|
||||
if (DPORT_GET_PERI_REG_MASK(DPORT_APP_DCACHE_DBUG3_REG, app_mask)) {
|
||||
return APP_CPU_NUM;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed 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 __ESP_BROWNOUT_H
|
||||
#define __ESP_BROWNOUT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void esp_brownout_init(void);
|
||||
|
||||
void esp_brownout_disable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed 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.
|
||||
|
||||
|
||||
/**
|
||||
* @brief initialize cache invalid access interrupt
|
||||
*
|
||||
* This function enables cache invalid access interrupt source and connects it
|
||||
* to interrupt input number ETS_MEMACCESS_ERR_INUM (see soc/soc.h). It is called
|
||||
* from the startup code.
|
||||
*/
|
||||
void esp_cache_err_int_init(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief get the CPU which caused cache invalid access interrupt
|
||||
* @return
|
||||
* - PRO_CPU_NUM, if PRO_CPU has caused cache IA interrupt
|
||||
* - APP_CPU_NUM, if APP_CPU has caused cache IA interrupt
|
||||
* - (-1) otherwise
|
||||
*/
|
||||
int esp_cache_err_get_cpuid(void);
|
||||
@@ -31,7 +31,5 @@ CONFIG_BROWNOUT_DET_LVL_SEL_5 CONFIG_ESP32_BROWNOUT_DE
|
||||
CONFIG_BROWNOUT_DET_LVL_SEL_6 CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6
|
||||
CONFIG_BROWNOUT_DET_LVL_SEL_7 CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7
|
||||
CONFIG_BROWNOUT_DET_LVL CONFIG_ESP32_BROWNOUT_DET_LVL
|
||||
CONFIG_REDUCE_PHY_TX_POWER CONFIG_ESP32_REDUCE_PHY_TX_POWER
|
||||
|
||||
# SPI RAM config
|
||||
CONFIG_WIFI_LWIP_ALLOCATION_FROM_SPIRAM_FIRST CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
|
||||
#include "esp32/cache_err_int.h"
|
||||
|
||||
/* "inner" restart function for after RTOS, interrupts & anything else on this
|
||||
* core are already stopped. Stalls other core, resets hardware,
|
||||
* triggers restart.
|
||||
|
||||
Reference in New Issue
Block a user