I've been playing around with "driverless" devices lately, with the end goal of making my debugger firmware usable on recent versions of Windows without installing drivers, including the firmware upgrade.
My understanding is that LeafLabs had two obstacles to implementing the bootloader with a composite runtime DFU + CDC-ACM device:
- Composite USB devices used different custom descriptors on Windows, Mac OSX, and Linux
- On Windows, the DFU and CDC-ACM functions had no native Windows driver. Even where there were existing kernel drivers, they had to be bound to the USB device in a separate installation step.
Point 1 isn't an issue anymore, since I think all three major OSes accept the standardized interface association descriptors.
Point 2 remains, but isn't as bad on Windows 10 (and maybe Windows 8, I haven't tried it). On Windows 10, it will load the default CDC-ACM driver as long as your interface class/subclass/protocol codes match, even if it's embedded in a composite device with other functions that it doesn't understand, like DFU.
For DFU, the end goal is to bind the interface to WinUSB or LibUSB, as the Zadig installer does so that dfu-util can access it. It's possible to do this with Microsoft's custom OS descriptors and the compatible ID descriptor.
As a proof of concept, I've built a proof of concept USB-serial adapter for the bluepill:
- At boot, the DFU bootloader checks if the flash is empty or if a magic flag is set (in an RTC backup register, which survives reset)
- The rest of the time, the main application runs a composite DFU + CDC-ACM device on PA2/PA3
- When the runtime DFU interface receives a detach request, it writes to the RTC backup register and resets so that the main bootloader runs.
I've confirmed that I can load firmware with dfu-util in a Windows 10 VM (with manual intervention to connect the device after it switches to the bootloader and back) and that loopback with a jumper works from PuTTY.
The forum doesn't seem to like .bin attachments (virus risk, probably), so here's a DropBox link to the combined bootloader + usb-serial firmware that can be flashed directly with no offset (ie, address 0x08000000).
If you want to test that dfu-util works, I have an alternative application-only image with a slightly different product string ("TERMLINK103-2" instead of "TERMLINK103"):
The source isn't really documented yet, but it's up on GitHub under the winusb branch:
As Roger mentioned in the original thread, it would still be a bit of work to integrate a DFU runtime into the libmaple core proper - my code is using libopencm3's USB stack - but on the Windows side of things at least, things don't seem too bad.
As for older versions of Windows - well, the LeafLabs bootloader seems to work okay for most people anyways .