Is it safe to reuse USB D+/D- (PA11/PA12) as GPIO after one-time DFU programming?
Hi,
I'm using the STM32C071K8U6's built-in USB DFU bootloader for one-time production programming. After flashing, PA11/PA12 (USB D+/D-) are used as regular GPIO outputs to control two P-MOSFETs (each with their 100kΩ gate pull-ups to 4.2V).
The USB functionality is not used by the end customer, but the USB connector remains accessible for charging. This means a PC's USB cable may be connected during normal use allowing for potential signal injected into those traces resulting into the PMOS being turned on/off by the PC if it detects there is a USB device connected and tries to enumerate it.
The two core issues:
a) When a user plugs into a PC for charging, we need to guarantee the host does not attempt enumeration, and that nothing the host does on D+/D- interferes with our GPIO-driven MOSFET gates.
b) because the PA11 and PA12 traces also go all over the PCB - i.e. they form very long stubs - we need to make sure this does not prevent the USB from working properly during that one time DFU happens in production.
Questions:
- Attached is the schematic of how I am thinking of implementing this. Is this the correct approach to guarantee the host does not detect the microcontroller as a peripheral — i.e., ensuring it never attempts enumeration, thereby guaranteeing zero interference with the P-MOS switching — while still allowing reliable DFU programming during production?
- if that is correct, are the values in my schematic correct (100% safe to achieve the goals)?
- I am fairly certain of the following but would like confirmation: despite using the USB pins for DFU during production, because PA11 and PA12 are used only as GPIOs at runtime, we should configure them as GPIOs in CubeMX from the outset — rather than configuring them as USB and then changing them to GPIO in firmware. Is that correct?
Thank you as always!
