How to set malloc heap size on ModusToolbox 2.0.0? (again)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
KiOk_2981821
Level 1
Level 1
First question asked First reply posted

I asked this at How to set malloc heap size on ModusToolbox 2.0.0? .

> How to set malloc heap size on ModusToolbox 2.0.0?

> Sometime I would like to use small heap or large one.

>

> I'm using ModusToolbox Version:  2.0.0 Build ID: 1703 and CY8CPROTO-062-4343W PSoC 6.

The answer was:

> In the Project Explorer in ModusToolbox 2.0, go to libs > TARGET_CY8CPROTO-062-4343W > startup > TOOLCHAIN_GCC_ARM > startup_psoc6_02_cm4.S

>

> Please find the following code -

> #ifdef __HEAP_SIZE

>    .equ    Heap_Size, __HEAP_SIZE

> #else

>    .equ    Heap_Size, 0x00000400

>

> You can change the heap size here.

Then I tried to modify it and also specify it at Makefile:

$ vi libs/TARGET_CY8CPROTO-062-4343W/startup/TOOLCHAIN_GCC_ARM/startup_psoc6_02_cm4.S

__StackLimit:     .space    Stack_Size     .size    __StackLimit, . - __StackLimit __StackTop:     .size    __StackTop, . - __StackTop      .section .heap     .align    3     .equ    Heap_Size, 0x00000100     .globl    __HeapBase     .globl    __HeapLimit __HeapBase:     .if    Heap_Size     .space    Heap_Size     .endif     .size    __HeapBase, . - __HeapBase 

But it doesn't change the heap size:

$ make clean $ make build --snip--    --------------------------------------------------    | Section Name         |  Address      |  Size     |     --------------------------------------------------    | .cy_m0p_image        |  0x10000000   |  5068     |    | .text                |  0x10002000   |  41060    |    | .ARM.exidx           |  0x1000c064   |  8        |    | .copy.table          |  0x1000c06c   |  24       |    | .zero.table          |  0x1000c084   |  8        |    | .data                |  0x080022e0   |  1912     |    | .cy_sharedmem        |  0x08002a58   |  8        |    | .noinit              |  0x08002a60   |  148      |    | .bss                 |  0x08002af4   |  836      |    | .heap                |  0x08002e38   |  1030600  |     --------------------------------------------------     Total Internal Flash (Available)          2097152     Total Internal Flash (Utilized)           51220        Total Internal SRAM (Available)           1046528     Total Internal SRAM (Utilized)            1033504  
0 Likes
1 Solution

Hi KiOk_2981821,

Per linker script (see section .heap), the heap area will allocate all unused ram. So it's expected that changing __HEAP_SIZE does not show effect in the final heap size calculation.


Regards,
Nazar

View solution in original post

0 Likes
2 Replies
KiOk_2981821
Level 1
Level 1
First question asked First reply posted

Sorry my text is broken. Following gist shows it correctly:

Why we can't change size of malloc heap for PSoC 6? · GitHub

0 Likes

Hi KiOk_2981821,

Per linker script (see section .heap), the heap area will allocate all unused ram. So it's expected that changing __HEAP_SIZE does not show effect in the final heap size calculation.


Regards,
Nazar

0 Likes