Skip to content

Add padding up to restrict_size #11043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tools/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def merge_region_list(
destination,
notify,
padding=b'\xFF',
restrict_size=None
restrict_size=None,
pad_to_restrict_size=False
):
"""Merge the region_list into a single image

Expand All @@ -116,6 +117,7 @@ def merge_region_list(
destination - file name to write all regions to
padding - bytes to fill gaps with
restrict_size - check to ensure a region fits within the given size
pad_to_restrict_size - fill with padding up to restrict_size
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we need pad_to_restrict_size, I cannot see a situation where this would be needed and without it I think it fixes the regression that appeared in 11.1

"""
merged = IntelHex()
_, format = splitext(destination)
Expand Down Expand Up @@ -168,6 +170,9 @@ def merge_region_list(
pad_size = start - begin
merged.puts(begin, padding * pad_size)
begin = stop + 1
if restrict_size is not None and pad_to_restrict_size:
pad_size = int(restrict_size, 0) - begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would restore the output to something similar to pre 11.1 behaviour

Suggested change
pad_size = int(restrict_size, 0) - begin
pad_size = int(restrict_size, 0) - begin
notify.info(" Padding region with 0x%x bytes" % pad_size)

merged.puts(begin, padding * pad_size)

if not exists(dirname(destination)):
makedirs(dirname(destination))
Expand Down
3 changes: 2 additions & 1 deletion tools/toolchains/mbed_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,8 @@ def _do_region_merge(self, name, binary, ext):
res = "{}.{}".format(join(self.build_dir, name), ext)
merge_region_list(
region_list, res, self.notify,
restrict_size=self.config.target.restrict_size
restrict_size=self.config.target.restrict_size,
pad_to_restrict_size=True
)
update_regions = [
r for r in region_list if r.name in UPDATE_WHITELIST
Expand Down