rp-rs / rp-hal

A Rust Embedded-HAL for the rp series microcontrollers
https://crates.io/crates/rp2040-hal
Apache License 2.0
1.44k stars 234 forks source link

reset rp235x into bootrom question #858

Closed Navelwriter closed 3 weeks ago

Navelwriter commented 3 weeks ago

I'm trying to create a decent development workflow on the Raspberry Pi Pico. With the current limitations with probe-rs, I've been trying to get picotool in my runner to work in a automated fashion, rebooting and setting it to BOOTSEL so I can program it. I tried forking usbd picotool reset over to work with the rp2350, but there remains one key error.

The crate I'm using uses rp2040_hal::rom_data::reset_to_usb_boot to reset, this is found in rp2040-hal/src/rom_data.rs:

    /// Resets the RP2040 and uses the watchdog facility to re-start in BOOTSEL mode:
    ///
    ///   * gpio_activity_pin_mask is provided to enable an 'activity light' via GPIO attached LED
    ///     for the USB Mass Storage Device:
    ///     * 0 No pins are used as per cold boot.
    ///     * Otherwise a single bit set indicating which GPIO pin should be set to output and
    ///       raised whenever there is mass storage activity from the host.
    ///  * disable_interface_mask may be used to control the exposed USB interfaces:
    ///    * 0 To enable both interfaces (as per cold boot).
    ///    * 1 To disable the USB Mass Storage Interface.
    ///    * 2 to Disable the USB PICOBOOT Interface.
    b"UB" fn reset_to_usb_boot(gpio_activity_pin_mask: u32, disable_interface_mask: u32) -> ();

but I do not see an equivalent in the rp235x-hal. Looking at 5.2.4 of the rp2350 datasheet, the Watchdog Boot Vector seems to be somewhat similar, but too be honest I'm unsure about how I would go about it. I know this is early days (and my 2nd day learning rust) but some suggestions would be appreciated.

thejpster commented 3 weeks ago

https://github.com/rp-rs/rp-hal/blob/63af8640a666ad329a0ddb1b8501a75d2ff61e3b/rp235x-hal-examples/src/bin/rom_funcs.rs#L186

Navelwriter commented 3 weeks ago

That definitely works out, thank you for the help