-
Notifications
You must be signed in to change notification settings - Fork 5
Feat: Add watchdog disable #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,11 +10,13 @@ | |
| #include <stdbool.h> | ||
|
|
||
| /** | ||
| * @brief Check if USB-Serial/JTAG is supported on this chip | ||
| * @brief Disable watchdogs for USB-Serial/JTAG | ||
| * | ||
| * @return true if USB-Serial/JTAG is supported, false otherwise | ||
| * This function disables the watchdogs for USB-Serial/JTAG to prevent the device from resetting. | ||
| * By default watchdog is disabled after chip reset, but second stage bootloader may enable it again, | ||
| * and if application does not disable it, it will reset the device, because USB-Serial/JTAG does only software reset. | ||
|
Comment on lines
+15
to
+17
|
||
| */ | ||
| bool stub_target_usb_serial_jtag_is_supported(void); | ||
| void stub_target_usb_serial_jtag_disable_watchdogs(void); | ||
|
|
||
| /** | ||
| * @brief Attach interrupt handler to USB-Serial/JTAG and configure interrupts | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,16 +10,28 @@ | |
| #include <target/usb_serial_jtag.h> | ||
| #include <soc/usb_serial_jtag_reg.h> | ||
| #include <soc/interrupt_core0_reg.h> | ||
| #include <soc/rtc_cntl_reg.h> | ||
| #include <soc_utils.h> | ||
|
|
||
| // External ROM functions | ||
| extern void esp_rom_isr_attach(int int_num, void *handler, void *arg); | ||
| extern void esp_rom_isr_unmask(int int_num); | ||
| extern void esprv_intc_int_set_priority(int int_num, int priority); | ||
|
|
||
| bool stub_target_usb_serial_jtag_is_supported(void) | ||
| #define RTC_CNTL_WDT_KEY 0x50D83AA1 | ||
| #define RTC_CNTL_SWD_KEY 0x8F1D312A | ||
|
|
||
| void stub_target_usb_serial_jtag_disable_watchdogs(void) | ||
| { | ||
| return true; | ||
| // Disable RWDT (RTC Watchdog) | ||
| WRITE_PERI_REG(RTC_CNTL_WDTWPROTECT_REG, RTC_CNTL_WDT_WKEY); | ||
|
||
| WRITE_PERI_REG(RTC_CNTL_WDTCONFIG0_REG, 0x0); | ||
| WRITE_PERI_REG(RTC_CNTL_WDTWPROTECT_REG, 0x0); | ||
|
|
||
| // Configure SWD (Super Watchdog) to autofeed | ||
| WRITE_PERI_REG(RTC_CNTL_SWD_WPROTECT_REG, RTC_CNTL_SWD_WKEY); | ||
|
||
| SET_PERI_REG_MASK(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_AUTO_FEED_EN); | ||
| WRITE_PERI_REG(RTC_CNTL_SWD_WPROTECT_REG, 0x0); | ||
| } | ||
|
|
||
| void stub_target_usb_serial_jtag_rominit_intr_attach(int intr_num, void *handler, uint32_t flags) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment - "preven" should be "prevent"