Skip to content

Issues with the fixed heap size in IAR #3681

Closed
@bogdanm

Description

@bogdanm

I compiled a project for K64F with three compilers (GCC_ARM, ARMCC and IAR). The binaries compiled with GCC_ARM and ARMCC worked fine, but the one compiled with IAR failed with an out of memory error. After further investigation, it appears that IAR linker command file declares a maximum size for the heap, which is enforced at runtime:

https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_IAR/MK64FN1M0xxx12.icf#L85
https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_IAR/MK64FN1M0xxx12.icf#L104

This isn't consistent with GCC_ARM and ARMCC, which check for a heap/stack colision first, and only then with a dynamically computed heap limit (https://github.com/ARMmbed/mbed-os/blob/master/platform/retarget.cpp#L596).

So the question is, what can be done to make this consistent in all three toolchains? As a quick fix, it appears that it's possible to declare the heap without a maximum size in IAR:

define block HEAP      with alignment = 8     { };

The above change fixes my particular issue, but I'm not sure about its full implications.

@marcuschangarm

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions