Skip to content

Implement BOOTSEL button entry to safe mode for RP2. #10231

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

Merged
merged 6 commits into from
Apr 15, 2025

Conversation

eightycc
Copy link
Collaborator

@eightycc eightycc commented Apr 7, 2025

Implements BOOTSEL button entry to safe mode the RP2 port.

Resolves issue #9710.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Looks fine to me but the CI is unhappy.

@eightycc eightycc linked an issue Apr 8, 2025 that may be closed by this pull request
@eightycc
Copy link
Collaborator Author

eightycc commented Apr 8, 2025

Fixed up CI by adding an additional CIRCUITPY_BOOT_BUTTON_NO_GPIO pre-processor macro for RP2 boards w/o a BOOTSEL GPIO pin connection. All RP2 boards are now coded this way, but I don't think there's any advantage to special-casing the ones that do have a GPIO pin connection.

Noticed an opportunity for a bit of code refactoring and took it.

@eightycc eightycc requested a review from tannewt April 8, 2025 22:16
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Refactor looks good! One other question before approving.

@@ -576,3 +583,53 @@ void port_boot_info(void) {
mp_printf(&mp_plat_print, "\n");
#endif
}

#if defined(CIRCUITPY_BOOT_BUTTON_NO_GPIO)
Copy link
Member

Choose a reason for hiding this comment

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

Do you only want this if there is no separate BOOT button?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's there for some flexibility that we may not need. For example, an individual board could undefine CIRCUITPY_BOOT_BUTTON_NO_GPIO and define a GPIO pin with CIRCUITPY_BOOT_BUTTON.

Copy link
Member

Choose a reason for hiding this comment

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

I'd assume that CIRCUITPY_BOOT_BUTTON would take precedence.

Note we generally don't use defined/undefined for CP macros. Instead we always test their value and have a default value #ifndef in py/. This ensures the code that uses it includes the correct headers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it and agree that that is the correct policy. Will update.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Made CIRCUITPY_BOOT_BUTTON_NO_GPIO default to 0, changed usage to #if from #ifdef. Added compile-time check prohibiting CIRCUITPY_BOOT_BUTTON and CIRCUITPY_BOOT_BUTTON_NO_GPIO.

…le time check forbidding CIRCUITPY_BOOT_BUTTON and CIRCUITPY_BOOT_BUTTON_NO_GPIO.
@eightycc eightycc requested a review from tannewt April 12, 2025 12:45
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

One question. Thanks for the update!

… defined.

Co-authored-by: Scott Shawcroft <scott@tannewt.org>
@eightycc eightycc requested a review from tannewt April 15, 2025 16:46
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thank you!

@tannewt tannewt merged commit 8f7496c into adafruit:main Apr 15, 2025
159 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.

Raspberry Pi Pico 2 can't enter Safe Mode
2 participants