Hi folks,
NuttX uses SYSTICK for it's kernel timeslice. Under WFI SYSTICK is not reliably waking the CPU but, strangely, the fault only occurs from cold boot; On an EVKB pressing the ONOFF button fixes the issue and SYSTICK is then reliable. If the chip is has SNVS power connected then SYSTICK remains reliable until SNVS power is removed, even if the chip itself is repeatedly power cycled.
In this ( imxrt1050: Disable low-power modes by MaureenHelm · Pull Request #8535 · zephyrproject-rtos/zephyr ·... ) patch to Zephyr Maureen notes that SYSTICK cannot wake the CPU from low power modes, but I don't think 'regular' WFI with no other clock stops enabled is viewed as a low power mode, and that wouldn't quite fit with the observed behaviour where, mostly, it _does_ wake from WFI except from SNVS-absent power on.
So, a few questions;
1) If my CPU is in WFI can SYSTICK wake it OK?
2) I understand that SYSTICK takes a 100KHz tick clock directly from the XTALOSC. Is this ever gated?
3) It appears this 100KHz is considered an 'external' clock in ARM NVIC terms. Generic SYSTICK can also be clocked via the CPU clock but when you set CLKSOURCE=1 in the Control and Status Register at 0xE000E010 then no clocking seems to happen? Is there a gated clock here somewhere we can enable?
bonus question;
4) I also notice that SWD based debug does not work in this startup sequence until the ONOFF button has been pushed....what root clock is involved in that (it's not shown in the CCM Clock Tree)? I'm worried that the CPU is not coming up 'cleanly' in this circumstance.
In short, I'm trying to understand why the OS is mostly-working except following an SNVS-absent power on event!
Regards
DAVE
Hi Dave,
Do you mean the problem can be seen in system idle mode? Cold boot means power on boot? I made a simple demo, but I can't repeat your problem on RT1050-EVKB. Please try the attachment.
By default, the systick use core clock (initialized by SysTick_Config()). If you want to keep systick during WFI wait, you should enable them. Please see the demo.
Please refer to AN12085 for more low power mode detail.
Regards,
Jing@
Hi Jing,
Thanks for the example. Well, this is fascinating. Your code does indeed behave correctly and the debugger will connect immediately, and SYSTICK is running too (The '2's being printed).
Mine, not so much.
I still have the problem that I cannot get SYSTICK running, or connect with the debugger, from cold boot (i.e. power on) unless SNVS power is ready there. I must have done something silly with the clock configuration. I will investigate further and then report back to close off the issue for anyone else who may come across it.
Just so you can see the issue, I've attached a built elf of my code which will give you a shell over LPUART1 (the debugger multiplexed port). Load it onto your board and then from cold (with no battery) it will not start until you press SW2. You will also not be able to attach a debugger (at least for the case of JLink) until you've done that.
Regards
DAVE
OK, Just to close this one off.
It would seem (at least for my code) that it is essential to set CCM_CGPR::INT_MEM_CLK_LPM=1'b1 before going into WFI from cold boot, otherwise you get this locked behaviour whereby SYSTICK does not fire and you cannot connect to a debugger.
This can be closed off now. Thanks for the help, it made the fix painless.
Regards
DAVE