Skip to content

Commit e2c8fc6

Browse files
authored
Merge branch 'wled:main' into main
2 parents 51a7431 + ae37f42 commit e2c8fc6

File tree

7 files changed

+163
-15
lines changed

7 files changed

+163
-15
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*-------------------------------------------------------------------------
2+
NeoPixel library helper functions for Esp8266.
3+
4+
FIXED VERSION FROM https://github.com/Makuna/NeoPixelBus/pull/894
5+
This library will overlay/shadow the base version from NeoPixelBus
6+
7+
Written by Michael C. Miller.
8+
Thanks to g3gg0.de for porting the initial DMA support which lead to this.
9+
Thanks to github/cnlohr for the original work on DMA support, which opend
10+
all our minds to a better way (located at https://github.com/cnlohr/esp8266ws2812i2s).
11+
12+
I invest time and resources providing this open source code,
13+
please support me by donating (see https://github.com/Makuna/NeoPixelBus)
14+
15+
-------------------------------------------------------------------------
16+
This file is part of the Makuna/NeoPixelBus library.
17+
18+
NeoPixelBus is free software: you can redistribute it and/or modify
19+
it under the terms of the GNU Lesser General Public License as
20+
published by the Free Software Foundation, either version 3 of
21+
the License, or (at your option) any later version.
22+
23+
NeoPixelBus is distributed in the hope that it will be useful,
24+
but WITHOUT ANY WARRANTY; without even the implied warranty of
25+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26+
GNU Lesser General Public License for more details.
27+
28+
You should have received a copy of the GNU Lesser General Public
29+
License along with NeoPixel. If not, see
30+
<http://www.gnu.org/licenses/>.
31+
-------------------------------------------------------------------------*/
32+
33+
#pragma once
34+
35+
#ifdef ARDUINO_ARCH_ESP8266
36+
#include "internal/methods/NeoEsp8266DmaMethod.h"
37+
38+
template<typename T_PATTERN> class NeoEsp8266Dma3StepEncodeFixed : public T_PATTERN
39+
{
40+
public:
41+
const static size_t DmaBitsPerPixelBit = 3; // 3 step cadence, matches encoding
42+
43+
static size_t SpacingPixelSize(size_t sizePixel)
44+
{
45+
return sizePixel;
46+
}
47+
48+
static void FillBuffers(uint8_t* i2sBuffer,
49+
const uint8_t* data,
50+
size_t sizeData,
51+
[[maybe_unused]] size_t sizePixel)
52+
{
53+
const uint8_t SrcBitMask = 0x80;
54+
const size_t BitsInSample = sizeof(uint32_t) * 8;
55+
56+
uint32_t* pDma = reinterpret_cast<uint32_t*>(i2sBuffer);
57+
uint32_t dmaValue = 0;
58+
uint8_t destBitsLeft = BitsInSample;
59+
60+
const uint8_t* pSrc = data;
61+
const uint8_t* pEnd = pSrc + sizeData;
62+
63+
while (pSrc < pEnd)
64+
{
65+
uint8_t value = *(pSrc++);
66+
67+
for (uint8_t bitSrc = 0; bitSrc < 8; bitSrc++)
68+
{
69+
const uint16_t Bit = ((value & SrcBitMask) ? T_PATTERN::OneBit3Step : T_PATTERN::ZeroBit3Step);
70+
71+
if (destBitsLeft > 3)
72+
{
73+
destBitsLeft -= 3;
74+
dmaValue |= Bit << destBitsLeft;
75+
76+
#if defined(NEO_DEBUG_DUMP_I2S_BUFFER)
77+
NeoUtil::PrintBin<uint32_t>(dmaValue);
78+
Serial.print(" < ");
79+
Serial.println(destBitsLeft);
80+
#endif
81+
}
82+
else if (destBitsLeft <= 3)
83+
{
84+
uint8_t bitSplit = (3 - destBitsLeft);
85+
dmaValue |= Bit >> bitSplit;
86+
87+
#if defined(NEO_DEBUG_DUMP_I2S_BUFFER)
88+
NeoUtil::PrintBin<uint32_t>(dmaValue);
89+
Serial.print(" > ");
90+
Serial.println(bitSplit);
91+
#endif
92+
// next dma value, store and reset
93+
*(pDma++) = dmaValue;
94+
dmaValue = 0;
95+
96+
destBitsLeft = BitsInSample - bitSplit;
97+
if (bitSplit)
98+
{
99+
dmaValue |= Bit << destBitsLeft;
100+
}
101+
102+
#if defined(NEO_DEBUG_DUMP_I2S_BUFFER)
103+
NeoUtil::PrintBin<uint32_t>(dmaValue);
104+
Serial.print(" v ");
105+
Serial.println(bitSplit);
106+
#endif
107+
}
108+
109+
// Next
110+
value <<= 1;
111+
}
112+
}
113+
// store the remaining bits
114+
if (destBitsLeft != BitsInSample) *pDma++ = dmaValue;
115+
}
116+
};
117+
118+
// Abuse explict specialization to overlay the methods
119+
template<> class NeoEsp8266Dma3StepEncode<NeoEsp8266DmaNormalPattern> : public NeoEsp8266Dma3StepEncodeFixed<NeoEsp8266DmaNormalPattern> {};
120+
template<> class NeoEsp8266Dma3StepEncode<NeoEsp8266DmaInvertedPattern> : public NeoEsp8266Dma3StepEncodeFixed<NeoEsp8266DmaInvertedPattern> {};
121+
122+
#endif

lib/NeoESP8266DMAFix/library.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "NeoESP8266DMAFix",
3+
"build": { "libArchive": false },
4+
"platforms": ["espressif8266"],
5+
"dependencies": [
6+
{
7+
"owner": "makuna",
8+
"name": "NeoPixelBus",
9+
"version": "2.8.3"
10+
}
11+
]
12+
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
},
1515
"repository": {
1616
"type": "git",
17-
"url": "git+https://github.com/wled-dev/WLED.git"
17+
"url": "git+https://github.com/wled/WLED.git"
1818
},
1919
"author": "",
2020
"license": "ISC",
2121
"bugs": {
22-
"url": "https://github.com/wled-dev/WLED/issues"
22+
"url": "https://github.com/wled/WLED/issues"
2323
},
24-
"homepage": "https://github.com/wled-dev/WLED#readme",
24+
"homepage": "https://github.com/wled/WLED#readme",
2525
"dependencies": {
2626
"clean-css": "^5.3.3",
2727
"html-minifier-terser": "^7.2.0",
@@ -31,4 +31,4 @@
3131
"engines": {
3232
"node": ">=20.0.0"
3333
}
34-
}
34+
}

platformio.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ lib_deps =
220220
ESPAsyncUDP
221221
ESP8266PWM
222222
${env.lib_deps}
223+
NeoESP8266DMAFix
223224

224225
;; compatibilty flags - same as 0.14.0 which seems to work better on some 8266 boards. Not using PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48
225226
build_flags_compat =
@@ -256,7 +257,7 @@ lib_deps_compat =
256257
lib_deps =
257258
esp32async/AsyncTCP @ 3.4.7
258259
bitbank2/AnimatedGIF@^1.4.7
259-
https://github.com/Aircoookie/GifDecoder#bc3af18
260+
https://github.com/Aircoookie/GifDecoder.git#bc3af189b6b1e06946569f6b4287f0b79a860f8e
260261
build_flags =
261262
-D CONFIG_ASYNC_TCP_USE_WDT=0
262263
-D CONFIG_ASYNC_TCP_STACK_SIZE=8192
@@ -300,7 +301,7 @@ build_flags = -g
300301
-D WLED_ENABLE_DMX_INPUT
301302
lib_deps =
302303
${esp32_all_variants.lib_deps}
303-
https://github.com/someweisguy/esp_dmx.git#47db25d
304+
https://github.com/someweisguy/esp_dmx.git#47db25d8c515e76fabcf5fc5ab0b786f98eeade0
304305
${env.lib_deps}
305306

306307
[esp32s2]

wled00/bus_wrapper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
//#define NPB_CONF_4STEP_CADENCE
66
#include "NeoPixelBus.h"
7+
#ifdef ARDUINO_ARCH_ESP8266
8+
#include <NeoEsp8266DmaMethodFix.h>
9+
#endif
710

811
//Hardware SPI Pins
912
#define P_8266_HS_MOSI 13

wled00/ota_update.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,20 @@
1212
#ifdef ESP32
1313
constexpr size_t METADATA_OFFSET = 256; // ESP32: metadata appears after Espressif metadata
1414
#define UPDATE_ERROR errorString
15-
const size_t BOOTLOADER_OFFSET = 0x1000;
15+
16+
// Bootloader is at fixed offset 0x1000 (4KB), 0x0000 (0KB), or 0x2000 (8KB), and is typically 32KB
17+
// Bootloader offsets for different MCUs => see https://github.com/wled/WLED/issues/5064
18+
#if defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6)
19+
constexpr size_t BOOTLOADER_OFFSET = 0x0000; // esp32-S3, esp32-C3 and (future support) esp32-c6
20+
constexpr size_t BOOTLOADER_SIZE = 0x8000; // 32KB, typical bootloader size
21+
#elif defined(CONFIG_IDF_TARGET_ESP32P4) || defined(CONFIG_IDF_TARGET_ESP32C5)
22+
constexpr size_t BOOTLOADER_OFFSET = 0x2000; // (future support) esp32-P4 and esp32-C5
23+
constexpr size_t BOOTLOADER_SIZE = 0x8000; // 32KB, typical bootloader size
24+
#else
25+
constexpr size_t BOOTLOADER_OFFSET = 0x1000; // esp32 and esp32-s2
26+
constexpr size_t BOOTLOADER_SIZE = 0x8000; // 32KB, typical bootloader size
27+
#endif
28+
1629
#elif defined(ESP8266)
1730
constexpr size_t METADATA_OFFSET = 0x1000; // ESP8266: metadata appears at 4KB offset
1831
#define UPDATE_ERROR getErrorString
@@ -280,9 +293,6 @@ static String bootloaderSHA256HexCache = "";
280293
void calculateBootloaderSHA256() {
281294
if (!bootloaderSHA256HexCache.isEmpty()) return;
282295

283-
// Bootloader is at fixed offset 0x1000 (4KB) and is typically 32KB
284-
const uint32_t bootloaderSize = 0x8000; // 32KB, typical bootloader size
285-
286296
// Calculate SHA256
287297
uint8_t sha256[32];
288298
mbedtls_sha256_context ctx;
@@ -292,8 +302,8 @@ void calculateBootloaderSHA256() {
292302
const size_t chunkSize = 256;
293303
uint8_t buffer[chunkSize];
294304

295-
for (uint32_t offset = 0; offset < bootloaderSize; offset += chunkSize) {
296-
size_t readSize = min((size_t)(bootloaderSize - offset), chunkSize);
305+
for (uint32_t offset = 0; offset < BOOTLOADER_SIZE; offset += chunkSize) {
306+
size_t readSize = min((size_t)(BOOTLOADER_SIZE - offset), chunkSize);
297307
if (esp_flash_read(NULL, buffer, BOOTLOADER_OFFSET + offset, readSize) == ESP_OK) {
298308
mbedtls_sha256_update(&ctx, buffer, readSize);
299309
}

wled00/util.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,11 +1170,11 @@ String generateDeviceFingerprint() {
11701170
// mix in ADC calibration data:
11711171
esp_adc_cal_characteristics_t ch;
11721172
#if SOC_ADC_MAX_BITWIDTH == 13 // S2 has 13 bit ADC
1173-
#define BIT_WIDTH ADC_WIDTH_BIT_13
1173+
constexpr auto myBIT_WIDTH = ADC_WIDTH_BIT_13;
11741174
#else
1175-
#define BIT_WIDTH ADC_WIDTH_BIT_12
1175+
constexpr auto myBIT_WIDTH = ADC_WIDTH_BIT_12;
11761176
#endif
1177-
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, BIT_WIDTH, 1100, &ch);
1177+
esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, myBIT_WIDTH, 1100, &ch);
11781178
fp[0] ^= ch.coeff_a;
11791179
fp[1] ^= ch.coeff_b;
11801180
if (ch.low_curve) {

0 commit comments

Comments
 (0)