Skip to content
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

stm32: pm: Enable to driver JTAG port pns to analog when not required #63495

Merged

Conversation

erwango
Copy link
Member

@erwango erwango commented Oct 4, 2023

Configuring JTAG port pins in analog when not required (build time) can save few uA.

Requires #64109

Note:
This operation can also be done using pinctrl API, which would allow dynamic handling of the pins (JTAG function are alternate functions which can't be configured using GPIO API)
Main reason to push this PR using GPIO API is that this is my first shot at this. If everyone agrees this is good enough, this is fine with me

@erwango erwango added the RFC Request For Comments: want input from the community label Oct 4, 2023
@erwango erwango requested a review from galak as a code owner October 4, 2023 07:35
@erwango erwango requested a review from gmarull October 4, 2023 07:36
@zephyrbot zephyrbot added platform: STM32 ST Micro STM32 area: Devicetree Binding PR modifies or adds a Device Tree binding labels Oct 4, 2023
dts/arm/st/wba/stm32wba.dtsi Outdated Show resolved Hide resolved
soc/arm/st_stm32/common/pm_debug_jtag.c Outdated Show resolved Hide resolved
#include <zephyr/drivers/gpio.h>
#include <zephyr/init.h>

#if !defined(CONFIG_DEBUG) && defined(CONFIG_PM)
Copy link
Member

Choose a reason for hiding this comment

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

is CONFIG_PM a strict condition here?

Copy link
Member Author

Choose a reason for hiding this comment

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

If CONFIG_PM is not a condition, it would mean that you can't use gdb unless CONFIG_DEBUG is set, which is not a condition today.
I already foresee that I will get tens of questions around this..
Using CONFIG_PM, I don't break anything as gdb can't be used today with CONFIG_PM unless CONFIG_DEBUG is set.

@zephyrbot zephyrbot added manifest manifest-hal_stm32 DNM This PR should not be merged (Do Not Merge) labels Oct 6, 2023
@zephyrbot
Copy link
Collaborator

zephyrbot commented Oct 6, 2023

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff
hal_stm32 zephyrproject-rtos/hal_stm32@2292590 zephyrproject-rtos/hal_stm32@60c9634 (main) zephyrproject-rtos/hal_stm32@22925907..60c9634f

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@erwango erwango requested a review from gmarull October 12, 2023 12:02
dts/arm/st/wba/stm32wba.dtsi Outdated Show resolved Hide resolved
OpenOCD can now be used to flash and debug nucleo_wba52cg.
However it required use of STMicroelectronics OpenOCD fork.

Add instructions on how to use it.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
@erwango erwango removed the DNM This PR should not be merged (Do Not Merge) label Jan 16, 2024
@erwango erwango requested a review from gmarull January 17, 2024 10:46
FRASTM
FRASTM previously approved these changes Jan 17, 2024
west.yml Outdated Show resolved Hide resolved
Comment on lines +468 to +471
&debug_jtdi_pa15 &debug_jtdo_swo_pb3
&debug_jtrst_pb4>;
pinctrl-1 = <&analog_pa13 &analog_pa14 &analog_pa15
&analog_pb3 &analog_pb4>;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure the dtsi is the best place to put that since the pins can be used for something else than debug.
For example, in the nucleo_wba55cg.dts, PA15, PB3 and PB4 are used for SPI1. Depending on the order of initialization, I think it could result in drivers not functioning.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, so we should make sure this is done before configuring any other device and change priority

SW/JTAG signals description are useful when we don't need them.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
At chip startup, jtag pins are configured by default to enable
debug.
This configuration adds consumption and when using PM profile,
we can save ~40uA by resetting this configuration and setting pins
to analog mode.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
Provide jtag port pins description, so they can be used to be set in
analog mode when not required to save power (around 40uA saved in total).

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
In some cases, PINCTRL_STATE_SLEEP may be required even when
CONFIG_PM_DEVICE is not defined.
One example is the possibility/need to put JTAG pins to analog when
CONIG_PM=y and CONFIG_DEBUG=n.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
@erwango
Copy link
Member Author

erwango commented Jan 24, 2024

@gautierg-st PTAL

@fabiobaltieri fabiobaltieri merged commit b772e36 into zephyrproject-rtos:main Jan 26, 2024
22 checks passed
FRASTM added a commit to FRASTM/zephyr that referenced this pull request Mar 28, 2024
During the migration to Hw model V2 the PR zephyrproject-rtos#63495
was not fully reported.
This change is adding the support Serial Wire / JTAG port pins

Signed-off-by: Francois Ramu <francois.ramu@st.com>
fabiobaltieri pushed a commit that referenced this pull request Apr 1, 2024
During the migration to Hw model V2 the PR #63495
was not fully reported.
This change is adding the support Serial Wire / JTAG port pins

Signed-off-by: Francois Ramu <francois.ramu@st.com>
Lahyllas pushed a commit to tsnlab/zephyr that referenced this pull request May 16, 2024
During the migration to Hw model V2 the PR zephyrproject-rtos#63495
was not fully reported.
This change is adding the support Serial Wire / JTAG port pins

Signed-off-by: Francois Ramu <francois.ramu@st.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: Pinctrl manifest manifest-hal_stm32 platform: STM32 ST Micro STM32 RFC Request For Comments: want input from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants