esp32 automatically download the principles and reasons for failure analysis

Automatic downloads principle

esp32 code is the most common way is to download via the serial port, which is the TXD and RXD. But only these two lines can not complete the download automatically. Because of the need to find ways to make esp32 enter the download start mode, and enter download mode method is to boot the system to reboot, reboot and GPIO0 GPIO2 remain low, this is described in official documents.

Here I have a doubt, this down a specific time in the end is how much? That is how much time before the reset and put GPIO0 GPIO2 pulled low, while the need to maintain reset the down how long? Note that this problem will continue to be discussed below, relates to whether the two time programming can be successful.

Flow control, RTS and DTR on automatic reset and automatic down on the need to borrow serial port. Flow control itself is not for us to automatically download the code used, but because they can change their function, so you can artificially control their timing, gpio become similar to ordinary functions. Official circuit given is this:

Specific analysis of the triode principle not directly see the truth table on it. EN pulse can give a low level, so that the system is restarted, while allowing IO0 and IO2 pulled down in an instant EN, so you can allow the system to boot into the download mode. Such seems to be the perfect solution to the problem of automatic download.

Problems encountered

However, in actual use, I often encounter problems automatically download times out, there are some with a number of motherboards can automatically download, some not; may, in some computers may not be on some computers. But at the time not too concerned about, after all, the project can be ground by one button, pressing the button will be able to download on IO0 . This was a little bit sorry for my colleagues, because of personal laziness, leading you by the hand pain. Recently idle have time to carefully thought about this problem (unfortunately do not have an oscilloscope waveform can not catch).

theoretical analysis

With a multimeter volume a bit, flow control signals DTR, RTS are out, the system also can be a normal restart, but just can not burn, indicating that the entire hardware connection is no problem. Then the problem should be out on the timing, that is, the above-mentioned problems, in the end after the reset, IO0 how long to maintain a low level.

Meanwhile fancy truth table map. If you want to reset a certain time will give a low pulse EN, it is bound to enter EN = 0, IO0 = 1 state. At this time, the next step is to make EN = 1, IO0 = 0. The completion of these two steps, you need to flip the same time DTR and RTS, I feel based on PC real-time operating system is not the relationship between the two can not be reversed instantaneously , but no matter what the first flip, EN must be reversed before the IO0. And assuming that DTR and RTS flip difference is high enough, then there may be a delay occur IO0 down, at the beginning of the system reset is high, so the system directly into the spiflash startup mode.

Actual waveform crawl

Not being on hand oscilloscope, skip this step, some students saw can help me to test.

Solution

According to the conclusions of theoretical analysis, the cause can not enter download mode is the flip DTR and RTS have led to IO0 delay time difference becomes low, then theoretically we can synchronize the delay IO0 by delaying EN is high time to change delayed EN high way is:

                                           To EN plus a large capacitance to ground

Of course, this delay how long it needs oscilloscope waveform view (delayed too long I did not reflect what will happen). Normally reset to-ground capacitance is 0.1uf, I try to modify the order 10uf, directly addresses this problem can not be automatically downloaded. Of course 10uf may not be perfect, but the general idea is like that of.

Egg

IO2 on the circuit diagram of a box, where long-winded, because I negligence in the actual work has led to some problems. First, the control circuit IO0 and IO2 circuit is the same, so their logic states is the same. However, according to the first graph analysis, pulldown IO2 default, and the default pull IO0, so can not in most cases this circuit. But there is a case to, and IO2 serve as the SDIO function of TF_D0 when using sd card will generally take a pull-up resistor, the circuit if IO2 an external pull-up resistors will be box, or still can not enter Download startup mode. So the question is, why IO sd card must be connected to the pull?

Published an original article · won praise 0 · Views 10

Guess you like

Origin blog.csdn.net/weixin_41975300/article/details/104834771