How to reset the uptime after a reboot?

Hi,

Is there a way to reset the uptime after doing a reboot? Rebooting the device by resetting the power does reset the uptime, however we need a way to initiate the reboot using firmware.

What we have tried so far:
Using sys_reboot();

Putting in either SYS_REBOOT_COLD or SYS_REBOOT_WARM as arguments in sys_reboot();

NVIC_SystemReset().

Implenenting SYSTEM_TIMER_HAS_DISABLE_SUPPORT in Kconfig, to enable sys_clock_disable();, but then the compiler spits out that sys_clock_disable(); is an undefined reference.

We are using a custom board, with MCU nrf54l15 and NRF Connect SDK 2.9.0.

Parents
  • The Zephyr function `k_uptime_get()` should return the uptime in milliseconds since boot.

    The function `NVIC_SystemReset()` should perform a reboot. Can you verify that your system actually reboots?

    How do you read the uptime in your system?

    Can you reproduce your problem on a standard development board?

    Can you share a minimum example that makes it possible for others to reproduce your problem?

  • I tried checking k_uptime_get() and its not reset after the reboot.

    Using sys_reboot(); or NVIC_SystemReset(); does perform a reboot. Logs clearly indicate that the device is rebooted, by showing the startup of the bootloader and the startup process of our device, but the uptime is carried over, instead of starting at 0.


    Uptime is printed first things first with the logging system:

    [00:47:01.025,216] <dbg> watchdog: primary_feed_worker: Feeding watchdog
    [00:47:31.025,280] <dbg> watchdog: primary_feed_worker: Feeding watchdog
    [00:48:01.025,344] <dbg> watchdog: primary_feed_worker: Feeding watchdog


    I tried reproducing the problem by using the "button" sample. Constantly printing out uptime by using k_uptime_get() and calling NVIC_SystemReset() when the button is pressed, the uptime does reset. I was using the N52832 DK, since it is the only one I had on hand. However, on our device, printing k_uptime_get() on boot and then initiating NVIC_SystemReset() does not reset the uptime. 

  • I see. Strange.

    What output do you get if you call this function twice during each boot?

    void startup_test(void)
    {
        static int b1;
        static int b2 = 42;
        LOG_INF("%s: b1: %d, b2: %d", __func__, b1, b2);
        b1++;
        b2++;
    }

    Since I know nothing about how much you have customized for your board I just want to check that the `bss` and `data` sections are initialized correctly by the reset handler. If they are not, you would probably see other, more severe, problems. But it should be quick to test and rule out at least. 

  • First time booting: 

    startup_test: b1: 0, b2: 42

    Second time booting after calling NVIC_SystemReset(): 

    startup_test: b1: 0, b2: 42

    No change.

  • OK. It was a very long shot indeed. I have no more ideas at the moment. I think you need to share more about your board and how you have configured it, in order for others to help you troubleshoot further.

Reply Children
No Data
Related