Hi Peter,

As per your suggestion  i tried changing my U-boot configuration options to.

#undef CONFIG_INIT_CRITICAL             /* undef for developing */
#define CONFIG_SKIP_LOWLEVEL_INIT   1    /* needed for U-Boot 1.1.3*/
#undef  CONFIG_SKIP_RELOCATE_UBOOT

But still it hangs at when i try to give load or start u-boot instruction.
I have attached windows program for your refrence. I am not sure where i am
making mistake.
can you please suggest.

Thanks and regards,
Aleem

On 5/2/07, Peter Wippich <[EMAIL PROTECTED]> wrote:


Hi Allem,

probably you are booting a u-boot which is compiled for flash boot. This
one tries to copy itself from flash to RAM. You need a version which skips
low level init (done by bootloader) and the selfcopy. Something like

/* for Ram load version do not do low level init and do not relocate */
#undef  CONFIG_INIT_CRITICAL
#define CONFIG_SKIP_LOWLEVEL_INIT
/* #define CONFIG_SKIP_RELOCATE_UBOOT not needed, tested by boot code */

inside your u-boot config .h file will do the job.

Ciao,

Peter


On Wed, 2 May 2007, aleem shariff wrote:

> Hi,
>
> I have tried TI's Document SPRAAI0 & SPRAAI4  & Downloaded code
> spraai4.zipit did not help me much.
> when i referred forum it got me going with Ruby's boot loader.
> Thanks to Ruby i am able to download u-boot image.
> But when i try to  start u-boot with command < u >
> on the console i get BOOTME BOOTME......
> Can any one help me who have already worked on Uart boot.
> any suggestions will be appreciated.
>
>
-------------------------------------------------------------------------------
> D:\uart_booting\uart\exe>win_flash.exe r-boot.bin 1
> read 14336 bytes from r-boot.bin
> Waiting for boot message from Davinci
> . BOOTME
> sending ACK
> Waiting for begin message from Davinci
>   BEGINsending empty CRC table
> Waiting for done message from Davinci
>    DONESending data
> Waiting for done message from Davinci
>    DONEWaiting for UBL message from Davinci
> e?ì
> Rboot->uboot size is 107484 bytes
>
********************************************************************************
> lDo?e.
> #
> Rboot-?timed out
>
> D:\uart_booting\uart\exe>
> D:\uart_booting\uart\exe>
>
---------------------------------------------------------------------------------
>
> Òboot->¿
> Rudy's Wonderful UBL.
> d  - Display Memory
> l  - Load Program/Data
> g  - Goto Address
> z  - Reset
> u  - Start U-Boot
>
> Rboot->u BOOTME BOOTME BOOTME BOOTME BOOTME BOOTME
>
>
>
> Thanks in advance,
>
> Aleem
>


|       Peter Wippich                   Voice: +49 30 46776411          |
|       G&W Instruments GmbH            fax:   +49 30 46776419          |
|       Gustav-Meyer-Allee 25, Geb. 12  Email: [EMAIL PROTECTED]   |
|       D-13355 Berlin  / Germany                                       |

//-----------------------------------------------------------------------------
// File load.c
// Load UBL to davinci over UART 
// Win32 console application 
// (c) 2005 G&W Instruments 
//-----------------------------------------------------------------------------

#include <windows.h>
#include <stdio.h>
#include <time.h>

#define MAX_UBL_SIZE (14*1024) 

static HANDLE DevHandle = INVALID_HANDLE_VALUE ;

//---------------------------------------------------------------------------
int OpenCom(int portnum)
{
    char portname[12] ; // 10 shall do ...
        const int RxQueueSize=4*1024;
        const int TxQueueSize=4*1024;
    int NumWritten ; 
        DCB dcb;
    COMMTIMEOUTS ComTimeouts ; 

    memset(portname, 0, 12) ;
    sprintf(portname,"\\\\.\\COM%d",portnum) ; 

    // open Port 
        DevHandle = CreateFile(portname,
                        GENERIC_READ | GENERIC_WRITE,
                        0,
                        NULL,
                        OPEN_EXISTING,
                        FILE_ATTRIBUTE_NORMAL,
                        0);
    
        if (DevHandle==INVALID_HANDLE_VALUE) {
        printf("CreateFile for %s failed %d\n", portname, GetLastError());
            return 0;
        }

        if (!SetupComm(DevHandle, RxQueueSize, TxQueueSize)) {
        printf("SetupComm failed %d\n", GetLastError());
            CloseHandle(DevHandle);
        DevHandle = INVALID_HANDLE_VALUE ;
            return 0;
        }

        memset(&dcb, 0, sizeof(dcb));
        dcb.DCBlength = sizeof(DCB);

        if (!GetCommState(DevHandle, &dcb)) {
        printf("GetCommState failed %d\n", GetLastError());
            CloseHandle(DevHandle);
        DevHandle = INVALID_HANDLE_VALUE ;
            return 0;
        }
  
        dcb.DCBlength = sizeof(DCB);
        dcb.BaudRate = 115200;              /* Baudrate   */
    dcb.fBinary = 1 ; 
        dcb.fParity  = 0;                   /* Disable parity checking          
*/
        dcb.fOutxCtsFlow = 0 ;                  /* CTS handshaking on output    
   */
        dcb.fOutxDsrFlow = 0;                       /* no SR handshaking on 
output       */
        dcb.fDtrControl  = DTR_CONTROL_DISABLE;     /* DTR off control          
  */
        dcb.fOutX = 0;                          /* Disable output X-ON/X-OFF    
    */
        dcb.fInX  = 0;                          /* Disable input X-ON/X-OFF     
    */
    dcb.fErrorChar = 0 ;                    // do not replace witherror char 
        dcb.fNull = 0;                          /* Enable Null stripping        
   */
        dcb.fRtsControl  = RTS_CONTROL_DISABLE; // RTS off 
    dcb.fAbortOnError = 0 ; 
        dcb.XonLim  = 500 ;
        dcb.XoffLim = RxQueueSize * 80 / 100;
        dcb.Parity   = NOPARITY;  /* 0-4=None,Odd,Even,Mark,Space    */
        dcb.ByteSize = 8;         /* Number of bits/byte, 4-8        */
        dcb.StopBits = ONESTOPBIT; /* 0,1,2 = 1, 1.5, 2               */
        dcb.XonChar  = 0x11;        /* Tx and Rx X-ON character        */
        dcb.XoffChar = 0x13;        /* Tx and Rx X-OFF character       */


        #if 0
        DWORD fDsrSensitivity:1; /* DSR Sensitivity              */
        DWORD fTXContinueOnXoff: 1; /* Continue TX when Xoff sent */
        WORD wReserved;       /* Not currently used              */
        char ErrorChar;       /* Error replacement char          */
        char EofChar;         /* End of Input character          */
        char EvtChar;         /* Received Event character        */
        #endif

        if (!SetCommState(DevHandle, &dcb)) {
        printf("SetCommState failed %d\n", GetLastError());
            CloseHandle(DevHandle);
        DevHandle = INVALID_HANDLE_VALUE ;
            return 0;
        }

    ComTimeouts.ReadIntervalTimeout = 1000 ;
    ComTimeouts.ReadTotalTimeoutMultiplier = 500 ; 
    ComTimeouts.ReadTotalTimeoutConstant = 1000 ; 
    ComTimeouts.WriteTotalTimeoutMultiplier = 500 ; 
    ComTimeouts.WriteTotalTimeoutConstant = 1000; 
    SetCommTimeouts(DevHandle, &ComTimeouts) ; 

        PurgeComm(DevHandle,PURGE_RXABORT | PURGE_RXCLEAR | PURGE_TXABORT | 
PURGE_TXCLEAR);

#if 0 
    // Set timeouts to something which gives us not to slow response 
    // when waiting for events 
    ComTimeouts.ReadIntervalTimeout = 50 ;
    ComTimeouts.ReadTotalTimeoutMultiplier = 10 ; 
    ComTimeouts.ReadTotalTimeoutConstant = 100 ; 
    ComTimeouts.WriteTotalTimeoutMultiplier = 500 ; 
    ComTimeouts.WriteTotalTimeoutConstant = 1000; 
    SetCommTimeouts(DevHandle, &ComTimeouts) ; 
#endif 
    return 1 ;
}

//---------------------------------------------------------------------------

void CloseCom(void)
{
    if(DevHandle != INVALID_HANDLE_VALUE)
    {
            PurgeComm(DevHandle,PURGE_RXABORT | PURGE_RXCLEAR | PURGE_TXABORT | 
PURGE_TXCLEAR);
        CloseHandle(DevHandle);
        DevHandle = INVALID_HANDLE_VALUE ;
    }
}

//---------------------------------------------------------------------------

/*---------------------------------------------------------------------------
Wait for (partial) string with timeout (in milliseconds) 
----------------------------------------------------------------------------*/
int WaitFor(char * wstring, int timeout) 
{
    char c ; 
    int cmplen = strlen(wstring) ; 
    int nmatch = 0; 
    unsigned long  timeout_ticks ;
    int nread = 0;
    clock_t stop ;

    
    timeout_ticks = (CLOCKS_PER_SEC * (unsigned long) timeout) ;
    timeout_ticks += 500 ;                        // round up
    timeout_ticks /= 1000 ;                       // scale for CPS 
    stop = clock() + (clock_t)timeout_ticks ;
    while(stop > clock()) 
    {
        if(!ReadFile(DevHandle, &c, 1, &nread, 0)) 
        {
            printf("Read Failed %d\n", GetLastError() )  ;
            nread = 0 ; 
        }            

        if(nread) 
        {
            printf("%c",c) ; 

            if(c == wstring[nmatch])
            {
                nmatch++ ; 
                if(nmatch == cmplen) return 1 ; 
            }
            else 
            {
                nmatch = 0 ; 
            }
        }
    }

    return 0 ; 
}

//---------------------------------------------------------------------------

static void print_usage(char *pgm)
{
        printf("Usage:\n");
        printf("%s [file to load] [portnum]\n", pgm) ;
}

//---------------------------------------------------------------------------

//test only 
int main(int argc, char ** argv) 
{

        unsigned long baudrate = 115200 ; 
        DCB dcb;    
        char ch ;
        FILE * file ;
        unsigned char *buf, *loc ;
        int numread, numwritten ;
        int i ; 
        char txbuf[1024] ;
        long uboot_size ; 

        if(argc =! 3) {
                print_usage(argv[0]) ;
                exit(1) ;
        }

        if( !OpenCom(atoi(argv[2])) ){
                printf("failed to open com%s\n", argv[2]) ; 
                exit(1) ;
        }

        file = fopen(argv[1],"rb") ;
        if(!file) {
                printf("failed to open %s\n", argv[1] ) ;
                CloseCom() ;
                exit(1) ; 
        }

        buf = malloc(MAX_UBL_SIZE) ;
        if(!buf) {
                printf("failed to allocate buffer\n") ;
                fclose(file) ;
                CloseCom() ;
                exit(1) ;
        }
        numread = fread(buf, 1, MAX_UBL_SIZE, file) ;
        printf("read %d bytes from %s\n", numread, argv[1]) ;
        fclose(file) ; 
        if(!numread) {
                printf("nothing read, exiting\n") ;
                free(buf) ; 
                CloseCom() ;
                exit(1) ;
        }

        printf("Waiting for boot message from Davinci\n") ;
        while(1) {
                printf(".") ;
                if( WaitFor(" BOOTME\0", 5000) ) break ;
                if(kbhit()) {
                        ch = getch() ;
                        if(ch == 0x1b) {
                                printf("aborted\n") ;
                                CloseCom() ;
                                free(buf) ; 
                                exit(0) ;
                        }
                }
        }       
        
        printf("\nsending ACK\n") ;
        memset(txbuf, 0, 8) ; 
        sprintf(txbuf,"    ACK") ;
        WriteFile(DevHandle, txbuf, 8, &numwritten, 0) ;
        memset(txbuf, 0, 20) ; 
        sprintf(txbuf,"00000000%.4x%.4x0000", numread - (8*4), 0x100) ;
        WriteFile(DevHandle, txbuf, 20, &numwritten, 0) ;


        printf("Waiting for begin message from Davinci\n") ;
        if( ! WaitFor("  BEGIN\0", 5000) ) {
                printf("timed out\n") ;
                CloseCom() ;
                free(buf) ; 
                exit(1) ;
        }
        printf("sending empty CRC table\n") ;
        memset(txbuf, 0, 8) ;
        sprintf(txbuf,"00000000") ;
        for(i=0; i<256 ; i++) WriteFile(DevHandle, txbuf, 8, &numwritten, 0) ;

        printf("Waiting for done message from Davinci\n") ;
        if( ! WaitFor("   DONE\0", 5000) ) {
                printf("timed out\n") ;
                free(buf) ; 
                CloseCom() ;
                exit(1) ;
        }

        printf("Sending data\n") ;

        for(i=8*4 ; i<numread ; i+=4)
        {
                // XXXX assumes LE machine !! 
                unsigned long *p = (unsigned long *)&buf[i]; 
                sprintf(txbuf,"%.8x",*p) ;
                WriteFile(DevHandle, txbuf, 8, &numwritten, 0) ;
        }
        free(buf) ; 

        printf("Waiting for done message from Davinci\n") ;
        if( ! WaitFor("   DONE\0", 5000) ) {
                printf("timed out\n") ;
                CloseCom() ;
                exit(1) ;
        }

        printf("Waiting for UBL message from Davinci\n") ;
        if( ! WaitFor("Rboot->", 5000) ) {
                printf("timed out\n") ;
                CloseCom() ;
                exit(1) ;
        }

        // load uboot to ram at 0x81080000, default textbase
        // see u-boot config
        // XXXX : hardwired
        file = fopen("u-boot_ram.bin","rb") ;
        if(!file) {
                printf("u-boot not found\n") ; 
                CloseCom() ;
                exit(1) ;
        }
        fseek(file, 0, SEEK_END) ;
        uboot_size = ftell(file)  ;
        printf("uboot size is %d bytes\n", uboot_size) ;
        fseek(file, 0, SEEK_SET) ;
        txbuf[0] = 'l' ;
        txbuf[1] = 0 ;
        txbuf[2] = 0 ;
        txbuf[3] = 0x08 ;
        txbuf[4] = 0x81 ;
        txbuf[5] = uboot_size & 0xff ;
        txbuf[6] = (uboot_size >> 8) & 0xff ;
        txbuf[7] = (uboot_size >> 16) & 0xff ;
        txbuf[8] = (uboot_size >> 24) & 0xff ;
        WriteFile(DevHandle, txbuf, 9, &numwritten, 0) ;
        for(i=0 ; i<uboot_size ; i+=1024)
        {
                printf("*") ; 
                numread = fread(txbuf, 1, 1024, file) ;
                WriteFile(DevHandle, txbuf, numread, &numwritten, 0) ;
        }
        fclose(file) ; 
        printf("\n") ; 

        if( ! WaitFor("Rboot->", 5000) ) {
                printf("timed out\n") ;
                CloseCom() ;
                exit(1) ;
        }

        // start uboot at 0x81080000
        txbuf[0] = 'g' ;
        txbuf[1] = 0 ;
        txbuf[2] = 0 ;
        txbuf[3] = 0x08 ;
        txbuf[4] = 0x81 ;
        WriteFile(DevHandle, txbuf, 5, &numwritten, 0) ;

        WaitFor("autoboot:", 5000) ; 
        WriteFile(DevHandle, "\r", 1, &numwritten, 0) ;
        
        CloseCom();   
}


_______________________________________________
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to