aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-rp/CHANGELOG.md1
-rw-r--r--embassy-rp/src/rom_data/rp235x.rs32
2 files changed, 33 insertions, 0 deletions
diff --git a/embassy-rp/CHANGELOG.md b/embassy-rp/CHANGELOG.md
index ea62c2387..e932bcaa3 100644
--- a/embassy-rp/CHANGELOG.md
+++ b/embassy-rp/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13- Add PIO onewire parasite power strong pullup 13- Add PIO onewire parasite power strong pullup
14- add `wait_for_alarm` and `alarm_scheduled` methods to rtc module ([#4216](https://github.com/embassy-rs/embassy/pull/4216)) 14- add `wait_for_alarm` and `alarm_scheduled` methods to rtc module ([#4216](https://github.com/embassy-rs/embassy/pull/4216))
15- rp235x: use msplim for stack guard instead of MPU 15- rp235x: use msplim for stack guard instead of MPU
16- Add reset_to_usb_boot for rp235x ([#4705](https://github.com/embassy-rs/embassy/pull/4705))
16 17
17## 0.8.0 - 2025-08-26 18## 0.8.0 - 2025-08-26
18 19
diff --git a/embassy-rp/src/rom_data/rp235x.rs b/embassy-rp/src/rom_data/rp235x.rs
index b16fee8f7..c0a1ed6fb 100644
--- a/embassy-rp/src/rom_data/rp235x.rs
+++ b/embassy-rp/src/rom_data/rp235x.rs
@@ -750,3 +750,35 @@ pub fn is_secure_mode() -> bool {
750pub fn is_secure_mode() -> bool { 750pub fn is_secure_mode() -> bool {
751 false 751 false
752} 752}
753
754// These and the reset_to_usb_boot function are found from https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_bootrom/bootrom.c#L35-L51
755// The following has just been translated to rust from the original c++
756const BOOTSEL_FLAG_GPIO_PIN_SPECIFIED: u32 = 0x20;
757const REBOOT2_FLAG_REBOOT_TYPE_BOOTSEL: u32 = 0x2;
758const REBOOT2_FLAG_NO_RETURN_ON_SUCCESS: u32 = 0x100;
759
760/// Resets the RP235x and uses the watchdog facility to re-start in BOOTSEL mode:
761/// * gpio_activity_pin_mask is provided to enable an 'activity light' via GPIO attached LED
762/// for the USB Mass Storage Device:
763/// * 0 No pins are used as per cold boot.
764/// * Otherwise a single bit set indicating which GPIO pin should be set to output and
765/// raised whenever there is mass storage activity from the host.
766/// * disable_interface_mask may be used to control the exposed USB interfaces:
767/// * 0 To enable both interfaces (as per cold boot).
768/// * 1 To disable the USB Mass Storage Interface.
769/// * 2 to Disable the USB PICOBOOT Interface.
770pub fn reset_to_usb_boot(mut usb_activity_gpio_pin_mask: u32, disable_interface_mask: u32) {
771 let mut flags = disable_interface_mask;
772
773 if usb_activity_gpio_pin_mask != 0 {
774 flags = flags | BOOTSEL_FLAG_GPIO_PIN_SPECIFIED;
775 usb_activity_gpio_pin_mask = usb_activity_gpio_pin_mask.trailing_zeros()
776 }
777
778 reboot(
779 REBOOT2_FLAG_REBOOT_TYPE_BOOTSEL | REBOOT2_FLAG_NO_RETURN_ON_SUCCESS,
780 10,
781 flags,
782 usb_activity_gpio_pin_mask,
783 );
784}