raspberrypi / picotool

BSD 3-Clause "New" or "Revised" License
555 stars 95 forks source link

Unable to see device via --address flag on Windows #48

Closed neilenns closed 2 years ago

neilenns commented 2 years ago

Steps to reproduce:

  1. Plug in a RP2040 Pico to Windows 11 while holding down the BOOTSEL button
  2. Run picotool info

Result: device is found, reports no program information (correct)

  1. Run picotool info --address 5

Result: "No accessible RP2040 devices in BOOTSEL mode were found with address 5." Expected result: device is found and reports no program information

I'm using WinUSB v6.1.760.16385 for the driver, installed via zadig. The device address comes from the device properties in Device Manager.

neilenns commented 2 years ago

I've also tried with libusb-win32 (v1.2.6.0) just for fun but no change in behaviour.

neilenns commented 2 years ago

It took a while but I was able to build the latest version of picotool locally. Running that with the device not in BOOTSEL mode got me output saying the device was at address 15, not 5. Using address 15 worked.

So I guess there's nothing wrong with picotool and it's just a matter of figuring out how to discover the address for the pico in device manager? I'll keep digging.

lurch commented 2 years ago

See also #26

neilenns commented 2 years ago

@lurch I did see that as well. In my case I am trying to programmatically run picotool so I need some way to identify the boards beforehand then pass in the address of the board I want to reference.

For Arduinos this is done with the COM port, and that port is available in the Windows registry. I can enumerate the USB devices from the registry, find the COM port, then call avrdude accordingly.

I'm struggling to do the same with picotool because I can't find the address picotool is using in the registry (which shows 5 not 15 and a bus of 0 which picotool also doesn't think is valid).

lurch commented 2 years ago

Perhaps picotool is using some kind of "libusb addressing scheme" which is different to the Device-Manager addressing scheme? :shrug: (the fun thing about USB is how many different "layers" there are!)

And just in case it's not obvious - AFAIK it's only necessary to use the --address flag if you've got more than one Pico connected at once. With only a single Pico in use, picotool should just always correctly auto-detect it.

neilenns commented 2 years ago

@lurch In my situation it's possible there will be many Picos connected at the same time so I need to be able to directly address them.

I agree, I think there's some sort of magic libusb addressing scheme going on. Unfortunately that's yet another layer down in the libusb code so I'm not sure how it's doing it :(

kilograham commented 2 years ago

Yes, we are just relying on libusb - you may want to google to see if that is fabricating bus/addresses on Windows

neilenns commented 2 years ago

I was able to get a sample app running using a .NET USB library (which I can integrate into my project) and enumerate the devices and see the address (15) and bus (2).

Closing this since it's obviously not a picotool problem.