-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix heap base/limit error with ARM_LIB_STACK/ARM_LIB_HEAP in RTOS-less #6985
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
@SenRamakri @c1728p9 Can you please review this fix? |
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.
Hi @ccli8 rtos-less builds have a different memory map than the RTOS builds. The interrupt stack becomes the main stack. Additionally, the heap no longer has a strict limit, and instead is checked against the stack pointer.
The memory map looks something like this:
+--------+ Last Address of RAM
| Stack |
| | |
| v |
+--------+
RAM | |
| |
+--------+
| ^ |
| | |
| Heap |
+--------+
| ZI |
+--------+
| RW |
+========+ First Address of RAM
| |
Flash | |
For reference, the RTOS code which turns on the two region memory model (and turns off the rtos-less one region mode) can be found here:
https://github.com/ARMmbed/mbed-os/blob/master/rtos/TARGET_CORTEX/mbed_boot.c#L410
@c1728p9 Yes. In rtos-less build, stack/heap share one region. This holds for most targets, but not for Nuvoton targets (NUMAKER_PFM_NUC472/NUMAKER_PFM_M453/NUMAKER_PFM_M487/NUMAKER_PFM_NANO130). On Nuvoton targets, LR_IROM1 0x0 { ER_IROM1 0x0 { *(RESET, +First) *(InRoot$$Sections) .ANY (+RO) } ARM_LIB_STACK 0x20000000 EMPTY 0x800 { } ER_IRAMVEC 0x20000800 EMPTY (4*(16 + 96)) { } RW_IRAM1 AlignExpr(+0, 16) { .ANY (+RW +ZI) } ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (0x20000000 + 0x28000 - AlignExpr(ImageLimit(RW_IRAM1), 16)) { } } This PR just targets the targets in which __value_in_regs struct __argc_argv $Sub$$__rt_lib_init (unsigned heapbase, unsigned heaptop) { if (Image$$ARM_LIB_HEAP$$ZI$$Limit) { return $Super$$__rt_lib_init((unsigned) Image$$ARM_LIB_HEAP$$ZI$$Base, (unsigned) Image$$ARM_LIB_HEAP$$ZI$$Limit); } else { return $Super$$__rt_lib_init(heapbase, heaptop); } } In rtos build, there's no such issue because |
@ccli8 I would recommend updating the .sct file to match other mbed 2 targets. For just one ram bank I don't know of a technical reason this Nuvoton should be different than the other mbed 2 targets. |
This is to locate stack at start of SRAM and detect stack overflow by H/W bus error in rtos-less program. After scanning all target folder, there are other few targets which also define I don't prefer changing to one-region model because its influence range is large. Besides, all toolchains (ARM/ARMC6/GCC_ARM/IAR) on Nuvoton targets all apply two-region model. It is easier for maintenance with such consistency. If you worry this PR would influence other targets, I could add |
@c1728p9 Any comment? |
@c1728p9 Ping |
62b69ab
to
e942803
Compare
Hi can anyone help comment why this PR is not progressing for Nuvoton? Thanks. |
There are other targets that have the similar memory layout. Browsing their linker files and startup files, some differences are there. Retarget implementation implements From the http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0179b/CHDEGGBA.html, you should define From the note:
|
I would suggest moving
|
e942803
to
44a7fa2
Compare
…annot co-exist in RTOS-less build
44a7fa2
to
caf06e8
Compare
I see it now, rt entry invokes this function only for v5.
It's moved now to only for nuvoton. @ARMmbed/team-st-mcd there are few targets that define TWO_RAM_REGIONS, isn't this issue also present there and the fix should be applied? @ARMmbed/mbed-os-core Please review. Also is two rams regions documented ?
@c1728p9 Is this hard requirement? There are couple of targets that have two ram regions memory defined. As noted, this is working fine for all supported toolchains. |
I make the following modifications:
|
I noted that few targets overwrite stack/heap settings in assembly startup files hence recommended to set it in Nuvoton specific code. Below is example for few |
/morph build |
Build : SUCCESSBuild number : 2692 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2322 |
Test : SUCCESSBuild number : 2423 |
…_heap Fix heap base/limit error with ARM_LIB_STACK/ARM_LIB_HEAP in RTOS-less
Description
This PR tries to fix heap memory error with
ARM_LIB_STACK
/ARM_LIB_HEAP
in RTOS-less code. Per our check, heap base/limit passed to__rt_lib_init
are incorrect in the condition that__user_setup_stackheap
andARM_LIB_STACK
/ARM_LIB_HEAP
co-exist. BothARM
/ARMC6
have the same issue.The issue occurs only in RTOS-less, not in RTOS. This PR doesn't influence RTOS code.
Related issue
#6899
Pull request type