usb: dfu: add separate pid for dfu mode
Refactor the file structure for USB DFU class to facilitate separate PID for USB DFU when in DFU mode. As required by USB DFU 1.1 Section 2, the PID in the USB device descriptor must be different between the Run-time and DFU mode device descriptor to avoid problems caused by the host OS caching the remaining descriptors when switching to DFU mode, thus hiding the new interface descriptors from applications on the host and reporting the Run-time descriptors when the device is in DFU mode. To avoid adding too much clutter to the root USB class Kconfig and CMakeLists files, move the DFU class files into their own directory with dedicated Kconfig and CMakeLists.txt. Signed-off-by: Michael Rosen <michael.r.rosen@intel.com>
This commit is contained in:
parent
d92ee92c95
commit
1c89837e79
@ -4,9 +4,9 @@ zephyr_sources_ifdef(CONFIG_USB_CDC_ACM cdc_acm.c)
|
||||
zephyr_sources_ifdef(CONFIG_USB_MASS_STORAGE mass_storage.c)
|
||||
zephyr_sources_ifdef(CONFIG_USB_DEVICE_BLUETOOTH bluetooth.c)
|
||||
zephyr_sources_ifdef(CONFIG_USB_DEVICE_BT_H4 bt_h4.c)
|
||||
zephyr_sources_ifdef(CONFIG_USB_DFU_CLASS usb_dfu.c)
|
||||
zephyr_sources_ifdef(CONFIG_USB_DEVICE_LOOPBACK loopback.c)
|
||||
|
||||
add_subdirectory_ifdef(CONFIG_USB_DEVICE_AUDIO audio)
|
||||
add_subdirectory_ifdef(CONFIG_USB_DEVICE_NETWORK netusb)
|
||||
add_subdirectory_ifdef(CONFIG_USB_DEVICE_HID hid)
|
||||
add_subdirectory_ifdef(CONFIG_USB_DFU_CLASS dfu)
|
||||
|
||||
@ -136,33 +136,4 @@ source "subsys/usb/class/hid/Kconfig"
|
||||
|
||||
source "subsys/usb/class/audio/Kconfig"
|
||||
|
||||
config USB_DFU_CLASS
|
||||
bool "USB DFU Class Driver"
|
||||
select MPU_ALLOW_FLASH_WRITE
|
||||
select POLL
|
||||
depends on IMG_MANAGER
|
||||
select IMG_ERASE_PROGRESSIVELY if SOC_FLASH_NRF
|
||||
help
|
||||
USB DFU class driver
|
||||
|
||||
config USB_DFU_WAIT_DELAY_MS
|
||||
int "wait_for_usb_dfu() timeout"
|
||||
depends on USB_DFU_CLASS
|
||||
default 12000
|
||||
range 1000 120000
|
||||
help
|
||||
A thread can use wait_for_usb_dfu() call for wait a prescribed
|
||||
time (in ms) for DFU to begin
|
||||
|
||||
config USB_DFU_DETACH_TIMEOUT
|
||||
int
|
||||
depends on USB_DFU_CLASS
|
||||
default 1000
|
||||
|
||||
config USB_DFU_DEFAULT_POLLTIMEOUT
|
||||
int "Default value for bwPollTimeout"
|
||||
depends on USB_DFU_CLASS
|
||||
default 256
|
||||
range 0 1000
|
||||
help
|
||||
Default value for bwPollTimeout (in ms)
|
||||
source "subsys/usb/class/dfu/Kconfig"
|
||||
|
||||
11
subsys/usb/class/dfu/CMakeLists.txt
Normal file
11
subsys/usb/class/dfu/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_sources(usb_dfu.c)
|
||||
|
||||
if(CONFIG_USB_DEVICE_PID EQUAL CONFIG_USB_DEVICE_DFU_PID)
|
||||
message(WARNING
|
||||
"Run-Time and DFU Mode VID and PID are equal, which can lead to incorrect \
|
||||
behavior on some operating systems; see DFU 1.1 Specification Ch. 2 for \
|
||||
more details."
|
||||
)
|
||||
endif()
|
||||
40
subsys/usb/class/dfu/Kconfig
Normal file
40
subsys/usb/class/dfu/Kconfig
Normal file
@ -0,0 +1,40 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menuconfig USB_DFU_CLASS
|
||||
bool "USB DFU Class Driver"
|
||||
select MPU_ALLOW_FLASH_WRITE
|
||||
select POLL
|
||||
depends on IMG_MANAGER
|
||||
select IMG_ERASE_PROGRESSIVELY if SOC_FLASH_NRF
|
||||
help
|
||||
USB DFU class driver
|
||||
|
||||
if USB_DFU_CLASS
|
||||
|
||||
config USB_DEVICE_DFU_PID
|
||||
hex "USB DFU Product ID"
|
||||
default 0xFFFF
|
||||
help
|
||||
USB device product ID in DFU mode. MUST be configured by vendor.
|
||||
|
||||
config USB_DFU_WAIT_DELAY_MS
|
||||
int "wait_for_usb_dfu() timeout"
|
||||
default 12000
|
||||
range 1000 120000
|
||||
help
|
||||
A thread can use wait_for_usb_dfu() call for wait a prescribed
|
||||
time (in ms) for DFU to begin
|
||||
|
||||
config USB_DFU_DETACH_TIMEOUT
|
||||
int
|
||||
default 1000
|
||||
|
||||
config USB_DFU_DEFAULT_POLLTIMEOUT
|
||||
int "Default value for bwPollTimeout"
|
||||
default 256
|
||||
range 0 1000
|
||||
help
|
||||
Default value for bwPollTimeout (in ms)
|
||||
|
||||
endif # USB_DFU_CLASS
|
||||
@ -144,7 +144,8 @@ struct dev_dfu_mode_descriptor dfu_mode_desc = {
|
||||
.bDeviceProtocol = 0,
|
||||
.bMaxPacketSize0 = USB_MAX_CTRL_MPS,
|
||||
.idVendor = sys_cpu_to_le16((uint16_t)CONFIG_USB_DEVICE_VID),
|
||||
.idProduct = sys_cpu_to_le16((uint16_t)CONFIG_USB_DEVICE_PID),
|
||||
.idProduct =
|
||||
sys_cpu_to_le16((uint16_t)CONFIG_USB_DEVICE_DFU_PID),
|
||||
.bcdDevice = sys_cpu_to_le16(BCDDEVICE_RELNUM),
|
||||
.iManufacturer = 1,
|
||||
.iProduct = 2,
|
||||
Loading…
Reference in New Issue
Block a user