Reset the ULP after OTA update

Palonso
Posts: 95
Joined: Tue Sep 24, 2019 8:43 pm

Reset the ULP after OTA update

Postby Palonso » Tue Jan 18, 2022 9:33 pm

Hi,

I'm using an ESP WROVER module ULP to count pulses and I realized that after performing an OTA update the ULP seems to do nothing, the ULP program changes in this update.

After looking in some posts, it looks that the ULP ends in an undetermined state after a esp_reset(); command. Is any way to reset the ULP or its PC in order to load and run the new program? prefereably without messing with the RTC_WDT.

Regards,
P

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: Reset the ULP after OTA update

Postby boarchuz » Wed Jan 19, 2022 2:45 am

Your best shot would be to gracefully shut it down before a soft reset, although it might not be possible to do this in all cases (eg. a failed assertion somewhere).

On startup, try to clear RTC_CNTL_ULP_CP_SLP_TIMER_EN and hope the ULP hits a halt soon? Fill ULP program memory with halt instructions? Have a SoC heartbeat, with the ULP ending itself if that's not updated for x ms (assuming the program is still intact, ULP running normally, etc)? Maybe there's a bit in a register somewhere to kill the ULP?

Or do a simple RTC reset and have 100% confidence that you have a clear slate... I know it sounds dirty but it's a lot cleaner than any of that^

Palonso
Posts: 95
Joined: Tue Sep 24, 2019 8:43 pm

Re: Reset the ULP after OTA update

Postby Palonso » Wed Jan 19, 2022 3:44 pm

Hi boarchuz,

How would you do an RTC reset? from what I understand thats possible when hitting the EN pin or by disconnecting the module supply, any of them are possible in my project.

My idea is to do some OTA update without physically going to the place and "reset" it so the ULP would work.

Regards,
P

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: Reset the ULP after OTA update

Postby boarchuz » Wed Jan 19, 2022 5:45 pm

Palonso wrote:
Wed Jan 19, 2022 3:44 pm
How would you do an RTC reset?

Code: Select all

#include "soc/rtc_cntl_struct.h"
#include "hal/wdt_types.h"
#include "hal/rwdt_ll.h"

void __attribute__((noreturn)) esp_rtc_reset(void)
{
    rwdt_ll_write_protect_disable(&RTCCNTL);
    rwdt_ll_disable(&RTCCNTL);
    rwdt_ll_config_stage(&RTCCNTL, WDT_STAGE0, 0, WDT_STAGE_ACTION_RESET_RTC);
    rwdt_ll_disable_stage(&RTCCNTL, WDT_STAGE1);
    rwdt_ll_disable_stage(&RTCCNTL, WDT_STAGE2);
    rwdt_ll_disable_stage(&RTCCNTL, WDT_STAGE3);
    rwdt_ll_set_sys_reset_length(&RTCCNTL, WDT_RESET_SIG_LENGTH_3_2us);
    rwdt_ll_feed(&RTCCNTL);
    rwdt_ll_enable(&RTCCNTL);
    rwdt_ll_write_protect_enable(&RTCCNTL);
    for(;;);
}
You could catch 'dirty' resets in the bootloader using hooks: https://github.com/espressif/esp-idf/tr ... ader_hooks

Who is online

Users browsing this forum: ElectricThanhTung and 113 guests