-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Enable nxp mcus general power off demo #93248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Enable nxp mcus general power off demo #93248
Conversation
ZhaoxiangJin
commented
Jul 17, 2025
- Enabled generic poweroff example for NXP MCUs. The example can test pass on frdm_mcxa153, frdm_mcxa156, frdm_mcxa166, frdm_mcxa276, frdm_mcxn236, frdm_mcxn947 and mimxrt595_evk.
- Migrate the existing mimxrt595_evk/system_off example to the new poweroff example.
e5b989b
to
b5b52a1
Compare
b5b52a1
to
af45214
Compare
@ZhaoxiangJin please address the CI issues |
0ef42bc
to
8266f47
Compare
samples/boards/nxp/poweroff/Kconfig
Outdated
config COUNTER_WAKEUP_ENABLE | ||
bool | ||
select COUNTER | ||
default y if BOARD_FRDM_MCXA153 || BOARD_FRDM_MCXA156 || \ | ||
BOARD_FRDM_MCXA166 || BOARD_FRDM_MCXA276 || \ | ||
BOARD_FRDM_MCXN947 || BOARD_MIMXRT595_EVK | ||
help | ||
Use counter to wake up device from poweroff. | ||
|
||
config GPIO_WAKEUP_ENABLE | ||
bool | ||
select GPIO | ||
default y if BOARD_FRDM_MCXN236 | ||
help | ||
Use gpio to wake up device from poweroff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these kconfigs need to be namedspaced for the sample. also, I recommend using zephyr,user
node in DT to drive this instead of kconfig anyways. ie, put a property for counter and a property for gpio and determine from that in the code based on which property exists in zephyr,user
node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the advantage of using DT to drive this? The advantage of using Kconfig is that users can select the wakeup source (wakeup button or counter) as needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine I guess but you still need to namespace the configs, and I wouldn't call them _ENABLE, and make this a choice config instead (unless you intend both to be possible at once)
soc/nxp/mcx/mcxa/power.c
Outdated
#define WAKEUP_DELAY 0x5B | ||
#define WAKEUP_COUNTER_INDEX 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least they have names but they are still kind of magically chosen numbers it looks like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wakeup delay is the minimum value should be configured when a different VDD_CORE level is configured in low power modes (LP_CFG register) compared to active modes (ACTIVE_CFG register). From RM, it should be 0x5B.
Wakeup counter index is used for wakeup unit (WUU) addressing, wuu manages many wakeup sources, lptmr index is 6.
what about create a Kconfig.poweroff and add Kconfig options for them?
8266f47
to
3b7d942
Compare
d16fd19
to
76fb580
Compare
CI blocked by #94169 |
Ping @decsny for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocked over kconfig namespaces and Kconfig.soc
soc/nxp/mcx/mcxa/Kconfig.soc
Outdated
|
||
config SOC_WAKEUP_DELAY | ||
int "Wakeup delay" | ||
default 91 | ||
help | ||
When a different VDD_CORE level is configured in low | ||
power modes compared to active modes, the wakeup delay | ||
must be configured to a minimum value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this config should not be added in a Kconfig.soc file, Kconfig.soc is only for HWM hierarchy description, put in Kconfig file and namespace for the platform
soc/nxp/mcx/mcxn/Kconfig.soc
Outdated
config SOC_WAKEUP_DELAY | ||
int "Wakeup delay" | ||
default 780 | ||
help | ||
When a different VDD_CORE level is configured in low | ||
power modes compared to active modes, the wakeup delay | ||
must be configured to a minimum value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
soc/nxp/mcx/mcxn/power.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the power.c code looks almost the same between mcxa and mcxn, not required but would it be a good idea or not to share code somewhere in a file somewhere like mcx/common ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the code looks very similar, as MCXA and MCXN using the same power architecture. I plan to enable power management for MCXA and MCXN later, and there are still some hardware differences between MCXA and MCXN. So it's probably better to keep them relatively independent for now.
76fb580
to
782a375
Compare
Update:
|
782a375
to
a7b0195
Compare
Update: |
Hello @dleach02, @mmahadevan108, please help to review this PR, thanks. |
Pulling MCUX SDK cmc, vbat, wuu driver to Zephyr build tree. Signed-off-by: Zhaoxiang Jin <[email protected]>
This commit enables MCXN236, MCXN947 LPUART pin internal pullup resistor. For MCXN947 and MCXN236, during LPUAR initialization, the RX pin is pulled down internally and STAT[RAF] is set to one. In this state, attempting to enter low power mode will trigger LPACK reset and therefore cannot truly enter low power mode. The correct setting should be to enable LPUART pin internal pullup resistor. Signed-off-by: Zhaoxiang Jin <[email protected]>
This commit introduced the following changes: 1. Selected kconfig option 'HAS_POWEROFF' for NXP MCXA series. 2. Added power.c for NXP MCXA series, in this file, we currently implemented 'z_sys_poweroff()' function. 3. For the MCXA series, after waking up from the deep power down mode, the reset handler will be executed, and we need to release the I/O pads and certain peripheral devices to normal operating mode in 'soc_reset_hook'. Signed-off-by: Zhaoxiang Jin <[email protected]>
This commit introduced the following changes: 1. Selected kconfig option 'HAS_POWEROFF' for NXP MCXN series. 2. Added power.c for NXP MCXN series, in this file, we currently implemented 'z_sys_poweroff()' function. 3. For the MCXN series, after waking up from the deep power down mode, the reset handler will be executed, and we need to release the I/O pads and certain peripheral devices to normal operating mode in 'soc_reset_hook'. Signed-off-by: Zhaoxiang Jin <[email protected]>
This commit introduced the following changes: 1. MIMXRT595 poweroff corresponds to its full deep power down mode not deep power down mode. 2. Enable OSC32K before poweroff, the OSC32K is the clock source of the wakeup source RTC. 3. Enable RTC wake-up function. Signed-off-by: Zhaoxiang Jin <[email protected]>
Enabled FRO16k for LPTMR when LPTMR clock source is set to 0x1. Signed-off-by: Zhaoxiang Jin <[email protected]>
Enabled FRO16k for LPTMR when LPTMR clock source is set to 0x1. Signed-off-by: Zhaoxiang Jin <[email protected]>
Introduce Kconfig.peripherals for NXP devices. In this file, we defined kconfig options like MCUX_HW_HAS_xxx, these kconfig option is set to true or false depending on whether the peripheral instance node in DT is enabled or not. why we need MCUX_HW_HAS_xxx? For example, the konfig option 'COUNTER_MCUX_LPTMR_WAKEUP_SOURCE_INDEX' only sets its value when LPTMR is used as a wakeup source. Therefore, we need to use the predefined kconfig function 'dt_nodelabel_bool_prop' in kconfig to determine whether LPTMR enabled the wakeup-source property. To do this, we need to iterate over all LPTMR nodes in the DT, such as lptmr0, lptmr1, and so on, to see if they enabled the wakeup-source property. How can we iterate over all LPTMR nodes? We need to pass in the currently iterated LPTMR instance. How do we know which instance we are currently iterating over? We need to determine whether MCUX_HW_HAS_LPTMRn is true and then define the current mcux_hw_lptmr_index to n. This will determine the instance. This is why we need MCUX_HW_HAS_xxx and Kconfig.peripherals Signed-off-by: Zhaoxiang Jin <[email protected]>
1. Enable lptmr wakeup feature 2. Enable lptmr get_freq function Signed-off-by: Zhaoxiang Jin <[email protected]>
Enable gpio_mcux wakeup feature Signed-off-by: Zhaoxiang Jin <[email protected]>
This commit introduced the following changes: 1. Enabled generic poweroff example for NXP MCUs. The example is test on frdm_mcxa153, frdm_mcxa156, frdm_mcxa166, frdm_mcxa276, frdm_mcxn236, frdm_mcxn947 and mimxrt595_evk. 3. Migrate the existing mimxrt595_evk/system_off example to the new poweroff example. 4. The Poweroff example now supports counter wake-up and button/GPIO wake-up, suitable for most NXP devices/boards. For testing purposes, frdm_mcxn236 is wakeup using the wake-up button; frdm_mcxa153, frdm_mcxa156, frdm_mcxa166, frdm_mcxa276, and frdm_mcxn947 are wakeup using lptmr; mimxrt595_evk is wakeup using high-resolution RTC. Signed-off-by: Zhaoxiang Jin <[email protected]>
1. Update redirects.py to find the correct mimxrt595_evk system_off example README. 2. Update release-notes to record the new nxp poweroff example. Signed-off-by: Zhaoxiang Jin <[email protected]>
a7b0195
to
758f0a9
Compare
Update: |
|