Skip to content

Conversation

@geekman
Copy link
Contributor

@geekman geekman commented Feb 26, 2024

There are multiple problems that prevent target reset functionality from working properly:

  1. GP1 doesn't seem to work, haven't really dug into why.
    Moving to GP4 works, but this also means having to shift the UART to GP8/9.

  2. gpio_set_dir() for the reset pin is opposite to what was intended:
    state = 0 means assert reset, but the current logic in probe_assert_reset passes state directly to gpio_set_dir, which when 0 actually means GPIO_IN. When the pin is an input state, it is pulled-up high, so reset is actually not assserted.

  3. Reset pin also needs to be de-asserted in probe_deinit.
    Otherwise when a connection is first attempted and failed, nRESET will be stuck in an asserted state subsequently.

With multiple issues stacked together, target reset functionality could not be enabled easily by tweaking some #defines,
as evidenced by issue #120.

This PR should make target reset work properly now.

- Correct GPIO direction logic error in `probe_assert_reset` - Remember to de-assert nRESET on deinit
@lurch
Copy link
Contributor

lurch commented Feb 26, 2024

I'd be reluctant to move the UART pins as it'd make the wiring instructions in https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf invalid.

@geekman
Copy link
Contributor Author

geekman commented Feb 26, 2024

Understood. What pin should I assign it then? GP6?

@lurch
Copy link
Contributor

lurch commented Feb 26, 2024

That's a question that @P33M is probably better-placed to answer than I am.

@P33M
Copy link
Contributor

P33M commented Feb 26, 2024

GPIO6 is un-levelshifted uart RX input on the Debug Probe. Unfortunately only GPIO0 and 1 are the only unassigned pins broken out to somewhere accessible on that board. Why doesn't GPIO0 or 1 work as a reset output?

@geekman
Copy link
Contributor Author

geekman commented Feb 26, 2024

No idea, GP0/1 just doesn't respond to the code, it always stays high. When I change it to GP4 it works as expected (after all the other changes, of course).

@lurch
Copy link
Contributor

lurch commented Feb 26, 2024

I don't know how / when / where the "debug pins" are used, but I wonder if it might be clashing with DBG_PIN_WRITE ?

@xobs
Copy link
Contributor

xobs commented Mar 18, 2024

I've added some patches on top of the ones by @geekman. The big change is to move DAP_Setup() to come after stdio_uart_init(). The former muxes PROBE_PIN_RESET as a GPIO, and the last muxes GP0 and GP1 as a UART. If you select either of those as a reset pin, your choise will get overwritten.

I've also made a minor change in that I disable the pullup for the reset pin, under the assumption that the target already has a pull one way or the other.

The pull request there is https://github.com/geekman/debugprobe-dev/pull/1 and includes this nice screenshot of a reset working well from openocd using GP1 as the target:

Screenshot_2024-03-18-15-18-46

It's possible there is still some interference going on if you use GP0, but overall I'm happy with this result.

xobs added 3 commits March 18, 2024 21:28
This is the pin pair used in documentation. Signed-off-by: Sean Cross <sean@xobs.io>
This pin is normally used for UART debug output, but that is undocumented. Repurpose it as reset output. Signed-off-by: Sean Cross <sean@xobs.io>
When using GP1 as a reset line, this is necessary to overwrite the stdio function call from reusing the pin as a debug output. Signed-off-by: Sean Cross <sean@xobs.io>
@geekman
Copy link
Contributor Author

geekman commented Mar 18, 2024

Thanks for chasing this down. I've added your commits onto the PR.

@P33M P33M merged commit a7aa076 into raspberrypi:master Mar 18, 2024
P33M added a commit that referenced this pull request Mar 18, 2024
@P33M
Copy link
Contributor

P33M commented Mar 18, 2024

Merged, thanks - ignore the spurious revert message.

@lurch
Copy link
Contributor

lurch commented Mar 18, 2024

So in hindsight, perhaps the problem was that the #define PROBE_PIN_RESET 1 in include/board_pico_config.h was conflicting with the #define PICO_DEFAULT_UART_RX_PIN 1 in https://github.com/raspberrypi/pico-sdk/blob/master/src/boards/include/boards/pico.h ?

@P33M Should there be a #define in debugprobe that can be used to (more easily) disable usage of stdio_uart ?

recursivenomad added a commit to recursivenomad/picoprobe-candybar that referenced this pull request Aug 1, 2024
Was previously rolling with the Debug Probe default of GPIO1, but that definition appears to be due to Debug Probe's limited pinout [1]. This schematic will read easier if GPIO1 isn't shared. (Plus UART0 probably wouldn't have worked if this firmware needed to be debugged when it was shared with nRST) [1]: <raspberrypi/debugprobe#123 (comment)>
Terstegge pushed a commit to Terstegge/rp2040-launchpad-probe that referenced this pull request Feb 5, 2025
* Fix up target reset functionality. - Correct GPIO direction logic error in `probe_assert_reset` - Remember to de-assert nRESET on deinit * board_pico_config: use pin 1 for reset This pin is normally used for UART debug output, but that is undocumented. Repurpose it as reset output. Signed-off-by: Sean Cross <sean@xobs.io> * main: move stdio_uart_init() before DAP_Setup() When using GP1 as a reset line, this is necessary to overwrite the stdio function call from reusing the pin as a debug output. Signed-off-by: Sean Cross <sean@xobs.io> --------- Signed-off-by: Sean Cross <sean@xobs.io> Co-authored-by: Sean Cross <sean@xobs.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants