aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rp2040_flash/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rp2040_flash/main.c')
-rw-r--r--lib/rp2040_flash/main.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/rp2040_flash/main.c b/lib/rp2040_flash/main.c
index 69ea168d..78007130 100644
--- a/lib/rp2040_flash/main.c
+++ b/lib/rp2040_flash/main.c
@@ -110,7 +110,7 @@ int report_error(libusb_device_handle *handle, const char *cmd) {
return 1;
};
-int picoboot_flash(libusb_device_handle *handle, struct flash_data *image) {
+int picoboot_flash(libusb_device_handle *handle, struct flash_data *image, model_t model) {
fprintf(stderr, "Resetting interface\n");
if (picoboot_reset(handle)) {
return report_error(handle, "reset");
@@ -146,8 +146,18 @@ int picoboot_flash(libusb_device_handle *handle, struct flash_data *image) {
}
fprintf(stderr, "Rebooting device\n");
- if (picoboot_reboot(handle, 0, 0, 500)) {
- return report_error(handle, "reboot");
+ if (model == 2040) {
+ if (picoboot_reboot(handle, 0, 0, 500)) {
+ return report_error(handle, "reboot");
+ }
+ } else {
+ struct picoboot_reboot2_cmd cmd = {
+ .dFlags = REBOOT2_FLAG_REBOOT_TYPE_NORMAL,
+ .dDelayMS = 500,
+ };
+ if (picoboot_reboot2(handle, &cmd)) {
+ return report_error(handle, "reboot");
+ }
}
return 0;
@@ -204,12 +214,12 @@ int main(int argc, char *argv[]) {
goto do_exit;
}
+ model_t model;
for (libusb_device **dev = devs; *dev; ++dev) {
if (has_target) {
if (target_bus != libusb_get_bus_number(*dev)) continue;
if (target_address != libusb_get_device_address(*dev)) continue;
}
- model_t model;
enum picoboot_device_result res = picoboot_open_device(*dev, &handle, &model, -1, -1, "");
if (res == dr_vidpid_bootrom_ok) {
break;
@@ -230,7 +240,7 @@ int main(int argc, char *argv[]) {
libusb_get_bus_number(dev), libusb_get_device_address(dev));
fprintf(stderr, "Flashing...\n");
- rc = picoboot_flash(handle, image);
+ rc = picoboot_flash(handle, image, model);
do_exit:
if (handle) {