Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rebooting picoprobe CMSIS-DAP v2 devices #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2110,7 +2110,12 @@ static int reboot_device(libusb_device *device, bool bootsel, uint disable_mask=

bool reboot_command::execute(device_map &devices) {
if (settings.force) {
reboot_device(devices[dr_vidpid_stdio_usb][0].first, settings.reboot_usb);
if (!devices[dr_vidpid_stdio_usb].empty()) {
reboot_device(devices[dr_vidpid_stdio_usb][0].first, settings.reboot_usb);
}
if (!devices[dr_vidpid_cmsis].empty()) {
reboot_device(devices[dr_vidpid_cmsis][0].first, settings.reboot_usb);
}
if (!quiet) {
if (settings.reboot_usb) {
std::cout << "The device was asked to reboot into BOOTSEL mode.\n";
Expand Down Expand Up @@ -2242,7 +2247,7 @@ int main(int argc, char **argv) {
// fall thru
case cmd::device_support::one:
if (devices[dr_vidpid_bootrom_ok].empty() &&
(!settings.force || devices[dr_vidpid_stdio_usb].empty())) {
(!settings.force || (devices[dr_vidpid_stdio_usb].empty() && devices[dr_vidpid_cmsis].empty()) )) {
bool had_note = false;
fos << missing_device_string(tries>0);
if (tries > 0) {
Expand Down Expand Up @@ -2270,6 +2275,8 @@ int main(int argc, char **argv) {
#endif
printer(dr_vidpid_picoprobe,
" appears to be a RP2040 PicoProbe device not in BOOTSEL mode.");
printer(dr_vidpid_cmsis,
" appears to be a RP2040 CMSIS-DAP device not in BOOTSEL mode.");
printer(dr_vidpid_micropython,
" appears to be a RP2040 MicroPython device not in BOOTSEL mode.");
if (selected_cmd->force_requires_pre_reboot()) {
Expand Down Expand Up @@ -2306,7 +2313,7 @@ int main(int argc, char **argv) {
}
if (!rc) {
if (settings.force && ctx) { // actually ctx should never be null as we are targeting device if force is set, but still
if (devices[dr_vidpid_stdio_usb].size() != 1) {
if (devices[dr_vidpid_stdio_usb].size() + devices[dr_vidpid_cmsis].size() != 1) {
fail(ERROR_NOT_POSSIBLE,
"Forced command requires a single rebootable RP2040 device to be targeted.");
}
Expand Down
3 changes: 3 additions & 0 deletions picoboot_connection/picoboot_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static bool verbose;
#define PRODUCT_ID_PICOPROBE 0x0004u
#define PRODUCT_ID_MICROPYTHON 0x0005u
#define PRODUCT_ID_STDIO_USB 0x000au
#define PRODUCT_ID_CMSIS 0x000cu

uint32_t crc32_for_byte(uint32_t remainder) {
const uint32_t POLYNOMIAL = 0x4C11DB7;
Expand Down Expand Up @@ -75,6 +76,8 @@ enum picoboot_device_result picoboot_open_device(libusb_device *device, libusb_d
return dr_vidpid_picoprobe;
case PRODUCT_ID_STDIO_USB:
return dr_vidpid_stdio_usb;
case PRODUCT_ID_CMSIS:
return dr_vidpid_cmsis;
case PRODUCT_ID_RP2_USBBOOT:
break;
default:
Expand Down
1 change: 1 addition & 0 deletions picoboot_connection/picoboot_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum picoboot_device_result {
dr_vidpid_unknown,
dr_error,
dr_vidpid_stdio_usb,
dr_vidpid_cmsis,
};

enum picoboot_device_result picoboot_open_device(libusb_device *device, libusb_device_handle **dev_handle);
Expand Down