"Driverless" Bootloader Proof of Concept

STM32duino bootloader aka Maple bootloader
devan
Posts: 45
Joined: Sat May 14, 2016 1:45 am

Re: "Driverless" Bootloader Proof of Concept

Post by devan » Sat Jul 16, 2016 7:41 am

That's odd. I already knew that it would only partially work on Windows 7 vs Windows 10, but the DFU interface should've installed cleanly.

Edit: I just noticed that you have installing drivers through Windows Update disabled in that screenshot. I know I said it's driverless, but I think you have to install the WinUSB driver through Windows Update at least once.

Extra edit: apparently I swapped the order of the screenshots originally.

Here's what showed up when I plugged mine in. Note: the name is slightly different because I tweaked to product string so I could verify that it loaded the new application over DFU. The part where the DFU interface gets renamed to "WinUsb device" is a limitation for Windows 7 and earlier, according to the libwdi wiki.
driver_install_status.png
driver_install_status.png (21.27 KiB) Viewed 658 times
The notes from the libwdi wiki say that it should automatically install the WinUSB driver through Windows Update on Windows 7, so I'm not sure what went wrong.

If you're up for it, could you try poking around the registry to see if a couple of entries are set correctly?
Under Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\120900020100, you should see that osvc is set to "01 21". The vendor code is 0x21 (libwdi's example uses 0x20, but 0x21 maps to '!' instead of ' ', which I find a bit more readable), which Windows uses to request its special descriptors.
registry_compatible_id.PNG
registry_compatible_id.PNG (67.02 KiB) Viewed 658 times
If that's set correctly, then the next thing to check is that the "CompatibleIDs" field is set correctly.
Under Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_1209&PID_0002&MI_02\some_random_id_gibberish, the "CompatibleIDs" key should start with "USB\MS_COMP_WINUSB"
registry_vendor_code.PNG
registry_vendor_code.PNG (43.41 KiB) Viewed 658 times
Last edited by devan on Wed Jul 20, 2016 3:07 am, edited 1 time in total.

User avatar
RogerClark
Posts: 6673
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: "Driverless" Bootloader Proof of Concept

Post by RogerClark » Sat Jul 16, 2016 8:30 am

I will try it on another machine, but I don't think it going to work on any of my machines, as they are all W7

Edit.

Tried on 2 more W7 machines and they both are worse as all I get is to bubble in the notifications tray
unrecognised.png
unrecognised.png (15.43 KiB) Viewed 652 times

User avatar
RogerClark
Posts: 6673
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: "Driverless" Bootloader Proof of Concept

Post by RogerClark » Sun Jul 17, 2016 11:15 pm

I tried making a few changes to my W7 update settings to ensure that Windows was definitely able to go and look for a matching driver, but when I made the change, and uninstalled and reconnected the bootloader, Windows seem to go off indefinitely looking for a driver, and I was unable to close the driver searching dialog.

I tried this twice and on both occasions the driver update seemed to crash and I had to kill it in the task manager.

devan
Posts: 45
Joined: Sat May 14, 2016 1:45 am

Re: "Driverless" Bootloader Proof of Concept

Post by devan » Mon Jul 18, 2016 1:20 am

On the first machine, were you using a USB 3.0 port or a USB 2.0 port? I can reproduce the issue where the DFU interface fails to install if I plug it into a USB 3.0 port first.

I'm trying to figure out a work-around for USB 3.0 issue, but USB 3.0 tracing with logman doesn't seem to work on my machine, so I'm stuck with applying fixes based on other diagnoses I can find online.

As for the other two machines, I've only seen the "USB Device Not Recognized" error when sending bad descriptors back - I'm not sure why it would be different on those machines versus the first one.

I guess WinUSB/WCID is not as simple to work with as I thought. Hopefully when I get my hands on a native Windows 10 machine, I can verify if it works as well on real hardware as it does in the VM...

User avatar
RogerClark
Posts: 6673
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: "Driverless" Bootloader Proof of Concept

Post by RogerClark » Tue Jul 19, 2016 11:15 pm

I tried all the ports on my PC and it just comes up as "unrecognized device"

I tried culling all unused items from the device manager, by running as admin, but again, it didnt make any difference.

I read yesterday that when Windows had a new VID/PID of unknown manufacturer device plugged in, it tries to load the device driver for the device class, but it then associates the driver with the VID / PID, so next time you plug the same VID/PID it loads the driver it loaded for the same VID/PID the last time it was inserted.

So, I presume that somehow Windows has now got its self screwed up and my only option is probably to go though the registry and try to remove this association.

But I'd need to try it on a machine I don't care about. As the worst case is that I break Windows

devan
Posts: 45
Joined: Sat May 14, 2016 1:45 am

Re: "Driverless" Bootloader Proof of Concept

Post by devan » Wed Jul 20, 2016 3:04 am

Yeah, some of the steps needed to make Windows load the WinUSB driver are done during the first time it sees that VID/PID pair - it caches stuff in the registry and never queries any device with the same VID/PID pair again.

From what I've seen, the device manager can be used to delete some of those cached registry entries. For example, after plugging it into the USB 3.0 port and failing to install drivers, I can get it to install successfully on the USB 2.0 port if I first uninstall the device from the device manager.

For any machines where it doesn't think that the device is malfunctioning, could you try looking at the registry entries as I described here?
viewtopic.php?f=10&t=1242&start=10#p15985

Short of getting an actual USB event trace, that would probably be the most useful debugging information I could get.

I can also build a new image that uses a different PID, if you want to try fresh without hunting down more clean Windows installs.

User avatar
RogerClark
Posts: 6673
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: "Driverless" Bootloader Proof of Concept

Post by RogerClark » Wed Jul 20, 2016 3:23 am

I checked and the first reg entry was correct, but the second reg entry
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_1209

does not exist at all.

stevestrong
Posts: 1502
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: "Driverless" Bootloader Proof of Concept

Post by stevestrong » Wed Jul 20, 2016 8:37 am

On windows, you could try simply uninstalling the driver for it, also removing existing driver.
This way it will trigger a new driver search, and will look again for VID/PID.

User avatar
RogerClark
Posts: 6673
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: "Driverless" Bootloader Proof of Concept

Post by RogerClark » Wed Jul 20, 2016 8:43 am

It comes up as "unknown device" and does not give the option to uninstall any driver :-(

devan
Posts: 45
Joined: Sat May 14, 2016 1:45 am

Re: "Driverless" Bootloader Proof of Concept

Post by devan » Sat Jul 23, 2016 10:15 pm

It's weird that the registry doesn't have any entry at all for the extended properties. I guess the whole magically-install-registry-entries-on-first-insertion strategy that Windows uses for automatically installing drivers is a bit error prone compared to just manually installing drivers as a separate step.

I finally installed Windows 10 on a used laptop. It takes a very long time to auto-install the WinUSB driver when plugging it in the first time, but it seems to eventually work. The CDC-ACM class works out of the box, as expected.

If you want to try again, I've built new firmware images for the bluepill and the Maple Mini with a test VID/PID of 1209:0003 instead of 1209:0002, which should force it to go through the installation process from scratch.
Attachments
termlink-combined-0003.zip
(16.75 KiB) Downloaded 18 times

Post Reply

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest