DSPRelated.com
Forums

how many heap can I use on 6713?

Started by yaoxuchen July 16, 2007
Hi,

I use a 6713 DSP with only on-chip RAM from 0x80 to 0x40000 (about 256KB in
all). I malloc about 100KB ram from heap in my program, so I specify:

-heap 20000h

-stack 1000h

-l rts6700.lib

MEMORY

{

IRAM: o = 00000080h l = 0x00040000

}

SECTIONS

{

.cinit > IRAM

.text > IRAM

.stack > IRAM

.bss > IRAM

.const > IRAM

.data > IRAM

.far > IRAM

.switch > IRAM

.sysmem > IRAM

.cio > IRAM

}

20000h is about 128K heap size. But CCS gives an error:

can't allocate .IRAM$heap (sz: 00020000 page: 0) in IRAM (avail: 0001d738)

Why does CCS give this error? How will the 256KB RAM be used? If I want to
make the heap size be 30000h(192KB), is it possible?

Could somebody tell me how can I specify how much memory can be used as
heap? Thank you.

Xuchen
What you need to do is to look at the map file that is generated and see
how much ram is used by your program. Since all of the sections are put
into the same memory, the math should be fairly simple. Whatever is not
used can be allocated to the stack and heap.

On a related question, is there any way of having the linker
automatically allocate all unused memory to the heap?

yaoxuchen wrote:
> Hi,
>
> I use a 6713 DSP with only on-chip RAM from 0x80 to 0x40000 (about 256KB in
> all). I malloc about 100KB ram from heap in my program, so I specify:
>
> -heap 20000h
> -stack 1000h
> -l rts6700.lib
>
> MEMORY
> {
> IRAM: o = 00000080h l = 0x00040000
> }
>
> SECTIONS
> {
> .cinit > IRAM
> .text > IRAM
> .stack > IRAM
> .bss > IRAM
> .const > IRAM
> .data > IRAM
> .far > IRAM
> .switch > IRAM
> .sysmem > IRAM
> .cio > IRAM
> }
>
> 20000h is about 128K heap size. But CCS gives an error:
>
> can't allocate .IRAM$heap (sz: 00020000 page: 0) in IRAM (avail: 0001d738)
>
> Why does CCS give this error? How will the 256KB RAM be used? If I want to
> make the heap size be 30000h(192KB), is it possible?
>
> Could somebody tell me how can I specify how much memory can be used as
> heap? Thank you.
>
>
On 7/16/07, William C Bonner wrote:
> What you need to do is to look at the map file that is generated and see
> how much ram is used by your program. Since all of the sections are put
> into the same memory, the math should be fairly simple. Whatever is not
> used can be allocated to the stack and heap.
>
> On a related question, is there any way of having the linker
> automatically allocate all unused memory to the heap?

well, sort of...would this help?

A] making sure that under MEMORY you declare as many _different_
possible named regions, with each ones size not more than the largest
indivisible section/unit of program code. For ex: 3 memory regions
like P1, P2 and P3.

B] Then allocate all your known sections to to named memory
regions(preferably each section into each named memory region)

C] And then use the following command on sysmem allocation:

.sysmem >> P1 | P2 | P3
notice the >> greater than operator? thats section splitting for ye.

--Bhooshan

> yaoxuchen wrote:
> > Hi,
> >
> > I use a 6713 DSP with only on-chip RAM from 0x80 to 0x40000 (about 256KB in
> > all). I malloc about 100KB ram from heap in my program, so I specify:
> >
> > -heap 20000h
> > -stack 1000h
> > -l rts6700.lib
> >
> > MEMORY
> > {
> > IRAM: o = 00000080h l = 0x00040000
> > }
> >
> > SECTIONS
> > {
> > .cinit > IRAM
> > .text > IRAM
> > .stack > IRAM
> > .bss > IRAM
> > .const > IRAM
> > .data > IRAM
> > .far > IRAM
> > .switch > IRAM
> > .sysmem > IRAM
> > .cio > IRAM
> > }
> >
> > 20000h is about 128K heap size. But CCS gives an error:
> >
> > can't allocate .IRAM$heap (sz: 00020000 page: 0) in IRAM (avail: 0001d738)
> >
> > Why does CCS give this error? How will the 256KB RAM be used? If I want to
> > make the heap size be 30000h(192KB), is it possible?
> >
> > Could somebody tell me how can I specify how much memory can be used as
> > heap? Thank you.
> >
> >
>

--
-------------------------------
"I've missed more than 9000 shots in my career.
I've lost almost 300 games. 26 times I've been trusted to take the
game winning shot and missed.
I've failed over and over again in my life.
And that is why I succeed."
-- Michael Jordan
--------------------------------
yaox,

First, I would reduce the heap allocation to say 1000h, just for test purposes.
Then I would link again.
Then your output list file would indicate the size and location of everything.
>From your remarks, I expect that all the parts of the rest of your RAM allocation are taking up way
more space that you are currently expecting.

As an initial question, just how big is everything?

R. Williams

---------- Original Message -----------
From: "yaoxuchen"
To:
Sent: Sat, 14 Jul 2007 08:58:58 +0800
Subject: [c6x] how many heap can I use on 6713?

> Hi,
>
> I use a 6713 DSP with only on-chip RAM from 0x80 to 0x40000 (about 256KB in
> all). I malloc about 100KB ram from heap in my program, so I specify:
>
> -heap 20000h
>
> -stack 1000h
>
> -l rts6700.lib
>
> MEMORY
>
> {
>
> IRAM: o = 00000080h l = 0x00040000
>
> }
>
> SECTIONS
>
> {
>
> .cinit > IRAM
>
> .text > IRAM
>
> .stack > IRAM
>
> .bss > IRAM
>
> .const > IRAM
>
> .data > IRAM
>
> .far > IRAM
>
> .switch > IRAM
>
> .sysmem > IRAM
>
> .cio > IRAM
>
> }
>
> 20000h is about 128K heap size. But CCS gives an error:
>
> can't allocate .IRAM$heap (sz: 00020000 page: 0) in IRAM (avail: 0001d738)
>
> Why does CCS give this error? How will the 256KB RAM be used? If I want to
> make the heap size be 30000h(192KB), is it possible?
>
> Could somebody tell me how can I specify how much memory can be used as
> heap? Thank you.
>
> Xuchen
------- End of Original Message -------
Dear both,

The CCS' error messaging is more informative than you might thought so far.
But first, as a matter of fact, a C6713 silicon has 256K of internal ram,
therefore the original map declaration

>> IRAM: o = 00000080h l = 0x00040000

is off the internal address space by 80h. The correct len = 3ff80h.

Next, the total code/data size without sysmem (heap) section is

>> can't allocate .IRAM$heap (sz: 00020000 page: 0) in IRAM (avail: 0001d738)
^^^^^^^^^^^^^^^
40000h - 1d738h = 228C8h and what is left for the heap is 1d738h, as the error
message informs. But as a matter of fact, the linker has been given wrong
total size of available IRAM (more by 80h), so the above free space is
less: 1d738h - 80h = 1D6B8h.

If the code uses stdio (puts()s, printf()s) I usually allcate about 2800h for
the stack, otherwise the output is either blank of corrupted. The heap size
should be adjusted accordingly. The L2 cache size (if L2 cache is used) also
has to be taken into account.

Hope thihs helps,

Andrew

> Subject: Re: how many heap can I use on 6713?
> Posted by: "Richard Williams" r...@lewiscounty.com rkwill98356
> Date: Tue Jul 17, 2007 4:47 am ((PDT))
>
> yaox,
>
> First, I would reduce the heap allocation to say 1000h, just for test purposes.
> Then I would link again.
> Then your output list file would indicate the size and location of everything.
> From your remarks, I expect that all the parts of the rest of your RAM allocation are taking up way
> more space that you are currently expecting.
>
> As an initial question, just how big is everything?
>
> R. Williams
>
> ---------- Original Message -----------
> From: "yaoxuchen"
> To:
> Sent: Sat, 14 Jul 2007 08:58:58 +0800
> Subject: [c6x] how many heap can I use on 6713?
>
>> Hi,
>>
>> I use a 6713 DSP with only on-chip RAM from 0x80 to 0x40000 (about 256KB in
>> all). I malloc about 100KB ram from heap in my program, so I specify:
>>
>> -heap 20000h
>> -stack 1000h
>> -l rts6700.lib
>>
>> MEMORY
>> {
>> IRAM: o = 00000080h l = 0x00040000
>> }
>>
>> SECTIONS
>> {
>> .cinit > IRAM
>> .text > IRAM
>> .stack > IRAM
>> .bss > IRAM
>> .const > IRAM
>> .data > IRAM
>> .far > IRAM
>> .switch > IRAM
>> .sysmem > IRAM
>> .cio > IRAM
>> }
>>
>> 20000h is about 128K heap size. But CCS gives an error:
>>
>> can't allocate .IRAM$heap (sz: 00020000 page: 0) in IRAM (avail: 0001d738)
>>
>> Why does CCS give this error? How will the 256KB RAM be used? If I want to
>> make the heap size be 30000h(192KB), is it possible?
>>
>> Could somebody tell me how can I specify how much memory can be used as
>> heap? Thank you.
>>
>> Xuchen
> ------- End of Original Message -------
>
In my program I declare -heap 0x400, which should be 1k of heap space.
I am not intentionally using any heap in my program, so whatever is used
is used by various library calls. I've never found documented
information on the memory requirements of printf() or scanf() and would
like any pointers to real documentation on them. (I suppose I could dig
in the library source code, but simple documentation would be easier.)
I would assume that those library functions would be more likely to use
stack memory instead of heap memory, because allocation / deallocation
of stack memory is much more consistent.

Andrew Nesterov wrote:
> If the code uses stdio (puts()s, printf()s) I usually allcate about 2800h for
> the stack, otherwise the output is either blank of corrupted. The heap size
> should be adjusted accordingly. The L2 cache size (if L2 cache is used) also
> has to be taken into account.
>
>
Hi William,

The only info I am avare of so far is section 9.2 of spru187. The rest
is in the sources. However, I've never thoroughly researched memory needs
of the stdio functions, as they were not crusial for my work.

Rgds,

Andrew

On Wed, 18 Jul 2007, William C Bonner wrote:
> In my program I declare -heap 0x400, which should be 1k of heap space. I am
> not intentionally using any heap in my program, so whatever is used is used
> by various library calls. I've never found documented information on the
> memory requirements of printf() or scanf() and would like any pointers to
> real documentation on them. (I suppose I could dig in the library source
> code, but simple documentation would be easier.) I would assume that those
> library functions would be more likely to use stack memory instead of heap
> memory, because allocation / deallocation of stack memory is much more
> consistent.
>
> Andrew Nesterov wrote:
>> If the code uses stdio (puts()s, printf()s) I usually allcate about 2800h
>> for
>> the stack, otherwise the output is either blank of corrupted. The heap size
>> should be adjusted accordingly. The L2 cache size (if L2 cache is used)
>> also
>> has to be taken into account.
>