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.
// 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.
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) {
;
--- /dev/null
+#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) {
+ ;
+ }
+}
+
+