-
Notifications
You must be signed in to change notification settings - Fork 3k
tools: support cases where bootloader is in chunks #9317
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
Conversation
Tested with cloud client. Log from build where BOOTLOADER for NRF52 is placed at 0x64000
Log with configuration where the bootloader, header and application are linearly placed
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this approach, allowing regions within a build to overlap, will prevent us from checking conditions that should fail. Instead, we could create a way to have multiple regions refer to the same file, and keep these checks
tools/config/__init__.py
Outdated
@@ -769,9 +769,9 @@ def _make_header_region(self, start, header_format, offset=None): | |||
return (start, region) | |||
|
|||
@staticmethod | |||
def _assign_new_offset(rom_start, start, new_offset, region_name): | |||
def _assign_new_offset(rom_start, start, new_offset, region_name, override=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So:
- Adding
override=True
skips the check in this function - This function does
rom_start + new_offset
and an overflow check
I think adding override to this function misses the point: this function exists for combining the overflow check with the new offset calculation.
tools/config/__init__.py
Outdated
start = self._assign_new_offset( | ||
rom_start, start, self.target.app_offset, "application") | ||
yield Region("application", start, rom_end - start, | ||
rom_start, start, self.target.app_offset, "application", True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will not protect users from the following scenario, which it was originally designed for:
Say you have the following:
- A 16 K BL, end address is
0x4000
- Application configures it's offset to
0x3000
This situation should result in an error. With this change, it might raise an exception from IntelHex which will not help the user. I would like to keep this deterministic error message.
375a0ef
to
42b38b6
Compare
Build log from various build configurations attached
|
@theotherjimmy Can you please review the latest changes |
@bridadan @JanneKiiskila would you guys also like to review ? |
@LiyouZhou might be worth having a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style and UI nits.
tools/config/__init__.py
Outdated
else: | ||
break | ||
if end_address == None: | ||
raise ConfigException("bootloader segments don't fit within rom region") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove "region" from this exception, as ROM is not a region:
raise ConfigException("bootloader segments don't fit within rom region") | |
raise ConfigException("bootloader segments don't fit within rom") |
tools/config/__init__.py
Outdated
else: | ||
_, end_address = part.segments() | ||
if (end_address > rom_end): | ||
raise ConfigException("bootloader segments don't fit within rom region") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove "region" from this exception, as ROM is not a region:
raise ConfigException("bootloader segments don't fit within rom region") | |
raise ConfigException("bootloader segments don't fit within rom") |
tools/config/__init__.py
Outdated
if (end_address > rom_end): | ||
raise ConfigException("bootloader segments don't fit within rom region") | ||
part_size = Config._align_ceiling(end_address, self.sectors) - rom_start | ||
yield Region("bootloader", rom_start, part_size, False, | ||
filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you re-indent this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bootloader regions are generated (bootloader0, bootloader1, so on) within the loop. I hope that's clear. Added a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is off. I'm just asking you to line up filename
with the fist "
in the previous line.
tools/config/__init__.py
Outdated
raise ConfigException("bootloader segments don't fit within rom region") | ||
part_size = Config._align_ceiling(end_address, self.sectors) - rom_start | ||
yield Region("bootloader"+`part_count`, start, part_size, False, | ||
filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This indentation looks off. Could you re-indent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated indentation in the new patch-set.
@naveenkaje Do you think we could have a few tests of the behavior we're expecting here? |
can the header be moved freely as well? |
why does it say here region bootloader is at offset 0x0 and if what is printed here is correct, it looks like the application overlapped with bootloader and the bootloader is not at the offset you say it is. |
That's pretty straight forward: because you have part of your bootloader at 0. You may call it the MBR, but the tools don't know (or care) about that naming convention.
@naveenkaje I was under the impression that this would generate more than one bootloader region. If this is true then @LiyouZhou are you using the code from the most recent version of this branch?
This is addressed above. |
Oh I was just reading this output from the top of this PR. |
@naveenkaje Could you show us what the new version looks like? |
f6d6c30
to
501fb5f
Compare
Build logs from
mbed-client placed at 0x30000. Overlap is expected.
mbed-client placed now at 0x10000, no overlap.
|
@theotherjimmy @LiyouZhou |
@naveenkaje It looks like those are now out of order. Could we sort them by start address before printing? Also, it looks like we don't print "bootloader2" ever when merging at the end. Could we print skipped as it's already present or something? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is looking good so far! And thanks very much for the test cases.
Your last log output is confusing since the offset+sizes seem to overlap. Perhaps the sizes aren't being computed correctly anymore?
@naveenkaje Any update for the reviews? |
d85b9e9
to
9d3dfc2
Compare
Added a patch set to compute the size of the application region. With this change, sample output from before looks like this
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love that new log output! So slick! 😄
I have a few concerns about the _get_end_address
function.
tools/config/__init__.py
Outdated
end_address = rom_end | ||
|
||
for s, e in region_list: | ||
if start_address < s and start_address < e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the start_address < e
be unnecessary? The "end" address (e
) should always be greater than the "start" address (s)
right?
tools/config/__init__.py
Outdated
"""Given a start address and set of regions, compute | ||
the end address. The end address is either | ||
rom_end or beginning of next section, whichever | ||
is smaller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should document that we expect the region_list
to be sorted based on start address. OR you can always sort the regions in this function to ensure that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Uploaded a patch set with suggested changes. Please re-review
tools/config/__init__.py
Outdated
for s, e in region_list: | ||
if start_address < s and start_address < e: | ||
end_address = s | ||
return end_address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will continue looping even once the valid region is found, I think you want something closer to this:
for s, e in region_list
if start_address < s:
return s
return end_address
9d3dfc2
to
4e880e5
Compare
@theotherjimmy @bridadan Mind re-reviewing? Looks like all comments were addressed. |
Support the requirement where bootloader can be in chunks and enable placing the application at a particular offset specified by config. With FEATURE_BOOTLOADER support, the bootloader can be placed at a high address. Add support to the tools so that application can be placed in the available space before the beginning of the bootloader.
…er images Add tests to 1. Verify that a ConfigException is generated if application is placed within the bootloader region 2. Verify that a ConfigException is generated if bootloader segments don't fit witin rom.
4e880e5
to
a47cfd4
Compare
added _get_end_address helper method to compute the size of the regions and print the addresses in a sorted manner in the log as per offline discussion I had with Brian |
This PR is at risk of missing 5.12 release as it's marked as "needs: review". Code freeze is coming! On Friday 1st. Please review the changes ASAP. @ARMmbed/mbed-os-tools |
All commennts addressed from brian's review.
CI started |
Test run: FAILEDSummary: 1 of 1 test jobs failed Failed test jobs:
|
Started CI prematurely. Need IAR8 work to land first. |
CI started |
Test run: SUCCESSSummary: 12 of 12 test jobs passed |
Bootloader can be placed beyond the application. Support this requirement.
With FEATURE_BOOTLOADER support, the bootloader can be placed at a
high address. Add support to the tools so that Application can be placed in
the available space before the beginning of the Bootloader.
Pull request type