diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2024-10-26 11:55:21 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2024-11-14 11:17:52 -0500 |
commit | 3cdb1793d4656717a679a73cae880589bb9267ad (patch) | |
tree | 54c21462a650dde4362d4bcd44067366afd80086 | |
parent | 64ba37c02e3bfa290321713aa4e5a082993ff65e (diff) | |
download | kutter-3cdb1793d4656717a679a73cae880589bb9267ad.tar.gz kutter-3cdb1793d4656717a679a73cae880589bb9267ad.tar.xz kutter-3cdb1793d4656717a679a73cae880589bb9267ad.zip |
lib: Update rp2040_flash code to support rp2350 reboot
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | lib/rp2040_flash/main.c | 20 |
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) { |