Skip to content
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

ESP32-C3 pulls up GPIO19 because it is used by USB (IDFGH-7984) #9495

Closed
DCSBL opened this issue Aug 4, 2022 · 4 comments
Closed

ESP32-C3 pulls up GPIO19 because it is used by USB (IDFGH-7984) #9495

DCSBL opened this issue Aug 4, 2022 · 4 comments
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@DCSBL
Copy link
Contributor

DCSBL commented Aug 4, 2022

Environment

  • Development Kit: None
  • Kit version (for WroverKit/PicoKit/DevKitC): na
  • Module or chip used: ESP32-C3
  • IDF version (run git describe --tags to find it): v4.4.1
  • Build System: idf.py
  • Compiler version (run xtensa-esp32-elf-gcc --version to find it): riscv32-esp-elf-gcc (crosstool-NG esp-2021r2-patch3) 8.4.0 (or xtensa-esp32-elf-gcc (crosstool-NG esp-2021r2-patch3) 8.4.0)
  • Operating System: macOS
  • (Windows only) environment type: Na
  • Using an IDE?: VSCode
  • Power Supply: external 5V

Problem Description

The GPIO pull-up configuration to configure GPIO19 does not work as expected.

Actual Behavior

After configuring gpio with the config below, the input is still pulled up.

gpio_config_t io_conf = {};
io_conf.pin_bit_mask = BIT64(GPIO_NUM_19);
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_up_en = 0;
io_conf.pull_down_en = 0;
gpio_config(&io_conf);

To fix this, we have to clear the USB_SERIAL_JTAG_DP_PULLUP bit with CLEAR_PERI_REG_MASK(USB_SERIAL_JTAG_CONF0_REG, USB_SERIAL_JTAG_DP_PULLUP);. That works but only after a second reset. ->

https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf page 21
USB - GPIO18 and GPIO19 are USB pins. The pull-up value of a USB pin is controlled by the pin’s pull-up value together with USB pull-up value. If any of the two pull-up values is 1, the pin’s pull-up resistor will be enabled. The pull-up resistors of USB pins are controlled by USB_SERIAL_JTAG_DP_PULLUP bit.

Expected Behavior

We expect that GPIO19 is put in the desired state without other config. Or that this, or 'a' workaround is documented somewhere (if that is not the case)

@espressif-bot espressif-bot added the Status: Opened Issue is new label Aug 4, 2022
@github-actions github-actions bot changed the title ESP32-C3 pulls up GPIO19 because it is used by USB ESP32-C3 pulls up GPIO19 because it is used by USB (IDFGH-7984) Aug 4, 2022
@espressif-bot espressif-bot assigned zikalino and songruo and unassigned zikalino Aug 5, 2022
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Aug 8, 2022
@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: In Progress Work is in progress Status: Reviewing Issue is being reviewed Resolution: NA Issue resolution is unavailable labels Aug 19, 2022
@DCSBL
Copy link
Contributor Author

DCSBL commented Aug 24, 2022

Thanks @zikalino !

espressif-bot pushed a commit that referenced this issue Sep 2, 2022
Internally, disable usb serial jtag DP pin's pullup when calling gpio_ll_pullup_dis and rtcio_ll_pullup_disable
At usb serial jtag setup/install, re-enable DP pin's pullup

Closes #9495
espressif-bot pushed a commit that referenced this issue Sep 21, 2022
Internally, disable usb serial jtag DP pin's pullup when calling gpio_ll_pullup_dis and rtcio_ll_pullup_disable
At usb serial jtag setup/install, re-enable DP pin's pullup

Closes #9495
bbinet pushed a commit to bbinet/esp-idf that referenced this issue Jan 20, 2023
Internally, disable usb serial jtag DP pin's pullup when calling gpio_ll_pullup_dis and rtcio_ll_pullup_disable
At usb serial jtag setup/install, re-enable DP pin's pullup

Closes espressif#9495
@michaesc
Copy link

Does anyone happen to have a ESP-IDF (5.1.2 or similar) project that demonstrates (re)using the GPIO18 and GPIO19 of a ESP32-C3 for any simple purpose?

I'm trying to put a simple SPST tactical switch (push button) on each pin, which drives GPIO18 and GPIO19 low when pressed. The MCU should get an interrupt, but this is not happening. I'm not sure why, and I've written to the forum asking for help.

@wormyrocks
Copy link

Assuming you aren't using the USB JTAG feature, have you tried setting the eFuse bit for DIS_USB_SERIAL_JTAG?
espefuse.py -p COMx burn_efuse DIS_USB_SERIAL_JTAG 1
Anecdotally, it disables the pull-up on IO19 on boot, but I haven't tested whether I can subsequently reuse the pin as you describe.
Keep in mind it's a one-time programmable setting.

@michaesc
Copy link

I'm trying to not use the eFuse, in order to allow users to selectively disable USB-JTAG.

It makes no sense to me that the feature cannot be disabled, and worse yet there is no documentation stating whether it can or cannot be disabled. I'm still trying to debug the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

6 participants