Skip to content

Commit 7250925

Browse files
authored
Merge pull request #3802 from tannewt/fix_s2_safe_mode
Store safe mode state in the RTC.
2 parents 054eafd + 44b56f7 commit 7250925

File tree

1 file changed

+11
-1
lines changed
  • ports/esp32s2/supervisor

1 file changed

+11
-1
lines changed

ports/esp32s2/supervisor/port.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@
5454
#include "peripherals/rmt.h"
5555
#include "peripherals/pcnt.h"
5656
#include "peripherals/timer.h"
57+
#include "components/esp_rom/include/esp_rom_uart.h"
5758
#include "components/heap/include/esp_heap_caps.h"
59+
#include "components/xtensa/include/esp_debug_helpers.h"
5860
#include "components/soc/soc/esp32s2/include/soc/cache_memory.h"
61+
#include "components/soc/soc/esp32s2/include/soc/rtc_cntl_reg.h"
5962

6063
#define HEAP_SIZE (48 * 1024)
6164

@@ -78,6 +81,11 @@ safe_mode_t port_init(void) {
7881
args.name = "CircuitPython Tick";
7982
esp_timer_create(&args, &_tick_timer);
8083

84+
#ifdef DEBUG
85+
// Send the ROM output out of the UART. This includes early logs.
86+
esp_rom_install_channel_putc(1, esp_rom_uart_putc);
87+
#endif
88+
8189
heap = NULL;
8290
never_reset_module_internal_pins();
8391

@@ -165,6 +173,7 @@ void reset_to_bootloader(void) {
165173
}
166174

167175
void reset_cpu(void) {
176+
esp_backtrace_print(100);
168177
esp_restart();
169178
}
170179

@@ -204,10 +213,11 @@ bool port_has_fixed_stack(void) {
204213

205214
// Place the word to save just after our BSS section that gets blanked.
206215
void port_set_saved_word(uint32_t value) {
216+
REG_WRITE(RTC_CNTL_STORE0_REG, value);
207217
}
208218

209219
uint32_t port_get_saved_word(void) {
210-
return 0;
220+
return REG_READ(RTC_CNTL_STORE0_REG);
211221
}
212222

213223
uint64_t port_get_raw_ticks(uint8_t* subticks) {

0 commit comments

Comments
 (0)