Add ability to trigger firmware update mode from Harp protocol #166
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR proposes modifying the core Harp protocol to include standardized semantics for updating the firmware of Harp-compliant devices.
Motivation
All devices that implement the Harp protocol require regular firmware updates to fix bugs and add new functionality. Currently, the update process varies depending on the hardware vendor and specific implementation. This variability could be abstracted from the user by exposing a common firmware update interface through the Harp protocol.
Standardizing this process would enable developers to target a unified update mechanism, facilitating reusability of tools (e.g., Harp CLI and Bonsai) and eliminating the need for one-off “incantations” that must otherwise be documented and communicated to users.
Detailed Design
Option 1 (The one included in the PR)
R_RESET_DEVbit 5 to trigger firmware update mode. (proposed bit name:FIRMWARE_UPDATE). This decision is justified since:Optionalunder the current protocol, but strongly recommended for boards that support it.Pros
Very simple change to the protocol and generalizable across different SDKs
Fully backward compatible (the bit was not used)
No extra register needed
Cons
No way to know what the device “supports”
Not a lot of room for additional features in this register.
Option 2
This proposal has been summarized in Issue 18
Add two registers
R_FIRMWARE_UPDATE_CAPABILITIESR_FIRMWARE_UPDATE_START_COMMANDR_FIRMWARE_UPDATE_CAPABILITIESis a bitfield that communicates the well-known firmware update strategies supported by the device.For example bit 0 is defined as
FIRMWARE_UPDATE_PICO_BOOTSEL, which indicates the strategy of the device rebooting into the BOOTSEL mode provided by the RP2040/RP2350 hardware bootloader and being programmed using thepicobootprotocol.R_FIRMWARE_UPDATE_START_COMMANDis a bitfield with the same layout. Writing to a bit instructs the device to initiate that firmware update scheme. So writingFIRMWARE_UPDATE_PICO_BOOTSELto it causes the device to reboot into BOOTSEL mode. (Similar to what Sonya is doing withRST_DFU.)Pros
Easy discoverability of update functionality
Extensible (see #18 (comment))
Cons
2 extra registers must be added to core
The core may become contaminated with sdk-specific functionality (e.g. in the cited example bit 0 seems specific for pico). There may not be a good way around this unless we go back to the idea of maintaining two cores.
Option 3 (both?)
It should be noted that, until we are sure about option 2, we could go with option 1 for the near future while we test its functionality. Option 2 could then be implemented by deprecating the previous bit (e.g. writing to the previous bit would instead trigger the functionality of bit 0 of the new register).