diff --git a/arch/esp32/base.ini b/arch/esp32/base.ini index 9c99a02b7..187f8b0e1 100644 --- a/arch/esp32/base.ini +++ b/arch/esp32/base.ini @@ -38,7 +38,6 @@ build_flags = -DLIBPAX_BLE -DHAS_UDP_MULTICAST=1 ;-DDEBUG_HEAP - -include src/platform/esp32/quirks.h lib_deps = ${arduino_base.lib_deps} diff --git a/bin/platformio-custom.py b/bin/platformio-custom.py index cf38dd1de..14295a616 100644 --- a/bin/platformio-custom.py +++ b/bin/platformio-custom.py @@ -83,13 +83,6 @@ if platform.name == "espressif32": # For newer ESP32 targets, using newlib nano works better. env.Append(LINKFLAGS=["--specs=nano.specs", "-u", "_printf_float"]) - # XXX - for lb in env.GetLibBuilders(): - if lb.name == "NonBlockingRTTTL": - lb.env.Append(CPPDEFINES=[("QUIRK_RTTTL", 1)]) - elif lb.name == "LovyanGFX": - lb.env.Append(CPPDEFINES=[("QUIRK_LOVYAN", 1)]) - if platform.name == "nordicnrf52": env.AddPostAction("$BUILD_DIR/${PROGNAME}.hex", env.VerboseAction(f"\"{sys.executable}\" ./bin/uf2conv.py $BUILD_DIR/firmware.hex -c -f 0xADA52840 -o $BUILD_DIR/firmware.uf2", @@ -140,3 +133,29 @@ for lb in env.GetLibBuilders(): if lb.name == "meshtastic-device-ui": lb.env.Append(CPPDEFINES=[("APP_VERSION", verObj["long"])]) break + +############################# Libraries Patching ############################# + +env.Execute("$PYTHONEXE -m pip install patch") + +import pathlib +import glob +import os +import patch + +libsToPatch = {} +for entry in glob.glob("patches/*.patch"): + p = pathlib.Path(entry).stem + libsToPatch[p] = entry + +for lb in env.GetLibBuilders(): + if lb.name in libsToPatch: + marker_path = os.path.join(pathlib.Path(lb.src_dir), ".patched") + if not os.path.exists(marker_path): + patch_path = libsToPatch[lb.name] + ps = patch.fromfile(patch_path) + if not ps.apply(0, lb.src_dir): + print(f"Failed to apply patch {patch_path}") + exit(1) + print(f"Patched {lb.name}") + open(marker_path, "w").close() diff --git a/patches/NonBlockingRTTTL.patch b/patches/NonBlockingRTTTL.patch new file mode 100644 index 000000000..eb68fa3fa --- /dev/null +++ b/patches/NonBlockingRTTTL.patch @@ -0,0 +1,15 @@ +diff --git a/NonBlockingRtttl.cpp b/NonBlockingRtttl.cpp +index 76dea43..ba8c4e5 100644 +--- a/NonBlockingRtttl.cpp ++++ b/NonBlockingRtttl.cpp +@@ -69,8 +69,8 @@ void begin(byte iPin, const char * iSongBuffer) + //init values + pin = iPin; + #if defined(ESP32) +- ledcSetup(0, 1000, 10); // resolution always seems to be 10bit, no matter what is given +- ledcAttachPin(pin, 0); ++ // resolution always seems to be 10bit, no matter what is given ++ ledcAttachChannel(pin, 1000, 10, 0); + #endif + buffer = iSongBuffer; + bufferIndex = 0; diff --git a/patches/SdFat.patch b/patches/SdFat.patch new file mode 100644 index 000000000..d84244400 --- /dev/null +++ b/patches/SdFat.patch @@ -0,0 +1,12 @@ +diff --git a/iostream/ostream.h b/iostream/ostream.h +index e313ccf..9ac8c24 100644 +--- a/iostream/ostream.h ++++ b/iostream/ostream.h +@@ -290,6 +290,7 @@ class ostream : public virtual ios { + void putNum(int64_t n); + void putNum(uint32_t n) { putNum(n, false); } + void putNum(uint64_t n) { putNum(n, false); } ++ void putNum(uintptr_t n) { putNum(n, false); } + void putPgm(const char *str); + void putStr(const char *str); + diff --git a/src/platform/esp32/quirks.h b/src/platform/esp32/quirks.h deleted file mode 100644 index 49f192d29..000000000 --- a/src/platform/esp32/quirks.h +++ /dev/null @@ -1,16 +0,0 @@ -#if QUIRK_RTTTL -#define ledcSetup(ch, freq, res) \ - uint32_t __freq = freq; \ - uint8_t __res = res; \ - do { \ - } while (0) -#define ledcAttachPin(pin, ch) ledcAttachChannel(pin, __freq, __res, ch) -#endif - -#if QUIRK_LOVYAN && (CHATTER_2 || M5STACK) -#include "rom/ets_sys.h" -#include -#undef bool -#undef true -#undef false -#endif