diff options
| author | Bjorn Beishline <[email protected]> | 2025-09-23 14:17:33 -0700 |
|---|---|---|
| committer | Bjorn Beishline <[email protected]> | 2025-09-23 14:28:10 -0700 |
| commit | 1d494594e8b96255fefb994ddcc2f46e4dec3772 (patch) | |
| tree | 254aa04fdc10a228ae0e24f0ae34436d6cca4a09 /embassy-rp/src/rom_data | |
| parent | bcb2d98fc0a3f4435d5b256b5e6b8926c6b34365 (diff) | |
Add reset_to_usb_boot to rp235x
Diffstat (limited to 'embassy-rp/src/rom_data')
| -rw-r--r-- | embassy-rp/src/rom_data/rp235x.rs | 32 |
1 files changed, 32 insertions, 0 deletions
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 { | |||
| 750 | pub fn is_secure_mode() -> bool { | 750 | pub 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++ | ||
| 756 | const BOOTSEL_FLAG_GPIO_PIN_SPECIFIED: u32 = 0x20; | ||
| 757 | const REBOOT2_FLAG_REBOOT_TYPE_BOOTSEL: u32 = 0x2; | ||
| 758 | const 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. | ||
| 770 | pub 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 | } | ||
