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

scripts: runners: nrf: Default to soft reset for the nRF52 series #85014

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

carlescufi
Copy link
Member

@carlescufi carlescufi commented Feb 1, 2025

scripts: runners: nrf: Default to soft reset for the nRF52 series

The Nordic nRF52 series have a peculiarity that is not shared with any
other Nordic families of SoCs: the reset pin can be reconfigured as a
regular GPIO. This has an unintended consequence: if the user has
reconfigured the pin in Devicetree to be a GPIO, `west flash` will
override that and configure the IC to use it as a reset pin, and the firmware
at boot won't be able to switch it back to GPIO, because that requires a UICR
erase. This behavior is very confusing to users, because the GPIO does
not work at all, since it is now just a reset line.

With this patch, `west flash` defaults to using soft reset instead of
pin reset for the nRF52 family of devices, to avoid overwriting the
reset pin configuration that the user includes in the image.

In order to be able to continue to use pin reset for users that so
desire it, a new option `--pinreset` is added that forces the use of pin
reset. The existing `--softreset` option is left exactly as it was, but
it is now applicable only to families other than the nRF52.

@zephyrbot zephyrbot added the area: West West utility label Feb 1, 2025
@carlescufi carlescufi assigned carlescufi and unassigned pdgendt Feb 1, 2025
@carlescufi carlescufi added the DNM This PR should not be merged (Do Not Merge) label Feb 1, 2025
@zephyrbot zephyrbot added the Release Notes To be mentioned in the release notes label Feb 1, 2025
@carlescufi carlescufi added Breaking API Change Breaking changes to stable, public APIs and removed Breaking API Change Breaking changes to stable, public APIs labels Feb 1, 2025
@carlescufi carlescufi force-pushed the softreset-52 branch 2 times, most recently from 35d20fa to 26161b6 Compare February 1, 2025 17:33
fabiobaltieri
fabiobaltieri previously approved these changes Feb 1, 2025
Copy link
Member

@fabiobaltieri fabiobaltieri left a comment

Choose a reason for hiding this comment

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

Looks good fell for this few times myself as well, flashing a custom board with a hacked nrf52dk image and then go to the custom firmware and the pin is still mysteriously not working until one does a uicr reset, I presume that the counter-case of this would be if the board has something else connected to that reset line in addition to the nrf chip? Anyway looks good. (just checked the last patch)

@carlescufi
Copy link
Member Author

carlescufi commented Feb 2, 2025

Thanks @fabiobaltieri!

Looks good fell for this few times myself as well, flashing a custom board with a hacked nrf52dk image and then go to the custom firmware and the pin is still mysteriously not working until one does a uicr reset,

Glad to hear that this will be useful for you too, it's a common issue.

I presume that the counter-case of this would be if the board has something else connected to that reset line in addition to the nrf chip?

Not sure I get that. This solves the problem of having something (e.g. MISO line for an SPI link) connected to the nRESET pin and west flash making that unavailable because it has configured it as nRESET instead of GPIO. The counter case would be using it as reset?

Last push is just for a couple of test updates.

mbolivar
mbolivar previously approved these changes Feb 2, 2025
rerickson1
rerickson1 previously approved these changes Feb 3, 2025
anangl
anangl previously approved these changes Feb 3, 2025
scripts/west_commands/runners/nrf_common.py Outdated Show resolved Hide resolved
scripts/west_commands/tests/test_nrf.py Outdated Show resolved Hide resolved
fabiobaltieri
fabiobaltieri previously approved these changes Feb 3, 2025
The Nordic nRF52 series have a peculiarity that is not shared with any
other Nordic families of SoCs: the reset pin can be reconfigured as a
regular GPIO. This has an unintended consequence: if the user has
reconfigured the pin in Devicetree to be a GPIO, `west flash` will
override that and configure the IC to use it as a reset pin, and the
firmware at boot won't be able to switch it back to GPIO, because that
requires a UICR erase. This behavior is very confusing to users, because
the GPIO does not work at all, since it is now just a reset line.

With this patch, `west flash` defaults to using soft reset instead of
pin reset for the nRF52 family of devices, to avoid overwriting the
reset pin configuration that the user includes in the image.

In order to be able to continue to use pin reset for users that so
desire it, a new option `--pinreset` is added that forces the use of pin
reset. The existing `--softreset` option is left exactly as it was, but
it is now applicable only to families other than the nRF52.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
@carlescufi
Copy link
Member Author

Last push: rebase

@carlescufi carlescufi removed the DNM This PR should not be merged (Do Not Merge) label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: West West utility Release Notes To be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants