diff --git a/builder/utils/env.py b/builder/utils/env.py index c9f53a4..f56db6a 100644 --- a/builder/utils/env.py +++ b/builder/utils/env.py @@ -8,6 +8,7 @@ from subprocess import PIPE, Popen from typing import Dict from ltchiptool import Family, get_version +from ltchiptool.util.misc import sizeof from platformio.platform.base import PlatformBase from platformio.platform.board import PlatformBoardConfig from SCons.Script import DefaultEnvironment, Environment @@ -121,8 +122,10 @@ def env_print_info( # Print custom flash layout if env.get("FLASH_IS_CUSTOM", False): print("CUSTOM FLASH LAYOUT:") - for k, v in board.get("flash").items(): - print(f" - {k}: {v}") + for name, layout in board.get("flash").items(): + (_, _, length) = v.partition("+") + length = int(length, 16) + print(f" - {name}: {layout} ({sizeof(length)})") def env_parse_custom_options(env: Environment, platform: PlatformBase): diff --git a/builder/utils/flash.py b/builder/utils/flash.py index af521e5..59ebd52 100644 --- a/builder/utils/flash.py +++ b/builder/utils/flash.py @@ -93,7 +93,7 @@ def env_generate_linker_script(env: Environment, board: PlatformBoardConfig, nam with open(input, "r") as f: ldscript = f.read() - def transform(match: re.Match[str]): + def transform(match: re.Match): key = match[1] if key in env: return env[key] diff --git a/cores/common/arduino/libraries/common/Update/UpdateUtil.cpp b/cores/common/arduino/libraries/common/Update/UpdateUtil.cpp index 59c28b2..3d6ac9f 100644 --- a/cores/common/arduino/libraries/common/Update/UpdateUtil.cpp +++ b/cores/common/arduino/libraries/common/Update/UpdateUtil.cpp @@ -43,7 +43,7 @@ void UpdateClass::cleanup(uint8_t ardErr, uf2_err_t uf2Err) { printErrorContext1(); #endif - free(ctx); // NULL in constructor + uf2_ctx_free(ctx); // NULL in constructor ctx = NULL; uf2_info_free(info); // NULL in constructor info = NULL; diff --git a/platform.json b/platform.json index 4f032bb..40ba606 100644 --- a/platform.json +++ b/platform.json @@ -101,7 +101,7 @@ }, "tool-ltchiptool": { "type": "uploader", - "version": "https://github.com/libretuya/ltchiptool#v2.0.2", + "version": "https://github.com/libretuya/ltchiptool#v4.0.0a0", "version_prefix": true, "note": "This is used only for C/C++ code from ltchiptool." }, diff --git a/platform.py b/platform.py index e5248ea..6d9f412 100644 --- a/platform.py +++ b/platform.py @@ -17,7 +17,7 @@ from platformio.platform.base import PlatformBase from platformio.platform.board import PlatformBoardConfig from semantic_version import SimpleSpec, Version -LTCHIPTOOL_VERSION = "^3.0.0" +LTCHIPTOOL_VERSION = "^4.0.0" # Install & import tools @@ -27,7 +27,7 @@ def check_ltchiptool(install: bool): print("Installing/updating ltchiptool") system( f"{sys.executable} -m pip install -U --force-reinstall " - f'"ltchiptool >= {LTCHIPTOOL_VERSION}, < 4.0"' + f'"ltchiptool >= {LTCHIPTOOL_VERSION}, < 5.0"' ) # unload all modules from the old version