aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb-dfu/src
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-usb-dfu/src')
-rw-r--r--embassy-usb-dfu/src/application.rs21
-rw-r--r--embassy-usb-dfu/src/dfu.rs21
2 files changed, 12 insertions, 30 deletions
diff --git a/embassy-usb-dfu/src/application.rs b/embassy-usb-dfu/src/application.rs
index 2646d100d..4b7b72073 100644
--- a/embassy-usb-dfu/src/application.rs
+++ b/embassy-usb-dfu/src/application.rs
@@ -2,7 +2,7 @@ use embassy_boot::BlockingFirmwareState;
2use embassy_time::{Duration, Instant}; 2use embassy_time::{Duration, Instant};
3use embassy_usb::control::{InResponse, OutResponse, Recipient, RequestType}; 3use embassy_usb::control::{InResponse, OutResponse, Recipient, RequestType};
4use embassy_usb::driver::Driver; 4use embassy_usb::driver::Driver;
5use embassy_usb::{msos, Builder, Handler}; 5use embassy_usb::{Builder, FunctionBuilder, Handler};
6use embedded_storage::nor_flash::NorFlash; 6use embedded_storage::nor_flash::NorFlash;
7 7
8use crate::consts::{ 8use crate::consts::{
@@ -130,22 +130,13 @@ pub fn usb_dfu<'d, D: Driver<'d>, MARK: DfuMarker, RST: Reset>(
130 builder: &mut Builder<'d, D>, 130 builder: &mut Builder<'d, D>,
131 handler: &'d mut Control<MARK, RST>, 131 handler: &'d mut Control<MARK, RST>,
132 timeout: Duration, 132 timeout: Duration,
133 winusb_guids: Option<&'d [&str]>, 133 func_modifier: impl Fn(&mut FunctionBuilder<'_, 'd, D>),
134) { 134) {
135 let mut func = builder.function(0x00, 0x00, 0x00); 135 let mut func = builder.function(0x00, 0x00, 0x00);
136 if let Some(winusb_guids) = winusb_guids { 136
137 // We add MSOS headers so that the device automatically gets assigned the WinUSB driver on Windows. 137 // Here we give users the opportunity to add their own function level MSOS headers for instance.
138 // Otherwise users need to do this manually using a tool like Zadig. 138 // This is useful when DFU functionality is part of a composite USB device.
139 // 139 func_modifier(&mut func);
140 // Adding them here on the function level appears to only be needed for compositive devices.
141 // In addition to being on the function level, they should also be added to the device level.
142 //
143 func.msos_feature(msos::CompatibleIdFeatureDescriptor::new("WINUSB", ""));
144 func.msos_feature(msos::RegistryPropertyFeatureDescriptor::new(
145 "DeviceInterfaceGUIDs",
146 msos::PropertyData::RegMultiSz(winusb_guids),
147 ));
148 }
149 140
150 let mut iface = func.interface(); 141 let mut iface = func.interface();
151 let mut alt = iface.alt_setting(USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_RT, None); 142 let mut alt = iface.alt_setting(USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_RT, None);
diff --git a/embassy-usb-dfu/src/dfu.rs b/embassy-usb-dfu/src/dfu.rs
index 43a35637d..0f39d906b 100644
--- a/embassy-usb-dfu/src/dfu.rs
+++ b/embassy-usb-dfu/src/dfu.rs
@@ -1,7 +1,7 @@
1use embassy_boot::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterError}; 1use embassy_boot::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterError};
2use embassy_usb::control::{InResponse, OutResponse, Recipient, RequestType}; 2use embassy_usb::control::{InResponse, OutResponse, Recipient, RequestType};
3use embassy_usb::driver::Driver; 3use embassy_usb::driver::Driver;
4use embassy_usb::{msos, Builder, Handler}; 4use embassy_usb::{Builder, FunctionBuilder, Handler};
5use embedded_storage::nor_flash::{NorFlash, NorFlashErrorKind}; 5use embedded_storage::nor_flash::{NorFlash, NorFlashErrorKind};
6 6
7use crate::consts::{ 7use crate::consts::{
@@ -186,22 +186,13 @@ impl<'d, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize> Ha
186pub fn usb_dfu<'d, D: Driver<'d>, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize>( 186pub fn usb_dfu<'d, D: Driver<'d>, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize>(
187 builder: &mut Builder<'d, D>, 187 builder: &mut Builder<'d, D>,
188 handler: &'d mut Control<'d, DFU, STATE, RST, BLOCK_SIZE>, 188 handler: &'d mut Control<'d, DFU, STATE, RST, BLOCK_SIZE>,
189 winusb_guids: Option<&'d [&str]>, 189 func_modifier: impl Fn(&mut FunctionBuilder<'_, 'd, D>),
190) { 190) {
191 let mut func = builder.function(USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_DFU); 191 let mut func = builder.function(USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_DFU);
192 if let Some(winusb_guids) = winusb_guids { 192
193 // We add MSOS headers so that the device automatically gets assigned the WinUSB driver on Windows. 193 // Here we give users the opportunity to add their own function level MSOS headers for instance.
194 // Otherwise users need to do this manually using a tool like Zadig. 194 // This is useful when DFU functionality is part of a composite USB device.
195 // 195 func_modifier(&mut func);
196 // Adding them here on the function level appears to only be needed for compositive devices.
197 // In addition to being on the function level, they should also be added to the device level.
198 //
199 func.msos_feature(msos::CompatibleIdFeatureDescriptor::new("WINUSB", ""));
200 func.msos_feature(msos::RegistryPropertyFeatureDescriptor::new(
201 "DeviceInterfaceGUIDs",
202 msos::PropertyData::RegMultiSz(winusb_guids),
203 ));
204 }
205 196
206 let mut iface = func.interface(); 197 let mut iface = func.interface();
207 let mut alt = iface.alt_setting(USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_DFU, None); 198 let mut alt = iface.alt_setting(USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_DFU, None);