1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
//! System reboot through the bootrom
//!
//! [`reboot`] asks the bootrom to reset the chip via the watchdog, choosing the
//! boot path: normal flash boot, BOOTSEL (`usb boot`), an image in RAM, a flash
//! update, or a direct PC/SP jump. This is the mechanism the bootrom's own USB
//! boot interfaces use, and it is a superset of
//! [`watchdog::reboot`](crate::watchdog::reboot), which always takes the normal
//! path.
//!
//! ## Features
//!
//! - Normal / BOOTSEL / RAM image / flash update / PC+SP boot targets
//! - BOOTSEL with the picoboot and/or mass-storage USB interface suppressed
//!
//! ## Example
//!
//! ```ignore
//! use rp2350::reboot::{self, RebootKind};
//!
//! // Equivalent of the SDK's `reset_usb_boot(0, 0)`: reboot into BOOTSEL with
//! // both USB interfaces enabled and no activity LED.
//! reboot::reboot(RebootKind::BootSel {
//! picoboot_disabled: false,
//! msd_disabled: false,
//! });
//! ```
//!
//! ## Notes
//!
//! The reset is asynchronous: the bootrom arms the watchdog and returns, and
//! the chip resets [`REBOOT_DELAY_MS`] later. [`reboot`] never returns — it
//! spins until the reset happens, and panics if the bootrom refuses the request
//! (for example [`RebootKind::PcSp`] from a Non-secure ARM caller).
//!
//! This HAL is ARM-only (Cortex-M33), so no architecture-switch flags are set:
//! both cores stay on the architecture the chip booted with.
/// Delay between arming the watchdog and the reset, in milliseconds.
///
/// The bootrom needs a few hundred microseconds to shut down USB and the other
/// boot-time state; this matches what `picotool` and `rp235x-hal` use.
pub const REBOOT_DELAY_MS: u32 = 500;
// Boot types (`flags[3:0]`), RP2350 datasheet §5.5.10.1.
/// Reboot through the normal boot path.
const REBOOT_TYPE_NORMAL: u32 = 0x0000;
/// Reboot like BOOTSEL being held during power-up.
const REBOOT_TYPE_BOOTSEL: u32 = 0x0002;
/// Search RAM (including XIP RAM) for an image and boot it.
const REBOOT_TYPE_RAM_IMAGE: u32 = 0x0003;
/// Normal boot, but preferring the partition that was just updated.
const REBOOT_TYPE_FLASH_UPDATE: u32 = 0x0004;
/// Jump straight to a PC/SP pair (secure ARM callers only).
const REBOOT_TYPE_PC_SP: u32 = 0x000d;
// `p0` carries these flags; `p1` is the optional activity-indicator GPIO
// number, which this API does not expose.
/// BOOTSEL flag: do not expose the picoboot interface (`p0` bit 1).
const BOOTSEL_DISABLE_PICOBOOT: u32 = 0x02;
/// BOOTSEL flag: do not expose the mass-storage interface (`p0` bit 0).
const BOOTSEL_DISABLE_MSD: u32 = 0x01;
/// Which boot path the next reset should take.
///
/// Mirrors the bootrom's `REBOOT_TYPE_*` values; see RP2350 datasheet §5.5.10.1.
/// Reboot the chip. Never returns.
///
/// # Panics
///
/// Panics if the bootrom refuses the reboot, e.g. [`RebootKind::PcSp`] from a
/// Non-secure ARM caller.
!