When using the startup code (e.g. startup_ARMCM4.s) for a generic Arm device (e.g. Cortex M0, Cortex M3, Cortex M4...) from the ARM::CMSIS pack version 5.4.0 together with the Arm C library (not MicroLIB), dynamic memory allocation functions (malloc, calloc ...) will most likely fail.
Almost all startup codes from Arm Packs, define the Stack and the Heap in two independent memory areas. In order to select this two region model, the symbol __use_two_region_memory must be imported into the startup code. This was missing in these startup files. By default, the Arm C library uses the one region model.
Since the MicroLIB uses the two region model by default, the symbol __use_two_region_memory must only be imported for the Arm C library. This Arm C library is selected if MicroLIB not selected in a µVision project.
This issue was introduced with ARM:CMSIS pack v 5.4.0 and will be fixed in ARM::CMSIS pack v 5.5.0. It was already fixed in the CMSIS version 5 GitHub repository with commit 605e4d6.
Refer to Stack pointer initialization and heap bounds in the Arm Compiler Arm C and C++ Libraries and Floating-Point Support User Guide.
Refer to Application Note 241 ARM Compiler C Library Startup and Initialization.