$npx -y skills add easyzoom/aix-skills --skill power-management-integrationUse when integrating, porting, configuring, or debugging embedded PowerManagement libraries, power domains, sleep policies, device suspend/resume, or runtime PM frameworks
| 1 | # PowerManagement Integration |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Use this skill for library/framework-level power management, not just one low-power symptom. Confirm the system's power states, device dependencies, suspend/resume ordering, wake sources, and measurement method before enabling automatic PM policies. |
| 6 | |
| 7 | ## When To Use |
| 8 | |
| 9 | Use this skill when: |
| 10 | |
| 11 | - The user mentions `PowerManagement`, PM framework, runtime PM, device suspend/resume, power domains, or system sleep policy. |
| 12 | - The project needs coordinated low-power behavior across drivers, RTOS tasks, clocks, and wake sources. |
| 13 | - Devices fail after resume, wake immediately, lose state, or consume too much current under a PM framework. |
| 14 | |
| 15 | Do not use this skill for one-off current measurement without a PM framework. Use `low-power-debug` first. |
| 16 | |
| 17 | ## First Questions |
| 18 | |
| 19 | Ask for: |
| 20 | |
| 21 | - Power-management library/framework source and target MCU/RTOS. |
| 22 | - Power states: run, idle, sleep, stop, standby, deep sleep, off, or custom. |
| 23 | - Device list and dependencies: clocks, buses, sensors, radio, display, storage, and debug. |
| 24 | - Wake sources, retention requirements, and expected current. |
| 25 | - Existing suspend/resume hooks and current symptom. |
| 26 | |
| 27 | ## Integration Checklist |
| 28 | |
| 29 | 1. Define state model. |
| 30 | Each power state needs entry conditions, exit sources, retained resources, and forbidden operations. |
| 31 | |
| 32 | 1. Build dependency order. |
| 33 | Suspend children before parents and resume parents before children. Clocks and buses must wrap device hooks. |
| 34 | |
| 35 | 1. Separate policy from mechanism. |
| 36 | Drivers expose capabilities; policy decides when to enter a state. |
| 37 | |
| 38 | 1. Verify wake source ownership. |
| 39 | Wake flags must be read before clearing, and the responsible device should be identifiable. |
| 40 | |
| 41 | 1. Protect debug and recovery. |
| 42 | Deep states may disconnect SWD/JTAG or UART; define a recovery path. |
| 43 | |
| 44 | 1. Measure with framework enabled. |
| 45 | Compare current in each state and after resume, not only during entry. |
| 46 | |
| 47 | ## Common Failures |
| 48 | |
| 49 | - Driver resumes before its bus or clock is restored. |
| 50 | - Wake flags are cleared before being logged. |
| 51 | - A task vetoes sleep forever but does not report why. |
| 52 | - Device state is not reinitialized after deep sleep. |
| 53 | - Debug probe keeps rails active and invalidates current measurements. |
| 54 | |
| 55 | ## Verification |
| 56 | |
| 57 | Before claiming PM integration works: |
| 58 | |
| 59 | - State power states, policy, device dependency order, and wake sources. |
| 60 | - Confirm at least one enter/resume cycle for the target state. |
| 61 | - Report current measurement setup and measured value if power is in scope. |
| 62 | - Confirm recovery/debug path after deep sleep. |
| 63 | - List devices without suspend/resume support. |
| 64 | |
| 65 | ## Example |
| 66 | |
| 67 | User: |
| 68 | |
| 69 | ```text |
| 70 | 接了 PowerManagement 框架后,睡眠能进但唤醒后 I2C 传感器读不到。 |
| 71 | ``` |
| 72 | |
| 73 | Agent: |
| 74 | |
| 75 | 1. Asks for PM state, I2C bus/device hooks, clock dependencies, and wake source. |
| 76 | 1. Checks resume ordering and bus clock restoration. |
| 77 | 1. Verifies repeated suspend/resume cycles with current and device-read evidence. |