RTEMS | Draft: bsps/riscv/esp32: Disable the watchdogs bsp_start() means to disable (!1555)
Sam Price (@TheSamPrice)
gitlab at rtems.org
Tue Nov 3 05:21:24 UTC 2026
Sam Price started a new discussion on bsps/riscv/esp32/start/bspstart.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1555#note_161778
> + * as section 12.2.2.3 prescribes.
> + *
> + * The flash-boot mode bit keeps a watchdog running even with its enable bit
> + * clear, so both bits are cleared (section 12.2.2.4).
> + */
> + RTC_WRITE( RTC_CNTL_WDTWPROTECT_REG, WDT_WKEY_VALUE );
> wdt_config0 = RTC_READ( RTC_CNTL_WDTCONFIG0_REG );
> - RTC_WRITE( RTC_CNTL_WDTCONFIG0_REG, wdt_config0 & RTC_CNTL_WDTCONFIG0_EN );
> -
> - /* disable super watchdog write protection */
> - RTC_WRITE( RTC_CNTL_SWD_WPROTECT_REG, RTC_CNTL_SWD_WPROTECT_KEY );
> -
> - /* Set SWD auto feed */
> + RTC_WRITE(
> + RTC_CNTL_WDTCONFIG0_REG,
> + wdt_config0 & ~( RTC_CNTL_WDTCONFIG0_EN | RTC_CNTL_WDT_FLASHBOOT_MOD_EN )
**Reference code for disabling the RTC watchdog.** ESP-IDF does this in two steps, at different points in boot. This line does both at once, because a direct-boot image has no bootloader stage in between:
1. The second-stage bootloader, [`bootloader_config_wdt()`](https://github.com/espressif/esp-idf/blob/0e6b480f858c69862ffb6001d96e9eef74599a6e/components/bootloader_support/src/bootloader_init.c#L85-L89), clears only flash-boot mode, under unlock and lock. That goes through [`rwdt_ll_set_flashboot_en()`](https://github.com/espressif/esp-idf/blob/0e6b480f858c69862ffb6001d96e9eef74599a6e/components/esp_hal_wdt/esp32c3/include/hal/rwdt_ll.h#L193-L196). With `CONFIG_BOOTLOADER_WDT_ENABLE` (default `y`), [the bootloader then re-arms the watchdog](https://github.com/espressif/esp-idf/blob/0e6b480f858c69862ffb6001d96e9eef74599a6e/components/bootloader_support/src/bootloader_init.c#L91-L100) to guard the rest of boot.
2. The application, [`init_disable_rtc_wdt()`](https://github.com/espressif/esp-idf/blob/0e6b480f858c69862ffb6001d96e9eef74599a6e/components/esp_system/startup_funcs.c#L132-L141), clears the enable bit under unlock and lock, through [`rwdt_ll_disable()`](https://github.com/espressif/esp-idf/blob/0e6b480f858c69862ffb6001d96e9eef74599a6e/components/esp_hal_wdt/esp32c3/include/hal/rwdt_ll.h#L76-L79).
NuttX does both steps together as this BSP does, in [`esp_start.c`](https://github.com/apache/nuttx/blob/5eca74f254c8d32847179f6ebbd5a6e4b588bec0/arch/risc-v/src/common/espressif/esp_start.c#L666-L676): `wdt_hal_set_flashboot_en(false)` and then `wdt_hal_disable()`, under one unlock.
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1555#note_161778
You're receiving this email because of your account on gitlab.rtems.org. Unsubscribe from this thread: https://gitlab.rtems.org/-/namespace/49/sent_notifications/6-4a8cfy05doavjcy4jyvoqffbi-1d/unsubscribe | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | Help: https://gitlab.rtems.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20261103/5870a90e/attachment-0001.htm>
More information about the bugs
mailing list