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

Initial pin states after power up (ESP32-S2) #8066

Closed
T94T opened this issue Jun 5, 2023 · 6 comments
Closed

Initial pin states after power up (ESP32-S2) #8066

T94T opened this issue Jun 5, 2023 · 6 comments
Labels
bug espressif applies to multiple Espressif chips
Milestone

Comments

@T94T
Copy link

T94T commented Jun 5, 2023

CircuitPython version

Adafruit CircuitPython v8.1.0 available from official download page
and
Custom compiled Adafruit CircuitPython v8.2.0

Code/REPL

# no custom code (just the factory default code.py file)

Description

I have noticed that all pins output 3.3V after a power up. Presumably the internal pull-ups have been activated by default. So I ask here where this is defined in the source code of CircuitPython. Is this intentional or a bug?

This is my setup and procedure:
Hardware: Lolin S2 Mini (based on ESP32-S2FN4R2)

Step 1: Uploaded an "empty" script compiled with arduino-esp32 (v2.0.6) and all pins remained in input state (0V).
Step 2: Burned the TinyUF2 bootloader. The board stays in DFU mode and all pins remain in input state (0 V).
Step 3: Uploaded CircuitPython (UF2 binary, v8.1.0 and also custom compiled v8.2.0). After reset and waiting for CircuitPython to fully boot, all pins output 3.3V.

Additional information / Update

I tried the above with an ESP32-S3-DevKitM-1-N8R2 with exactly the same behaviour.

@T94T T94T added the bug label Jun 5, 2023
@dhalbert dhalbert added this to the Support milestone Jun 5, 2023
@dhalbert dhalbert added the espressif applies to multiple Espressif chips label Jun 5, 2023
@dhalbert
Copy link
Collaborator

dhalbert commented Jun 5, 2023

The default pin reset code provided by the ESP-IDF resets the pins with pull-up (instead of floating). According to the documentation, this minimizes power consumption. It also prevents glitches on external pins that might trigger NeoPixels, etc. This is discussed in the comments in #5931.

@tannewt tannewt closed this as completed Jun 5, 2023
@T94T
Copy link
Author

T94T commented Jun 6, 2023

@dhalbert, thank you for pointing me to the right direction. This is not good because the board always goes into DFU mode on single reset if DOUBLE_RESET_RC has been activated when using the TinyUF2 bootloader (https://github.com/adafruit/tinyuf2/tree/master/ports/espressif#usage). A simple but ugly workaround will be to set the PIN_DOUBLE_RESET_RC as an input pin in code.py (or main.py)

@jepler
Copy link
Member

jepler commented Jun 6, 2023

In CircuitPython espressif port, we have a special case for what Adafruit terms the "double tap pin":

// _reset_pin in common-hal/microcontroller/Pin.c
    #ifdef DOUBLE_TAP_PIN
    // Pull the double tap pin down so that resets come back to CircuitPython.
    pull_down = pull_down || pin_number == DOUBLE_TAP_PIN->number;
    #endif

I do not know if this is equivalent to the functionality on this board; there's also espressif_board_reset_pin_number which allows a particular board to override how a particular pin is set when not otherwise in use.

@T94T
Copy link
Author

T94T commented Jun 6, 2023

Amazing, thanks so much for the in-depth look at this issue.

@dhalbert
Copy link
Collaborator

dhalbert commented Jun 6, 2023

@T94T is the DOUBLE_TAP_PIN definition missing from this particular board? If so, that would fix the problem, I think.

@T94T
Copy link
Author

T94T commented Jul 21, 2023

Ok, got it. The DOUBLE_TAP_PIN definition needs to be set in the board's mpconfigboard.h file. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug espressif applies to multiple Espressif chips
Projects
None yet
Development

No branches or pull requests

4 participants