Skip to content

USB: Remove DFU interface from Uno R4 WiFi #471

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mgcookson
Copy link
Contributor

Change motivation summary

The Uno R4 WiFi mistakenly presents a DFU port to its host when connected via USB.

Change motivation details

When the Uno R4 WiFi is connected to a Windows host via USB cable, the Windows Device Manager app reveals that the device's DFU port is missing a driver. Attempting to install a driver via the Windows driver installer in this repository's ..\drivers folder does not resolve the issue. However, since the Uno R4 WiFi uploads applications via a COM port, not DFU, it should not be presenting a DFU port to the host at all.

Resolution summary

  • Modify the Uno R4 WiFi's variant specific header file (tusb_config.h) to disable CFG_TUD_DFU_RUNTIME.
  • Modify the USB descriptor setup code (in USB.cpp) to respect the CFG_TUD_DFU_RUNTIME value in the header file.

Resolution notes

I have altered how all of the USB interface descriptors are constructed to unify the approach used for each and improve the maintainability of the code. This expanded the scope of changes that were strictly required to address the issue, but I felt it made the entire method a bit easier to understand and manage going forward.

Research supporting chosen resolution

Examination of the two files noted below leads me to believe that all board variants supported by this repository support DFU except the Uno R4 WiFi.

DFU device driver installer INF (../drivers/renesas.inf)

  • The PID for the Uno R4 WiFi device (0x006D) is not present in the DFU device driver installer INF file.
  • The PID for all other board variants are present in the DFU device driver installer INF file, and have CFG_TUD_DFU_RUNTIME enabled in their variant specific header file.

Arduino boards definition (../boards.txt)

  1. All boards use dfu-util except Uno R4 WiFi, which uses bossac.

Notes

  • While I recognize that the ESP32-S3 used in the Uno R4 WiFi does in fact support DFU, I don't believe that people who are using that ability will be affected by this change. If I am incorrect on this point, let me know and I will review further.
  • In addition to the Uno R4 WiFi, I also have an Uno R4 Minima. I tested its behavior with this PR - it continues to function using DFU as expected. I do not have any other devices to test with, so that is a potential gap that could be addressed prior to merging this PR.
  • Pre-existing behavior when the DISABLE_USB_SERIAL macro is defined has been preserved. Specifically, when this macro is defined at compile time the device will not present either a DFU or a CDC interface to its host at runtime.
  • This PR has the following effect on program memory usage for the following few devices I checked:
    • Uno R4 Minima: +168 bytes
    • Uno R4 WiFi: -200 bytes
    • Portenta C33: +208 bytes

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants