mirror of
https://github.com/espressif/esp-idf.git
synced 2024-09-20 10:46:02 -04:00
esp32: reset APP CPU when doing esp_restart
This fixes a bug introduced by !848, where APP CPU would not be reset during esp_restart, if esp_restart was called from a task running on APP CPU, and wouldn’t be reset by PRO CPU on startup. This change replaces stalling APP CPU with resetting it. Also adds a non-automated esp_restart tests.
This commit is contained in:
parent
a72b1abc51
commit
9353666cc1
@ -298,6 +298,9 @@ void IRAM_ATTR esp_restart_noos()
|
||||
// Set CPU back to XTAL source, no PLL, same as hard reset
|
||||
rtc_clk_cpu_freq_set(RTC_CPU_FREQ_XTAL);
|
||||
|
||||
// Clear entry point for APP CPU
|
||||
DPORT_REG_WRITE(DPORT_APPCPU_CTRL_D_REG, 0);
|
||||
|
||||
// Reset CPUs
|
||||
if (core_id == 0) {
|
||||
// Running on PRO CPU: APP CPU is stalled. Can reset both CPUs.
|
||||
@ -305,10 +308,10 @@ void IRAM_ATTR esp_restart_noos()
|
||||
RTC_CNTL_SW_PROCPU_RST_M | RTC_CNTL_SW_APPCPU_RST_M);
|
||||
} else {
|
||||
// Running on APP CPU: need to reset PRO CPU and unstall it,
|
||||
// then stall APP CPU
|
||||
// then reset APP CPU
|
||||
SET_PERI_REG_MASK(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_SW_PROCPU_RST_M);
|
||||
esp_cpu_unstall(0);
|
||||
esp_cpu_stall(1);
|
||||
SET_PERI_REG_MASK(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_SW_APPCPU_RST_M);
|
||||
}
|
||||
while(true) {
|
||||
;
|
||||
|
26
components/esp32/test/test_restart.c
Normal file
26
components/esp32/test/test_restart.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include "unity.h"
|
||||
#include "esp_system.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
|
||||
TEST_CASE("restart from PRO CPU", "[restart][ignore]")
|
||||
{
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
static void restart_task(void* arg)
|
||||
{
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
TEST_CASE("restart from APP CPU", "[restart][ignore]")
|
||||
{
|
||||
xTaskCreatePinnedToCore(&restart_task, "restart", 2048, NULL, 5, NULL, 1);
|
||||
|
||||
while(true) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user