-
Notifications
You must be signed in to change notification settings - Fork 3k
EFM32GG: Fix heap size formula in scatter files #14129
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
The heap size was incorrectly calculated. This fixes it by subtracting the Stack size, any memory chunks allocated before the start of the application (for vectors and/or crash report), and finally the size of the application from the total RAM size.
@hugueskamba, thank you for your changes. |
CI started |
.ANY (+RW +ZI) | ||
} | ||
|
||
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM_START-AlignExpr(ImageLimit(RW_IRAM1), 16) - MBED_CONF_TARGET_BOOT_STACK_SIZE) { | ||
ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_SIZE-RAM_FIXED_SIZE+MBED_RAM1_START-AlignExpr(ImageLimit(RW_IRAM1), 16)) { |
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 is convoluted to the point I can't really visualise it (and I think that's how the error wasn't spotted in the first place).
I think it's correct now - "heap size = total RAM size - fixed size - IRAM1 used space", with the used space being "AlignExpr(ImageLimit(RW_IRAM1, 16)) - MBED_RAM1_START", but the sign flippery confuses that.
Last time I touched this on a branch, I went with
(MBED_RAM_START+MBED_RAM_SIZE-MBED_BOOT_STACK_SIZE)-AlignExpr(ImageLimit(RW_IRAM1), 16)
or "heap size = Stack start address - IRAM1 end address".
Actually, we can just say that more simply:
ImageBase(ARM_LIB_STACK) - AlignExpr(ImageLimit(RW_IRAM1), 16)
although I guess you'd have to reorder the sections to decare stack first. Kind of makes sense though - you're laying out the fixed things and finally heap is what's left.
Or the original size-based formula could be somewhat simplified the same way:
MBED_RAM_SIZE-RAM_FIXED_SIZE-AlignExpr(ImageLength(RW_IRAM1), 16)
But I think it's clearest to denote the heap by its direct boundaries (end of IRAM1, start of stack).
It would help if you could just set the limit as an absolute address rather than a size, then we could just say ImageBase(ARM_LIB_STACK)
for 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.
Completely agree. ImageLength()
looks useful, so we don't need to do image start - ImageLimit()
.
Also, some of the terms we put in RAM_FIXED_SIZE
's definition eventually get cancelled out in the maths of the heap size. But this PR is to make as small change as possible, so keeping the existing logic is fine.
Jenkins CI Test : ✔️ SUCCESSBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Thanks @kjbracey-arm for details. I'll merge this as it is. We can work on simplifying it in a separate issue. |
Summary of changes
The heap size was incorrectly calculated.
This fixes it by subtracting the Stack size, any memory chunks allocated
before the start of the application (for vectors and/or crash report), and
finally the size of the application from the total RAM size.
Impact of changes
Migration actions required
Documentation
Pull request type
Test results
Reviewers