Skip to content

Commit c1c707c

Browse files
committed
8266 compatibility builds for older chips (another attempt t o solve wled#3690 and wled#3685)
some users have reported that releases after 0.14.0 are not working reliably. So we add a few "compat" for 8266 that try to reproduce the buildenv of 0.14.0 as much as possible. * platform and platform_packages from 0.14.0 * not using PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48 * due to smaller IRAM, we had to move some functions back from IRAM to normal flash (may cause slowdown)
1 parent cb22e19 commit c1c707c

File tree

4 files changed

+74
-12
lines changed

4 files changed

+74
-12
lines changed

platformio.ini

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# ------------------------------------------------------------------------------
1111

1212
# CI/release binaries
13-
default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, nodemcuv2_160, esp8266_2m_160, esp01_1m_full_160, esp32dev, esp32_eth, esp32dev_audioreactive, lolin_s2_mini, esp32c3dev, esp32s3dev_16MB_opi, esp32s3dev_8MB_opi, esp32s3_4M_qspi, esp32_wrover
13+
default_envs = nodemcuv2, esp8266_2m, esp01_1m_full, nodemcuv2_160, esp8266_2m_160, esp01_1m_full_160, nodemcuv2_compat, esp8266_2m_compat, esp01_1m_full_compat, esp32dev, esp32_eth, esp32dev_audioreactive, lolin_s2_mini, esp32c3dev, esp32s3dev_16MB_opi, esp32s3dev_8MB_opi, esp32s3_4M_qspi, esp32_wrover
1414

1515
src_dir = ./wled00
1616
data_dir = ./wled00/data
@@ -205,6 +205,38 @@ lib_deps =
205205
ESP8266PWM
206206
${env.lib_deps}
207207

208+
;; compatibilty flags - same as 0.14.0 which seems to work better on some 8266 boards. Not using PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48
209+
build_flags_compat =
210+
-DESP8266
211+
-DFP_IN_IROM
212+
;;-Wno-deprecated-declarations
213+
-Wno-misleading-indentation
214+
;;-Wno-attributes ;; silence warnings about unknown attribute 'maybe_unused' in NeoPixelBus
215+
-DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_190703
216+
-DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
217+
-DVTABLES_IN_FLASH
218+
-DMIMETYPE_MINIMAL
219+
-DWLED_SAVE_IRAM ;; needed to prevent linker error
220+
221+
;; this platform version was used for WLED 0.14.0
222+
platform_compat = [email protected]
223+
platform_packages_compat =
224+
platformio/toolchain-xtensa @ ~2.100300.220621 #2.40802.200502
225+
platformio/tool-esptool #@ ~1.413.0
226+
platformio/tool-esptoolpy #@ ~1.30000.0
227+
228+
;; experimental - for using older NeoPixelBus 2.7.9
229+
lib_deps_compat =
230+
ESPAsyncTCP @ 1.2.2
231+
ESPAsyncUDP
232+
ESP8266PWM
233+
fastled/FastLED @ 3.6.0
234+
IRremoteESP8266 @ 2.8.2
235+
makuna/NeoPixelBus @ 2.7.9
236+
https://github.com/blazoncek/QuickESPNow.git#optional-debug
237+
https://github.com/Aircoookie/ESPAsyncWebServer.git @ 2.2.1
238+
239+
208240
[esp32]
209241
#platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.3/platform-espressif32-2.0.2.3.zip
210242
@@ -315,6 +347,14 @@ build_flags = ${common.build_flags} ${esp8266.build_flags} -D WLED_RELEASE_NAME=
315347
lib_deps = ${esp8266.lib_deps}
316348
monitor_filters = esp8266_exception_decoder
317349

350+
[env:nodemcuv2_compat]
351+
extends = env:nodemcuv2
352+
;; using platform version and build options from WLED 0.14.0
353+
platform = ${esp8266.platform_compat}
354+
platform_packages = ${esp8266.platform_packages_compat}
355+
build_flags = ${common.build_flags} ${esp8266.build_flags_compat} -D WLED_RELEASE_NAME=ESP8266_compat #-DWLED_DISABLE_2D
356+
;; lib_deps = ${esp8266.lib_deps_compat} ;; experimental - use older NeoPixelBus 2.7.9
357+
318358
[env:nodemcuv2_160]
319359
extends = env:nodemcuv2
320360
board_build.f_cpu = 160000000L
@@ -329,6 +369,13 @@ build_unflags = ${common.build_unflags}
329369
build_flags = ${common.build_flags} ${esp8266.build_flags} -D WLED_RELEASE_NAME=ESP02
330370
lib_deps = ${esp8266.lib_deps}
331371

372+
[env:esp8266_2m_compat]
373+
extends = env:esp8266_2m
374+
;; using platform version and build options from WLED 0.14.0
375+
platform = ${esp8266.platform_compat}
376+
platform_packages = ${esp8266.platform_packages_compat}
377+
build_flags = ${common.build_flags} ${esp8266.build_flags_compat} -D WLED_RELEASE_NAME=ESP02_compat #-DWLED_DISABLE_2D
378+
332379
[env:esp8266_2m_160]
333380
extends = env:esp8266_2m
334381
board_build.f_cpu = 160000000L
@@ -344,6 +391,13 @@ build_flags = ${common.build_flags} ${esp8266.build_flags} -D WLED_RELEASE_NAME=
344391
; -D WLED_USE_REAL_MATH ;; may fix wrong sunset/sunrise times, at the cost of 7064 bytes FLASH and 975 bytes RAM
345392
lib_deps = ${esp8266.lib_deps}
346393

394+
[env:esp01_1m_full_compat]
395+
extends = env:esp01_1m_full
396+
;; using platform version and build options from WLED 0.14.0
397+
platform = ${esp8266.platform_compat}
398+
platform_packages = ${esp8266.platform_packages_compat}
399+
build_flags = ${common.build_flags} ${esp8266.build_flags_compat} -D WLED_RELEASE_NAME=ESP01_compat -D WLED_DISABLE_OTA #-DWLED_DISABLE_2D
400+
347401
[env:esp01_1m_full_160]
348402
extends = env:esp01_1m_full
349403
board_build.f_cpu = 160000000L

wled00/FX_2Dfcn.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ void WS2812FX::setUpMatrix() {
161161
#ifndef WLED_DISABLE_2D
162162

163163
// XY(x,y) - gets pixel index within current segment (often used to reference leds[] array element)
164-
uint16_t IRAM_ATTR Segment::XY(uint16_t x, uint16_t y)
164+
uint16_t IRAM_ATTR_YN Segment::XY(uint16_t x, uint16_t y)
165165
{
166166
unsigned width = virtualWidth(); // segment width in logical pixels (can be 0 if segment is inactive)
167167
unsigned height = virtualHeight(); // segment height in logical pixels (is always >= 1)
168168
return isActive() ? (x%width) + (y%height) * width : 0;
169169
}
170170

171-
void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col)
171+
void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col)
172172
{
173173
if (!isActive()) return; // not active
174174
if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0) return; // if pixel would fall out of virtual segment just exit
@@ -264,7 +264,7 @@ void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa)
264264
#endif
265265

266266
// returns RGBW values of pixel
267-
uint32_t IRAM_ATTR Segment::getPixelColorXY(int x, int y) const {
267+
uint32_t IRAM_ATTR_YN Segment::getPixelColorXY(int x, int y) const {
268268
if (!isActive()) return 0; // not active
269269
if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0) return 0; // if pixel would fall out of virtual segment just exit
270270
if (reverse ) x = virtualWidth() - x - 1;

wled00/FX_fcn.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Segment& Segment::operator= (Segment &&orig) noexcept {
146146
}
147147

148148
// allocates effect data buffer on heap and initialises (erases) it
149-
bool IRAM_ATTR Segment::allocateData(size_t len) {
149+
bool IRAM_ATTR_YN Segment::allocateData(size_t len) {
150150
if (len == 0) return false; // nothing to do
151151
if (data && _dataLen >= len) { // already allocated enough (reduce fragmentation)
152152
if (call == 0) memset(data, 0, len); // erase buffer if called during effect initialisation
@@ -170,7 +170,7 @@ bool IRAM_ATTR Segment::allocateData(size_t len) {
170170
return true;
171171
}
172172

173-
void IRAM_ATTR Segment::deallocateData() {
173+
void IRAM_ATTR_YN Segment::deallocateData() {
174174
if (!data) { _dataLen = 0; return; }
175175
//DEBUG_PRINTF_P(PSTR("--- Released data (%p): %d/%d -> %p\n"), this, _dataLen, Segment::getUsedSegmentData(), data);
176176
if ((Segment::getUsedSegmentData() > 0) && (_dataLen > 0)) { // check that we don't have a dangling / inconsistent data pointer
@@ -202,7 +202,7 @@ void Segment::resetIfRequired() {
202202
reset = false;
203203
}
204204

205-
CRGBPalette16 IRAM_ATTR &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
205+
CRGBPalette16 IRAM_ATTR_YN &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
206206
if (pal < 245 && pal > GRADIENT_PALETTE_COUNT+13) pal = 0;
207207
if (pal > 245 && (strip.customPalettes.size() == 0 || 255U-pal > strip.customPalettes.size()-1)) pal = 0; // TODO remove strip dependency by moving customPalettes out of strip
208208
//default palette. Differs depending on effect
@@ -417,15 +417,15 @@ uint8_t IRAM_ATTR Segment::currentBri(bool useCct) const {
417417
return (useCct ? cct : (on ? opacity : 0));
418418
}
419419

420-
uint8_t IRAM_ATTR Segment::currentMode() const {
420+
uint8_t IRAM_ATTR_YN Segment::currentMode() const {
421421
#ifndef WLED_DISABLE_MODE_BLEND
422422
unsigned prog = progress();
423423
if (modeBlending && prog < 0xFFFFU) return _t->_modeT;
424424
#endif
425425
return mode;
426426
}
427427

428-
uint32_t IRAM_ATTR Segment::currentColor(uint8_t slot) const {
428+
uint32_t IRAM_ATTR_YN Segment::currentColor(uint8_t slot) const {
429429
if (slot >= NUM_COLORS) slot = 0;
430430
#ifndef WLED_DISABLE_MODE_BLEND
431431
return isInTransition() ? color_blend(_t->_segT._colorT[slot], colors[slot], progress(), true) : colors[slot];
@@ -618,7 +618,7 @@ uint16_t IRAM_ATTR Segment::virtualHeight() const {
618618
return vHeight;
619619
}
620620

621-
uint16_t IRAM_ATTR Segment::nrOfVStrips() const {
621+
uint16_t IRAM_ATTR_YN Segment::nrOfVStrips() const {
622622
unsigned vLen = 1;
623623
#ifndef WLED_DISABLE_2D
624624
if (is2D()) {
@@ -701,7 +701,7 @@ uint16_t IRAM_ATTR Segment::virtualLength() const {
701701
return vLength;
702702
}
703703

704-
void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
704+
void IRAM_ATTR_YN Segment::setPixelColor(int i, uint32_t col)
705705
{
706706
if (!isActive()) return; // not active
707707
#ifndef WLED_DISABLE_2D
@@ -895,7 +895,7 @@ void Segment::setPixelColor(float i, uint32_t col, bool aa)
895895
}
896896
#endif
897897

898-
uint32_t IRAM_ATTR Segment::getPixelColor(int i) const
898+
uint32_t IRAM_ATTR_YN Segment::getPixelColor(int i) const
899899
{
900900
if (!isActive()) return 0; // not active
901901
#ifndef WLED_DISABLE_2D

wled00/const.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,4 +628,12 @@
628628
#define HW_PIN_MISOSPI MISO
629629
#endif
630630

631+
// IRAM_ATTR for 8266 with 32Kb IRAM causes error: section `.text1' will not fit in region `iram1_0_seg'
632+
// this hack removes the IRAM flag for some 1D/2D functions - somewhat slower, but it solves problems with some older 8266 chips
633+
#ifdef WLED_SAVE_IRAM
634+
#define IRAM_ATTR_YN
635+
#else
636+
#define IRAM_ATTR_YN IRAM_ATTR
637+
#endif
638+
631639
#endif

0 commit comments

Comments
 (0)