-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Using pins 18 & 19 as GPIO on ESP32-C3 (disabling USB-JTAG) #10783
Comments
@Rob58329 - Please confirm some information related to this issue: 1- Is this board: https://www.waveshare.com/wiki/ESP32-C3-Zero ? |
No Issue found with Arduino Core 3.1.0. Board Configuration:Sketch executed:// NB. "USB CDC on Boot=Disabled"
// ESP32-C3
void setup() {
delay(5000);
pinMode(18,INPUT); // does NOT remove USB-JTAG pulses from GPIO-18
pinMode(19,INPUT); // DOES remove USB-JTAG pulses from BOTH GPIO-18 & GPIO-19
}
void loop() {} Debug Output:
|
@Rob58329 - I can't reproduce the reported issue. Using this sketch: // NB. "USB CDC on Boot=Disabled"
// ESP32-C3
void setup() {
pinMode(18, INPUT_PULLUP); // does NOT remove USB-JTAG pulses from GPIO-18
pinMode(19, INPUT_PULLUP); // DOES remove USB-JTAG pulses from BOTH GPIO-18 & GPIO-19
Serial.begin(115200);
}
// Use a wire to connect Pins 18 and 19 to +3.3v or GND
void loop() {
Serial.printf("Pin 18 = %s || Pin 19 = %s\r\n",
digitalRead(18) == HIGH ? "High" : "Low",
digitalRead(19) == HIGH ? "High" : "Low"
);
delay(1000);
} I can ground each pin and read the correct input:
|
@SuGlider - thank you for getting back to me! As I said above "In order to disconnect the USB-JTAG from GPIO-18, you actually need to do a “ (In your above test sketch you are using GPIO-19 to obtain your DEBUG-OUTPUT, so this will remove the "USB-JTAG" signals from both GPIO-19 AND GPIO-18. - if you instead use GPIO-18 as your Serial-Tx, and set the Serial-Rx to say GPIO-1 [ie. NOT GPIO-19], you would probably see a significantly corrupted output on your Serial-monitor, but I haven't tried this!) IF you ONLY do a " (The bug I am reporting is that trying to use " PS. I am using the IDE "Board=ESP32C3 Dev Module" for my "https://www.waveshare.com/wiki/ESP32-C3-Zero", but I suspect this will be an issue for ALL ESP32-C3 boards (and probably for ESP32-S3 boards too). The below oscilloscope picture shows one such GPIO-18 pulse when using my above example " |
This is incorrect. The debug output I got is from pin 21 which is UART0 Tx. |
I'm not sure about the eFuses that Wavewhare has burned for their board. It is possible to burn an eFuse that forces using JTAG/USB-CDC as the console default port. Boot Loader may also automaticaly initialize the JTAG/USB-CDC port depending on reading the eFuse. |
I'll try to check my ESP32-C3 Devkit board in the osciloscope in order to verify if this spike also happens here. |
Sorry - my bad. I connected a Serial-to-USB adapter-Rx to GPIO-21 and got the following differences in "Core Debug Level=Verbose" outputs (A) With " [ 0][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42002cf2 ============ Before Setup End ============ (B) With " [ 0][V][esp32-hal-periman.c:235] perimanSetBusDeinit(): Deinit function for type UART_RX (2) successfully set to 0x42002cfa ============ Before Setup End ============ Interestingly if you use "pinMode(18,INPUT_PULLUP);" ONLY you get a really weird waveform (as shown below) which is nominally about 1V only (ie NOT the 3.3V pulled-up value it should be), and intermittent 1us USB-JTAG pulses shooting up to 3.3V down to 0V then ending at about 1V... (This with the ESP32-C3 powered by it's USB-C connected to a computer.) (I assume the USB-JTAG circuitry must be putting some type of pull-down resistor onto GPIO-18.) The below sketch shows the effect of this (using a Serial-to-USB adapter-Rx to GPIO-21 to view the Serial-output):
Edit - the above sketch doesn't really help, as it effectively only tells you what the external pulldown/pullups which the USB-C D+/D- lines have got on them. ie. if you power the ESP32-C3 from it's 5V pin you will get the correct "Pin 18 = HIGH" output, but if you power the ESP32-C3 from it's USB-C connected to a computer, you will get "Pin 18 = LOW". |
Does this pulse happen one time only? |
The debug output is correct. |
@Rob58329 - I found some information about Boot configuration and ROM Boot Code in the C3 datasheet: I think that the pulse you have seen is actually the default Boot Message in USB Serial/JTAG port (pins 18 and 19 USB Hardware CDC). The message is "ESP-ROM:esp32c3-api1-20210207" It is printed by ROM code into USB Serial/JTAG before any bootloader or application code is executed. eFuse eFuse can be listed and burned by using |
@Rob58329 - Use |
@SuGlider - many thanks for your comments.
No, you see the pulses continuously (every few seconds or more frequently) on both GPIO-18 and GPIO-19, UNTIL you do a I'm surprised it isn't possible to do whatever
Instead I will probably just do a Interestingly although Also note that this 18k pulldown actually seems to be provided by the D+/D- voltages on the USB-C-connector; if instead I power the USB-C from a USB-Power-Supply, this changes to a 30k pullup, and interestingly you DO NOT get the above unwanted USB-JTAG pulses from GPIO-18 at all! Also, if you power directly from the 5V pin, then you don't get the unwanted USB-JTAG pulses on GPIO-18, and ALSO I would therefore suspect that burning an eFuse won't actually effect these external pullup/pulldown resistances, so if you wan't to use a pullup on GPIO-18, either power the ESP32-C3 from it's 5V (or 3.3V?) pin and use |
ROM code enables Hardware Serial (USB CDC) by default. The CDC hardware implementation may try to talk to the USB Host from time to time and it may be the pulse. When any other device is attached to pins 18 or 19, the HW Serial/JTAG is detached and it stops sending the pulse. This is done by ROM code and it can be changed using eFuses. Arduino can't help it, unless by changing these pins function. |
This is not what I have seen with |
one option is to set the peripheral manager to have the USB set by default, so when you try to reassign one of the pins, it will trigger detach from the driver for both |
Yes, this is already done for UART0, but not for USB/JTAG. |
Board
Waveshare ESP32-C3 Zero Mini Development Board
Device Description
Basic board only, an oscilloscope attached to GPIO-18
Hardware Configuration
Basic board only, an oscilloscope attached to GPIO-18
Version
latest master (checkout manually)
IDE Name
Arduino IDE v1.8.19
Operating System
Windows 10
Flash frequency
80MHz
PSRAM enabled
no
Upload speed
921600
Description
(This issue is a bit similar to #10587 which was for ESP32-S3.)
Using Arduino-IDE and latest "https://github.com/espressif/arduino-esp32" as at 24Dec24.
If you try to use pin 18 as GPIO on ESP32-C3 (either doing “
pinMode(18,INPUT)
” or “pinMode(18,OUTPUT)
” you still get unwanted fast pulse spikes on pin 18 (USB-JTAG signals).In order to disconnect the USB-JTAG from GPIO-18, you actually need to do a “
pinMode(19,INPUT)
” or “pinMode(19,OUTPUT)
” (which appears to disconnect the USB-JTAG from BOTH GPIO-19 AND GPIO-18).It would appear to be a bug that doing “
pinMode(18,INPUT)
” or “pinMode(18,OUTPUT)
” does not do the same?Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: