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

boot stage2: double reset to uf2 #87

Closed
hathach opened this issue Feb 5, 2021 · 11 comments · Fixed by #137
Closed

boot stage2: double reset to uf2 #87

hathach opened this issue Feb 5, 2021 · 11 comments · Fixed by #137
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@hathach
Copy link
Contributor

hathach commented Feb 5, 2021

Hi hi, thank you for the pico.

It is great to have uf2 built into the bootrom, as maintainer of similar tinyuf2 (cross-platform uf2 bootloader), I kind of miss the double tap on reset button to enter uf2 feature. Which set a sram location to a magic number and wait for 0.5 second. If another reset occurs (double reset) during wait time then mcu will enter uf2 mode as following code does:

https://github.com/adafruit/tinyuf2/blob/master/src/main.c#L84

  • pros: it requires only 1 button (RST) for small form factor PCB and in general easier to operate than press reset and hold BOOTSEL.
  • cons: it does introduce additional 0.5s to boot process.

I wonder if RPI would be interested in adding this feature, my approach would be modify boot stage2 for double reset detection then use watchdog reset to jump to UF2. https://github.com/raspberrypi/pico-sdk/tree/master/src/rp2_common/boot_stage2

Thanks

@Wren6991
Copy link
Contributor

Wren6991 commented Feb 5, 2021

Hi,

We have an example of a library for doing this by injecting before main, here:

https://github.com/raspberrypi/pico-examples/tree/master/system/double_tap_usb_boot

An example of using it is here:

https://github.com/raspberrypi/pico-examples/tree/master/system/hello_double_tap

The second stage is responsible for setting up flash execution -- anything not directly related to that does not need to be in the second stage, and can be registered to run before main() with a constructor attribute (or by explicitly allocating a function pointer in .init_array)

@hathach
Copy link
Contributor Author

hathach commented Feb 5, 2021

Oh that is great to hear, sorry, I didn't notice it is already available for usage as library. It is probably better to include it as default, so that user can quickly switch between examples. Though that is totally your call to apply to sdk examples. I will notify other folks at adafruit to include this @tannewt . Thanks for the tips.

@hathach hathach closed this as completed Feb 5, 2021
@Wren6991
Copy link
Contributor

Wren6991 commented Feb 5, 2021

We can look at moving it to the SDK and adding a build flag. I'll talk to @kilograham when he is back from holiday

@hathach
Copy link
Contributor Author

hathach commented Feb 5, 2021

We can look at moving it to the SDK and adding a build flag. I'll talk to @kilograham when he is back from holiday

That sounds like a great plan 👍

@hathach
Copy link
Contributor Author

hathach commented Feb 9, 2021

I reopen the issue as reminder for your decision on the SDK discussion. Feel free to close it anytime you make the decision. Thanks

@hathach hathach reopened this Feb 9, 2021
@Wren6991
Copy link
Contributor

I did ask him last night but will ping here -- @kilograham are you happy to move that library into the SDK? Seems like it would mostly be a positive change, only major problem I see is that you can inadvertently wipe your flash or not include the lib, and you might prefer to still have a BOOTSEL button for those cases.

@kilograham
Copy link
Contributor

i'm fine with adding the library... name needs some thought; double tap of what? perhaps it is obvious idk

@Wren6991
Copy link
Contributor

Let's start the bidding at pico_bootsel_on_double_reset?

@kilograham
Copy link
Contributor

not sure if you are making fun of my like of long names, but i'm fine with that (or pico_bootsel_via_double_reset)

@hathach
Copy link
Contributor Author

hathach commented Feb 12, 2021

Superb news. Thanks for adding this, I am happy with any names 👍 👍

@kilograham kilograham self-assigned this Feb 14, 2021
@kilograham kilograham added this to the 1.0.2 milestone Feb 15, 2021
@kilograham kilograham added the enhancement New feature or request label Feb 15, 2021
@kilograham kilograham linked a pull request Feb 17, 2021 that will close this issue
Wren6991 added a commit that referenced this issue Feb 18, 2021
* Add pico_bootsel_via_double_reset library, fix #87

* pico_bootsel_via_double_reset: remove unnecessary library guard, fix subdirectory ordering

* Fix C type used as PICO_CONFIG type
@hathach
Copy link
Contributor Author

hathach commented Feb 18, 2021

closed thanks to #137

@hathach hathach closed this as completed Feb 18, 2021
kilograham pushed a commit that referenced this issue Mar 5, 2021
* Add pico_bootsel_via_double_reset library, fix #87

* pico_bootsel_via_double_reset: remove unnecessary library guard, fix subdirectory ordering

* Fix C type used as PICO_CONFIG type
kilograham pushed a commit that referenced this issue Mar 5, 2021
* Add pico_bootsel_via_double_reset library, fix #87

* pico_bootsel_via_double_reset: remove unnecessary library guard, fix subdirectory ordering

* Fix C type used as PICO_CONFIG type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants