Cortex-m App Flashing: Ordering and Padding Improvements #128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR updates the logic when inspecting the tab of cortex-m apps to use mpu subregions for apps larger than 64kB. This helps prevent wasted space vs rounding to the nearest power of two. Additionally, this introduces a change to default to flashing applications in ascending order (there are tradeoffs to this vs descending discussed below).
Flashing Application Before Changes
Attempting to install ~85kB lorawan application results in Tockloader only being able to flash one application.
Flashing Application After Changes
Able to flash many applications with lorawan application.
Ascending vs Descending Ordering
When flashing applications in descending order, we minimize fragmentation with smaller applications. For instance, flashing in the order:
c_helloand thenblinkin descending order would not result in fragmentation. This is true so long as we follow a strict power of two rounding.With the introduction of using subregions in this PR, apps larger than 64kB are no longer powers of two (resulting in larger padding before applications).
There does not seem to be a one size fits all solution for ascending vs descending (as there are cases where each might be better). I lean towards the ascending order as fragmentation with larger apps requiring padding often is much larger than the fragmentation arising from padding smaller applications. In my opinion it seems we should prioritize many small fragmentation (ascending order) so long as this is smaller than the fragmentation arising from descending order (open to counter examples where this may not be true).