DevKit Auto USB Programming: A New Fix
Posted: Thu Jun 02, 2022 7:51 pm
Hello Forum Folks,
There have been numerous conversations about the behavior of the clever little 2-Transistor circuit used on DevKit boards to allow for Host tools to initiate bootloader and code download to ESP devices. Seemingly inexplicably it works "no problem" for some people, "never" for some, and "Sometimes" for the rest of us. We recently dug a bit deeper to see if we could understand the problem and to propose a fix which would not have other undesirable system consequences.
The typical go-to solution has been to hang a capacitor on the EN signal. This has the effect of slowing its rise time, and (hopefully) catching IO_0 as being LO at the time the ESP wakes up. There are numerous problems with this approach and it can lead to other forms of system unreliability. Furthermore, it still actually doesn't always work.
The real problem here is in the Host OS software. The transistor circuit was designed with the intention that the controlling signals transition simultaneously. In practice, these signals do not transition simultaneously because each transition is triggered by a distinct command. The time between execution of each of these commands is actually dependent on the Host OS and driver implementation.
In our development setup, we experienced an EVEN LONGER delay between these transitions as we have an ESP development environment embedded in a VM which runs on a host. Because of USB virtualization, each command has to traverse two (or three) OS-uncertainty domains before it is executed. The delays, and delay variations, we observed were diverse and quite long.
Hanging an arbitrarily large capacitor off of the EN signal was not a good option, nor scalable.
After some sleuthing to understand this issue, a bit of circuit analysis, and a bit of spice simulation, we have arrived at a solution we would like to present to the community. The "short" version is that a capacitor connected to the BASE of Q1 in the DevKit schematic has the effect of delaying the transition of EN without significantly affecting its rise time. In other words, the circuit operates as designed, despite significant delay between the control signal transitions. We were able to mask 20+ ms delays with this method, which was sufficient to bridge the delays we observed.
The "long" version is contained in the attached document:
Here we describe the problem and the proposed solution, including scope traces, simulations, and a circuit analysis.
We hope that the community finds this information useful, and that this fix might one day be considered for integration into the DevKit schematics as a way to better mitigate this problem for future users. As can be seen in the document, implementing the fix on current DevKit boards is pretty straightforward as an aftermarket mod. Not much different than the capacitor on EN in complexity.
Thanks for your consideration of this solution, and we look forward to your thoughts and comments. We hope that this helps the community have a more enjoyable and productive Espressif experience!
There have been numerous conversations about the behavior of the clever little 2-Transistor circuit used on DevKit boards to allow for Host tools to initiate bootloader and code download to ESP devices. Seemingly inexplicably it works "no problem" for some people, "never" for some, and "Sometimes" for the rest of us. We recently dug a bit deeper to see if we could understand the problem and to propose a fix which would not have other undesirable system consequences.
The typical go-to solution has been to hang a capacitor on the EN signal. This has the effect of slowing its rise time, and (hopefully) catching IO_0 as being LO at the time the ESP wakes up. There are numerous problems with this approach and it can lead to other forms of system unreliability. Furthermore, it still actually doesn't always work.
The real problem here is in the Host OS software. The transistor circuit was designed with the intention that the controlling signals transition simultaneously. In practice, these signals do not transition simultaneously because each transition is triggered by a distinct command. The time between execution of each of these commands is actually dependent on the Host OS and driver implementation.
In our development setup, we experienced an EVEN LONGER delay between these transitions as we have an ESP development environment embedded in a VM which runs on a host. Because of USB virtualization, each command has to traverse two (or three) OS-uncertainty domains before it is executed. The delays, and delay variations, we observed were diverse and quite long.
Hanging an arbitrarily large capacitor off of the EN signal was not a good option, nor scalable.
After some sleuthing to understand this issue, a bit of circuit analysis, and a bit of spice simulation, we have arrived at a solution we would like to present to the community. The "short" version is that a capacitor connected to the BASE of Q1 in the DevKit schematic has the effect of delaying the transition of EN without significantly affecting its rise time. In other words, the circuit operates as designed, despite significant delay between the control signal transitions. We were able to mask 20+ ms delays with this method, which was sufficient to bridge the delays we observed.
The "long" version is contained in the attached document:
Here we describe the problem and the proposed solution, including scope traces, simulations, and a circuit analysis.
We hope that the community finds this information useful, and that this fix might one day be considered for integration into the DevKit schematics as a way to better mitigate this problem for future users. As can be seen in the document, implementing the fix on current DevKit boards is pretty straightforward as an aftermarket mod. Not much different than the capacitor on EN in complexity.
Thanks for your consideration of this solution, and we look forward to your thoughts and comments. We hope that this helps the community have a more enjoyable and productive Espressif experience!