aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGerhard de Clercq <[email protected]>2024-12-10 09:31:47 +0100
committerGerhard de Clercq <[email protected]>2024-12-10 09:31:47 +0100
commit5963a10d4d541ef93e42ccfe339aa9aa343f2914 (patch)
tree80180de422c25e759125b959e743bcdf45a716b2 /examples
parent0b9cdd86ab398ddbc96f6859c6a33f55c788fbc6 (diff)
stm32wb-dfu: add MSOS headers
The USB DFU example now shows how to automatically get the WinUSB driver assigned.
Diffstat (limited to 'examples')
-rw-r--r--examples/boot/bootloader/stm32wb-dfu/src/main.rs17
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;
12use embassy_stm32::usb::Driver; 12use embassy_stm32::usb::Driver;
13use embassy_stm32::{bind_interrupts, peripherals, usb}; 13use embassy_stm32::{bind_interrupts, peripherals, usb};
14use embassy_sync::blocking_mutex::Mutex; 14use embassy_sync::blocking_mutex::Mutex;
15use embassy_usb::Builder; 15use embassy_usb::{msos, Builder};
16use embassy_usb_dfu::consts::DfuAttributes; 16use embassy_usb_dfu::consts::DfuAttributes;
17use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; 17use 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
24const DEVICE_INTERFACE_GUIDS: &[&str] = &["{EAA9A5DC-30BA-44BC-9232-606CDC875321}"];
25
23#[entry] 26#[entry]
24fn main() -> ! { 27fn 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();