Skip to content

Correct auto-sizing last region of bl #6017

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

Merged
merged 2 commits into from
Feb 7, 2018
Merged
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
5 changes: 3 additions & 2 deletions tools/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ def regions(self):

def _generate_bootloader_build(self, rom_start, rom_size):
start = rom_start
rom_end = rom_start + rom_size
if self.target.bootloader_img:
if isabs(self.target.bootloader_img):
filename = self.target.bootloader_img
Expand All @@ -588,10 +589,10 @@ def _generate_bootloader_build(self, rom_start, rom_size):
new_size = Config._align_floor(start + new_size, self.sectors) - start
yield Region("application", start, new_size, True, None)
start += new_size
yield Region("post_application", start, rom_size - start,
yield Region("post_application", start, rom_end - start,
False, None)
else:
yield Region("application", start, rom_size - start,
yield Region("application", start, rom_end - start,
True, None)
if start > rom_start + rom_size:
raise ConfigException("Not enough memory on device to fit all "
Expand Down
22 changes: 22 additions & 0 deletions tools/test/config/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,25 @@ def test_init_override_app_config(target):

mock_json_file_to_dict.assert_any_call(app_config)
assert config.app_config_data == mock_return

@pytest.mark.parametrize("target", ["K64F", "UBLOX_EVK_ODIN_W2"])
@pytest.mark.parametrize("overrides", [
{},
{"restrict_size": "0x200"},
{"mbed_app_start": "0x200"}
])
def test_basic_regions(target, overrides):
"""
Test that the region lists are sane with various configurations
"""
set_targets_json_location()
config = Config(target)
for o, v in overrides.items():
setattr(config.target, o, v)
try:
if config.has_regions:
regions = list(config.regions)
for r in regions:
assert r.size >= 0
except ConfigException:
pass