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

Implement reset() and halt() functions #613

Merged
merged 4 commits into from
Sep 8, 2023
Merged

Conversation

jannic
Copy link
Member

@jannic jannic commented May 16, 2023

Possible implementation of #564

rp2040-hal/src/lib.rs Outdated Show resolved Hide resolved
rp2040-hal/src/lib.rs Outdated Show resolved Hide resolved
@jannic
Copy link
Member Author

jannic commented Jul 22, 2023

Unfortunately, I'm yet to find a good way to reset the rp2040 without losing the debug connection.

The current implementation, which just stops core1 an then calls sys_reset does work, but doesn't fully reset the rp2040. Notably, the spinlocks aren't reset.

However, any attempt to also reset the SIO (which hosts the spinlocks) also breaks the debug connection.

I tend to drop the requirement that the debug connection should stay alive, and instead just trigger a full watchdog reset. Any opinions?

@jannic
Copy link
Member Author

jannic commented Jul 22, 2023

For now, I settled on just doing a full reset, even if it breaks the debug connection. I consider a reliable reset more important than the ability to debug through a reset sequence.

@jannic jannic marked this pull request as ready for review July 22, 2023 14:12
@0xa10 0xa10 mentioned this pull request Jul 29, 2023
@thejpster
Copy link
Member

Neotron Pico BIOS uses scratchpad registers to detect a core0 reset and forces a SoC reset with the watchdog. probe-rs gets kicked out, but the workaround I found is to flash it from within the USB bootloader - none of my hardware is configured, and so my crowbar routine is neither triggered nor required.

rp2040-hal/src/lib.rs Outdated Show resolved Hide resolved
@jannic
Copy link
Member Author

jannic commented Aug 22, 2023

Neotron Pico BIOS uses scratchpad registers to detect a core0 reset and forces a SoC reset with the watchdog. probe-rs gets kicked out, but the workaround I found is to flash it from within the USB bootloader - none of my hardware is configured, and so my crowbar routine is neither triggered nor required.

That's a nice solution, but I don't think it's suitable for the HAL: The firmware might need the scratchpad registers for some other purpose.

Also, what this PR implements is mainly what you do in watchdog_reboot, just without the 10ms delay. If the firmware author makes sure to use it everywhere instead of calling sys_reset, no boot-time workaround is needed. (Of course, the workaround would still be useful in case the incomplete reset was done by the debug probe.)

@thejpster
Copy link
Member

rebase on 674 I guess?

@jannic jannic merged commit 2eb3d6f into rp-rs:main Sep 8, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide functions to safely halt or reset the RP2040
2 participants