From 9c0a37717c9326c9e6a110e72ade283754c56363 Mon Sep 17 00:00:00 2001 From: cepetr Date: Wed, 20 Nov 2024 08:35:37 +0100 Subject: [PATCH] fix(core): fix invalid symbol for deflated bootloader [no changelog] --- core/SConscript.kernel | 3 ++- core/embed/util/bl_check/bl_check.c | 11 ++++------- core/site_scons/tools.py | 13 ++++--------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/core/SConscript.kernel b/core/SConscript.kernel index 51d625fa1e..e07f16d1e3 100644 --- a/core/SConscript.kernel +++ b/core/SConscript.kernel @@ -374,7 +374,8 @@ tools.embed_compressed_binary( 'bootloader', 'embed/projects/bootloaders/bootloader.o', f'embed/models/{MODEL_IDENTIFIER}/bootloaders/bootloader_{BOOTLOADER_SUFFIX}.bin', - 'kernel' + 'kernel', + 'bootloader', ) linkerscript_gen = env.Command( diff --git a/core/embed/util/bl_check/bl_check.c b/core/embed/util/bl_check/bl_check.c index 3acca64369..3aa2bba67d 100644 --- a/core/embed/util/bl_check/bl_check.c +++ b/core/embed/util/bl_check/bl_check.c @@ -29,8 +29,8 @@ #include "uzlib.h" // symbols from bootloader.bin => bootloader.o -extern const void _binary_embed_bootloaders_bootloader_bin_deflated_start; -extern const void _binary_embed_bootloaders_bootloader_bin_deflated_size; +extern const void _deflated_bootloader_start; +extern const void _deflated_bootloader_size; #define CONCAT_NAME_HELPER(prefix, name, suffix) prefix##name##suffix #define CONCAT_NAME(name, var) CONCAT_NAME_HELPER(BOOTLOADER_, name, var) @@ -99,11 +99,8 @@ void check_and_replace_bootloader(void) { } // replace bootloader with the latest one - const uint32_t *data = - (const uint32_t - *)&_binary_embed_bootloaders_bootloader_bin_deflated_start; - const uint32_t len = - (const uint32_t)&_binary_embed_bootloaders_bootloader_bin_deflated_size; + const uint32_t *data = (const uint32_t *)&_deflated_bootloader_start; + const uint32_t len = (const uint32_t)&_deflated_bootloader_size; struct uzlib_uncomp decomp = {0}; uint8_t decomp_window[UZLIB_WINDOW_SIZE] = {0}; diff --git a/core/site_scons/tools.py b/core/site_scons/tools.py index 2f91feb4c1..58ec3efdec 100644 --- a/core/site_scons/tools.py +++ b/core/site_scons/tools.py @@ -85,22 +85,17 @@ def get_bindgen_defines( return ",".join(rest_defs) -def embed_compressed_binary(obj_program, env, section, target_, file, build): +def embed_compressed_binary(obj_program, env, section, target_, file, build, symbol): _in = f"embedded_{section}.bin.deflated" - def redefine_sym(name): + def redefine_sym(suffix): src = ( f"_binary_build_{build}_" + _in.replace("/", "_").replace(".", "_") + "_" - + name - ) - dest = ( - "_binary_" - + target_.replace("/", "_").replace(".o", "_bin_deflated") - + "_" - + name + + suffix ) + dest = f"_deflated_{symbol}_{suffix}" return f" --redefine-sym {src}={dest}" def compress_action(target, source, env):