DSPRelated.com
Forums

Memory allocation problems

Started by Giovanni March 15, 2005

Hello evrybody
I am using an EVM board with C6701 processor and I have some problems
with memory allocation:
Here is my cmd file

/*** CMD file settings ***/
-c
-heap 0xA000
-stack 0xB000
-m memory.txt

MEMORY
{

PMEM: o = 00000000h l = 00010000h
EXT0: o = 00400000h l = 01000000h
EXT1: o = 01400000h l = 00010000h
EXT2: o = 02000000h l = 01000000h
EXT3: o = 03000000h l = 01000000h
BMEM: o = 80000000h l = 00010000h
}

SECTIONS
{
.text > PMEM
.stack > BMEM
.bss > EXT2
.cinit > EXT2
.cio > EXT2
.const > EXT2
.data > EXT2
.Img_sect > EXT2
.far > EXT2
}

/*** end CMD file ***/

Here there is the code that produces the error.

/*** C code ***/

#include <stdio.h>
#define HI 540
#define WI 720
#define H 147
#define W 192

typedef struct {
/* Bitmap File Header (14 bytes) */
char bfType[2];
unsigned int bfSize;
..........
} BMPH; #pragma DATA_SECTION (foreg,".Img_sect")
unsigned char foreg[HI][WI];
BMPH head_f;

#pragma DATA_SECTION (backg,".Img_sect")
unsigned char backg[HI][WI];
BMPH head_b;

int main()
{
unsigned char u_foreg[H][W];
//BMPH head_u_f;
unsigned char u_backg[H][W];
//BMPH head_u_b;

u_foreg[0][0]%5;
u_backg[0][0]=0;

printf("Fine\n");
return 0;
}

/*** end C code ***/

I think u_foreg and u_backg matrixes would be stored in EXT2, but CCS
tells us that their starting address are respectively 0x7FFFD374
(Reserved area) and 0x800041B4 (Internal Program Memory).
However head_f, head_b, foreg, backg are stored in external memory.
Do you have some idea about the error that I'm doing?
In the following section you can find the DIP switch settings

---------------------
---------------------
EVM Settings

Boot mode HPI
Map Map 1
Memory at address 0 Internal
Sw6 Multiply-by-4 mode
SW7 Osc B
SW8 Little Endian
SW9 External (XDS510)
SW10 User2=0
SW11 User1=0
SW12 User0=0
---------------------
---------------------


Hi,

I'm not sure what your problem is. But I think u_foreg and u_backg are
placed on the stack. They need 0x6E40 Bytes each. So your stack has to
be at least greater than 0xDC80.

Why don't you do the same as with foreg and backg? Declare them outside
main() and use a pragma to place them.

HTH

Gustl Giovanni wrote:
>
> Hello evrybody
> I am using an EVM board with C6701 processor and I have some problems
> with memory allocation:
> Here is my cmd file
>
> /*** CMD file settings ***/
> -c
> -heap 0xA000
> -stack 0xB000
> -m memory.txt
>
> MEMORY
> {
>
> PMEM: o = 00000000h l = 00010000h
> EXT0: o = 00400000h l = 01000000h
> EXT1: o = 01400000h l = 00010000h
> EXT2: o = 02000000h l = 01000000h
> EXT3: o = 03000000h l = 01000000h
> BMEM: o = 80000000h l = 00010000h
> }
>
> SECTIONS
> {
> .text > PMEM
> .stack > BMEM
> .bss > EXT2
> .cinit > EXT2
> .cio > EXT2
> .const > EXT2
> .data > EXT2
> .Img_sect > EXT2
> .far > EXT2
> }
>
> /*** end CMD file ***/
>
> Here there is the code that produces the error.
>
> /*** C code ***/
>
> #include <stdio.h>
> #define HI 540
> #define WI 720
> #define H 147
> #define W 192
>
> typedef struct {
> /* Bitmap File Header (14 bytes) */
> char bfType[2];
> unsigned int bfSize;
> ..........
> } BMPH; > #pragma DATA_SECTION (foreg,".Img_sect")
> unsigned char foreg[HI][WI];
> BMPH head_f;
>
> #pragma DATA_SECTION (backg,".Img_sect")
> unsigned char backg[HI][WI];
> BMPH head_b;
>
> int main()
> {
> unsigned char u_foreg[H][W];
> //BMPH head_u_f;
> unsigned char u_backg[H][W];
> //BMPH head_u_b;
>
> u_foreg[0][0]%5;
> u_backg[0][0]=0;
>
> printf("Fine\n");
> return 0;
> }
>
> /*** end C code ***/
>
> I think u_foreg and u_backg matrixes would be stored in EXT2, but CCS
> tells us that their starting address are respectively 0x7FFFD374
> (Reserved area) and 0x800041B4 (Internal Program Memory).
> However head_f, head_b, foreg, backg are stored in external memory.
> Do you have some idea about the error that I'm doing?
> In the following section you can find the DIP switch settings
>
> ---------------------
> ---------------------
> EVM Settings
>
> Boot mode HPI
> Map Map 1
> Memory at address 0 Internal
> Sw6 Multiply-by-4 mode
> SW7 Osc B
> SW8 Little Endian
> SW9 External (XDS510)
> SW10 User2=0
> SW11 User1=0
> SW12 User0=0
> ---------------------
> ---------------------





Sigh I didn't see the code line
-stack 0xB000
This has been a "mispelling", now I changed it and it works
Thanks Giovanni Bernhard 'Gustl' Bauer wrote:

> Hi,
>
> I'm not sure what your problem is. But I think u_foreg and u_backg are
> placed on the stack. They need 0x6E40 Bytes each. So your stack has to
> be at least greater than 0xDC80.
>
> Why don't you do the same as with foreg and backg? Declare them
> outside main() and use a pragma to place them.
>
> HTH
>
> Gustl > Giovanni wrote:
>
>>
>> Hello evrybody
>> I am using an EVM board with C6701 processor and I have some problems
>> with memory allocation:
>> Here is my cmd file
>>
>> /*** CMD file settings ***/
>> -c
>> -heap 0xA000
>> -stack 0xB000
>> -m memory.txt
>>
>> MEMORY
>> {
>>
>> PMEM: o = 00000000h l = 00010000h
>> EXT0: o = 00400000h l = 01000000h
>> EXT1: o = 01400000h l = 00010000h
>> EXT2: o = 02000000h l = 01000000h
>> EXT3: o = 03000000h l = 01000000h
>> BMEM: o = 80000000h l = 00010000h
>> }
>>
>> SECTIONS
>> {
>> .text > PMEM
>> .stack > BMEM
>> .bss > EXT2
>> .cinit > EXT2
>> .cio > EXT2
>> .const > EXT2 .data > EXT2
>> .Img_sect > EXT2
>> .far > EXT2
>> }
>>
>> /*** end CMD file ***/
>>
>> Here there is the code that produces the error.
>>
>> /*** C code ***/
>>
>> #include <stdio.h>
>> #define HI 540
>> #define WI 720
>> #define H 147
>> #define W 192
>>
>> typedef struct {
>> /* Bitmap File Header (14 bytes) */
>> char bfType[2];
>> unsigned int bfSize;
>> ..........
>> } BMPH;
>>
>>
>> #pragma DATA_SECTION (foreg,".Img_sect") unsigned char foreg[HI][WI];
>> BMPH head_f;
>>
>> #pragma DATA_SECTION (backg,".Img_sect")
>> unsigned char backg[HI][WI];
>> BMPH head_b;
>>
>> int main()
>> { unsigned char u_foreg[H][W];
>> //BMPH head_u_f;
>> unsigned char u_backg[H][W];
>> //BMPH head_u_b;
>> u_foreg[0][0]%5;
>> u_backg[0][0]=0;
>> printf("Fine\n");
>> return 0;
>> }
>>
>> /*** end C code ***/
>>
>> I think u_foreg and u_backg matrixes would be stored in EXT2, but CCS
>> tells us that their starting address are respectively 0x7FFFD374
>> (Reserved area) and 0x800041B4 (Internal Program Memory).
>> However head_f, head_b, foreg, backg are stored in external memory.
>> Do you have some idea about the error that I'm doing?
>> In the following section you can find the DIP switch settings
>>
>> ---------------------
>> ---------------------
>> EVM Settings
>>
>> Boot mode HPI
>> Map Map 1
>> Memory at address 0 Internal
>> Sw6 Multiply-by-4 mode
>> SW7 Osc B
>> SW8 Little Endian
>> SW9 External (XDS510)
>> SW10 User2=0
>> SW11 User1=0
>> SW12 User0=0
>> ---------------------
>> --------------------- >