esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 36 forks source link

ESP32-C3 in DIO mode should allow use of GPIO12 and GPIO13 #3744

Closed davidmonro closed 10 months ago

davidmonro commented 2 years ago

The problem

I'm using a "luatos.com/t/esp32c3" board (airm2m_core_esp32c3 is the board type). Attempting to use GPIO12 or GPIO13 in the config produces the following error:

This pin cannot be used on ESP32-C3s and is already used by the SPI/PSRAM interface (function: SPIHD).

However, this board uses DIO flash mode, so GPIO12 and GPIO13 are not actually used for the flash interface, and should be available as general purpose IO pins.

(Google translated from the maker of the board at https://wiki.luatos.com/chips/esp32c3/board.html: IO12 (GPIO12) and IO13 (GPIO13) are multiplexed for SPI signals SPIHD and SPIWP in QIO mode. In order to increase the number of available GPIOs, the development board chooses the DIO mode of 2-wire SPI. IO12 and IO13 are not connected to flash, and use their own compilation The software needs to pay attention to configure the flash as DIO mode.)

Currently, gpio_esp32_c3.py just defines pins 12-17 as the PSRAM pins and doesn't pay attention the flash mode used for the board.

I don't know if it is possible to access the board config from within this code?

If not, perhaps it could be handled like the S3R8 and S3R8V chips where it throws a warning rather than an error for those pins?

Which version of ESPHome has the issue?

2022.9.4 (but git dev branch is the same)

What type of installation are you using?

pip

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP32

Board

airm2m_core_esp32c3

Component causing the issue

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

davidmonro commented 1 year ago

This is still an issue.

roommaster commented 1 year ago

I‘m using the same board and want it be solved.

fluppie commented 1 year ago

Yes, using the Arduino IDE I can use the onboard leds of this board without any problem.

#define ledPin                 13  // D5
#define ledPinDataRequest      12  // D4

Doing this in ESPHome gives the famous error.

  This pin cannot be used on ESP32-C3s and is already used by the SPI/PSRAM interface (function: SPIWP).
  This pin cannot be used on ESP32-C3s and is already used by the SPI/PSRAM interface (function: SPIHD).
esphome:
  name: ${device_name}
  friendly_name: ${device_name}
  comment: $device_comment
  name_add_mac_suffix: false
  project:
    name: "Generator"
    version: "1"
  platformio_options:
    board_build.flash_mode: dio

esp32:
#  board: airm2m_core_esp32c3
  board: esp32-c3-devkitm-1
  framework:
#    type: arduino
    type: esp-idf

output:
  - platform: gpio
    pin: 13  # D5
    id: LedPin

  - platform: gpio
    pin: 12  # D4
    id: LedPinDataRequest
skyboooox commented 11 months ago

+1

Soviet-Steve commented 11 months ago

yep, not stale

skyboooox commented 11 months ago

I was able to build after changing the local python code Change the source code of the local pip package and delete pycache

C:\Users\[YOUR_USERNAME]\AppData\Local\Programs\Python\Python311\Lib\site-packages\esphome\components\esp32\gpio_esp32_c3.py

_ESP32C3_SPI_PSRAM_PINS = {
    # 12: "SPIHD",
    # 13: "SPIWP",
    14: "SPICS0",
    15: "SPICLK",
    16: "SPID",
    17: "SPIQ",
}

This is not a long term solution Must to repeat this operation every time esphome updates

hailinmail commented 7 months ago

+1

dablanco83 commented 5 months ago

+1

hldh214 commented 4 months ago

FYI, since 2024.6.0, the GPIO validation behavior has changed. Previously(https://github.com/esphome/esphome/pull/5982), setting the board to "airm2m_core_esp32c3" could avoid this issue. Now(https://github.com/esphome/esphome/pull/5615), you must also set ignore_pin_validation_error for each pin. for example:

output:
  - platform: ledc
    pin: 
      number: LED1_BUILTIN
      ignore_pin_validation_error: true

Refs: https://github.com/esphome/esphome/commit/f0ec900e4841a32023491f8482af3c4a07432adb

ZDZX-T commented 4 months ago

FYI, since 2024.6.0, the GPIO validation behavior has changed. Previously(esphome/esphome#5982), setting the board to "airm2m_core_esp32c3" could avoid this issue. Now(esphome/esphome#5615), you must also set ignore_pin_validation_error for each pin. for example:

output:
  - platform: ledc
    pin: 
      number: LED1_BUILTIN
      ignore_pin_validation_error: true

Refs: esphome/esphome@f0ec900

感谢!这个方法较为优雅地起了作用。我认为这个解决方法应该添加到错误提示中,以帮助人们更快地找到解决方法。 Thanks! This approach worked gracefully. I think this solution should be added to the error message to help people find a solution faster.

cropse commented 1 month ago

Thanks for the solution, but maybe we should add this solution in the error log? I encounter this issue, but in the error log well help a lot to begin with.