DSPRelated.com
Forums

huge code size !!

Started by Alex...@gmx.net May 8, 2007
Hello

I am using the DSK6713 for Speech recognition application which performs
Cepstrum feature Extraction and Hidden Markow Model for recognition.

The feature extraction worked well, but after adding additional files to the project my code size is getting huge.

After all I got error message from the linker. It tells me that some of the code is stored to non writable memory space.

Here is my command file:

MEMORY
{
vecs: o = 00000000h l = 00000200h
IRAM: o = 00000200h l = 00030000h
SDRAM: o = 80000000h l = 01000000h
}

SECTIONS
{
.vectors > vecs
.cinit > IRAM
.text > IRAM
.stack > IRAM
.bss > IRAM
.const > IRAM
.data > IRAM
.far > IRAM
.switch > IRAM
.sysmem > SDRAM
.tables > IRAM
.cio > IRAM
.EXTERNAL > SDRAM
}

Greetings from germany

Alex.
The first thing that I notice is that you are declaring your IRAM space
to be length 192k, but you are offset by 200 hex. That's going to
overlap into the cache space, if you are enabling cache at run time.
You should change the length of IRAM to subtract it's starting offset,
which would make it 2FE00. If you are not using cache, then you can add
in another 64k of length to IRAM.

Your board has 16MB of ram available to it, starting at address
80000000h? That's cool. my board only has 16Mb available at that
address, so I've got a length of 200000h. My board is a custom board,
so it's not surprising that these are different values.

Are you getting the error message from the linker, or from the loader in
CCS, loading software over a JTAG connector? If it's from the linker,
the exact message may be helpful for diagnostics.

Wim.

A...@gmx.net wrote:
> I am using the DSK6713 for Speech recognition application which performs
> Cepstrum feature Extraction and Hidden Markow Model for recognition.
>
> The feature extraction worked well, but after adding additional files to the project my code size is getting huge.
>
> After all I got error message from the linker. It tells me that some of the code is stored to non writable memory space.
>
> Here is my command file:
>
> MEMORY
> {
> vecs: o = 00000000h l = 00000200h
> IRAM: o = 00000200h l = 00030000h
> SDRAM: o = 80000000h l = 01000000h
> }
>
> SECTIONS
> {
> .vectors > vecs
> .cinit > IRAM
> .text > IRAM
> .stack > IRAM
> .bss > IRAM
> .const > IRAM
> .data > IRAM
> .far > IRAM
> .switch > IRAM
> .sysmem > SDRAM
> .tables > IRAM
> .cio > IRAM
> .EXTERNAL > SDRAM
> }
>
>
Alexander,

I don't know the available size of the different memory areas. So that is a detail for you.
--Look in the resulting .map file to find what is overflowing the available memory area.
--Assure the .cmd file is not requesting memory areas that do not exist.
--do the compile steps with a higher level of 'size' optimization.
(then check afterward that everything still executes correctly)
--Examine the code to look for common routines/functions, etc that can be moved to a seperate file
and called from multiple places.
--Stay away from 'inline' when ever possible.
--Examine the function algorithms to see if a different approach will produce less code.
--do not use 'float' 'double' 'long long' if at all possible
--avoid using any 'float' or 'double' library functions if at all possible.
--Lower the 'precision' requirement when ever possible.
--Use 'const' when ever possible
--Reuse tables (with the same values) when every possible
--(sadly)using global variables produces less code BUT is a very bad coding practice.

*I* would start with the examination of the .map file so you know exactly what/where the problem is.

R. Williams
---------- Original Message -----------
From: A...@gmx.net
To: c...
Sent: Tue, 08 May 2007 08:47:41 -0400
Subject: [c6x] huge code size !!

> Hello
>
> I am using the DSK6713 for Speech recognition application which performs
> Cepstrum feature Extraction and Hidden Markow Model for recognition.
>
> The feature extraction worked well, but after adding additional files to the project my
> code size is getting huge.
>
> After all I got error message from the linker. It tells me that some of the code is stored
> to non writable memory space.
>
> Here is my command file:
>
> MEMORY
> {
> vecs: o = 00000000h l = 00000200h
> IRAM: o = 00000200h l = 00030000h
> SDRAM: o = 80000000h l = 01000000h
> }
>
> SECTIONS
> {
> .vectors > vecs
> .cinit > IRAM
> .text > IRAM
> .stack > IRAM
> .bss > IRAM
> .const > IRAM
> .data > IRAM
> .far > IRAM
> .switch > IRAM
> .sysmem > SDRAM
> .tables > IRAM
> .cio > IRAM
> .EXTERNAL > SDRAM
> }
>
> Greetings from germany
>
> Alex.
------- End of Original Message -------
Hello Alex,

just another pointer: you can optimize your code for speed or size. Have
a look at 'Projekt/Build Options'.

regards

Gustl

A...@gmx.net schrieb:
> Hello
>
> I am using the DSK6713 for Speech recognition application which performs
> Cepstrum feature Extraction and Hidden Markow Model for recognition.
>
> The feature extraction worked well, but after adding additional files to
> the project my code size is getting huge.
>
> After all I got error message from the linker. It tells me that some of
> the code is stored to non writable memory space.
>
> Here is my command file:
>
> MEMORY
> {
> vecs: o = 00000000h l = 00000200h
> IRAM: o = 00000200h l = 00030000h
> SDRAM: o = 80000000h l = 01000000h
> }
>
> SECTIONS
> {
> .vectors > vecs
> .cinit > IRAM
> .text > IRAM
> .stack > IRAM
> .bss > IRAM
> .const > IRAM
> .data > IRAM
> .far > IRAM
> .switch > IRAM
> .sysmem > SDRAM
> .tables > IRAM
> .cio > IRAM
> .EXTERNAL > SDRAM
> }
>
> Greetings from germany
>
> Alex.
Well thanks for all your advices.

If I want to configure IRAM without using cache, do I just need the following command ?

CACHE_setL2Mode(CACHE_256KSRAM)
Next thing is that I cannont avoid using float because I am using
big software modules from my professor. They all use float calculation.

I also using now pragma directives like:

#pragma CODE_SECTION(estimate_noise_init, ".ext_code");

So I try to bann those parts of the code which are only called once within the programm.

I will check the map file out, may be I am missing something.

Thx a lot for your reply.

Greetings !

Alex
Hello Alex,

A...@gmx.net schrieb:
> Well thanks for all your advices.
>
> If I want to configure IRAM without using cache, do I just need the
> following command ?
>
> CACHE_setL2Mode(CACHE_256KSRAM)

AFAIR cache is disabled by default.

>
> Next thing is that I cannont avoid using float because I am using
> big software modules from my professor. They all use float calculation.

Should be no problem as C6713 is a float processor.

> I also using now pragma directives like:
>
> #pragma CODE_SECTION(estimate_noise_init, ".ext_code");
>
> So I try to bann those parts of the code which are only called once
> within the programm.

I can see no section '.ext_code' in your link.cmd.

I have done it the other way round. I placed all code into ext. SRAM,
only IRQ routines and routines called from them are in int. memory. Be
aware to place used lib functions into int memory too.

SECTIONS
{
...
.memcpy > ICODE3
{
-lcsl6713.lib (.text)
-lcsl6713.lib (.text)
}
...
}

regards

Gustl
Well thanks for all your advices.

If I want to configure IRAM without using cache, do I just need the following command ?

CACHE_setL2Mode(CACHE_256KSRAM)
Next thing is that I cannont avoid using float because I am using
big software modules from my professor. They all use float calculation.

I also using now pragma directives like:

#pragma CODE_SECTION(estimate_noise_init, ".ext_code");

So I try to bann those parts of the code which are only called once within the programm.

I will check the map file out, may be I am missing something.

Thx a lot for your reply.

Greetings !

Alex
I usually use:

CACHE_setL2Mode(CACHE_0KCACHE); // Sets the Caching mode to use 0k of dsp ram
simply because it matches my thinking and I alternate between it and:

CACHE_setL2Mode(CACHE_64KCACHE); // Sets the Caching mode to use 64k of dsp ram.

CACHE_enableCaching(CACHE_CE00); // Enable caching for range CACHE_CE00 -(0x80000000 to 0x80FFFFFF)
in my different code sections.

I believe that the call the way you made it and the way I made it match
to the same constant, just different ways of thinking of the L2 ram usage.
A...@gmx.net wrote:
> Well thanks for all your advices.
>
> If I want to configure IRAM without using cache, do I just need the following command ?
>
> CACHE_setL2Mode(CACHE_256KSRAM)
>
>
Well, here is another question:

Now I tried to use the whole L2 as SRAM. I changed my command file as
listed below.
MEMORY
{
vecs: o = 00000000h l = 00000200h
IRAM: o = 00000200h l = 0003F000h
SDRAM: o = 80000000h l = 01000000h
}

SECTIONS
{
.vectors > vecs
.cinit > IRAM
.text > IRAM
.stack > IRAM
.bss > IRAM
.const > IRAM
.data > IRAM
.far > IRAM
.switch > IRAM
.sysmem > IRAM
.tables > IRAM
.cio > IRAM
.EXTERNAL > SDRAM
.ext_code > SDRAM
}

The Build worked fine, but after loading the programm into memory
an error message from the loader appeared:

" Some sections are written to non writable memory ....."

I checked CCS -> Options -> Memory Map. In that memory map my IRAM was definied from 0x0 to 0x0002FFFF. I changed it to 0x0 to 0x0003EFFF.

Then I rebuilt everything and the process starts. I have not yet implemented the algorithem but at least it works so far.

So I just needed to declare the region from 0x to to 0x0003EFFF to be (read/write) RAM ?? I thought this default ?

thanks for your attention.

greetings from good old germany.

Alex