panic.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #include <stdlib.h>
  14. #include <xtensa/config/core.h>
  15. #include "rom/rtc.h"
  16. #include "rom/uart.h"
  17. #include "freertos/FreeRTOS.h"
  18. #include "freertos/task.h"
  19. #include "freertos/xtensa_api.h"
  20. #include "soc/uart_reg.h"
  21. #include "soc/io_mux_reg.h"
  22. #include "soc/dport_reg.h"
  23. #include "soc/rtc_cntl_reg.h"
  24. #include "soc/timer_group_struct.h"
  25. #include "soc/timer_group_reg.h"
  26. #include "soc/cpu.h"
  27. #include "soc/rtc.h"
  28. #include "esp_gdbstub.h"
  29. #include "esp_panic.h"
  30. #include "esp_attr.h"
  31. #include "esp_err.h"
  32. #include "esp_core_dump.h"
  33. #include "esp_spi_flash.h"
  34. #include "esp_cache_err_int.h"
  35. #include "esp_app_trace.h"
  36. /*
  37. Panic handlers; these get called when an unhandled exception occurs or the assembly-level
  38. task switching / interrupt code runs into an unrecoverable error. The default task stack
  39. overflow handler and abort handler are also in here.
  40. */
  41. /*
  42. Note: The linker script will put everything in this file in IRAM/DRAM, so it also works with flash cache disabled.
  43. */
  44. #if !CONFIG_ESP32_PANIC_SILENT_REBOOT
  45. //printf may be broken, so we fix our own printing fns...
  46. static void panicPutChar(char c)
  47. {
  48. while (((READ_PERI_REG(UART_STATUS_REG(CONFIG_CONSOLE_UART_NUM)) >> UART_TXFIFO_CNT_S)&UART_TXFIFO_CNT) >= 126) ;
  49. WRITE_PERI_REG(UART_FIFO_REG(CONFIG_CONSOLE_UART_NUM), c);
  50. }
  51. static void panicPutStr(const char *c)
  52. {
  53. int x = 0;
  54. while (c[x] != 0) {
  55. panicPutChar(c[x]);
  56. x++;
  57. }
  58. }
  59. static void panicPutHex(int a)
  60. {
  61. int x;
  62. int c;
  63. for (x = 0; x < 8; x++) {
  64. c = (a >> 28) & 0xf;
  65. if (c < 10) {
  66. panicPutChar('0' + c);
  67. } else {
  68. panicPutChar('a' + c - 10);
  69. }
  70. a <<= 4;
  71. }
  72. }
  73. static void panicPutDec(int a)
  74. {
  75. int n1, n2;
  76. n1 = a % 10;
  77. n2 = a / 10;
  78. if (n2 == 0) {
  79. panicPutChar(' ');
  80. } else {
  81. panicPutChar(n2 + '0');
  82. }
  83. panicPutChar(n1 + '0');
  84. }
  85. #else
  86. //No printing wanted. Stub out these functions.
  87. static void panicPutChar(char c) { }
  88. static void panicPutStr(const char *c) { }
  89. static void panicPutHex(int a) { }
  90. static void panicPutDec(int a) { }
  91. #endif
  92. void __attribute__((weak)) vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName )
  93. {
  94. panicPutStr("***ERROR*** A stack overflow in task ");
  95. panicPutStr((char *)pcTaskName);
  96. panicPutStr(" has been detected.\r\n");
  97. abort();
  98. }
  99. static bool abort_called;
  100. static __attribute__((noreturn)) inline void invoke_abort()
  101. {
  102. abort_called = true;
  103. #if CONFIG_ESP32_APPTRACE_ENABLE
  104. esp_apptrace_flush_nolock(ESP_APPTRACE_DEST_TRAX, ESP_APPTRACE_TRAX_BLOCK_SIZE*CONFIG_ESP32_APPTRACE_ONPANIC_HOST_FLUSH_TRAX_THRESH/100, CONFIG_ESP32_APPTRACE_ONPANIC_HOST_FLUSH_TMO);
  105. #endif
  106. while(1) {
  107. __asm__ ("break 0,0");
  108. *((int*) 0) = 0;
  109. }
  110. }
  111. void abort()
  112. {
  113. #if !CONFIG_ESP32_PANIC_SILENT_REBOOT
  114. ets_printf("abort() was called at PC 0x%08x on core %d\n", (intptr_t)__builtin_return_address(0) - 3, xPortGetCoreID());
  115. #endif
  116. invoke_abort();
  117. }
  118. static const char *edesc[] = {
  119. "IllegalInstruction", "Syscall", "InstructionFetchError", "LoadStoreError",
  120. "Level1Interrupt", "Alloca", "IntegerDivideByZero", "PCValue",
  121. "Privileged", "LoadStoreAlignment", "res", "res",
  122. "InstrPDAddrError", "LoadStorePIFDataError", "InstrPIFAddrError", "LoadStorePIFAddrError",
  123. "InstTLBMiss", "InstTLBMultiHit", "InstFetchPrivilege", "res",
  124. "InstrFetchProhibited", "res", "res", "res",
  125. "LoadStoreTLBMiss", "LoadStoreTLBMultihit", "LoadStorePrivilege", "res",
  126. "LoadProhibited", "StoreProhibited", "res", "res",
  127. "Cp0Dis", "Cp1Dis", "Cp2Dis", "Cp3Dis",
  128. "Cp4Dis", "Cp5Dis", "Cp6Dis", "Cp7Dis"
  129. };
  130. static void commonErrorHandler(XtExcFrame *frame);
  131. //The fact that we've panic'ed probably means the other CPU is now running wild, possibly
  132. //messing up the serial output, so we stall it here.
  133. static void haltOtherCore()
  134. {
  135. esp_cpu_stall( xPortGetCoreID() == 0 ? 1 : 0 );
  136. }
  137. static void setFirstBreakpoint(uint32_t pc)
  138. {
  139. asm(
  140. "wsr.ibreaka0 %0\n" \
  141. "rsr.ibreakenable a3\n" \
  142. "movi a4,1\n" \
  143. "or a4, a4, a3\n" \
  144. "wsr.ibreakenable a4\n" \
  145. ::"r"(pc):"a3", "a4");
  146. }
  147. void panicHandler(XtExcFrame *frame)
  148. {
  149. int core_id = xPortGetCoreID();
  150. //Please keep in sync with PANIC_RSN_* defines
  151. const char *reasons[] = {
  152. "Unknown reason",
  153. "Unhandled debug exception",
  154. "Double exception",
  155. "Unhandled kernel exception",
  156. "Coprocessor exception",
  157. "Interrupt wdt timeout on CPU0",
  158. "Interrupt wdt timeout on CPU1",
  159. "Cache disabled but cached memory region accessed",
  160. };
  161. const char *reason = reasons[0];
  162. //The panic reason is stored in the EXCCAUSE register.
  163. if (frame->exccause <= PANIC_RSN_MAX) {
  164. reason = reasons[frame->exccause];
  165. }
  166. if (frame->exccause == PANIC_RSN_CACHEERR && esp_cache_err_get_cpuid() != core_id) {
  167. // Cache error interrupt will be handled by the panic handler
  168. // on the other CPU.
  169. return;
  170. }
  171. haltOtherCore();
  172. panicPutStr("Guru Meditation Error: Core ");
  173. panicPutDec(core_id);
  174. panicPutStr(" panic'ed (");
  175. if (!abort_called) {
  176. panicPutStr(reason);
  177. panicPutStr(")\r\n");
  178. if (frame->exccause == PANIC_RSN_DEBUGEXCEPTION) {
  179. int debugRsn;
  180. asm("rsr.debugcause %0":"=r"(debugRsn));
  181. panicPutStr("Debug exception reason: ");
  182. if (debugRsn&XCHAL_DEBUGCAUSE_ICOUNT_MASK) panicPutStr("SingleStep ");
  183. if (debugRsn&XCHAL_DEBUGCAUSE_IBREAK_MASK) panicPutStr("HwBreakpoint ");
  184. if (debugRsn&XCHAL_DEBUGCAUSE_DBREAK_MASK) {
  185. //Unlike what the ISA manual says, this core seemingly distinguishes from a DBREAK
  186. //reason caused by watchdog 0 and one caused by watchdog 1 by setting bit 8 of the
  187. //debugcause if the cause is watchdog 1 and clearing it if it's watchdog 0.
  188. if (debugRsn&(1<<8)) {
  189. #if CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK
  190. panicPutStr("Stack canary watchpoint triggered ");
  191. #else
  192. panicPutStr("Watchpoint 1 triggered ");
  193. #endif
  194. } else {
  195. panicPutStr("Watchpoint 0 triggered ");
  196. }
  197. }
  198. if (debugRsn&XCHAL_DEBUGCAUSE_BREAK_MASK) panicPutStr("BREAK instr ");
  199. if (debugRsn&XCHAL_DEBUGCAUSE_BREAKN_MASK) panicPutStr("BREAKN instr ");
  200. if (debugRsn&XCHAL_DEBUGCAUSE_DEBUGINT_MASK) panicPutStr("DebugIntr ");
  201. panicPutStr("\r\n");
  202. }
  203. } else {
  204. panicPutStr("abort)\r\n");
  205. }
  206. if (esp_cpu_in_ocd_debug_mode()) {
  207. #if CONFIG_ESP32_APPTRACE_ENABLE
  208. esp_apptrace_flush_nolock(ESP_APPTRACE_DEST_TRAX, ESP_APPTRACE_TRAX_BLOCK_SIZE*CONFIG_ESP32_APPTRACE_ONPANIC_HOST_FLUSH_TRAX_THRESH/100, CONFIG_ESP32_APPTRACE_ONPANIC_HOST_FLUSH_TMO);
  209. #endif
  210. setFirstBreakpoint(frame->pc);
  211. return;
  212. }
  213. commonErrorHandler(frame);
  214. }
  215. void xt_unhandled_exception(XtExcFrame *frame)
  216. {
  217. haltOtherCore();
  218. panicPutStr("Guru Meditation Error of type ");
  219. int exccause = frame->exccause;
  220. if (exccause < 40) {
  221. panicPutStr(edesc[exccause]);
  222. } else {
  223. panicPutStr("Unknown");
  224. }
  225. panicPutStr(" occurred on core ");
  226. panicPutDec(xPortGetCoreID());
  227. if (esp_cpu_in_ocd_debug_mode()) {
  228. panicPutStr(" at pc=");
  229. panicPutHex(frame->pc);
  230. panicPutStr(". Setting bp and returning..\r\n");
  231. #if CONFIG_ESP32_APPTRACE_ENABLE
  232. esp_apptrace_flush_nolock(ESP_APPTRACE_DEST_TRAX, ESP_APPTRACE_TRAX_BLOCK_SIZE*CONFIG_ESP32_APPTRACE_ONPANIC_HOST_FLUSH_TRAX_THRESH/100, CONFIG_ESP32_APPTRACE_ONPANIC_HOST_FLUSH_TMO);
  233. #endif
  234. //Stick a hardware breakpoint on the address the handler returns to. This way, the OCD debugger
  235. //will kick in exactly at the context the error happened.
  236. setFirstBreakpoint(frame->pc);
  237. return;
  238. }
  239. panicPutStr(". Exception was unhandled.\r\n");
  240. commonErrorHandler(frame);
  241. }
  242. /*
  243. If watchdogs are enabled, the panic handler runs the risk of getting aborted pre-emptively because
  244. an overzealous watchdog decides to reset it. On the other hand, if we disable all watchdogs, we run
  245. the risk of somehow halting in the panic handler and not resetting. That is why this routine kills
  246. all watchdogs except the timer group 0 watchdog, and it reconfigures that to reset the chip after
  247. one second.
  248. */
  249. static void reconfigureAllWdts()
  250. {
  251. TIMERG0.wdt_wprotect = TIMG_WDT_WKEY_VALUE;
  252. TIMERG0.wdt_feed = 1;
  253. TIMERG0.wdt_config0.sys_reset_length = 7; //3.2uS
  254. TIMERG0.wdt_config0.cpu_reset_length = 7; //3.2uS
  255. TIMERG0.wdt_config0.stg0 = TIMG_WDT_STG_SEL_RESET_SYSTEM; //1st stage timeout: reset system
  256. TIMERG0.wdt_config1.clk_prescale = 80 * 500; //Prescaler: wdt counts in ticks of 0.5mS
  257. TIMERG0.wdt_config2 = 2000; //1 second before reset
  258. TIMERG0.wdt_config0.en = 1;
  259. TIMERG0.wdt_wprotect = 0;
  260. //Disable wdt 1
  261. TIMERG1.wdt_wprotect = TIMG_WDT_WKEY_VALUE;
  262. TIMERG1.wdt_config0.en = 0;
  263. TIMERG1.wdt_wprotect = 0;
  264. }
  265. /*
  266. This disables all the watchdogs for when we call the gdbstub.
  267. */
  268. static inline void disableAllWdts()
  269. {
  270. TIMERG0.wdt_wprotect = TIMG_WDT_WKEY_VALUE;
  271. TIMERG0.wdt_config0.en = 0;
  272. TIMERG0.wdt_wprotect = 0;
  273. TIMERG1.wdt_wprotect = TIMG_WDT_WKEY_VALUE;
  274. TIMERG1.wdt_config0.en = 0;
  275. TIMERG1.wdt_wprotect = 0;
  276. }
  277. static void esp_panic_wdt_start()
  278. {
  279. if (REG_GET_BIT(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_EN)) {
  280. return;
  281. }
  282. WRITE_PERI_REG(RTC_CNTL_WDTWPROTECT_REG, RTC_CNTL_WDT_WKEY_VALUE);
  283. WRITE_PERI_REG(RTC_CNTL_WDTFEED_REG, 1);
  284. REG_SET_FIELD(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_SYS_RESET_LENGTH, 7);
  285. REG_SET_FIELD(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_CPU_RESET_LENGTH, 7);
  286. REG_SET_FIELD(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_STG0, RTC_WDT_STG_SEL_RESET_SYSTEM);
  287. // 64KB of core dump data (stacks of about 30 tasks) will produce ~85KB base64 data.
  288. // @ 115200 UART speed it will take more than 6 sec to print them out.
  289. WRITE_PERI_REG(RTC_CNTL_WDTCONFIG1_REG, RTC_CNTL_SLOWCLK_FREQ*7);
  290. REG_SET_BIT(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_EN);
  291. WRITE_PERI_REG(RTC_CNTL_WDTWPROTECT_REG, 0);
  292. }
  293. void esp_panic_wdt_stop()
  294. {
  295. WRITE_PERI_REG(RTC_CNTL_WDTWPROTECT_REG, RTC_CNTL_WDT_WKEY_VALUE);
  296. WRITE_PERI_REG(RTC_CNTL_WDTFEED_REG, 1);
  297. REG_SET_FIELD(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_STG0, RTC_WDT_STG_SEL_OFF);
  298. REG_CLR_BIT(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_EN);
  299. WRITE_PERI_REG(RTC_CNTL_WDTWPROTECT_REG, 0);
  300. }
  301. static void esp_panic_dig_reset() __attribute__((noreturn));
  302. static void esp_panic_dig_reset()
  303. {
  304. // make sure all the panic handler output is sent from UART FIFO
  305. uart_tx_wait_idle(CONFIG_CONSOLE_UART_NUM);
  306. // switch to XTAL (otherwise we will keep running from the PLL)
  307. rtc_clk_cpu_freq_set(RTC_CPU_FREQ_XTAL);
  308. // reset the digital part
  309. esp_cpu_unstall(PRO_CPU_NUM);
  310. SET_PERI_REG_MASK(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_SW_SYS_RST);
  311. while (true) {
  312. ;
  313. }
  314. }
  315. static inline bool stackPointerIsSane(uint32_t sp)
  316. {
  317. return !(sp < 0x3ffae010 || sp > 0x3ffffff0 || ((sp & 0xf) != 0));
  318. }
  319. static void putEntry(uint32_t pc, uint32_t sp)
  320. {
  321. if (pc & 0x80000000) {
  322. pc = (pc & 0x3fffffff) | 0x40000000;
  323. }
  324. panicPutStr(" 0x");
  325. panicPutHex(pc);
  326. panicPutStr(":0x");
  327. panicPutHex(sp);
  328. }
  329. static void doBacktrace(XtExcFrame *frame)
  330. {
  331. uint32_t i = 0, pc = frame->pc, sp = frame->a1;
  332. panicPutStr("\r\nBacktrace:");
  333. /* Do not check sanity on first entry, PC could be smashed. */
  334. putEntry(pc, sp);
  335. pc = frame->a0;
  336. while (i++ < 100) {
  337. uint32_t psp = sp;
  338. if (!stackPointerIsSane(sp) || i++ > 100) {
  339. break;
  340. }
  341. sp = *((uint32_t *) (sp - 0x10 + 4));
  342. putEntry(pc, sp);
  343. pc = *((uint32_t *) (psp - 0x10));
  344. if (pc < 0x40000000) {
  345. break;
  346. }
  347. }
  348. panicPutStr("\r\n\r\n");
  349. }
  350. void esp_restart_noos() __attribute__ ((noreturn));
  351. /*
  352. We arrive here after a panic or unhandled exception, when no OCD is detected. Dump the registers to the
  353. serial port and either jump to the gdb stub, halt the CPU or reboot.
  354. */
  355. static void commonErrorHandler(XtExcFrame *frame)
  356. {
  357. int *regs = (int *)frame;
  358. int x, y;
  359. const char *sdesc[] = {
  360. "PC ", "PS ", "A0 ", "A1 ", "A2 ", "A3 ", "A4 ", "A5 ",
  361. "A6 ", "A7 ", "A8 ", "A9 ", "A10 ", "A11 ", "A12 ", "A13 ",
  362. "A14 ", "A15 ", "SAR ", "EXCCAUSE", "EXCVADDR", "LBEG ", "LEND ", "LCOUNT "
  363. };
  364. // start panic WDT to restart system if we hang in this handler
  365. esp_panic_wdt_start();
  366. //Feed the watchdogs, so they will give us time to print out debug info
  367. reconfigureAllWdts();
  368. /* only dump registers for 'real' crashes, if crashing via abort()
  369. the register window is no longer useful.
  370. */
  371. if (!abort_called) {
  372. panicPutStr("Register dump:\r\n");
  373. for (x = 0; x < 24; x += 4) {
  374. for (y = 0; y < 4; y++) {
  375. if (sdesc[x + y][0] != 0) {
  376. panicPutStr(sdesc[x + y]);
  377. panicPutStr(": 0x");
  378. panicPutHex(regs[x + y + 1]);
  379. panicPutStr(" ");
  380. }
  381. }
  382. panicPutStr("\r\n");
  383. }
  384. }
  385. /* With windowed ABI backtracing is easy, let's do it. */
  386. doBacktrace(frame);
  387. #if CONFIG_ESP32_APPTRACE_ENABLE
  388. disableAllWdts();
  389. esp_apptrace_flush_nolock(ESP_APPTRACE_DEST_TRAX, ESP_APPTRACE_TRAX_BLOCK_SIZE*CONFIG_ESP32_APPTRACE_ONPANIC_HOST_FLUSH_TRAX_THRESH/100, CONFIG_ESP32_APPTRACE_ONPANIC_HOST_FLUSH_TMO);
  390. reconfigureAllWdts();
  391. #endif
  392. #if CONFIG_ESP32_PANIC_GDBSTUB
  393. disableAllWdts();
  394. esp_panic_wdt_stop();
  395. panicPutStr("Entering gdb stub now.\r\n");
  396. esp_gdbstub_panic_handler(frame);
  397. #else
  398. #if CONFIG_ESP32_ENABLE_COREDUMP
  399. disableAllWdts();
  400. #if CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH
  401. esp_core_dump_to_flash(frame);
  402. #endif
  403. #if CONFIG_ESP32_ENABLE_COREDUMP_TO_UART && !CONFIG_ESP32_PANIC_SILENT_REBOOT
  404. esp_core_dump_to_uart(frame);
  405. #endif
  406. reconfigureAllWdts();
  407. #endif
  408. esp_panic_wdt_stop();
  409. #if CONFIG_ESP32_PANIC_PRINT_REBOOT || CONFIG_ESP32_PANIC_SILENT_REBOOT
  410. panicPutStr("Rebooting...\r\n");
  411. if (frame->exccause != PANIC_RSN_CACHEERR) {
  412. esp_restart_noos();
  413. } else {
  414. // The only way to clear invalid cache access interrupt is to reset the digital part
  415. esp_panic_dig_reset();
  416. }
  417. #else
  418. disableAllWdts();
  419. panicPutStr("CPU halted.\r\n");
  420. while (1);
  421. #endif
  422. #endif
  423. }
  424. void esp_set_breakpoint_if_jtag(void *fn)
  425. {
  426. if (esp_cpu_in_ocd_debug_mode()) {
  427. setFirstBreakpoint((uint32_t)fn);
  428. }
  429. }
  430. esp_err_t esp_set_watchpoint(int no, void *adr, int size, int flags)
  431. {
  432. int x;
  433. if (no<0 || no>1) return ESP_ERR_INVALID_ARG;
  434. if (flags&(~0xC0000000)) return ESP_ERR_INVALID_ARG;
  435. int dbreakc=0x3F;
  436. //We support watching 2^n byte values, from 1 to 64. Calculate the mask for that.
  437. for (x=0; x<7; x++) {
  438. if (size==(1<<x)) break;
  439. dbreakc<<=1;
  440. }
  441. if (x==7) return ESP_ERR_INVALID_ARG;
  442. //Mask mask and add in flags.
  443. dbreakc=(dbreakc&0x3f)|flags;
  444. if (no==0) {
  445. asm volatile(
  446. "wsr.dbreaka0 %0\n" \
  447. "wsr.dbreakc0 %1\n" \
  448. ::"r"(adr),"r"(dbreakc));
  449. } else {
  450. asm volatile(
  451. "wsr.dbreaka1 %0\n" \
  452. "wsr.dbreakc1 %1\n" \
  453. ::"r"(adr),"r"(dbreakc));
  454. }
  455. return ESP_OK;
  456. }
  457. void esp_clear_watchpoint(int no)
  458. {
  459. //Setting a dbreakc register to 0 makes it trigger on neither load nor store, effectively disabling it.
  460. int dbreakc=0;
  461. if (no==0) {
  462. asm volatile(
  463. "wsr.dbreakc0 %0\n" \
  464. ::"r"(dbreakc));
  465. } else {
  466. asm volatile(
  467. "wsr.dbreakc1 %0\n" \
  468. ::"r"(dbreakc));
  469. }
  470. }
  471. void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression)
  472. {
  473. ets_printf("ESP_ERROR_CHECK failed: esp_err_t 0x%x at 0x%08x\n", rc, (intptr_t)__builtin_return_address(0) - 3);
  474. if (spi_flash_cache_enabled()) { // strings may be in flash cache
  475. ets_printf("file: \"%s\" line %d\nfunc: %s\nexpression: %s\n", file, line, function, expression);
  476. }
  477. invoke_abort();
  478. }