-
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?
Conversation
This commit removes necessitty to define support function per target and removes common usb_serial_jtag c file. This also adds usb-Serial-JTAG functions to the build test.
Watchdog needs to be disabled in order to preven reset in the middle of a communication. 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.
👋 Hello Dzarda7, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
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.
Pull request overview
This PR adds watchdog disable functionality for USB-Serial-JTAG to prevent device resets during communication. The changes remove the common implementation file and the per-target stub_target_usb_serial_jtag_is_supported() function, replacing it with target-specific stub_target_usb_serial_jtag_disable_watchdogs() implementations.
Key changes include:
- New public API function
stub_lib_usb_serial_jtag_disable_watchdogs() - Target-specific implementations for disabling RWDT and configuring SWD to autofeed
- New LP_WDT register definition headers for multiple targets (ESP32C5/C6/C61, ESP32H2/H4/H21, ESP32P4)
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| include/esp-stub-lib/usb_serial_jtag.h | Adds public API declaration for watchdog disable function |
| src/usb_serial_jtag.c | Implements wrapper with conditional compilation for watchdog disable |
| src/target/base/include/target/usb_serial_jtag.h | Updates internal API signature from is_supported to disable_watchdogs |
| src/target/esp32s3/src/usb_serial_jtag.c | Implements RTC watchdog disable using RTC_CNTL registers |
| src/target/esp32p4/src/usb_serial_jtag.c | Implements LP watchdog disable for ESP32P4 |
| src/target/esp32h4/src/usb_serial_jtag.c | Implements LP watchdog disable for ESP32H4 |
| src/target/esp32h21/src/usb_serial_jtag.c | Implements LP watchdog disable for ESP32H21 |
| src/target/esp32h2/src/usb_serial_jtag.c | Implements LP watchdog disable for ESP32H2 |
| src/target/esp32c61/src/usb_serial_jtag.c | Implements LP watchdog disable for ESP32C61 |
| src/target/esp32c6/src/usb_serial_jtag.c | Implements LP watchdog disable for ESP32C6 |
| src/target/esp32c5/src/usb_serial_jtag.c | Implements LP watchdog disable for ESP32C5 |
| src/target/esp32c3/src/usb_serial_jtag.c | Implements RTC watchdog disable using RTC_CNTL registers |
| src/target/*/include/soc/lp_wdt_reg.h | New register definition headers for LP watchdog peripherals |
| src/target/common/CMakeLists.txt | Removes common usb_serial_jtag.c from build |
| example/stub_main.c | Adds test function demonstrating watchdog disable usage |
| { | ||
| return true; | ||
| // Disable RWDT (RTC Watchdog) | ||
| WRITE_PERI_REG(RTC_CNTL_WDTWPROTECT_REG, RTC_CNTL_WDT_WKEY); |
Copilot
AI
Dec 17, 2025
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.
The watchdog write protection key macro name uses "WKEY" but should use "KEY" to match the actual macro definition pattern. Line 27 writes RTC_CNTL_WDT_WKEY but the macro is defined as RTC_CNTL_WDT_KEY on line 21. This will cause a compilation error.
| 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); |
Copilot
AI
Dec 17, 2025
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.
The super watchdog write protection key macro name uses "WKEY" but should use "KEY" to match the actual macro definition pattern. Line 32 writes RTC_CNTL_SWD_WKEY but the macro is defined as RTC_CNTL_SWD_KEY on line 22. This will cause a compilation error.
| { | ||
| return true; | ||
| // Disable RWDT (RTC Watchdog) | ||
| WRITE_PERI_REG(RTC_CNTL_WDTWPROTECT_REG, RTC_CNTL_WDT_WKEY); |
Copilot
AI
Dec 17, 2025
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.
The watchdog write protection key macro name uses "WKEY" but should use "KEY" to match the actual macro definition pattern. Line 27 writes RTC_CNTL_WDT_WKEY but the macro is defined as RTC_CNTL_WDT_KEY on line 21. This will cause a compilation error.
| 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); |
Copilot
AI
Dec 17, 2025
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.
The super watchdog write protection key macro name uses "WKEY" but should use "KEY" to match the actual macro definition pattern. Line 32 writes RTC_CNTL_SWD_WKEY but the macro is defined as RTC_CNTL_SWD_KEY on line 22. This will cause a compilation error.
| WRITE_PERI_REG(RTC_CNTL_WDTCONFIG0_REG, 0x0); | ||
| WRITE_PERI_REG(RTC_CNTL_WDTWPROTECT_REG, 0x0); | ||
|
|
||
| // Configure SWD (Super Watchdog) to autofeed |
Copilot
AI
Dec 17, 2025
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"
| * 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. |
Copilot
AI
Dec 17, 2025
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"
| * 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. |
Copilot
AI
Dec 17, 2025
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"
|
I know this is intended to solve an issue in the USB-Serial/JTAG mode, but it is not related to the peripheral in any way. Should this be moved to another place? e.g.
|
Description
This PR simplifies USB-Serial-JTAG logic a bit by removing common file and one function per target that supports USB-Serial-JTAG. This also adds USB-Serial-JTAG into the build test.
This mainly adds watchdog disable, because watchdog needs to be disabled in order to preven reset in the middle of a communication. 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.
Related
Testing
Checklist
Before submitting a Pull Request, please ensure the following: