[core] Print platform versions, add GCC version to startup banner
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
from os.path import join
|
||||
|
||||
import click
|
||||
from ltchiptool import Family
|
||||
from ltchiptool import Family, get_version
|
||||
from platformio.platform.base import PlatformBase
|
||||
from platformio.platform.board import PlatformBoardConfig
|
||||
from SCons.Errors import UserError
|
||||
@@ -14,6 +14,12 @@ board: PlatformBoardConfig = env.BoardConfig()
|
||||
platform: PlatformBase = env.PioPlatform()
|
||||
family: Family = env["FAMILY_OBJ"]
|
||||
|
||||
# Print information about installed core versions
|
||||
lt_version: str = env.ReadLTVersion(platform.get_dir(), platform.version)
|
||||
print("PLATFORM VERSIONS:")
|
||||
print(" - libretuya @", lt_version)
|
||||
print(" - ltchiptool @", get_version())
|
||||
|
||||
# TODO remove include path prepending ("!<...>")
|
||||
# Move common core sources (env.AddCoreSources()) and Arduino libs
|
||||
# below per-family sources (to maintain child families taking precedence)
|
||||
@@ -86,6 +92,12 @@ queue.AddExternalLibrary("ltchiptool") # uf2ota source code
|
||||
queue.AddExternalLibrary("flashdb")
|
||||
queue.AddExternalLibrary("printf")
|
||||
|
||||
# Find optimization level and add __OPTIMIZE_LEVEL__ macro
|
||||
for flag in env["CCFLAGS"]:
|
||||
if not flag.startswith("-O"):
|
||||
continue
|
||||
env.Append(CPPDEFINES=[("__OPTIMIZE_LEVEL__", flag[2])])
|
||||
|
||||
# Non-SDK defines & linker options
|
||||
queue.AppendPublic(
|
||||
CCFLAGS=[
|
||||
@@ -102,13 +114,13 @@ queue.AppendPublic(
|
||||
],
|
||||
CPPDEFINES=[
|
||||
("LIBRETUYA", 1),
|
||||
("LT_VERSION", env.ReadLTVersion(platform.get_dir(), platform.version)),
|
||||
("LT_VERSION", lt_version),
|
||||
("LT_BOARD", "${VARIANT}"),
|
||||
("LT_VARIANT_H", r"\"${VARIANT}.h\""),
|
||||
("F_CPU", board.get("build.f_cpu")),
|
||||
("MCU", "${MCU}"),
|
||||
("MCULC", "${MCULC}"),
|
||||
("FAMILY", "F_${FAMILY}"),
|
||||
("FAMILY", "F_${FAMILY_SHORT_NAME}"),
|
||||
# Add flash layout defines created in env.AddFlashLayout()
|
||||
*env["FLASH_DEFINES"].items(),
|
||||
],
|
||||
|
||||
@@ -26,26 +26,24 @@ def env_uf2ota(env: Environment, *args, **kwargs):
|
||||
project_name,
|
||||
project_version,
|
||||
"${VARIANT}",
|
||||
"${FAMILY}",
|
||||
"${MCULC}",
|
||||
f"lt{lt_version}",
|
||||
]
|
||||
output = "_".join(output) + ".uf2"
|
||||
if platform.custom("fw_output"):
|
||||
output = platform.custom("fw_output")
|
||||
|
||||
output = join("${BUILD_DIR}", output)
|
||||
output_copy_1 = join("${BUILD_DIR}", "firmware.uf2")
|
||||
output_copy_2 = join("${BUILD_DIR}", "firmware.bin")
|
||||
|
||||
env["UF2OUT"] = output
|
||||
env["UF2OUT_BASE"] = basename(output)
|
||||
outputs = [
|
||||
join("${BUILD_DIR}", output),
|
||||
join("${BUILD_DIR}", "firmware.uf2"),
|
||||
join("${BUILD_DIR}", "firmware.bin"),
|
||||
]
|
||||
output_opts = [f'--output "{output}"' for output in outputs]
|
||||
|
||||
cmd = [
|
||||
"@${LTCHIPTOOL} uf2 write",
|
||||
f'--output "{output}"',
|
||||
f'--output-copy "{output_copy_1}"',
|
||||
f'--output-copy "{output_copy_2}"',
|
||||
"--family ${FAMILY}",
|
||||
*output_opts,
|
||||
"--family ${FAMILY_SHORT_NAME}",
|
||||
"--board ${VARIANT}",
|
||||
f"--lt-version {lt_version}",
|
||||
f'--fw "{project_name}:{project_version}"',
|
||||
@@ -53,10 +51,9 @@ def env_uf2ota(env: Environment, *args, **kwargs):
|
||||
*env["UF2OTA"],
|
||||
]
|
||||
|
||||
print(f"|-- {basename(env.subst(output))}")
|
||||
for output in outputs:
|
||||
print(f"|-- {basename(env.subst(output))}")
|
||||
env.Execute(" ".join(cmd))
|
||||
print(f"|-- {basename(env.subst(output_copy_1))}")
|
||||
print(f"|-- {basename(env.subst(output_copy_2))}")
|
||||
|
||||
|
||||
def env_flash_write(env: Environment):
|
||||
|
||||
@@ -27,16 +27,12 @@
|
||||
#define LT_BOARD_STR STRINGIFY_MACRO(LT_BOARD)
|
||||
#define GCC_VERSION_STR \
|
||||
STRINGIFY_MACRO(__GNUC__) "." STRINGIFY_MACRO(__GNUC_MINOR__) "." STRINGIFY_MACRO(__GNUC_PATCHLEVEL__)
|
||||
#define LT_BANNER_STR \
|
||||
"LibreTuya v" LT_VERSION_STR " on " LT_BOARD_STR ", compiled at " __DATE__ " " __TIME__ ", GCC " GCC_VERSION_STR \
|
||||
" (-O" STRINGIFY_MACRO(__OPTIMIZE_LEVEL__) ")"
|
||||
|
||||
// Functional macros
|
||||
#define LT_BANNER() \
|
||||
LT_LOG( \
|
||||
LT_LEVEL_INFO, \
|
||||
__FUNCTION__, \
|
||||
__LINE__, \
|
||||
"LibreTuya v" LT_VERSION_STR " on " LT_BOARD_STR ", compiled at " __DATE__ " " __TIME__ \
|
||||
", GCC " GCC_VERSION_STR \
|
||||
)
|
||||
#define LT_BANNER() LT_LOG(LT_LEVEL_INFO, __FUNCTION__, __LINE__, LT_BANNER_STR)
|
||||
|
||||
// Types & macros
|
||||
#include "lt_config.h" // platform configuration options
|
||||
|
||||
Reference in New Issue
Block a user