Skip to content

Conversation

hakehuang
Copy link
Contributor

@hakehuang hakehuang commented Aug 27, 2025

  1. Create adc_power_shield sample for any board with adc can be used for power measurement.
  2. Add general_adc_platform power shiled, which can be used for power measurement with the sample application.
  3. the power data is stored in the power_shield folder for further analysis
  4. add power measure config in testsuite.

@zephyrbot zephyrbot added area: ADC Analog-to-Digital Converter (ADC) platform: NXP NXP area: Twister Twister area: Samples Samples labels Aug 27, 2025
@hakehuang
Copy link
Contributor Author

log for mimxrt595_evk board

((.venv) ) ubuntu@ubuntu-OptiPlex-7050:/home/shared/disk/zephyr_project/zephyr_test/zephyr$ scripts/twister --device-testing --hardware-map /home/ubuntu/nxp/mimxrt595_evk_cm33/map.yaml -T samples/boards/nxp/mimxrt595_evk/system_off
ZEPHYR_BASE unset, using "/home/shared/disk/zephyr_project/zephyr_test/zephyr"
Renaming previous output directory to /home/shared/disk/zephyr_project/zephyr_test/zephyr/twister-out.1
INFO    - Using Ninja..
INFO    - Zephyr version: v4.2.0-2411-g0f6f916cbaa4
INFO    - Using 'zephyr' toolchain.
INFO    - Building initial testsuite list...
INFO    - Writing JSON report /home/shared/disk/zephyr_project/zephyr_test/zephyr/twister-out/testplan.json

Device testing on:

| Platform                      |        ID | Serial device                                         |
|-------------------------------|-----------|-------------------------------------------------------|
| mimxrt595_evk/mimxrt595s/cm33 | 727562924 | /dev/serial/by-id/usb-SEGGER_J-Link_000727562924-if00 |

INFO    - JOBS: 8
INFO    - Adding tasks to the queue...
INFO    - Added initial list of jobs to queue
INFO    - Total complete:    1/   1  100%  built (not run):    0, filtered:    0, failed:    0, error:    0
INFO    - 1 test scenarios (1 configurations) selected, 0 configurations filtered (0 by static filter, 0 at runtime).
INFO    - 1 of 1 executed test configurations passed (100.00%), 0 built (not run), 0 failed, 0 errored, with no warnings in 29.99 seconds.
INFO    - 1 of 1 executed test cases passed (100.00%) on 1 out of total 1154 platforms (0.09%).
INFO    - 1 test configurations executed on platforms, 0 test configurations were only built.


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at #94585, and only keep 1 platform per vendor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @JarmouniA PR #94585 looks good, I will update according after your PR merged

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to wait for it to be merged, just apply the same filtering and only keep overlay/conf of 1 platform per vendor in the new sample.


config SEQUENCE_32BITS_REGISTERS
bool "ADC data sequences are on 32bits"
default n
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default n

Comment on lines 36 to 37
pinctrl-0 = <&adc0_default>;
pinctrl-names = "default";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move above child node

@hakehuang hakehuang marked this pull request as draft August 28, 2025 03:32
@hakehuang hakehuang force-pushed the lc_power_shield branch 2 times, most recently from c19dcd6 to 78d25a9 Compare August 28, 2025 05:03
@hakehuang
Copy link
Contributor Author

hakehuang commented Oct 3, 2025

We already have a twister harness for the shell, can it not be reused? and regarding the specific ADC channel, that can be added in an overlay when building surely, like this PR is already doing? We can also add a custom shell command to use specifically if needed, no need to implement command line parsing in the sample

@bjarki-andreasen if you look at my PR, I add a 'dft' which reuse the whole pytest serial handler see

def dft(request: pytest.FixtureRequest, dft_object) -> Generator[DeviceAdapter, None, None]:
. ADC channel is already controlled by overlay, but the problem is that we need map the channel to the target power rails see below definition:
the channels_p and channel_n to the power rail "VDD_CORE" / "VDD_IO" is by your board setting definition, this could be different pre your test harness setting, and this has to be customized, here is use a yaml to control it.

device_id: "adc_power_monitor_01"
routes:
  - id: 0
    name: "VDD_CORE"
    shunt_resistor: 0.1  # ohms
    gain: 1.0
    type: "single"
    channels:
      channels_p: 4
      channels_n: 0
  - id: 1
    name: "VDD_IO"
    shunt_resistor: 0.1  # ohms
    gain: 1.0
    type: "single"
    channels:
      channels_p: 7
      channels_n: 3
calibration:
  offset: 0.0
  scale: 1.0

so nowhat where to add, we either add shell command or use a dedicated power shield sample application, we have to parse the shell/command output to get the board settings on its probe capacities, see below.

{
  "channel_count": 2,
  "resolution": 12,
  "channels": {
    "0": {
      "mode": "single",
      "verf_mv": 3300
    },
    "3": {
      "mode": "single",
      "verf_mv": 3300
    },
    "4": {
      "mode": "single",
      "verf_mv": 3300
    },
    "7": {
      "mode": "single",
      "verf_mv": 3300
    }
  }
}

and we need map the probe capacities to the target measure power rails as I mentioned above. My understanding is that you propose to use a series of shell command to replace the power measure sample which will be running on power shield. this will add adc shell linked with power calculations I am not sure this will accepted by ADC shell owner? As in this PR, we have an independent sample to host everything, move those to shell command needs approval, can you help to confirm on my understanding and if accepted by ADC shell group I can move the implement to shell.

@bjarki-andreasen
Copy link
Contributor

We already have a twister harness for the shell, can it not be reused? and regarding the specific ADC channel, that can be added in an overlay when building surely, like this PR is already doing? We can also add a custom shell command to use specifically if needed, no need to implement command line parsing in the sample

@bjarki-andreasen if you look at my PR, I add a 'dft' which reuse the whole pytest serial handler see

def dft(request: pytest.FixtureRequest, dft_object) -> Generator[DeviceAdapter, None, None]:
. ADC channel is already controlled by overlay, but the problem is that we need map the channel to the target power rails see below definition:
the channels_p and channel_n to the power rail "VDD_CORE" / "VDD_IO" is by your board setting definition, this could be different pre your test harness setting, and this has to be customized, here is use a yaml to control it.

device_id: "adc_power_monitor_01"
routes:
  - id: 0
    name: "VDD_CORE"
    shunt_resistor: 0.1  # ohms
    gain: 1.0
    type: "single"
    channels:
      channels_p: 4
      channels_n: 0
  - id: 1
    name: "VDD_IO"
    shunt_resistor: 0.1  # ohms
    gain: 1.0
    type: "single"
    channels:
      channels_p: 7
      channels_n: 3
calibration:
  offset: 0.0
  scale: 1.0

so nowhat where to add, we either add shell command or use a dedicated power shield sample application, we have to parse the shell/command output to get the board settings on its probe capacities, see below.

{
  "channel_count": 2,
  "resolution": 12,
  "channels": {
    "0": {
      "mode": "single",
      "verf_mv": 3300
    },
    "3": {
      "mode": "single",
      "verf_mv": 3300
    },
    "4": {
      "mode": "single",
      "verf_mv": 3300
    },
    "7": {
      "mode": "single",
      "verf_mv": 3300
    }
  }
}

and we need map the probe capacities to the target measure power rails as I mentioned above. My understanding is that you propose to use a series of shell command to replace the power measure sample which will be running on power shield. this will add adc shell linked with power calculations I am not sure this will accepted by ADC shell owner? As in this PR, we have an independent sample to host everything, move those to shell command needs approval, can you help to confirm on my understanding and if accepted by ADC shell group I can move the implement to shell.

No changes to the adc shell is needed. We would just create a set of custom shell commands as part of the power shield sample. The issue is not with having a sample at all, we need that, but with how the serial communication is implemented. We can freely create sample specific shell commands, so why not use that?

@hakehuang
Copy link
Contributor Author

No changes to the adc shell is needed. We would just create a set of custom shell commands as part of the power shield sample. The issue is not with having a sample at all, we need that, but with how the serial communication is implemented. We can freely create sample specific shell commands, so why not use that?

ok, I see, I will update this PR to add a sample specific shell command. but I have some concerns on the code size, I enable the stm32f030dlk as the low cost shield, which code size is very critical. Let me try and feedback.

@hakehuang hakehuang marked this pull request as draft October 5, 2025 01:57
@bjarki-andreasen
Copy link
Contributor

No changes to the adc shell is needed. We would just create a set of custom shell commands as part of the power shield sample. The issue is not with having a sample at all, we need that, but with how the serial communication is implemented. We can freely create sample specific shell commands, so why not use that?

ok, I see, I will update this PR to add a sample specific shell command. but I have some concerns on the code size, I enable the stm32f030dlk as the low cost shield, which code size is very critical. Let me try and feedback.

For this, enable SHELL_MINIMAL, the entire shell should "only" take up 6-8K ROM, if that is too much we may have to go with a custom solution

Comment on lines 30 to 35
config ENABLE_PM_MEASURE
bool "System Power Measure"
depends on SYS_CLOCK_EXISTS && HAS_PM
help
This option enables measurement on target power state

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These options do not belong with the subsystem, add them to the tests and/or samples where they are used

Copy link
Contributor Author

@hakehuang hakehuang Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjarki-andreasen , I move those options to testsuite config. is it OK?

@hakehuang hakehuang force-pushed the lc_power_shield branch 5 times, most recently from c1127b5 to fba939c Compare October 13, 2025 08:27
add power measure sample for general_adc_platform
power shiled, to record power/voltage/current

Signed-off-by: Hake Huang <[email protected]>
1. general power shield work with the adc_power_shield sample
2. config samples to config probe
3. add readme
4. enable parse shell command outputs, see readme for details

Signed-off-by: Hake Huang <[email protected]>
enable power shield testing on mimxrt595_evk

```
scripts/twister --device-testing --device-serial /dev/ttyACM0
-T samples/boards/nxp/mimxrt595_evk/system_off
-X pm_probe:/dev/ttyACM1,115200
```

an power_shield folder will be created in the build path
whith measured voltage/current/power

Signed-off-by: Hake Huang <[email protected]>
enable power measure on power_mgmt_soc for
mimxrt1060_evk@C

Signed-off-by: Hake Huang <[email protected]>
add power measure options to test

Signed-off-by: Hake Huang <[email protected]>
demo the power measure with frdm_rw612 boards
keep the system in final power state for measurement

Signed-off-by: Hake Huang <[email protected]>
Copy link

@hakehuang hakehuang marked this pull request as ready for review October 13, 2025 10:14
@zephyrbot zephyrbot added the area: Testsuite Testsuite label Oct 13, 2025
Copy link
Contributor

@bjarki-andreasen bjarki-andreasen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised how much python code is needed to make this work

@hakehuang
Copy link
Contributor Author

hakehuang commented Oct 14, 2025

I'm surprised how much python code is needed to make this work

@bjarki-andreasen, I want to make the adc_power_measure case simple, and move the complex things to python for easy change.
I update the pull-request description, please help to re-review again. Besides, I find there are some interrupt alignment issue with libc settings when I try to add CONFIG_GEN_SW_ISR_TABLE=n to reduce the code size. will follow up with another issue. Please help to review the pr description. Thanks a lot.

just realize that you have approved, and sorry for re-request review. My hand acts without thinking.

@bjarki-andreasen
Copy link
Contributor

I'm surprised how much python code is needed to make this work

@bjarki-andreasen, I want to make the adc_power_measure case simple, and move the complex things to python for easy change. I update the pull-request description, please help to re-review again. Besides, I find there are some interrupt alignment issue with libc settings when I try to add CONFIG_GEN_SW_ISR_TABLE=n to reduce the code size. will follow up with another issue.

CONFIG_GEN_SW_ISR_TABLE=n is not a commonly supported option, it requires CONFIG_MULTITHREADING=n and/or rewrites of IRQ handling in drivers, and is only applicable for some archs.

Please help to review the pr description. Thanks a lot.

just realize that you have approved, and sorry for re-request review. My hand acts without thinking.

No problem

@hakehuang
Copy link
Contributor Author

@kartben I update the sample application readme and reduce them to platforms that I tested. Please take a look. Thanks,

@hakehuang
Copy link
Contributor Author

CONFIG_GEN_SW_ISR_TABLE=n is not a commonly supported option, it requires CONFIG_MULTITHREADING=n and/or rewrites of IRQ handling in drivers, and is only applicable for some archs.

@bjarki-andreasen , I see. thanks a lot for this comments, I will drop the trier with CONFIG_GEN_SW_ISR_TABLE=n. Please help to approve the PR again. Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ADC Analog-to-Digital Converter (ADC) area: Power Management area: Samples Samples area: Tests Issues related to a particular existing or missing test area: Testsuite Testsuite area: Twister Twister platform: NXP MCU platform: NXP NXP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants