From f3b0b50ccea639edb4f09901c772907e9c0125bd Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sat, 13 Jan 2024 16:34:39 +0100 Subject: [PATCH] upd --- .../Xlatb_RA8876-gemu-1.0/RA8876.h | 9 ++- pio-tools/grepmodule-firmware.py | 71 +++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 pio-tools/grepmodule-firmware.py diff --git a/lib/lib_display/Xlatb_RA8876-gemu-1.0/RA8876.h b/lib/lib_display/Xlatb_RA8876-gemu-1.0/RA8876.h index 00317ec41a00..4033c45733ee 100644 --- a/lib/lib_display/Xlatb_RA8876-gemu-1.0/RA8876.h +++ b/lib/lib_display/Xlatb_RA8876-gemu-1.0/RA8876.h @@ -26,6 +26,8 @@ #include "driver/spi_master.h" #endif +#include "tasmota_options.h" + #undef SPRINT #define SPRINT(A) {char str[32];sprintf(str,"val: %d ",A);Serial.println((char*)str);} @@ -147,11 +149,14 @@ enum ExternalFontFamily typedef uint8_t FontFlags; #define RA8876_FONT_FLAG_XLAT_FULLWIDTH 0x01 // Translate ASCII to Unicode fullwidth forms + +#ifndef RA8876_SPI_SPEED // 1MHz. TODO: Figure out actual speed to use // Data sheet section 5.2 says maximum SPI clock is 50MHz. //#define RA8876_SPI_SPEED 10000000 -#define RA8876_SPI_SPEED 25000000 -//#define RA8876_SPI_SPEED 10000000 +//#define RA8876_SPI_SPEED 25000000 +#define RA8876_SPI_SPEED 40000000 +#endif // With SPI, the RA8876 expects an initial byte where the top two bits are meaningful. Bit 7 // is A0, bit 6 is WR#. See data sheet section 7.3.2 and section 19. diff --git a/pio-tools/grepmodule-firmware.py b/pio-tools/grepmodule-firmware.py new file mode 100644 index 000000000000..71cdb00a3db5 --- /dev/null +++ b/pio-tools/grepmodule-firmware.py @@ -0,0 +1,71 @@ +Import("env") + +import os +import shutil +import tasmotapiolib +import binascii + + +#MODULE_SYNC = 0x55aaFC4A + +if env["PIOPLATFORM"] != "espressif32" : + + def grep_module(source, target, env): + #print("searching binary for module ") + # create string with location and file names based on variant + bin_file = tasmotapiolib.get_final_bin_path(env) + dir_path = os.path.dirname(bin_file) + + start = 0 + size = 0 + with open(bin_file, "rb") as fp: + while (msync := fp.read(4)): + if start == 1: + size += 4 + + if start == 1: + fwp.write(msync) + + if msync[0] == 0x4a and msync[1] == 0xfc and msync[2] == 0xaa and msync[3] == 0x55: + xarch = fp.read(4) + arch = int.from_bytes(xarch, "little") + xtype = fp.read(4) + type = int.from_bytes(xtype, "little") + if arch == 0 and type <= 4: + #print("found start sync") + start = 1 + dummy = fp.read(4) + xname = fp.read(16) + fname = xname.decode('ascii') + name = fname.replace('\x00','') + mod_file = dir_path + "/" + name + ".bin" + if os.path.isfile(mod_file): + os.remove(mod_file) + fwp = open(mod_file, "wb") + fwp.write(msync) + fwp.write(xarch) + fwp.write(xtype) + fwp.write(dummy) + fwp.write(xname) + size += 28 + + if msync[0] == 0x55 and msync[1] == 0xaa and msync[2] == 0xfc and msync[3] == 0x4a: + start = 2 + size += 4 + #print("found end sync") + # set module size + fwp.seek(40) + sizeb = size.to_bytes( 4, "little" ) + fwp.write(sizeb) + fwp.close() + break + + + if start == 2: + print("extracted module: "+name) + if size > 8192: + print("module size error") + + + #if not tasmotapiolib.is_env_set(tasmotapiolib.DISABLE_BIN_GZ, env): + env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [grep_module])