Skip to content

Commit 49572d5

Browse files
author
Jammu Kekkonen
committed
Change update file format to binary to all targets
- Change the default file format to binary for all targets, even though some targets need hex as app format, updater always needs bin for now - Unify the file name generation from generator side and usage side for the update bin
1 parent 207ea79 commit 49572d5

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

tools/build_api.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from .arm_pack_manager import Cache
3737
from .utils import (mkdir, run_cmd, run_cmd_ext, NotSupportedException,
3838
ToolException, InvalidReleaseTargetException,
39-
intelhex_offset, integer)
39+
intelhex_offset, integer, generate_update_filename)
4040
from .paths import (MBED_CMSIS_PATH, MBED_TARGETS_PATH, MBED_LIBRARIES,
4141
MBED_HEADER, MBED_DRIVERS, MBED_PLATFORM, MBED_HAL,
4242
MBED_CONFIG_FILE, MBED_LIBRARIES_DRIVERS,
@@ -550,10 +550,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
550550
r for r in region_list if r.name in UPDATE_WHITELIST
551551
]
552552
if update_regions:
553-
update_res = "%s_update.%s" % (
554-
join(build_path, name),
555-
getattr(toolchain.target, "OUTPUT_EXT", "bin")
556-
)
553+
update_res = join(build_path, generate_update_filename(name, toolchain.target))
557554
merge_region_list(update_regions, update_res, notify)
558555
res = (res, update_res)
559556
else:

tools/device_management.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import colorama
3232
colorama.init()
3333

34+
from utils import (generate_update_filename)
35+
3436

3537
LOG = logging.getLogger(__name__)
3638
LOG_FORMAT = '[%(levelname)s] %(asctime)s - %(name)s - %(message)s'
@@ -69,10 +71,7 @@ def inner(options):
6971
sources = options.source_dir or ['.']
7072
config = Config(mcus[0], sources)
7173
app_name = config.name or basename(abspath(sources[0]))
72-
output_ext = getattr(config.target, "OUTPUT_EXT", "bin")
73-
payload_name = join(options.build, "{}_application.{}".format(
74-
app_name, output_ext
75-
))
74+
payload_name = join(options.build, generate_update_filename(app_name, config.target))
7675
options.payload = open(payload_name, "rb")
7776
return func(options)
7877
return inner

tools/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,15 @@ def intelhex_offset(filename, offset):
544544
% filename)
545545
return ih
546546

547-
548547
def integer(maybe_string, base):
549548
"""Make an integer of a number or a string"""
550549
if isinstance(maybe_string, int):
551550
return maybe_string
552551
else:
553552
return int(maybe_string, base)
553+
554+
def generate_update_filename(name, target):
555+
return "%s_update.%s" % (
556+
name,
557+
getattr(target, "OUTPUT_EXT_UPDATE", "bin")
558+
)

0 commit comments

Comments
 (0)