From ec00f0f7e2ead311de113462e20b5995aa491ad3 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 3 May 2023 11:04:10 +0200 Subject: [PATCH] esp8266 iram metrics (#18564) --- pio-tools/metrics-firmware.py | 16 ++++++++++++++++ pio-tools/name-firmware.py | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/pio-tools/metrics-firmware.py b/pio-tools/metrics-firmware.py index d9fb7a9ad..0ecdb3f36 100644 --- a/pio-tools/metrics-firmware.py +++ b/pio-tools/metrics-firmware.py @@ -1,9 +1,25 @@ Import("env") +import os import tasmotapiolib +from os.path import join + def firm_metrics(source, target, env): if env["PIOPLATFORM"] == "espressif32": import tasmota_metrics env.Execute("$PYTHONEXE -m tasmota_metrics " + str(tasmotapiolib.get_source_map_path(env).resolve())) + elif env["PIOPLATFORM"] == "espressif8266": + map_file = join(env.subst("$BUILD_DIR")) + os.sep + "firmware.map" + with open(map_file,'r') as f: + phrase = "_text_end = ABSOLUTE (.)" + for line in f: + if phrase in line: + address = line.strip().split(" ")[0] + if int(address, 16) < 0x40108000: + used_bytes = int(address, 16) - 0x40100000 + remaining_bytes = 0x8000 - used_bytes + percentage = round(used_bytes / 0x8000 * 100,1) + print("Used static IRAM:",used_bytes,"bytes (",remaining_bytes,"remain,",percentage,"% used)") + env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin",firm_metrics) \ No newline at end of file diff --git a/pio-tools/name-firmware.py b/pio-tools/name-firmware.py index 6162500da..0d853d035 100644 --- a/pio-tools/name-firmware.py +++ b/pio-tools/name-firmware.py @@ -1,8 +1,10 @@ Import("env") +import os import shutil import pathlib import tasmotapiolib +from os.path import join def bin_map_copy(source, target, env): @@ -30,5 +32,7 @@ def bin_map_copy(source, target, env): shutil.copy(tasmotapiolib.get_source_map_path(env), map_file) shutil.copy(factory, one_bin_file) else: + map_firm = join(env.subst("$BUILD_DIR")) + os.sep + "firmware.map" + shutil.copy(tasmotapiolib.get_source_map_path(env), map_firm) shutil.move(tasmotapiolib.get_source_map_path(env), map_file) env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", bin_map_copy)