Zephyr Warm-reset after propietary freeRTOS enabled bootloader

Hi,

So I have seen there is a clean-up option to set the architecture core HW registers to their warm-reset values as specified by the architecture before running the app from MCUBOOT (config MCUBOOT_CLEANUP_ARM_CORE).

Now I wonder if there is any similar option to be run on an application code itself. I am on a project that requires running on a propietary bootloader based on freeRTOS. My Zephyr application code runs fine apart from k_sleep function. My thinking is that the bootloader is altering some of the clock or timing register and this is upsetting the normal execution of zephyr. Is there an option that will set the architecture core HW registers to their warm-reset for an application init? If not, please share your thoughts on the most likely cause of the conflict (may be RTC configuration). Project runs on nRF52832 chip.

Thanks

  • I added the below code on the main to eliminate the timing conflict:

    static int nrf52_sys_init(void) {
       // Stop RTC1 to avoid conflit with
       // propietary bootloader RTC1 config
       NRF_RTC1->TASKS_STOP=1; return 0;
    }
    SYS_INIT(nrf52_sys_init, EARLY, 0);

    My observation is that if a proprietary code fiddles with RTC1 configuration will affect the normal running of k_sleep on Zephyr. I am currently working under NCS v2.6.0. Is that the expected behaviour?

  • I thought that MCUBOOT_CLEANUP_ARM_CORE is deprecated as my understanding was that this needed to be true for latest MCUBoot builds and I do not see any such option on the application side.

    In Zephyr, the Real-Time Counter (RTC) is typically used for timing services of the kernel, such as k_sleep() and the kernel timer API. This is usually a Real-time counter peripheral (RTC1) on Nordic SoCs and SiPs (nRF91, nRF53, nRF52 Series).
    The Zephyr kernel timer, used when you are using functions like k_cycle_get_32, is also based on the same  RTC as discussed in this thread.

  • Hi Susheel

    Thanks for your reply. Are the RTC register clear when you jump from a proprietary bootloader? What I can see is that I need to stop the RTC on a SYS_INIT operation before any other Zephyr core initialization to get k_sleep to work fine.

  • Ignacio said:
    What I can see is that I need to stop the RTC on a SYS_INIT operation before any other Zephyr core initialization to get k_sleep to work fine.

    That is strange, can you show me the code snippet and the context of this change? Can you connect a debugger and put a breakpoint early in your application at SYS_INIT and view the RTC registers to see if you see the values cleared as expected?

Related