ts-7000
[Top] [All Lists]

[ts-7000] Type Casting Error ???

To:
Subject: [ts-7000] Type Casting Error ???
From: "lymix3" <>
Date: Thu, 18 Jan 2007 06:09:35 -0000
Hi everyone..

I made ep9301 Custom board similar ts7200 edb9301  little different..
I made My own Bootloader(boot and zmodem) it's simple works

I met Strange Problem in Downloading My Own Bootloader
Download tool is cirrus download in "cirrus-arm-linux-2.0.2" package

compiling download tool has no problem,
But during downloading own bootloader, CheckSum Error and SizeError
has appeared.

i checked download.c(PC CLIENT) and /src/main.c(CUSTOM BOARD)

PC CLIENT CODE is
------------------------------------------------------------------
long lFileSize;

SendChar((char)(lFileSize & 0xFF));
printf("SendDATA %02x\r\n",(char)(lFileSize & 0xFF));
SendChar((char)((lFileSize >> 8) & 0xFF));
printf("SendDATA %02x\r\n",(char)((lFileSize >> 8) & 0xFF));
SendChar((char)((lFileSize >> 16) & 0xFF));
printf("SendDATA %02x\r\n",(char)((lFileSize >> 16) & 0xFF));
SendChar((char)((lFileSize >> 24) & 0xFF));
printf("SendDATA %02x\r\n",(char)((lFileSize >> 24) & 0xFF));


i printed "lFileSize" for each SendChar Fuction.
it works. good data...

Custom board code is...
--------------------------------------------------------------
long iFileSize;
unsigned char *pBuffer;
char    data0;
char    data1;
char    data2;
char    data3;

pBuffer = (volatile unsigned char *)&iFileSize;
        
pBuffer[0] = data0 = Serial_GetChar();
pBuffer[1] = data1 = Serial_GetChar();
pBuffer[2] = data2 = Serial_GetChar();
pBuffer[3] = data3 = Serial_GetChar();

We know if PC CLIENT send "0x11,0x22,0x33,0x44" sequencely..
Custom Board will Check 
pBuffer[0]= 0x11,pBuffer[1]= 0x22,pBuffer[2]= 0x33,pBuffer[3]= 0x44  

But, I'm so confused this result..
pBuffer[0]= 0x22,pBuffer[1]= 0x11,pBuffer[2]= 0x44,pBuffer[3]= 0x33

it seems like 16 bit big endian data...
if i have compiled big endian option, board didn't works.
because, I checked binary data of download tool, 

i thought, Serial function has Bug...
So, i changed code like this..
-----------------------------------------------------

pBuffer[0] = data0 = 0x11;
pBuffer[1] = data1 = 0x22;
pBuffer[2] = data2 = 0x33;
pBuffer[3] = data3 = 0x44;

    if( pBuffer[0] == 0x11)
        Serial_SendChar(0);
    if( pBuffer[1] == 0x22)
        Serial_SendChar(1);
    if( pBuffer[2] == 0x33)
        Serial_SendChar(2);
    if( pBuffer[3] == 0x44)
        Serial_SendChar(3);
        
    if( data0 == 0x11)
        Serial_SendChar(4);
    if( data1 == 0x22)
        Serial_SendChar(5);
    if( data2 == 0x33)
        Serial_SendChar(6);
    if( data3 == 0x44)
        Serial_SendChar(7);

4,5,6,7 has received... 1,2,3,4 is no...

result is...

pBuffer[0]=0x22, pBuffer[1]=0x11, pBuffer[2]=0x44, pBuffer[3]=0x33,
data0     =0x11, data1     =0x22, data2     =0x33, data3     =0x44

code used array value has bug.. seems like 16 bit big endian
and casting code(long & -> unsigned char *) has bug.. it's same
problem...

why happens.. hardware problem?, cross compiler problem?, compile 
option?.. do not casting 8bit pointer in bytes,strings,16bit,32bit?





 
Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

<Prev in Thread] Current Thread [Next in Thread>
  • [ts-7000] Type Casting Error ???, lymix3 <=
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU