Skip to content

Conversation

@petejohanson
Copy link
Contributor

Reboot to the bootloader if non-zero restart type.

Signed-off-by: Peter Johanson [email protected]

See https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_bootrom/include/pico/bootrom.h#L161 for the API used to reboot into the bootloader in ROM.

Reboot to the bootloader if non-zero restart type.

Signed-off-by: Peter Johanson <[email protected]>
Copy link
Contributor

@yonsch yonsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@petejohanson Please also explain in the commit message the rationale for this change

Set general purpose retention register and reboot */
void sys_arch_reboot(int type)
{
if (type != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use SYS_REBOOT_WARM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that really match? I know that nRF52840 uses a different special code shoved into a register that various bootloaders will honor to enter the bootloader, which seems a bit different than a normal "warm reboot".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you using this for? As far as I know type is either warm or cold

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nrf52840 version of this sets a specific retained register to whatever value is passed in:

void sys_arch_reboot(int type)
{
	nrf_power_gpregret_set(NRF_POWER, (uint8_t)type);
	NVIC_SystemReset();
}

The adafruit bootloader inspects that register for a specific value, and if detected, enters the bootloader instead of launching the already flashed application.

Ideally, we should be able to replicate that somehow on RP2040. I don't see any consistent conventions for other SoCs, nor any explicit note about the reboot type being extensible. From include/zephyr/sys/reboot.h:

#define SYS_REBOOT_WARM 0
#define SYS_REBOOT_COLD 1

/**
 * @brief Reboot the system
 *
 * Reboot the system in the manner specified by @a type.  Not all architectures
 * or platforms support the various reboot types (SYS_REBOOT_COLD,
 * SYS_REBOOT_WARM).
 *
 * When successful, this routine does not return.
 */
extern FUNC_NORETURN void sys_reboot(int type);

@gmarull Any suggestions for us?

@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Mar 30, 2023
@yonsch
Copy link
Contributor

yonsch commented Apr 2, 2023

@petejohanson Is this still relevant?

@github-actions github-actions bot removed the Stale label Apr 3, 2023
@github-actions
Copy link

github-actions bot commented Jun 3, 2023

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Jun 3, 2023
@github-actions github-actions bot closed this Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants