Skip to content

Commit

Permalink
Merge pull request letscontrolit#5175 from TD-er/feature/esp32c3_flas…
Browse files Browse the repository at this point in the history
…h_pins

[ESP32C3] Allow GPIO 11, 12, 13 to be used on specific boards
  • Loading branch information
TD-er authored Dec 18, 2024
2 parents 8769746 + 438a298 commit 9e560a5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 22 deletions.
5 changes: 5 additions & 0 deletions docs/source/Reference/GPIO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,14 @@ ESP32-C3 SPI flash pins

Pins connected to flash or PSRAM should not be used for anything else.

On boards with embedded flash, these pins cannot be used:

* GPIO-11: Flash voltage selector
* GPIO-12 ... -17: Connected to flash

On boards with external flash, GPIO-11, GPIO-12 and GPIO-13 can be selected.
However special care should be taken as some boards can still have these pins wired to the flash chip.

.. note:: By default VDD_SPI is the power supply pin for embedded flash or external flash. It can only be used as GPIO-11 only when the chip is connected to an external flash, and this flash is powered by an external power supply.


Expand Down
9 changes: 4 additions & 5 deletions platformio_core_defs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ extra_scripts = ${esp82xx_common.extra_scripts}
; IDF 4.4 = platform-espressif32 3.4.x = espressif/arduino-esp32 tag 2.0.4
; Just for those who lost track of the extremely confusing numbering schema.
; For MUSTFIX_CLIENT_TIMEOUT_IN_SECONDS See: https://github.com/espressif/arduino-esp32/pull/6676
[core_esp32_IDF5_1_4__3_0_5_SPIFFS]
[core_esp32_IDF5_1_4__3_1_0_SPIFFS]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.09.10/platform-espressif32.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3202/framework-arduinoespressif32-all-release_v5.1-41a885b.zip
build_flags = -DESP32_STAGE
Expand Down Expand Up @@ -196,9 +196,8 @@ lib_extra_dirs =


; ESP_IDF 5.3.1
[core_esp32_IDF5_3_1__3_0_5_LittleFS]
platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF53
;platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.10.31/platform-espressif32.zip
[core_esp32_IDF5_3_2__3_1_0_LittleFS]
platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF53
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3203/framework-arduinoespressif32-all-release_v5.3-ddc10306.zip
build_flags = -DESP32_STAGE
-DESP_IDF_VERSION_MAJOR=5
Expand All @@ -219,7 +218,7 @@ build_flags = -DESP32_STAGE
-include "ESPEasy_config.h"
-include "esp32x_fixes.h"
-Wnull-dereference
lib_ignore =
lib_ignore =
lib_extra_dirs =
lib/lib_ssl

Expand Down
14 changes: 7 additions & 7 deletions platformio_esp32_envs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


[esp32_base]
extends = common, core_esp32_IDF5_1_4__3_0_5_SPIFFS
extends = common, core_esp32_IDF5_1_4__3_1_0_SPIFFS
upload_speed = 460800
upload_before_reset = default_reset
upload_after_reset = hard_reset
Expand All @@ -19,7 +19,7 @@ extra_scripts = post:tools/pio/post_esp32.py
; pre:tools/pio/apply_patches.py
build_unflags = -Wall
-fno-lto
build_flags = ${core_esp32_IDF5_1_4__3_0_5_SPIFFS.build_flags}
build_flags = ${core_esp32_IDF5_1_4__3_1_0_SPIFFS.build_flags}
; ${mqtt_flags.build_flags}
-DMQTT_MAX_PACKET_SIZE=2048
-DCONFIG_FREERTOS_ASSERT_DISABLE
Expand All @@ -30,11 +30,11 @@ build_flags = ${core_esp32_IDF5_1_4__3_0_5_SPIFFS.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
monitor_filters = esp32_exception_decoder
lib_ignore =
${core_esp32_IDF5_1_4__3_0_5_SPIFFS.lib_ignore}
${core_esp32_IDF5_1_4__3_1_0_SPIFFS.lib_ignore}


[esp32_base_idf5]
extends = common, core_esp32_IDF5_3_1__3_0_5_LittleFS
extends = common, core_esp32_IDF5_3_2__3_1_0_LittleFS
upload_speed = 460800
upload_before_reset = default_reset
upload_after_reset = hard_reset
Expand All @@ -51,7 +51,7 @@ extra_scripts = post:tools/pio/post_esp32.py
; However LTO cannot optimize builds with text section literals and thus will result in quite a lot larger builds (80k - 140k larger)
build_unflags = -Wall
-fno-lto
build_flags = ${core_esp32_IDF5_3_1__3_0_5_LittleFS.build_flags}
build_flags = ${core_esp32_IDF5_3_2__3_1_0_LittleFS.build_flags}
; ${mqtt_flags.build_flags}
-DMQTT_MAX_PACKET_SIZE=2048
-DCONFIG_FREERTOS_ASSERT_DISABLE
Expand All @@ -65,7 +65,7 @@ build_flags = ${core_esp32_IDF5_3_1__3_0_5_LittleFS.build_flags}
-DLWIP_IPV6=1
monitor_filters = esp32_exception_decoder
lib_ignore =
${core_esp32_IDF5_3_1__3_0_5_LittleFS.lib_ignore}
${core_esp32_IDF5_3_2__3_1_0_LittleFS.lib_ignore}


; -flto cannot be used for ESP32 C3!
Expand Down Expand Up @@ -116,7 +116,7 @@ board_build.filesystem = littlefs
lib_ignore = ${esp32_always.lib_ignore}
ESP32_ping
ESP32 BLE Arduino
${core_esp32_IDF5_3_1__3_0_5_LittleFS.lib_ignore}
${core_esp32_IDF5_3_2__3_1_0_LittleFS.lib_ignore}


[esp32_IRExt]
Expand Down
5 changes: 2 additions & 3 deletions platformio_esp32_solo1.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
; IDF 5.3.1
[esp32_solo1_common_LittleFS]
extends = esp32_base_idf5
platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF53
;platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.12.30/platform-espressif32.zip
platform_packages = framework-arduino-solo1 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3204/framework-arduinoespressif32-solo1-release_v5.3-ddc10306.zip
platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF53
platform_packages = framework-arduino-solo1 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3204/framework-arduinoespressif32-solo1-release_v5.3-ddc10306.zip
build_flags = ${esp32_base_idf5.build_flags}
-DFEATURE_ARDUINO_OTA=1
-DUSE_LITTLEFS
Expand Down
32 changes: 25 additions & 7 deletions src/src/Helpers/Hardware_GPIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,35 @@ bool getGpioInfo(int gpio, int& pinnr, bool& input, bool& output, bool& warning)
}

if (gpio == 11) {
// By default VDD_SPI is the power supply pin for embedded flash or external flash. It can only be used as GPIO11
// only when the chip is connected to an external flash, and this flash is powered by an external power supply
input = false;
output = false;
if (getChipFeatures().embeddedFlash) {
// See: https://www.letscontrolit.com/forum/viewtopic.php?p=71880#p71874
//
// By default VDD_SPI is the power supply pin for embedded flash or external flash.
// It can only be used as GPIO11 only when the chip is connected to an
// external flash, and this flash is powered by an external power supply
input = false;
output = false;
}
warning = true;
}

if (isFlashInterfacePin_ESPEasy(gpio)) {
// Connected to the integrated SPI flash.
input = false;
output = false;
if (getChipFeatures().embeddedFlash) {
// Connected to the integrated SPI flash.
input = false;
output = false;
} else {
// See: https://www.letscontrolit.com/forum/viewtopic.php?p=71880#p71874
if (gpio == 12 || gpio == 13) {
// SPIHD/GPIO12
// SPIWP/GPIO13
if (ESP.getFlashChipMode() != FM_DOUT &&
ESP.getFlashChipMode() != FM_DIO) {
input = false;
output = false;
}
}
}
warning = true;
}

Expand Down

0 comments on commit 9e560a5

Please sign in to comment.