DSPRelated.com
Forums

Memory Copy on DM642

Started by Imran Akthar July 3, 2004
Hi all,
m using DM642 board and CCS 2.21 version.
I m reading a file whose size is 1MB(uinsg fread()in host PC) and
writing it to the External RAM ..SDRAM .
what i have noticed is that ,m able to copy contents of the file upto
certain location only.beyond that ,the copy is not sucessful.(m not
gettting memory errors..)
the count is 15099 bytes.beyond that ....its not gettting copied
properly beyond that location.

what may be the reasons.

also
1)what is the best way to copy from PC to board.??? thanks
MA Imran void main()
{
FILE *p;
unsigned char *p1;
unsigned char *image_data;
unsigned long file_size,count,i;
p1=(unsigned char *)0x80000000;

p=fopen("test.bmp","r");
if(p==NULL)
{
LOG_printf(&trace,"file open fail");
}
else
{
LOG_printf(&trace,"sucesful\n");

}

rewind(p);
fseek(p,0L,SEEK_END);
file_size=ftell(p);
rewind(p);
LOG_printf(&trace,"file size %x \n",file_size);

image_data=MEM_alloc(SEG0,file_size,0);
LOG_printf(&trace, "before allocating ...");

/* print initial memory status */
printmem(SEG0);//calling printmem function ..using SEG0 id.
if(image_data==MEM_ILLEGAL)
{
LOG_printf(&trace,"memory allocation failed\n");
exit();
}
else
{
LOG_printf(&trace,"mem allocation sucessful\n");
}

fread(image_data,file_size,1,p); count=0;

for(i=0;i<file_size;i++)

{
*p1=*image_data;
p1+=1;
image_data+=1;
count=count+1; if(count=0*1024)
{
LOG_printf(&trace,"i = %d ",i);
LOG_printf(&trace,"100K copy over\n");
count=0;

}

}
LOG_printf(&trace,"content %x %x ",*p1,*image_data);
LOG_printf(&trace,"memory copy over\n");
fclose(p);
MEM_free(SEG0,image_data,file_size);
}




MA Imran,
 
It looks like you might have hit a limit. 
 
My advice is "when you cannot eat an elephant in one bite, take more smaller bites". ie, read something like 14,000 bytes at a time.
 
FYI-I hope that you are using this for setup or initialization because standard I/O performance is very  S L O W!!
 
mikedunn

Imran Akthar <i...@yahoo.com> wrote:
Hi all,
m using DM642 board and CCS 2.21 version.
I m reading a file whose size is 1MB(uinsg fread()in host PC) and
writing it to the External RAM ..SDRAM .
what i have noticed is that ,m able to copy contents of the file upto
certain location only.beyond that ,the copy is not sucessful.(m not
gettting memory errors..)
the count is 15099 bytes.beyond that ....its not gettting copied
properly beyond that location.

what may be the reasons.

also
1)what is the best way to copy from PC to board.???thanks
MA Imranvoid main()
{
FILE *p;
unsigned char *p1;
unsigned char *image_data;
unsigned long file_size,count,i;
p1=(unsigned char *)0x80000000;

p=fopen("test.bmp","r");
if(p==NULL)
{
LOG_printf(&trace,"file open fail");
}
else
{
LOG_printf(&trace,"sucesful\n");

}

rewind(p);
fseek(p,0L,SEEK_END);
file_size=ftell(p);
rewind(p);
LOG_printf(&trace,"file size %x \n",file_size);

image_data=MEM_alloc(SEG0,file_size,0);
LOG_printf(&trace, "before allocating ...");

/* print initial memory status */
printmem(SEG0);//calling printmem function ..using SEG0 id.
if(image_data==MEM_ILLEGAL)
{
LOG_printf(&trace,"memory allocation failed\n");
exit();
}
else
{
LOG_printf(&trace,"mem allocation sucessful\n");
}

fread(image_data,file_size,1,p);count=0;

for(i=0;i
{
*p1=*image_data;
p1+=1;
image_data+=1;
count=count+1;if(count=0*1024)
{
LOG_printf(&trace,"i = %d ",i);
LOG_printf(&trace,"100K copy over\n");
count=0;

}

}
LOG_printf(&trace,"content %x %x ",*p1,*image_data);
LOG_printf(&trace,"memory copy over\n");
fclose(p);
MEM_free(SEG0,image_data,file_size);
}_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join: Send an email to c...@yahoogroups.com

To Post: Send an email to c...@yahoogroups.com

To Leave: Send an email to c...@yahoogroups.com

Archives: http://www.yahoogroups.com/group/c6x

Other Groups: http://www.dsprelated.com

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/c6x/

<*> To unsubscribe from this group, send an email to:
c...@yahoogroups.com

<*


Hi Imran,
I guess Mike is right. With my prior experience on C6x boards, I would like to share that FILE I/O operations are not implemented correctly
and moreover they have some problems. I would suggest you to read in chunks of 8 KB which is more appropriate. However, I have tried with 100 KB at one shot with a fread and maximum I have tried approx. 340 KB.
One suggestion: try this. p->flags |= 0x4; ./* where p is your file pointer which you are using to read */
Hope this helps.
Thanks and Regards,
Ganesh
 
----- Original Message -----
From: Mike Dunn
To: Imran Akthar ; c...@yahoogroups.com
Sent: Saturday, July 03, 2004 11:58 PM
Subject: Re: [c6x] Memory Copy on DM642

MA Imran,
 
It looks like you might have hit a limit. 
 
My advice is "when you cannot eat an elephant in one bite, take more smaller bites". ie, read something like 14,000 bytes at a time.
 
FYI-I hope that you are using this for setup or initialization because standard I/O performance is very  S L O W!!
 
mikedunn

Imran Akthar <i...@yahoo.com> wrote:
Hi all,
m using DM642 board and CCS 2.21 version.
I m reading a file whose size is 1MB(uinsg fread()in host PC) and
writing it to the External RAM ..SDRAM .
what i have noticed is that ,m able to copy contents of the file upto
certain location only.beyond that ,the copy is not sucessful.(m not
gettting memory errors..)
the count is 15099 bytes.beyond that ....its not gettting copied
properly beyond that location.

what may be the reasons.

also
1)what is the best way to copy from PC to board.???thanks
MA Imranvoid main()
{
FILE *p;
unsigned char *p1;
unsigned char *image_data;
unsigned long file_size,count,i;
p1=(unsigned char *)0x80000000;

p=fopen("test.bmp","r");
if(p==NULL)
{
LOG_printf(&trace,"file open fail");
}
else
{
LOG_printf(&trace,"sucesful\n");

}

rewind(p);
fseek(p,0L,SEEK_END);
file_size=ftell(p);
rewind(p);
LOG_printf(&trace,"file size %x \n",file_size);

image_data=MEM_alloc(SEG0,file_size,0);
LOG_printf(&trace, "before allocating ...");

/* print initial memory status */
printmem(SEG0);//calling printmem function ..using SEG0 id.
if(image_data==MEM_ILLEGAL)
{
LOG_printf(&trace,"memory allocation failed\n");
exit();
}
else
{
LOG_printf(&trace,"mem allocation sucessful\n");
}

fread(image_data,file_size,1,p);count=0;

for(i=0;i
{
*p1=*image_data;
p1+=1;
image_data+=1;
count=count+1;if(count=0*1024)
{
LOG_printf(&trace,"i = %d ",i);
LOG_printf(&trace,"100K copy over\n");
count=0;

}

}
LOG_printf(&trace,"content %x %x ",*p1,*image_data);
LOG_printf(&trace,"memory copy over\n");
fclose(p);
MEM_free(SEG0,image_data,file_size);
}_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join: Send an email to c...@yahoogroups.com

To Post: Send an email to c...@yahoogroups.com

To Leave: Send an email to c...@yahoogroups.com

Archives: http://www.yahoogroups.com/group/c6x

Other Groups: http://www.dsprelated.com

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/c6x/

<*> To unsubscribe from this group, send an email to:
c...@yahoogroups.com

<*


_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer.  You need to do a "reply all" if you want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:  Send an email to c...@yahoogroups.com

To Post:  Send an email to c...@yahoogroups.com

To Leave: Send an email to c...@yahoogroups.com

Archives: http://www.yahoogroups.com/group/c6x

Other Groups: http://www.dsprelated.com