Skip to content

Commit

Permalink
Merge pull request letscontrolit#5222 from TD-er/bugfix/gpio_platform…
Browse files Browse the repository at this point in the history
…_defines

[GPIO] update hardware defines for flash connected GPIO pins
  • Loading branch information
TD-er authored Jan 10, 2025
2 parents 6c7f805 + 7c86fc8 commit acce70e
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 29 deletions.
49 changes: 30 additions & 19 deletions src/src/Helpers/Hardware_GPIO_ESP32C6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,36 @@ bool getGpioInfo(int gpio, int& pinnr, bool& input, bool& output, bool& warning)
return (input || output);
}

bool isBootStrapPin(int gpio)
{
if (gpio == 8) {
// Strapping pin which must be high during flashing
return true;
}

if (gpio == 9) {
// Strapping pin to force download mode (like GPIO-0 on ESP8266/ESP32-classic)
return true;
}

if (gpio == 4 || gpio == 5 || gpio == 15) {
// FIXME TD-er: See what these do
return true;
}

return false;
}
bool isBootStrapPin(int gpio)
{
// See: https://www.espressif.com/sites/default/files/documentation/esp32-c6_datasheet_en.pdf
// Chapter 3 - Boot Configurations
if (gpio == 8) {
// Strapping pin which must be high during flashing
// ROM message printing
return true;
}

if (gpio == 9) {
// Strapping pin to force download mode (like GPIO-0 on ESP8266/ESP32-classic)
// internal Weak pull-up, must be pulled down to enter download boot mode.
return true;
}

if (gpio == 4 || gpio == 5) {
// SDIO Sampling and Driving Clock Edge
// MTMS = GPIO-4
// MTDI = Gpio-5
return true;
}

if (gpio == 15) {
// JTAG signal source
return true;
}

return false;
}

bool getGpioPullResistor(int gpio, bool& hasPullUp, bool& hasPullDown) {
hasPullDown = false;
Expand Down
2 changes: 2 additions & 0 deletions src/src/Helpers/Hardware_GPIO_ESP32S3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ bool isBootStrapPin(int gpio)

if (gpio == 46) {
// Strapping pin which must be low during flashing
// ROM message printing
return true;
}

// Chip boot mode
// GPIO 0 State during boot determines boot mode.
if (gpio == 0) { return true; }

Expand Down
13 changes: 12 additions & 1 deletion src/src/Helpers/Hardware_device_info_ESP32C2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# include <soc/soc.h>
# include <soc/efuse_reg.h>
# include <soc/spi_reg.h>
# include <soc/spi_pins.h>
# include <soc/rtc.h>
# include <esp_chip_info.h>
# include <bootloader_common.h>
Expand All @@ -13,7 +14,17 @@
bool isFlashInterfacePin_ESPEasy(int gpio) {
// GPIO-11: Flash voltage selector
// For chip variants with a SiP flash built in, GPIO11~ GPIO17 are dedicated to connecting SiP flash, not for other uses
return (gpio) >= 12 && (gpio) <= 17;
// return (gpio) >= 12 && (gpio) <= 17;
switch (gpio) {
case SPI_IOMUX_PIN_NUM_HD:
case SPI_IOMUX_PIN_NUM_CS:
case SPI_IOMUX_PIN_NUM_MOSI:
case SPI_IOMUX_PIN_NUM_CLK:
case SPI_IOMUX_PIN_NUM_MISO:
case SPI_IOMUX_PIN_NUM_WP:
return true;
}
return false;
}

bool flashVddPinCanBeUsedAsGPIO()
Expand Down
15 changes: 13 additions & 2 deletions src/src/Helpers/Hardware_device_info_ESP32C3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# include <soc/soc.h>
# include <soc/efuse_reg.h>
# include <soc/spi_reg.h>
# include <soc/spi_pins.h>
# include <soc/rtc.h>
# include <esp_chip_info.h>
# include <bootloader_common.h>
Expand All @@ -34,7 +35,17 @@
bool isFlashInterfacePin_ESPEasy(int gpio) {
// GPIO-11: Flash voltage selector
// GPIO-12 ... 17: Connected to flash
return (gpio) >= 12 && (gpio) <= 17;
// return (gpio) >= 12 && (gpio) <= 17;
switch (gpio) {
case SPI_IOMUX_PIN_NUM_HD:
case SPI_IOMUX_PIN_NUM_CS:
case SPI_IOMUX_PIN_NUM_MOSI:
case SPI_IOMUX_PIN_NUM_CLK:
case SPI_IOMUX_PIN_NUM_MISO:
case SPI_IOMUX_PIN_NUM_WP:
return true;
}
return false;
}

bool flashVddPinCanBeUsedAsGPIO()
Expand Down Expand Up @@ -76,7 +87,7 @@ bool isPSRAMInterfacePin(int gpio) {

const __FlashStringHelper* getChipModel(uint32_t chip_model, uint32_t chip_revision, uint32_t pkg_version, bool single_core)
{
if (CHIP_ESP32C3 == chip_model) { // ESP32-C3
if (CHIP_ESP32C3 == chip_model) { // ESP32-C3
/* esptool:
def get_pkg_version(self):
num_word = 3
Expand Down
24 changes: 19 additions & 5 deletions src/src/Helpers/Hardware_device_info_ESP32C6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# include <soc/soc.h>
# include <soc/efuse_reg.h>
# include <soc/spi_reg.h>
# include <soc/spi_pins.h>
# include <soc/rtc.h>
# include <esp_chip_info.h>
# include <bootloader_common.h>
Expand All @@ -17,19 +18,32 @@ bool isFlashInterfacePin_ESPEasy(int gpio) {

// FIXME TD-er: No idea where these pins come from. Disabled for now.
// See: https://github.com/letscontrolit/ESPEasy/issues/5220

/*
if ((gpio == 10) || (gpio == 11)) {
return true;
}
*/
if ((gpio == 10) || (gpio == 11)) {
return true;
}
*/

// For chip variants without an in-package flash, this pin can not be used.
// if (gpio == 14)
// return true;

// GPIO-27: Flash voltage selector
// GPIO-24 ... 30: Connected to internal flash (might be available when using external flash???)
return (gpio) >= 24 && (gpio) <= 30 && gpio != 27;

switch (gpio) {
case SPI_IOMUX_PIN_NUM_CS:
case SPI_IOMUX_PIN_NUM_CLK:
case SPI_IOMUX_PIN_NUM_MOSI:
case SPI_IOMUX_PIN_NUM_MISO:
case SPI_IOMUX_PIN_NUM_WP:
case SPI_IOMUX_PIN_NUM_HD:
return true;
}
return false;

// return (gpio) >= 24 && (gpio) <= 30 && gpio != 27;
}

bool flashVddPinCanBeUsedAsGPIO()
Expand Down
14 changes: 13 additions & 1 deletion src/src/Helpers/Hardware_device_info_ESP32S2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# include <soc/soc.h>
# include <soc/efuse_reg.h>
# include <soc/spi_reg.h>
# include <soc/spi_pins.h>
# include <soc/rtc.h>
# include <esp_chip_info.h>
# include <bootloader_common.h>
Expand All @@ -28,7 +29,18 @@ bool isFlashInterfacePin_ESPEasy(int gpio) {
// GPIO-22 ... 25: SPI flash and PSRAM
// GPIO-26: CS for PSRAM, thus only unuable when PSRAM is present
// GPIO-27 ... 32: SPI 8 ­line mode (OPI) pins for flash or PSRAM (e.g. ESP32-S2FH2 and ESP32-S2FH4)
return (gpio) >= 22 && (gpio) <= 25;
// return (gpio) >= 22 && (gpio) <= 25;
switch (gpio) {
case SPI_IOMUX_PIN_NUM_HD:
case SPI_IOMUX_PIN_NUM_CS:
case SPI_IOMUX_PIN_NUM_MOSI:
case SPI_IOMUX_PIN_NUM_CLK:
case SPI_IOMUX_PIN_NUM_MISO:
case SPI_IOMUX_PIN_NUM_WP:
return true;
}
return false;

}

bool flashVddPinCanBeUsedAsGPIO()
Expand Down
14 changes: 13 additions & 1 deletion src/src/Helpers/Hardware_device_info_ESP32S3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# include <soc/soc.h>
# include <soc/efuse_reg.h>
# include <soc/spi_reg.h>
# include <soc/spi_pins.h>
# include <soc/rtc.h>
# include <esp_chip_info.h>
# include <bootloader_common.h>
Expand Down Expand Up @@ -46,7 +47,18 @@
bool isFlashInterfacePin_ESPEasy(int gpio) {
// GPIO-26 ... 32: SPI flash and PSRAM
// GPIO-33 ... 37: SPI 8 ­line mode (OPI) pins for flash or PSRAM, like ESP32-S3R8 / ESP32-S3R8V.
return (gpio) >= 26 && (gpio) <= 32;
// return (gpio) >= 26 && (gpio) <= 32;
switch (gpio) {
case 26: // SPICS1 Only when PSRAM is present???
case SPI_IOMUX_PIN_NUM_HD:
case SPI_IOMUX_PIN_NUM_CS:
case SPI_IOMUX_PIN_NUM_MOSI:
case SPI_IOMUX_PIN_NUM_CLK:
case SPI_IOMUX_PIN_NUM_MISO:
case SPI_IOMUX_PIN_NUM_WP:
return true;
}
return false;
}

int32_t getEmbeddedFlashSize()
Expand Down

0 comments on commit acce70e

Please sign in to comment.