diff options
| -rw-r--r-- | examples/boot/bootloader/stm32wb-dfu/src/main.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/examples/boot/bootloader/stm32wb-dfu/src/main.rs b/examples/boot/bootloader/stm32wb-dfu/src/main.rs index 093b39f9d..b09d53cf0 100644 --- a/examples/boot/bootloader/stm32wb-dfu/src/main.rs +++ b/examples/boot/bootloader/stm32wb-dfu/src/main.rs | |||
| @@ -12,7 +12,7 @@ use embassy_stm32::rcc::WPAN_DEFAULT; | |||
| 12 | use embassy_stm32::usb::Driver; | 12 | use embassy_stm32::usb::Driver; |
| 13 | use embassy_stm32::{bind_interrupts, peripherals, usb}; | 13 | use embassy_stm32::{bind_interrupts, peripherals, usb}; |
| 14 | use embassy_sync::blocking_mutex::Mutex; | 14 | use embassy_sync::blocking_mutex::Mutex; |
| 15 | use embassy_usb::Builder; | 15 | use embassy_usb::{msos, Builder}; |
| 16 | use embassy_usb_dfu::consts::DfuAttributes; | 16 | use embassy_usb_dfu::consts::DfuAttributes; |
| 17 | use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; | 17 | use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; |
| 18 | 18 | ||
| @@ -20,6 +20,9 @@ bind_interrupts!(struct Irqs { | |||
| 20 | USB_LP => usb::InterruptHandler<peripherals::USB>; | 20 | USB_LP => usb::InterruptHandler<peripherals::USB>; |
| 21 | }); | 21 | }); |
| 22 | 22 | ||
| 23 | // This is a randomly generated GUID to allow clients on Windows to find our device | ||
| 24 | const DEVICE_INTERFACE_GUIDS: &[&str] = &["{EAA9A5DC-30BA-44BC-9232-606CDC875321}"]; | ||
| 25 | |||
| 23 | #[entry] | 26 | #[entry] |
| 24 | fn main() -> ! { | 27 | fn main() -> ! { |
| 25 | let mut config = embassy_stm32::Config::default(); | 28 | let mut config = embassy_stm32::Config::default(); |
| @@ -62,6 +65,18 @@ fn main() -> ! { | |||
| 62 | &mut control_buf, | 65 | &mut control_buf, |
| 63 | ); | 66 | ); |
| 64 | 67 | ||
| 68 | // We add MSOS headers so that the device automatically gets assigned the WinUSB driver on Windows. | ||
| 69 | // Otherwise users need to do this manually using a tool like Zadig. | ||
| 70 | // | ||
| 71 | // It seems it is important for the DFU class that these headers be on the Device level. | ||
| 72 | // | ||
| 73 | builder.msos_descriptor(msos::windows_version::WIN8_1, 2); | ||
| 74 | builder.msos_feature(msos::CompatibleIdFeatureDescriptor::new("WINUSB", "")); | ||
| 75 | builder.msos_feature(msos::RegistryPropertyFeatureDescriptor::new( | ||
| 76 | "DeviceInterfaceGUIDs", | ||
| 77 | msos::PropertyData::RegMultiSz(DEVICE_INTERFACE_GUIDS), | ||
| 78 | )); | ||
| 79 | |||
| 65 | usb_dfu::<_, _, _, ResetImmediate, 4096>(&mut builder, &mut state); | 80 | usb_dfu::<_, _, _, ResetImmediate, 4096>(&mut builder, &mut state); |
| 66 | 81 | ||
| 67 | let mut dev = builder.build(); | 82 | let mut dev = builder.build(); |
