-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USB DFU device + Composite Device with ACM Serial - Windows Fails #23337
Comments
@optdcw please provide more information, as requested in the GitHub issue template. At the very minimum wich board and Zephyr revision are you using. |
Board: nrf52840 DK |
Thanks. For good measure, since several fixes have landed since 2.1.0 related to both CDC ACM and USB DFU, could you please try the current master and see if the problem is present there too? |
I will test it with the master branch until the end of the week. I'm looking for using the dfu both inside mcu boot and in the user application to enable boatload during normal operations. |
What version of bootloader are You using? |
I'm using fw-nrfconnect-mcu boot, I think version 1.4.0. |
Please provide information about host OS version. Does the sample samples/subsys/usb/dfu work for you? |
@optdcw if possible, could you verify that the issue is also present in Zephyr 2.2 (released yesterday) and in the current master branch? |
The issue is indeed present in the Version Zephyr 2.2 - subsystem USB.
Note that i figure out that if you reinstall the WinUSB while the device is connected the dfu-utils successfuly downloads the image into the device. Only once. Log from MCU boot is following:
|
I am experiencing issue with dfu-util. I think its because of linux vm. I will try to help as soon i get done with that. |
It happened only on windows, right? I think the problem is with IAD descriptor which is not present when You config |
Yes it happends only on windows. |
Could You provide prj.conf that You are using for build the dfu + cdc sample? I believe You should be using cdc sample + dfu overlay from ./samples/usb/cdc/ + overlay-composite-cdc-dfu.conf. |
So i made clean installation of zephyr 2.2.0. Which is the reason i guess the example is not working. It propably expects mcuboot to be there however it is not. Which is strange given that the overlay has the CONFIG_BOOTLOADER_MCUBOOT=y in it. The complete prj.conf for the example is prj.txt |
So i made the similar test with nrf connect sdk zephyr version: Zephyr version: 2.1.99. (ncs-nrf tag: v1.2.0) There the mcuboot created merged.hex as expected. The application booted sucessfuly. I used this prj.conf. I installed the driver using zadig: WinUSB (v6.1.7600.16385). The output of the dfu util is here dfu_update.txt The dfu-util did not performed the bootload sequence. When CONFIG_USB_CDC_ACM=n is disabled(With some commenting lines in main.c). The dfu-util does not work. When CONFIG_USB_COMPOSITE_DEVICE=n and CONFIG_USB_CDC_ACM=n the dfu-util works prj.config. I had to add permission to allow mcu to be able to write into the flash. |
Any progress regarding this issue ? @emob-nordic |
Together with @carlescufi and @jfischer-phytec-iot we came up with conclusion: For me it happend once that I could actually use cdc+dfu on windows but this required swapping the drivers from one to another several times. It's very unstable. Why don't You configure dfu to actually flash the device with cdc function? I was about to refer to this issue by preparing the patch to the sample doc that actually using dfu+cdc on Windows may not work and We do not recommend using this configuration. |
I tried using the cdc-serial bootloader and got it to work however the dfu worked faster and seemed much more robust. If you don't recommend using this kind of configuration i will revert to using the cdc-serial bootloader. Which is a little bit unconvinient. |
Hi, I think under the circumstances we have this would be necessary for You to use cdc-serial instead of dfu. |
@optdcw To clarify, is it really necessary to trigger update process from application side without any barrier? |
@jfischer-phytec-iot we are currently in development stage of protable device, which will have usb interface only for chargin and bootload/debuging purposes. So it would be easier for us to use existing software to perform the DFU without the need to switch between them using CDC ACM. Which could be simple command. Your idea is also interesting to try, however it would require to modify existing usb subsystem parts to enable such behavior. Or is there some support for switching between usb interfaces ? The other option is to have USB DFU enabled inside MCUboot which would then wait for usb dfu. However i have not seed option for applicatino to specify for the mcu boot to wait for host after next reboot(which would be very convinient function). And the main application would after boot command restarted for the mcuboot bootload. |
@jfischer-phytec-iot if you have a chance, can you please comment on the question from @optdcw? |
I suggest to go with two CDC ACM interfaces (one for update and the other for logging) for now.
No, the stack supports only one configuration. I have an idea how to rework the initialization/interface of the classes so that the user or an application could initialize a class on demand and then enable usb stack, but it would take a while to get it mainline.
I do not know if there is a way to trigger an user defined behavior in MCUboot from the application.
|
Hi, PrepareBuild and flash the bootloader: Then prepared signed bin file for dfu upload. I personally took blinky. Simialr steps as with cdc+dfu app expect signed bin is required. General NotesZephyr is linnking descriptors in special RAM seciton and does it by sorting descriptors aplhabetically. Dfu device contains of 2 descriptor sets:
Dfu device is returning Run-Time descriptor when 1st connected to the Host. Linux testingStarting from APPEND in the screenshot is example how linux handles dfu capable device. Everything works fine there and image is downloaded correctly. Windows testingFor Windows You must install driver by Your own. At the first attachement of the composite device Note the driver is NONE. Here is what happend when I tried the dfu download. Treat 'APPENDs' as delimiters for dfu download tries. I am enclosing output form cmd window.
At the very first attpemt Windows is addresing proper interface wIndex = 0x02. Second attempt fails at requests because the device has already swapped The problem is: Windows never resets the device after requesting to switch to DFU-mode. EDIT: This is an explanation of one Windows flaw I have noticed. I was playing with zadig/dfu a lot and in the end I broke windows drivers that bad I had to reinstall the os. Before I reinstalled it I have seen one more case that windows was always addressing Interface 0 with dfu requests. I've reworked how linker places descriptors in RAM so Interface 0 was dfu (hack to fill Windows issues) and after all same happend. No bus reset form the Host and unable to proceed with dfu upload. I do not know why this happens. I just wanted to share my findings and build some reference for the future. |
Add a note for composite (CDC+DFU) device overlay. Composite device CDC+DFU may not work with Windows OS host. Windows OS does not send reset after DFU_DETACH request (does not re-enumerates) and thus make it unable for the device to restart in DFU mode. For more details refer to zephyrproject-rtos#23337. Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Add a note for composite (CDC+DFU) device overlay. Composite device CDC+DFU may not work with Windows OS host. Windows OS does not send reset after DFU_DETACH request (does not re-enumerates) and thus make it unable for the device to restart in DFU mode. For more details refer to #23337. Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Add a note for composite (CDC+DFU) device overlay. Composite device CDC+DFU may not work with Windows OS host. Windows OS does not send reset after DFU_DETACH request (does not re-enumerates) and thus make it unable for the device to restart in DFU mode. For more details refer to zephyrproject-rtos#23337. Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
I'm experiencing similar issue as this closed on [#15497] and [#14882]
I'm using USB DFU device with composite device ACM for serial port.
On linux everything runs ok, however on windows i keep getting the Lost device after RESET:
The windows also expiriences issue with listing mentioned in: [#15497]
It is listing single partition.
The main clue is propably that windows DFU-util works when the composite device with USB ACM is disabled.
I also found pull request: #15818 which mentions that:
'dfu + composite mode ❌ (class_handler (and custom_handler) is hardcoded to primary set of descriptors, dfu has two set of descriptors and does not work in composite configuration)'
The text was updated successfully, but these errors were encountered: