raspberrypi / picotool

BSD 3-Clause "New" or "Revised" License
525 stars 86 forks source link

picotool load works, then does not #64

Closed d-adamson closed 1 year ago

d-adamson commented 1 year ago

My development system Linux Mint 21.1, running on a fast PC (12th Gen Intel Core i9-12900K). The target board is a Pico W

The following command with the -f flag successfully uploads on the first try. $ picotool load -f filename
However, subsequent upload attempts fail with this error message. No accessible RP2040 devices in BOOTSEL mode were found. Unplugging the pico, pressing BOOTSEL button and replugging the board allows picotool to upload again ... but only once.

The following workaround using the -F flag seems to be robust $ picotool load -F filename $ picotool reboot

Seems like there may be a timing issue when using the -f flag

JamesH65 commented 1 year ago

Is the application you are uploading using USB STDIO?

d-adamson commented 1 year ago

Sorry, I wrote "picoprobe" in the title, but meant "picotool" (was a little tired at the time). Updated the title. @JamesH65. Not necessarily. Replicated the behavior using the example from the sdk pico_w/blink

FIRST ATTEMPT - OK ~/pico/pico-examples/build/pico_w/blink$ picotool load -f picow_blink.uf2 The device was asked to reboot into BOOTSEL mode so the command can be executed.

Loading into Flash: [==============================] 100%

The device was asked to reboot back into application mode.

SECOND ATTEMPT - NO GO ~/pico/pico-examples/build/pico_w/blink$ picotool load -f picow_blink.uf2 No accessible RP2040 devices in BOOTSEL mode were found.

lurch commented 1 year ago

As it notes in the picotool README "...but running compatible code..." i.e. there needs to be "something listening" on the Pico-side of the USB connection for these picotool commands. Which is typically either BOOTSEL mode or USB stdio. And so if you've not enabled USB stdio in your application, and you've "rebooted into application mode" (i.e. your application is actually running) then there's nothing on your Pico listening for picotool commands. Which perfectly explains the behaviour you're seeing.

P.S. If your Pico is in BOOTSEL mode, then neither of the -f / -F flags are necessary.

d-adamson commented 1 year ago

Thanks! Yeah, I wasn't sure what was meant by "...but running compatible code..." Seems to be working now.

SOLUTION: Rebuilt the program after adding the following lines in the example's CMakeLists.txt

pico_enable_stdio_usb(picow_blink 1) pico_enable_stdio_uart(picow_blink 0)