-
Notifications
You must be signed in to change notification settings - Fork 7.6k
programming + reset issue with CDC/USB-JTAG on ESP32C3 #7190
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
Comments
The ESP32-C3-DEVKITC-1 schematics has the CP2102 DTR/RTS and connection to GPIO 9 (Boot). https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/api-guides/usb-serial-jtag-console.html |
GPIO2, GPIO8, and GPIO9 are strapping pins of the ESP32-C3FN4 chip. These pins are used to control several chip functions depending on binary voltage values applied to the pins during chip power-up or system reset. For description and application of the strapping pins, please refer to Section Strapping Pins in ESP32-C3 Datasheet. |
i am sorry but your two answers are quite out of touch, maybe you should read the issue again, No one asked the principle of using internal JTAG to flash, nor what bootstrap pins are, it is rather obvious that i already know since i designed the board to use native USB for programming and i mention several times the boot strap pins pullup configuration. That doesnt help a bit with the problem. |
also, i use the C3F4H variant (but this changes nothing to the problem). |
I'm sorry for not been of help. What is the software issue, related to the ESP32 Arduino Core implementation, that you have? |
CDC software layer must be loaded prior to being able to use it. Thus, first upload any sketch using CDC enabled option from Arduino IDE in order to, in the next board reset, have CDC working and make it understand USB signaling for software upload and board reset. Not sure if this has been already tried. |
@SuGlider We do it this way for Tasmota and devices which "just" uses the CDC. |
@SuGlider @Jason2866 The problem is that, on this particular board, this programming via CDC/JTAG just fails and it shouldnt. Something is preventing it to work correctly. As I shown in the log, the C3 is still stuck in RUN mode after being reset by the CDC, that is the issue. Also, if we force PROG by booting with GPIO 9 low (and releasing it after power up) then the C3 become stuck in PROG mode, we can program it over and over but it never resets to RUN mode by itself, only a power cycle does. Which is also totally abnormal. |
@0x0fe - where do you think the problem is? |
Last 2 cents: JTAG/CDC USB interface uses DTR/RTS bits to reset and enter in Boot Mode. The way it works can change depending on the eFuses. Maybe you may want to check it. This information is in page 612 it the C3 TRM and eFuse is explained in the chapter 4 of the TRM. Maybe the eFuses of your chip are wrong. |
True, so i didnt get your problem. I thought it is to flash and run (after flash) the programmed firmware on the C3. If connected again to programm the device again and |
At this point i am not sure, i thought it could be related to strapping pins latching at a time where they are in a wrong state, maybe due to a glich after reset on the GPIO controlling OE of the bufferr, but the problem with this theory is :i dont think strapping pins are taken into account after the CDC reset, what lead me to this conclusion : if i hold GPIO9 low while the system is trying to program with CDC reset it doesnt work either, which seems to prove GPIO9 state is not taken into account here.
I also thought it could be GPIO10 since it seems to be able to disable JTAG function, however, it would not lead to an error of boot mode (0xc), rather a failure to program. Besides, i added a pullup to force it high after reset and it did not help. |
@Jason2866 no problem and sorry for the harsh tone, i appreciate you came to help. |
OK i will check these control lines bits, good idea, i still fail to understand how pin map of non strapping pins could impact these. |
So, BLOCK0 is all 0, the problem must be elsewhere
|
i removed the two buffers, so essentially the ESP32 is now only connected to USB receptacle and tact switch, the problem persists, the plot thickens... I will now replace the ESP32C3H4, maybe it is related to the chip itself (which was obviously new at assembly). |
i replaced the ESP32C3, same problem, so there must be something wrong with what remains of the hardware once the two buffers removed. |
the board has been stripped of anyting connected to GPIOs other than pull ups on GPIO2 and GPIO8, tact switchon GPIO9 and USB receptacle on D+ D-. the ESP32C3 has been replaced with a brand new 3 times. I noticed something very strange : GPIO9, measures 4.5V to 5V toward GND. The only other place where 5V can be found on this board now is the LDO input (output is 3.386V stable), of course the C3 only ever receives 3.38V on it VCCs and GPIOs, i did cut the 5V trace on the board at the LDO input to make sure leakge was not possible and 5V was not present anywhere on the board other than at the LDO input. USB D- measures 4.5V varying, This GPIO9 abnormal voltage seems pretty weak, it slowly discharges from 5V to about 4.2V and stays there but will increase back to 5V sometimes, i did not found a specific pattern, i assume it slowly regain 5V once i stop measring, so it would be very weak since the multimeter impedance is enough to slowly drop it until 4.2V . I must say i am very confused by this, but maybe it is the same on other C3, i will verify one of the previous C3 designs later, by the way i also tested the programming setup with a baord from a previous design and it works perfectly fine, automatically enters and leave programming mode, runs automatically after prog, just as it should, So, a little puzzled by the issue. It is clearly related to this particular board, but so far nothing makes much sense and despite the extensive testing no clue can be found except this abnormal voltage appearing on GPIO9. |
the 40M crystal has been replaced for another brand (also 12pF 10ppm), the inductor to limit amplitude on the crustal trace has bee replaced with 24nH wirewound, GPIO2 / GPIO8 pullups values have been measured and found to be within tolerance (10K 1%). the whole board has been fully cleaned with isopropyl, reflowed on hot plate and inspected under binaucular microscope to rule out any cold joint, the problem persists. Additional storage caps have been added to the VCCs on ESP32 side, no effect (there was ample storage and decoupling already). The USB cable is shielded, shielding is of course connected to GND on one side only. Tested on USB 2 and USB 3 ports. Tested with an older version of ESPTool. |
so, there is some news on the issue: I faced this issue again but with another design, which worked fine on last batch (with the previous revision of the core), so i tested another method and found something leading me to think it is related to arduino / ESPtool and not related to the hardware.
I tested it on both boards concerned by the issue, works for both. So, now that the cause is identified if someone at espressif could look into the issue it would be appreciated, obviously such upload method dramatically impacts the development workflow and is just not viable. For remind both Arduino (esptool.py v3.3) and ESPTOOL V4.2.1 are failing to automatically upload when used directly. The only way to reflash as of now is to use the external UART software first and then ESPTOOL V4.2.1. So it seems whatever method (pyserial?) is used to set DTR and RTS sequence is not working anymore with CDC, at least in some cases. IMHO It could be related to:
I am not sure, but the problem is very real, i dont know why it hasnt been reported yet, but most public dev boards are still using USB-UART bridges so they are not concerned by the issue, it only occurs with the USB CDC obviously, and it occured to me only on the last arduino core (may be coincidental). Side note #1, another design does not exhibit the issue, it can be flashed and run automatically with last core in CDC mode, however its the exact same hardware regarding the C3 (same routing, same layout same parts, same bootstraps). The only difference is : it has been used before on an older version of Arduino core (without issue) so, that may mean the issue is also related to the bootloader... Where the two new boards would only ever have had a newer version of the bootloader and fail, and the older board still uses an older version of the bootloader, and works. THis theory is yet unverified, i dont know if i can even verify the bootloaders version, but that may be a clue. Side note #2 i can confirm a voltage higher than VCC does appear on GPIO9, during the upload phase, in CDC mode, 3.8V to 4.0V, where the C3 only ever receives 3.3V at most on its VCC pins or GPIOs (except USB data lines). That is very strange for the least and confirmed on 3 board, of which two are different designs (but the C3 part is identical) |
i note that the custom sequence in esptool.py does not fully match what worked to go into PROG mode In esptool RTS is cleared after it was already clear, and DTR is also cleared after it was already clear, i dont really understand the logic of this sequence.
|
thanks espressif for not giving a fuck about a quite major issue |
Yeah apologizes for the harsh tone, i realize you are not a large team on the arduino core. |
also, i am a little puzzled about the voltage superior to VCC we get on GPIO9, i assume it is very low current builtup but still, quite strange. |
I did some test, it seems it is a windows issue. Just used esptool.py v4.21 and flashing did worked every time without doing anything. Erased the C3 before (only CDC; "Luatos Board") to be sure nothing is left. Using macOS (Monterey) with a M1 Air. +1 for board reset methode in Arduino menu. |
that is quite possible, i did not test on macOS, did you use --before default_reset though? |
No, was not needed. Somehow esptool.py seems to detect and choosed the right methode. |
--before default_reset is what the arduino IDE passes as argument to esptool, so if you want to test either use Arduino, or use the exact same arguments arduino is passing, otherwise the test is not quite valid. Anyway as shown previously the issue comes from that python does not see the productID correctly, apparently.
|
Hello guys, can you please give us know if you still face this under 2.0.5 version? Thanks you a lot for the help |
Hi @VojtechBartoska the issue seems OS dependent. For me it does work under macOS with Platformio. I do not use ArduinoIDE so idk how it is there. |
I had the same problem when using "idf.py flash" on Windows. The workaround I used was to add usb_reset to the before options in esptool_py/Kconfig.projbuild. |
I think that this issue is not related to Arduino itself. @0x0fe - There is a comment to a similar issue: Not sure if this comment applies to the issue you have found as well. |
@radimkarnis Can you please share your 2cents on this? Thanks! |
@SuGlider yes, this was related to the espressif tool indeed, and it was on windows, i believe i has been fixed on 2.0.5 and 2.0.6, since i dont recall to change the script when i upgraded to these versions |
esptool.py dev here. Most of what I wanted to say has already been mentioned. Explanation: When USB-JTAG/Serial is being used, a special reset sequence has to be triggered - but how do you detect that it is being used? Since the ESP chip can't be interrogated when it is not in the download mode, the only thing we can do is to look at the esptool.py uses pySerial under the hood for working with the serial port - including
I am sorry, but you achieve literally nothing by being this condescending. |
From this, I understand that the issue is solved by new versions of ESPTOOL.EXE packaged within Arduino Core 2.0.5+. Is it right? |
@radimkarnis |
Ok, thanks @0x0fe and @radimkarnis for the contributions and comments to this issue. I'm not sure if the issue is solved or not with the current version of esptool. |
@SuGlider this won't be solved by updating esptool - there are no changes in the more recent releases. And as I said, there's not much we can do on the side of esptool. This is either a driver or OS issue. If the VID:PID is not reported correctly, we can't trigger the right sequence. |
Thanks @radimkarnis for the suggestion. I think that the Arduino IDE doesn't know when a board has or not USB-JTAG/Serial. |
This is only for JTAG+CDC port. Can not add it as default. There is a way, but means we will need to adjust and clutter the menu even more. |
Since there are boards which are known to use only the inbuilt USB serial "modem", |
i want to add that since 2.0.5 and 2.0.6 the problem did not show up anymroe, so i assume USB PID/VID detection has been somehow improved in the last flashing tool binaries, maybe the problem can be considered solved (for now). |
Ok. Thanks. |
Board
ESP32C3 custom board
Device Description
Custom ESP32C3 board ;
The ESP32C3 is only connected to USB-C port, two 74HCT245D buffers (inputs only) and a tact switch (details below).
This ESP32C3 design block, which follows the hardware design guide, has already been used in several boards and products without issue, there is however always differences between the designs on the pullup/pulldowns presents on the various GPIOs, nontheless all designs have pullup on 2 and 8 boot strap pins, this one is no exception.
Hardware Configuration
PIN MAP:
High quality 3.3V LDO with very low drop at max load and high PSRR.
Sufficient decoupling all over (100nF 50V X7R class),
Sufficient storage capacitors on the 3.3V rail with large derating (2*22uF 16V).
Ferrite bead on 5V rail plus 3.3V rail filtering as per hardware design reference.
Version
v2.0.4
IDE Name
Arduino
Operating System
windows 10
Flash frequency
80M
PSRAM enabled
no
Upload speed
921600 (not relevant for CDC)
Description
The only way to program is to unplug, hold the tact switch (gpio9) plug USB and release tact to force PROG mode
the programming then executes normally, however it does not manage to reset and run afterwards, a manual power cycle has to be executed.
Is there another bootstrap pin causing the issue? (other than 2 and 8 which are already pulled high)
is it something with the RC reset?
It is unclear to me how only the CDC reset fails but when i cold boot (aka plug USB) the board starts in the correct RUN mode, and when i use GPIO9 it starts in the correct PROG mode.
Note :
Sketch
The text was updated successfully, but these errors were encountered: