Skip to content

Commit 1f833f3

Browse files
committed
disable -f on windows except for reboot
1 parent 5515049 commit 1f833f3

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

main.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,10 @@ auto device_selection =
268268
(option("--bus") & integer("bus").min_value(1).max_value(255).set(settings.bus)
269269
.if_missing([] { return "missing bus number"; })) % "Filter devices by USB bus number" +
270270
(option("--address") & integer("addr").min_value(1).max_value(127).set(settings.address)
271-
.if_missing([] { return "missing address"; })) % "Filter devices by USB device address" +
272-
#if defined(_WIN32)
273-
option('f', "--force").set(settings.force) % "Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. Unless the command itself causes a reboot, the device will be rebooted back to application mode" +
271+
.if_missing([] { return "missing address"; })) % "Filter devices by USB device address"
272+
#if !defined(_WIN32)
273+
+ option('f', "--force").set(settings.force) % "Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. Unless the command itself causes a reboot, the device will be rebooted back to application mode" +
274274
option('F', "--force-no-reboot").set(settings.no_reboot_if_forced) % "Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. Unless the command itself causes a reboot, the device will be left connected and accessible to picotool, but without the RPI-RP2 drive mounted"
275-
#else
276-
option('f', "--force").set(settings.force) % "Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. Unless the command itself causes a reboot, the device will be rebooted back to application mode. In either case the RPI-RP2 drive may briefly appear during the forced command" +
277-
option('F', "--force-no-reboot").set(settings.no_reboot_if_forced) % "Force a device not in BOOTSEL mode but running compatible code to reset so the command can be executed. Unless the command itself causes a reboot, the device will be left connected and accessible to picotool, with the RPI-RP2 drive mounted"
278275
#endif
279276
).min(0).doc_non_optional(true);
280277

@@ -421,6 +418,9 @@ struct reboot_command : public cmd {
421418
(
422419
option('a', "--application").clear(settings.reboot_usb) % "Reboot back into the application (this is the default)" +
423420
option('u', "--usb").set(settings.reboot_usb) % "Reboot back into BOOTSEL mode "
421+
#if defined(_WIN32)
422+
+ option('f', "--force").set(settings.force) % "Force a device not in BOOTSEL mode but running compatible code to reboot."
423+
#endif
424424
).min(0).doc_non_optional(true) % "Reboot type" +
425425
device_selection % "Selecting the device to reboot";
426426
}
@@ -1978,16 +1978,7 @@ static int reboot_device(libusb_device *device, bool bootsel, uint disable_mask=
19781978

19791979
void reboot_command::execute(device_map &devices) {
19801980
if (settings.force) {
1981-
// cannot
1982-
#if !defined(_WIN32)
1983-
uint disable_mask = settings.reboot_usb ? 1 : 0; // this is bit 0 for the USB drive
1984-
#else
1985-
// On Windows we cannot disable the USB drive as interface 0 changes type as as a result,
1986-
// and Windows starts breathing into a paper bag.
1987-
// The upshort is that on windows, the RPI-RP2 drive will briefly appear during forced commands
1988-
uint disable_mask = 0;
1989-
#endif
1990-
reboot_device(devices[dr_vidpid_stdio_usb][0].first, disable_mask);
1981+
reboot_device(devices[dr_vidpid_stdio_usb][0].first, settings.reboot_usb);
19911982
} else {
19921983

19931984
// not exclusive, because restoring un-exclusive could fail; also if we're rebooting, we don't much
@@ -2124,8 +2115,13 @@ int main(int argc, char **argv) {
21242115
" appears to be a RP2040 PicoProbe device not in BOOTSEL mode.");
21252116
printer(dr_vidpid_micropython,
21262117
" appears to be a RP2040 MicroPython device not in BOOTSEL mode.");
2118+
#if defined(_WIN32)
2119+
printer(dr_vidpid_stdio_usb,
2120+
" appears to be a RP2040 device with a USB serial connection, not in BOOTSEL mode. You can reset it into BOOTSEL mode via 'picotool reset -f' first.");
2121+
#else
21272122
printer(dr_vidpid_stdio_usb,
21282123
" appears to be a RP2040 device with a USB serial connection, so consider -f or -F.");
2124+
#endif
21292125
rc = ERROR_NO_DEVICE;
21302126
} else if (supported == cmd::device_support::one) {
21312127
if (devices[dr_vidpid_bootrom_ok].size() > 1 ||

0 commit comments

Comments
 (0)