Skip to content

Commit e9fddb6

Browse files
authored
Merge pull request #6017 from theotherjimmy/bl-nonzero-rom
Correct auto-sizing last region of bl
2 parents c679dee + 9c3b489 commit e9fddb6

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

tools/config/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ def regions(self):
570570

571571
def _generate_bootloader_build(self, rom_start, rom_size):
572572
start = rom_start
573+
rom_end = rom_start + rom_size
573574
if self.target.bootloader_img:
574575
if isabs(self.target.bootloader_img):
575576
filename = self.target.bootloader_img
@@ -592,10 +593,10 @@ def _generate_bootloader_build(self, rom_start, rom_size):
592593
new_size = Config._align_floor(start + new_size, self.sectors) - start
593594
yield Region("application", start, new_size, True, None)
594595
start += new_size
595-
yield Region("post_application", start, rom_size - start,
596+
yield Region("post_application", start, rom_end - start,
596597
False, None)
597598
else:
598-
yield Region("application", start, rom_size - start,
599+
yield Region("application", start, rom_end - start,
599600
True, None)
600601
if start > rom_start + rom_size:
601602
raise ConfigException("Not enough memory on device to fit all "

tools/test/config/config_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,25 @@ def test_init_override_app_config(target):
174174

175175
mock_json_file_to_dict.assert_any_call(app_config)
176176
assert config.app_config_data == mock_return
177+
178+
@pytest.mark.parametrize("target", ["K64F", "UBLOX_EVK_ODIN_W2"])
179+
@pytest.mark.parametrize("overrides", [
180+
{},
181+
{"restrict_size": "0x200"},
182+
{"mbed_app_start": "0x200"}
183+
])
184+
def test_basic_regions(target, overrides):
185+
"""
186+
Test that the region lists are sane with various configurations
187+
"""
188+
set_targets_json_location()
189+
config = Config(target)
190+
for o, v in overrides.items():
191+
setattr(config.target, o, v)
192+
try:
193+
if config.has_regions:
194+
regions = list(config.regions)
195+
for r in regions:
196+
assert r.size >= 0
197+
except ConfigException:
198+
pass

0 commit comments

Comments
 (0)