Skip to content

Commit

Permalink
Merge pull request #3934 from TD-er/feature/ESP8285_detect
Browse files Browse the repository at this point in the history
[ESP8285] Remove ESP8285 specific builds, detect at runtime (#3848)
  • Loading branch information
TD-er authored Jul 23, 2022
2 parents 375316a + 5f7cd53 commit 38f4b6a
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 113 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ core_274_sdk3 | Arduino Core 2.7.4 SDK v.3 release |
_[hardware-type]_ cn be any of:
Hardware type | Description |
-----------------|---------------------------------------------|
ESP8266 | Espressif ESP8266 generic boards |
ESP8285 | Espressif ESP8285 generic boards 1MB Flash |
ESP8266 | Espressif ESP8266/ESP8285 generic boards |
WROOM02 | Espressif ESP8266 WRoom02 boards |
ESP32 | Espressif ESP32 generic boards |
ESP32-wrover-kit | Espressif ESP32 wrover-kit boards |
Expand All @@ -81,6 +80,8 @@ Shelly_PLUG_S | Shelly plug S switch with power measurement |
Ventus | Ventus W266 weather station |
LCtech | LC-tech serial switch |

N.B. Starting 2022/07/23, 1M ESP8266 builds can also be used on ESP8285 units and thus there is no longer a specific ESP8285 build anymore.


_[flash-size]_ can be any of:
Flash size | Description |
Expand Down Expand Up @@ -112,7 +113,6 @@ Some example firmware names:
Firmware name | Hardware | Included plugins |
---------------------------------------------------|-------------------------|-------------------------------|
ESPEasy_mega-20210501_normal_ESP8266_1M.bin | ESP8266 with 1MB flash | Stable |
ESPEasy_mega-20210501_normal_ESP8285_1M.bin | ESP8285 with 1MB flash | Stable |
ESPEasy_mega-20210501_normal_ESP8266_4M1M.bin | ESP8266 with 4MB flash | Stable |
ESPEasy_mega-20210501_test_A_ESP8266_4M1M.bin | ESP8266 with 4MB flash | Stable + Testing base + set A |
ESPEasy_mega-20210501_normal_ESP32_4M316k.bin | ESP32 with 4MB flash | Stable |
Expand Down
6 changes: 4 additions & 2 deletions dist/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ There is also a number of special builds:
- normal_beta => "Normal" using the staged (beta) branch of the esp8266/Arduino repository.

Chip can be:
- ESP8266 => Most likely option
- ESP8285 => Used in some Sonoff modules
- ESP8266 => Most likely option (use also for ESP8285 chips)
- ESP32 => Showing up in commercial products, but mainly seen on NodeMCU like boards.
- ESP32-S2 => Newer version of ESP32, with more GPIO pins, but lacking some features of ESP32.
- ESP32-S3 => Not yet supported in ESPEasy. (hardly available to buy)
- ESP32-C3 => Support in ESPEasy will be added soon.

MemorySize can be:
- 1M => 1 MB flash modules (e.g. almost all Sonoff modules)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/Participate/PlatformIO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ The environment definitions all have at least the used micro controller in the n
For example:

* ..._ESP8266_4Mnn -> ESP8266 has external flash, which can vary in size from 512 kB to 16 MB, with nn configured as filesystem.
* ..._ESP8285_1M -> ESP8285 has the flash internal, it is always 1 MB.
* ..._ESP8266_1M -> ESP8285 has the flash internal, which is almost always 1 MB. ESP8266 does have an external flash chip, which allows for exchanging it for a larger flash chip (recommended).
* ..._ESP32_4M316k -> ESP32 with 4 MB flash and a 1.8 MB partition for the sketch. (316k SPIFFS)
* ..._ESP32s2_4M316k -> ESP32s2 with 4 MB flash and a 1.8 MB partition for the sketch. (316k SPIFFS)
* ..._ESP32_16M2M_LittleFS -> ESP32 with 16 MB flash and a 4 MB partition for the sketch. (2MB LittleFS)
Expand Down
7 changes: 5 additions & 2 deletions docs/source/Participate/ProjectStructure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,11 @@ ESP Chip Type
-------------

* ``ESP8266`` Most likely option.
* ``ESP8285`` Used in some Sonoff modules. This chip has embedded flash, so no extra flash chip.
* ``ESP32`` Experimental support at this moment.
* ``ESP8285`` Supported in ``ESP8266`` builds. Used in some Sonoff modules. This chip has embedded flash, so no extra flash chip.
* ``ESP32`` Allows for more memory and more GPIO pins.
* ``ESP32-S2`` Newer version of ESP32. Has even more GPIO pins, but some specific features of ESP32 were removed.
* ``ESP32-S3`` Not yet available.
* ``ESP32-C3`` Support will be added soon.

Memory Size and Partitioning
----------------------------
Expand Down
12 changes: 0 additions & 12 deletions platformio_esp82xx_base.ini
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,6 @@ extends = esp82xx_1M
board = esp8266_1M128k
build_flags = ${esp82xx_1M.build_flags}

[esp8285_1M]
extends = esp82xx_1M
board = esp8285_1M128k
build_flags = ${esp82xx_1M.build_flags}
-DESP8285


;;; Minimal ***********************************************************
; Minimal build size for OTA ;
Expand All @@ -264,12 +258,6 @@ extends = esp82xx_1M_OTA
board = esp8266_1M128k_OTA
build_flags = ${esp82xx_1M_OTA.build_flags}

[esp8285_1M_OTA]
extends = esp82xx_1M_OTA
board = esp8285_1M128k_OTA
build_flags = ${esp82xx_1M_OTA.build_flags}
-DESP8285


;;; 2MB flash nodes **************************************************
; Layout for 2M flash nodes ;
Expand Down
75 changes: 7 additions & 68 deletions platformio_esp82xx_envs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,13 @@ lib_ignore = ${regular_platform_alt_wifi.lib_ignore}



; NORMAL: 1024k for esp8285 ----------------------
[env:normal_ESP8285_1M]
extends = esp8285_1M
platform = ${regular_platform.platform}
platform_packages = ${regular_platform.platform_packages}
build_flags = ${regular_platform.build_flags}
${esp8285_1M.build_flags}
lib_ignore = ${regular_platform.lib_ignore}
SD(esp8266)
SD
SDFS
LittleFS(esp8266)

; NORMAL: 2048k WROOM02 version --------------------------
;[env:normal_WROOM02_2M]
;extends = espWroom2M
;platform = ${regular_platform.platform}
;platform_packages = ${regular_platform.platform_packages}
;build_flags = ${regular_platform.build_flags}
; ${espWroom2M.build_flags}


; NORMAL: 2048k WROOM02 version 256k SPIFFS --------------------------
Expand Down Expand Up @@ -391,13 +385,6 @@ build_flags = ${regular_platform.build_flags}
${esp8266_1M_OTA.build_flags}
${minimal_OTA_domoticz.build_flags}

[env:minimal_core_274_ESP8285_1M_OTA_Domoticz]
extends = esp8285_1M_OTA
platform = ${regular_platform.platform}
platform_packages = ${regular_platform.platform_packages}
build_flags = ${regular_platform.build_flags}
${esp8285_1M_OTA.build_flags}
${minimal_OTA_domoticz.build_flags}

[env:minimal_core_302_ESP8266_1M_OTA_Domoticz]
extends = esp8266_1M_OTA
Expand All @@ -407,14 +394,6 @@ build_flags = ${core302_platform.build_flags}
${esp8266_1M_OTA.build_flags}
${minimal_OTA_domoticz.build_flags}

[env:minimal_core_302_ESP8285_1M_OTA_Domoticz]
extends = esp8285_1M_OTA
platform = ${core302_platform.platform}
platform_packages = ${core302_platform.platform_packages}
build_flags = ${core302_platform.build_flags}
${esp8285_1M_OTA.build_flags}
${minimal_OTA_domoticz.build_flags}


[env:minimal_core_274_ESP8266_1M_OTA_FHEM_HA]
extends = esp8266_1M_OTA
Expand All @@ -424,13 +403,6 @@ build_flags = ${regular_platform.build_flags}
${esp8266_1M_OTA.build_flags}
${minimal_OTA_FHEM_HA.build_flags}

[env:minimal_core_274_ESP8285_1M_OTA_FHEM_HA]
extends = esp8285_1M_OTA
platform = ${regular_platform.platform}
platform_packages = ${regular_platform.platform_packages}
build_flags = ${regular_platform.build_flags}
${esp8285_1M_OTA.build_flags}
${minimal_OTA_FHEM_HA.build_flags}

[env:minimal_core_302_ESP8266_1M_OTA_FHEM_HA]
extends = esp8266_1M_OTA
Expand All @@ -440,14 +412,6 @@ build_flags = ${core302_platform.build_flags}
${esp8266_1M_OTA.build_flags}
${minimal_OTA_FHEM_HA.build_flags}

[env:minimal_core_302_ESP8285_1M_OTA_FHEM_HA]
extends = esp8285_1M_OTA
platform = ${core302_platform.platform}
platform_packages = ${core302_platform.platform_packages}
build_flags = ${core302_platform.build_flags}
${esp8285_1M_OTA.build_flags}
${minimal_OTA_FHEM_HA.build_flags}



;;; IR ***********************************************************
Expand Down Expand Up @@ -833,31 +797,6 @@ build_flags = ${hard_esp82xx.build_flags}
-D PLUGIN_SET_SONOFF_POW


; ITEAD / SONOFF S20 version --------------------
;[env:hard_SONOFF_S20_1M]
;extends = esp8266_1M_OTA
;platform = ${hard_esp82xx.platform}
;platform_packages = ${hard_esp82xx.platform_packages}
;build_flags = ${hard_esp82xx.build_flags} ${esp8266_1M_OTA.build_flags} -D PLUGIN_SET_SONOFF_S2x


; ITEAD / SONOFF 4CH version --------------------
;[env:hard_SONOFF_4CH_1M]
;extends = esp8285_1M_OTA
;platform = ${hard_esp82xx.platform}
;platform_packages = ${hard_esp82xx.platform_packages}
;build_flags = ${hard_esp82xx.build_flags} ${esp8285_1M_OTA.build_flags} -D PLUGIN_SET_SONOFF_4CH



; ITEAD / SONOFF TOUCH version ------------------
;[env:hard_SONOFF_TOUCH_1M]
;extends = esp8285_1M_OTA
;platform = ${hard_esp82xx.platform}
;platform_packages = ${hard_esp82xx.platform_packages}
;build_flags = ${hard_esp82xx.build_flags} ${esp8285_1M_OTA.build_flags} -D PLUGIN_SET_SONOFF_TOUCH


; Shelly1 Open Source (ESP8266-2MB)
; https://shelly.cloud/shelly1-open-source/
; GPIO04 Relay (non inverted)
Expand Down
60 changes: 35 additions & 25 deletions src/src/Helpers/Hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,15 +874,30 @@ const __FlashStringHelper* getChipModel() {
return F("ESP32-H2");
}
return F("ESP32");

#elif defined(ESP8285)
return F("ESP8285");
#elif defined(ESP8266)
return F("ESP8266");
#endif // ifdef ESP32
return isESP8285() ? F("ESP8285") : F("ESP8266");
#endif
return F("Unknown");
}

bool isESP8285() {
#ifdef ESP8266
const uint32_t efuse_blocks[4] {
READ_PERI_REG(0x3ff00050),
READ_PERI_REG(0x3ff00054),
READ_PERI_REG(0x3ff00058),
READ_PERI_REG(0x3ff0005c)
};

return (
(efuse_blocks[0] & (1 << 4))
|| (efuse_blocks[2] & (1 << 16))
);
#else
return false;
#endif
}

uint8_t getChipRevision() {
uint8_t rev = 0;

Expand Down Expand Up @@ -1543,29 +1558,24 @@ bool getGpioInfo(int gpio, int& pinnr, bool& input, bool& output, bool& warning)
}

if (isFlashInterfacePin(gpio)) {
# ifdef ESP8285

if ((gpio == 9) || (gpio == 10)) {
// Usable on ESP8285
if (isESP8285()) {
if ((gpio == 9) || (gpio == 10)) {
// Usable on ESP8285
} else {
warning = true;
}
} else {
warning = true;
// On ESP8266 GPIO 9 & 10 are only usable if not connected to flash
if (gpio == 9) {
// GPIO9 is internally used to control the flash memory.
input = false;
output = false;
} else if (gpio == 10) {
// GPIO10 can be used as input only.
output = false;
}
}

# else // ifdef ESP8285

warning = true;

// On ESP8266 GPIO 9 & 10 are only usable if not connected to flash
if (gpio == 9) {
// GPIO9 is internally used to control the flash memory.
input = false;
output = false;
} else if (gpio == 10) {
// GPIO10 can be used as input only.
output = false;
}

# endif // ifdef ESP8285
}

if ((pinnr < 0) || (pinnr > 16)) {
Expand Down
2 changes: 2 additions & 0 deletions src/src/Helpers/Hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ uint8_t getChipCores();

const __FlashStringHelper* getChipModel();

bool isESP8285();

uint8_t getChipRevision();

uint32_t getSketchSize();
Expand Down

0 comments on commit 38f4b6a

Please sign in to comment.