-
Notifications
You must be signed in to change notification settings - Fork 3k
stm32l475: lwip symbols in sram1 #9793
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
@juhoeskeli, thank you for your changes. |
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 seems to fit a given precise Use case and I'm not against it if this doesn't break other existing use cases. Note to mbed-os maintainers, I think it would be best to find ways to over-write the linker files from an application level as different applications could have very different memory map constraints.
. = ALIGN(8); | ||
__lwip_bss_start__ = .; | ||
*mbed-os/features/lwipstack*.o(.bss*) | ||
*mbed-os/features/lwipstack*.o(COMMON) |
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 don't think LWIP is a defaut feature on all L475 based boards - will that work fine anyway when there are no LWIP symbols at all (mbed2 application for instance)
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.
Should work, I tested this precise use case by disabling lwip. I saw no ill effects. Can't comment for mbed2, though.
@ARMmbed/mbed-os-maintainers please comment on idea to overload the linker files from an application level ? |
Pinging @ARMmbed/mbed-os-core for input. |
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 am worried about the impact of this change to applications without LWIP. For IAR build, the heap size is reduced to only 79K. When I ran Pelion client on this target, the peak usage was close to 70K. This change will cause Pelion example to break very soon as heap demand continues to grow.
Is it possible to change the linker script, or add another one for applications that require LWIP so that the heap size does not decrease for applications without LWIP?
@JanneKiiskila Mind chiming in? |
I must say 70k heap usage sounds quite heavy. What was the setup that resulted in this high usage? I think in the past the usage has been closer to 50k, now maybe closer to 60k. It is true it has been creeping up, but we should put stop to this. I would also like to hear @JanneKiiskila comment on that. If there is way to keep the IAR heap same without LWIP that would be perfect, but I don't know how to do that. |
@juhoeskeli Heavy heap usage was observed while running Pelion client example. max_size is the peak usage. |
TLS handshake is typically the peak point for our memory ussage. |
I wonder if @ARMmbed/mbed-os-tools or @deepikabhavnani would be able to chime in on this one. Afaik, there's no generic way of overwriting linker definitions, and would likely require a fair amount of planning and work. |
Issue over here seems only with IAR - because we do not have support for dynamic heap. With update to IAR 8.x we can resolve this by using dynamic heap, so the heap size will be set as minimum to 0x13C00. In case LWIP is not present, unused memory will got to heap section. But the catch is by changing linker file to use dynamic heap support, STM32L45 device will not compile for IAR 7.x. We are upgrading to IAR 8.x in 5.12 release, and that will make few targets with binaries to be non-compatible, but most will still work with IAR 7.x (no support though). Change suggested here https://github.com/ARMmbed/mbed-os/pull/9793/files#r261633149 |
@@ -33,7 +33,7 @@ if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) { | |||
} | |||
|
|||
define symbol __size_cstack__ = MBED_BOOT_STACK_SIZE; | |||
define symbol __size_heap__ = 0x17000; | |||
define symbol __size_heap__ = 0x13C00; | |||
define block CSTACK with alignment = 8, size = __size_cstack__ { }; | |||
define block HEAP with alignment = 8, size = __size_heap__ { }; |
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.
define block HEAP with alignment = 8, size = __size_heap__ { }; | |
define block HEAP with expanding size, minimum size = __size_heap__, alignment = 8 { }; |
Dynamic HEAP for IAR @juhoeskeli - Please verify this with IAR 8.x
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.
Deepika's suggestion is good. We don't waste RAM on a already constrained platform in builds without LWIP.
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.
Thanks @deepikabhavnani . I will verify this and report back results.
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.
Seems to work fine. Will do commit with the suggested change.
without PPP and with expanding change:
"P2", part 2 of 2: 0x17820
HEAP 0x2000'07e0 0x17820
HEAP uninit 0x2000'07e0 0x17820
- 0x2001'8000 0x17820
with PPP and with expanding change:
"P2", part 3 of 3: 0x144e8
HEAP 0x2000'3b18 0x144e8
HEAP uninit 0x2000'3b18 0x144e8
- 0x2001'8000 0x144e8
with&without PPP and without expanding change:
"P2", part 3 of 3: 0x13c00
HEAP 0x2000'3b18 0x13c00
HEAP uninit 0x2000'3b18 0x13c00
- 0x2001'7718 0x13c00
@ARMmbed/mbed-os-core same question as Laurent: |
@jeromecoutant - I understand the concerns, but adding overload for linker files will be an enhancement from tools side and will need design and planning to start with, which will take long. It will be good to add it as separate issue (enhancement) in github. For now, lets explore if we have any other option to resolve this issue, do you have any suggestions? |
@jeromecoutant I understand your viewpoint and I agree it is not optimal solution. However, in the short term I don't see other options. This is particularly important use case for us as we intend to combine PPP mode modems with this MCU. In the long term we should get this sorted out in different way, e.g. what you suggested. |
@juhoeskeli - Does this PR #9944 solve your issue of lwip without adding special lwip section? Solution is added for GCC only, but I will be exploring other toolchains as well |
@@ -61,6 +61,7 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region | |||
} | |||
RW_IRAM1 MBED_RAM0_START MBED_RAM0_SIZE-Stack_Size { ; RW data 96k L4-SRAM1 | |||
.ANY (+RW, +Last) | |||
lwip* (+ZI) |
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.
ARM compiler supports expansion of RW and ZI in multiple banks, please try below solution
RW_IRAM1 MBED_RAM0_START MBED_RAM0_SIZE-Stack_Size { ; RW data 96k L4-SRAM1
.ANY (+RW +ZI)
}
; Total: 98 vectors = 392 bytes (0x188) to be reserved in RAM
RW_IRAM2 (0x10000000+0x188) (0x08000-0x188) { ; ZI data 32k L4-ECC-SRAM2
.ANY (+RW +ZI)
}
@juhoeskeli - I have added solution for IAR compiler as well #10003, please see if this works for your application Solution for ARM is added as well - #10018 |
Thanks @deepikabhavnani. I think those PR are better general purpose solution. We tried already the GCC_ARM PR and it looks good so far. Let's wait for those to get merged and then I can close down this PR. |
@juhoeskeli What is the status on this PR ? No update for 16 days ? |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
A more generic solution for GCC/ARM/IAR is already implemented so closing down this PR |
Description
Move LWIP symbols to SRAM1 region, as they do not fit in the SRAM2 (32kB) with all the other symbols. This is done for purpose of using PDMC on this target with PPP modems. PPP requires LWIP which takes up additional RAM.
Tested to work with and without PPP on GCC_ARM, ARM, IAR. The only caveat is that HEAP size for IAR is reduced from 0x17000 to 0x13C00 even when PPP is not used. This is because heap is fixed size in IAR.
Pull request type
Reviewers
@linlingao
Release Notes
Fit LWIP into RAM regions
Heap size reduced for IAR from 0x17000 to 0x13C00