Commit graph

49 commits

Author SHA1 Message Date
Ivan Grokhotkov
90f5456dba Merge branch 'feature/rtc_cpu_freq_config' into 'master'
soc/rtc: Refactoring, support CPU frequencies lower than XTAL

See merge request idf/esp-idf!2856
2018-08-22 11:32:08 +08:00
Ivan Grokhotkov
bec70ce298 esp32: use new CPU frequency setting API 2018-08-21 13:02:46 +08:00
Ivan Grokhotkov
0aa384d40c esp32: add API to get reset reason 2018-08-20 16:49:20 +08:00
Konstantin Kondrashov
a8e46775c6 soc/rtc_wdt: Add API functions for rtc_wdt
Added functions:
rtc_wdt_protect_off/on
rtc_wdt_set_length_of_reset_signal
rtc_wdt_set_stage
rtc_wdt_set_time
rtc_wdt_feed
rtc_wdt_disable/enable
2018-08-14 17:48:02 +05:00
Ivan Grokhotkov
2f7d327978 panic: remove extra newline 2018-06-15 15:49:23 +08:00
Roland Dobai
07acbb5664 ESP_ERROR_CHECK converts error code to text
If CONFIG_ESP_ERR_TO_NAME_LOOKUP is enabled, ESP_ERROR_CHECK
prints error message in addition to the error code.
2018-05-31 12:53:37 +02:00
Jack
624828ce83 Dump the frame of the other core when interrupt watchdog happens 2018-01-18 23:10:29 +00:00
Ivan Grokhotkov
8e8cb1a139 panic: prevent INT WDT from re-triggering in OCD mode
When INT WDT fires, panicHandler is invoked. In OCD mode, panicHandler
sets a breakpoint on the PC from the exception frame and returns.
However in case of INT WDT, interrupt flag is still set in TIMERG1
peripheral, which causes INT WDT to trigger again. This causes an
endless stream of "Core  0 panic'ed (Interrupt wdt timeout on CPU1)"
messages. OpenOCD also gets terribly confused at this point.

Disable watchdogs when exiting panic handler in OCD mode.
Clear TIMERG1 WDT interrupt flag to prevent re-entry into panic handler.
2018-01-09 01:46:24 +08:00
houchenyao
f80824a2d8 test: support test for UT cases expect to reset 2017-11-07 12:19:39 +08:00
Jeroen Domburg
b3fd494e71 Panic: stop dport access handler without trying to use a lock 2017-09-11 17:24:22 +08:00
Alexey Gerenkov
fb8b0c534a esp32: Fixes infinite loop caused by exception during core dumping 2017-09-05 11:15:27 +08:00
Ivan Grokhotkov
65b046f17f dport access: introduce pause/resume instead of deinit 2017-09-01 10:36:14 +08:00
Ivan Grokhotkov
7fc25f18d2 Merge branch 'feature/enable_brownout_detector' into 'master'
Enable brownout detector

See merge request !811
2017-07-13 11:40:37 +08:00
Angus Gratton
c049cd55a6 gdbstub: Mark the panic handler entry as noreturn
Fixes a warning in panic.c when this panic mode is enabled.
2017-07-11 10:18:08 +08:00
Ivan Grokhotkov
01b185977c brownout detector: enable by default
Because of errata related to BOD reset function, brownout is handled as follows:

- attach an ISR to brownout interrupt
- when ISR happens, print a message and do a software restart
- esp_restart_nonos enables RTC watchdog, so if restart fails,
  there will be  one more attempt to restart (using the RTC
  watchdog)
2017-07-10 17:25:55 +08:00
Ivan Grokhotkov
9b955f4c9f Merge branch 'feature/sysview_via_apptrace' into 'master'
sysview via apptrace

See merge request !708
2017-06-29 08:40:13 +08:00
Alexey Gerenkov
8d43859b6a esp32: SEGGER SystemView Tracing Support
Implements support for system level traces compatible with SEGGER
SystemView tool on top of ESP32 application tracing module.
That kind of traces can help to analyse program's behaviour.
SystemView can show timeline of tasks/ISRs execution, context switches,
statistics related to the CPUs' load distribution etc.

Also this commit adds useful feature to ESP32 application tracing module:
 - Trace data buffering is implemented to handle temporary peaks of events load
2017-06-27 20:52:43 +03:00
Darian Leung
21f02a6955 Bugfix - Panic Handler not halting when running on both cores
Bug occurs when core dump destination in menuconfig is set to flash. When
programme crashes, xt_unhandled_exception or panicHandler will both trigger
commonErrorHandler. commonErrorHandler calls esp_core_dump_to_flash which
will attempt to use DPORT functions and hang due to trying to a stall and already
stalled processor (already stalled in xt_unhandled_exception and panicHandler).
Program will eventually be rebooted when wdt expires.

Added esp_dport_access_int_deinit after calls to haltOtherCore() so that DPORT
functions don't try to halt and already halted cpu hence preventing hang.

Fixes TW#12944 https://github.com/espressif/esp-idf/issues/646
2017-06-21 16:58:48 +08:00
Angus Gratton
5d7bffea2b panic handler: Print backtraces with calling address not return address
This seems to clean up some of the more wrong addr2line output results (not
sure why, something to do with optimisations I think - perhaps the return
address may also be a jump target from some earlier line of the code.)
2017-06-14 10:30:04 +10:00
Angus Gratton
47e789f538 abort handler: Fix abort stack trace when abort() called in ISR
Previously, this resulted in task stack frames turning up incorrectly in the backtrace, ie

Backtrace: 0x400d22a0:0x3ffb0fa0 0x40085a3c:0x3ffb0fc0 0x400f32c4:0x3ffb0fe0 0x40081965:0x3ffb1010
0x400d22a0: esp_vApplicationIdleHook at /home/esp/esp-idf/components/esp32/./freertos_hooks.c:
52
0x40085a3c: prvIdleTask at /home/esp/esp-idf/components/freertos/./tasks.c:4431
0x400f32c4: i2c_isr_handler_default at /home/esp/esp-idf/components/driver/./i2c.c:598
0x40081965: _xt_lowint1 at xtensa_vectors.o:?

Fix is to implement abort() via an unhandled exception rather than a breakpoint, I think
because of relative priority of exception types.

Another approach would be to assign a software-only INUM to abort()ing and defined a
PANIC_RSN_ABORTED, but this is more complex and interrupt numbers are more scarce than RAM!
2017-06-13 10:19:01 +10:00
Deomid Ryabkov
3ac3a78d7d Print the name of the task that hit the stack watchpoint
This may be enough to troubleshoot (increase stack size).

Merges https://github.com/espressif/esp-idf/pull/607
2017-05-17 11:36:13 +10:00
Ivan Grokhotkov
1324e565fa Merge branch 'bugfix/esp32_core_dump_sanity_checks' into 'master'
esp32: Core dump sanity checks

Adds sanity checks when doing core dump to flash

- CRC for core dump flash partition config
- Tasks with corrupted TCBs are skipped
- Assertions to check that nothing is written beyond core dump flash partition

Ref TW11879

See merge request !686
2017-04-27 10:43:58 +08:00
Alexey Gerenkov
98895af68b esp32: Core dump sanity checks were added
- CRC for core dump flash partition config
 - Tasks with corrupted TCBs are skipped
 - Assertions to check that nothing is written beyond core dump flash partition
2017-04-26 21:13:02 +03:00
Ivan Grokhotkov
6353bc40d7 Add support for 32k XTAL as RTC_SLOW_CLK source
- RTC_CNTL_SLOWCLK_FREQ define is removed; rtc_clk_slow_freq_get_hz
  function can be used instead to get an approximate RTC_SLOW_CLK
  frequency

- Clock calibration is performed at startup. The value is saved and used
  for timekeeping and when entering deep sleep.

- When using the 32k XTAL, startup code will wait for the oscillator to
  start up. This can be possibly optimized by starting a separate task
  to wait for oscillator startup, and performing clock switch in that
  task.

- Fix a bug that 32k XTAL would be disabled in rtc_clk_init.

- Fix a rounding error in rtc_clk_cal, which caused systematic frequency
  error.

- Fix an overflow bug which caused rtc_clk_cal to timeout early if the
  slow_clk_cycles argument would exceed certain value

- Improve 32k XTAL oscillator startup time by introducing bootstrapping
  code, which uses internal pullup/pulldown resistors on 32K_N/32K_P
  pins to set better initial conditions for the oscillator.
2017-04-26 12:43:22 +08:00
Alexey Gerenkov
55f1a63faf esp32: Adds functionality for application tracing over JTAG
- Implements application tracing module which allows to send arbitrary
   data to host over JTAG. This feature is useful for analyzing
   program modules behavior, dumping run-time application data etc.
 - Implements printf-like logging functions on top of apptrace module.
   This feature is a kind of semihosted printf functionality with lower
   overhead and impact on system behaviour as compared to standard printf.
2017-04-17 23:26:29 +03:00
Ivan Grokhotkov
a8f1918d88 panic handler: access exception frame members via struct fields 2017-04-13 15:27:38 +08:00
Ivan Grokhotkov
aae441951b panic handler: send output to the UART configured as console 2017-04-13 15:27:38 +08:00
Jeroen Domburg
0b79d07d34 add detection of invalid cache access
- fix level 4 interrupt vectors to produce correct backtrace
- initialize invalid cache access interrupt on startup
- handle invalid cache access in panic handler
2017-04-13 15:27:38 +08:00
Alexey Gerenkov
c142b9b9e5 esp32: RWDT is used to reboot system in case of panic handler crash
also fixes TG1WDG protection bug in panic handler
2017-04-07 02:34:29 +03:00
Angus Gratton
d6f183fbb9 esp_err: Use separate code path for ESP_ERROR_CHECK assertion
* Minimum code size overhead
* Makes function safe to use when flash cache is disabled

Builds on #339 https://github.com/espressif/esp-idf/pull/339
2017-03-03 15:33:23 +11:00
Alexey Gerenkov
04acc88023 esp32: Fixes watchdog problem when printing core dump to uart
Also fixes generation of core dumps when flash cache is disabled
2017-02-01 18:39:28 +03:00
Ivan Grokhotkov
6538252552 Merge branch 'bugfix/panic_reset_hangs' into 'master'
Panic handler: Use same reset path as esp_restart(), disabling hardware

Closes #223 https://github.com/espressif/esp-idf/issues/223

See merge request !417
2017-01-16 10:40:47 +08:00
Jeroen Domburg
08f11e4c53 Fix panic register dump format 2017-01-15 16:49:18 +08:00
Angus Gratton
e53d307814 Panic handler: Use same reset path as esp_restart(), disabling hardware
Closes #223 https://github.com/espressif/esp-idf/issues/223
2017-01-13 14:37:36 +11:00
Alexey Gerenkov
ad66fbe5ad esp32: Fixes issues discussed during code review of MR!341
The following issues mentioned during MR!341 review were fixed:
1) Core dump test application description
2) Usage of CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH and CONFIG_ESP32_ENABLE_COREDUMP_TO_UART
3) FLASH_GUARD_START macro usage is fixed in flash API
4) Core dump module logging facility
5) cache util functions doc updated
6) interactive delay before print core dump to uart
7) core dump partion support in build system
2017-01-12 19:38:19 +03:00
Alexey Gerenkov
39ddc7b836 esp32: Fixes several issues in core dump feature
1) PS is fixed up to allow GDB backtrace to work properly
2) MR!341 discussion: in core dump module: esp_panicPutXXX was replaced by ets_printf.
3) MR!341 discussion: core dump flash magic number was changed.
4) MR!341 discussion: SPI flash access API was redesigned to allow flexible critical section management.
5) test app for core dump feature was added
6) fixed base64 file reading issues on Windows platform
7) now raw bin core file is deleted upon core loader failure by epscoredump.py
2017-01-11 20:51:28 +03:00
Alexey Gerenkov
4a3e160888 esp32: Add core dump saving to flash feature
Complimentary changes:
1) Partition table definitions files with core dump partition
2) Special sub-type for core dump partition
3) Special version of spi_flash_xxx
4) espcoredump.py is script to get core dump from flash and print useful info
5) FreeRTOS API was extended to get tasks snapshots
2017-01-11 20:51:28 +03:00
Jeroen Domburg
881157e1ed Add documentation to panic handler functions, move watchpoint stuff from tasks.c to port.c, account for non-32-bytes-aligned stacks when setting watchpoint, add debug reason explanation to panic handler 2017-01-10 13:05:19 +08:00
Jeroen Domburg
ca57a86f20 Add option to automatically set a watchpoint at the end of the swapped-in task 2017-01-09 16:42:45 +08:00
Angus Gratton
da977149f6 panic handlers: Print the PC address where abort() was called, don't dump registers 2016-12-28 10:09:40 +11:00
Angus Gratton
b98405f9d9 esp32: ReformatReformat panic.c (remove tabs, etc) 2016-12-07 13:25:56 -08:00
Deomid Ryabkov
20fd57f147 Add backtrace to exception output.
On Xtensa windowed ABI backtrace is easy to do, and it's immensely
useful for debugging, so - do it by default.
We try to be careful and not deref bogus pointers while walking the
frames.

Example output (from debugging espressif/esp-idf#133):

Backtrace: 0x1:0x3ffc51e0 0x400e9dfa:0x3ffc5210 0x400e9ebc:0x3ffc5230 0x400ec487:0x3ffc5260

With just addr2line utility from binutils, this already pinpoints the
location of the crash.
2016-12-07 19:58:06 +00:00
Jeroen Domburg
c852e9958b Invoke panic handler when a stack overflow has been detected; unhandled interrupt now prints interrupt/cpu number. 2016-12-05 20:37:59 +08:00
Ivan Grokhotkov
8b2f933a51 Implement system_* APIs in IDF 2016-11-22 21:14:36 +08:00
Jeroen Domburg
309bd12855 Re-add panic.o to IRAM/DRAM. 2016-10-28 14:32:11 +08:00
Jeroen Domburg
ff6b8addd9 Fix panic config ifdefs, un-stall app cpu on boot so it restarts after panic 2016-10-27 11:17:24 +08:00
Jeroen Domburg
9546ad5b5e Move write key and stage action select constants into headers 2016-10-26 14:54:50 +08:00
Jeroen Domburg
7d254eb3f0 Move panic handler and gdbstub into esp32 component, clean up wdt according to merge req suggestions 2016-10-26 12:23:01 +08:00
Jeroen Domburg
1ca97f5adb Move panic handler code from FreeRTOS to esp32 component 2016-10-26 11:06:53 +08:00
Renamed from components/freertos/panic.c (Browse further)