This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OMAPL L137 BOOTING OPTION FROM SLAVE

HiI am trying to Boot omapl-137 using slave configuration(spi0)

I am able to achieve START  WORD SYNC AND OP CODE SYNC  as mentioned in the booting document of bootloader of omapl137

I am using MCU as the master and DSP acts as slave .

I have attached my code for reference.

I have created a hex file out of binary file that is generated from AIS . I have attached that for reference.

I am trying to send each byte from the array mentioned below and appropriate format of 16 bit transferring through spi

void localb2uint(unsigned char *buf) ///unsigned char buf[]
{
   // unsigned  short int value1,value2,value3;
    unsigned  short int *value_pointer;
    static int counter =0;
    int i,k;
    int val;
    static int count;
           
    for(k=0 ; k<=8844 ;k+=2)  ////8646   8782
     {        
      value1=0x0000;
      value2=0x0000;
      value3=0x0000;
      counter++;
      value1=(int)*buf++;
      value2=(int)*buf++;
    //value_pointer = (short int *)&buf[k];
    //*value_pointer=((*value_pointer>>8) + (*value_pointer << 8));
      value3=( value1 + (value2 << 8) );
    

      switch(value3)
     {
         case DISABLE_CRC :
         send_char(' ');
         send_str("********************DISABLE_CRC********************");
         send_str("\n\r");
         send_char(' ');
         send_int(value1);
         send_char(' ');
         send_int(value2);
         send_char(' ');
         
         case SECT_LOAD:
         send_char(' ');
         send_str("********************SECT_LOAD********************");
         send_str("\n\r");
        
         ///opcode_sync();                                           //function call for opcode sync    
         ///send_receive_dummy_check(11,0x000A);                     //function call for dummy values write and read the same value
         send_char(' ');
         send_int(value1);
         //send_char(' ');
         //send_int(value2);
         //send_char(' ');
         break;
         
         case JUMP_CLOSE:
         send_char(' ');  
         send_str("*******************JUMP_CLOSE**********************");
         send_str("\n\r");
         send_char(' ');
         send_int(value1);
         send_char(' ');
         send_int(value2);
         send_char(' '); 
         send_char(' ');
         send_int(k);  
         opcode_sync();                                           //function call for opcode sync    
         send_receive_dummy_check(11,0x000A);                     //function call for dummy values write and read the same value
  
         break;
         
         case SEQ_READ:
         send_char(' ');
         send_str("********************SEQ_READ***********************");
         send_str("\n\r");
         send_char(' ');
         break;
         
         case FUNCTION_EXEC:
         send_char(' ');  
         send_str("********************FUNCTION_EXEC******************");
         send_str("\n\r");
         send_char(' ');
         send_int(value1);
         send_char(' ');
         send_int(value2);
         send_char(' ');
        //opcode_sync();                                           //function call for opcode sync    
        //send_receive_dummy_check(11,0x000A);                     //function call for dummy values write and read the same value
         
         break;
         case BOOT_TABLE :
         send_char(' ');
         send_str("********************BOOT_TABLE********************");
         send_str("\n\r");
         send_char(' ');
         send_int(value1);
         send_char(' ');
         send_int(value2);
         send_char(' ');
         //opcode_sync();                                           //function call for opcode sync    
         //send_receive_dummy_check(11,0x000A);                     //function call for dummy values write and read the same value
         break;
         case ENABLE_CRC :
         send_char(' ');
         send_str("********************ENABLE_CRC********************");
         send_str("\n\r");
         send_char(' ');
         break;
         case PING_DEVICE :
         send_char(' ');
         send_str("******************** PING_DEVICE********************");
         send_str("\n\r");
         send_char(' ');
         break;
        
    }
     
   
  
  sleep(50);
 /// sleep(5);
 
      sws_send_synchronisaton_spi2(value3);
      
      //sleep(1);
      //send_char(' ');
      //send_int(value1);
      //send_char(' ');
      //send_int(value2);
      //send_char(' '); 
      if(counter == 1000)
      {
         send_char(' ');
         send_str("****************BYTES WRITTEN***********************");
         send_str("\n\r");
         send_char(' ');
         send_int(k);
         send_char(' ');
         counter=0;
      }
     }    
   
     send_str("DONE"); 
     send_char(' ');
     send_int(k);
} 

and its called from the mcu application 

sws_sync(1); //function call for sws sync 
opcode_sync(); //function call for opcode sync 
send_receive_dummy_check(11,0x000A); //function call for dummy values write and read the same value

localb2uint(toggle_buffer);

Here I am able to get sws and opcode i i transfer all the content of hex file to DSP using SPI But iam not able to get the application running!

My hex file reference is as like

unsigned char toggle_buffer[8844]={0X54,0X49,0X50,0X41,0X63,0X59,0X53,0X58,0X0d,0X59,0X53,0X58,0X5,0X0,0X3,0X0
,0X2,0X2,0X1,0X16,0Xcb,0X1,0X5,0X0,0X3,0X0,0X0,0X0,0X7,0X59,0X53,0X58
,0X4,0X0,0X2,0X0,0X88,0X41,0Xc1,0X1,0X5,0X0,0X0,0X0,0X0,0X0,0X0,0X0
,0X0d,0X59,0X53,0X58,0X2,0X0,0X4,0X0,0X21,0Xc4,0X1,0X0,0Xc8,0X29,0X91,0X0e
,0X5,0X0,0X8,0X78,0X10,0X4,0X0,0X0,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0
,0X3,0X0,0X0,0X0,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0,0X3,0X0,0X1,0X0
,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0,0X3,0X0,0X2,0X0,0X0d,0X59,0X53,0X58
,0X6,0X0,0X1,0X0,0X3,0X0,0X3,0X0,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0
,0X3,0X0,0X4,0X0,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0,0X3,0X0,0X5,0X0
,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0,0X3,0X0,0X6,0X0,0X0d,0X59,0X53,0X58
,0X6,0X0,0X1,0X0,0X3,0X0,0X7,0X0,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0
,0X3,0X0,0X8,0X0,0X0d,0X59,0X53};

Have attached few elements for refernce where hex file has all the values relating to AIS commands
Kindly let me know what could to dodne to sync ,Kindly do not refer to the existing link. i have gone through the those stuff !








 

 

  • We are working on your post.
  • Hi

    Titu

    Thanks for your reply!

    Here is the complete solution for SPIslave0 Hope this will help implementation in c

    STEP1:

    Kindly make sure the boot configuration pins are set for SPI0-slave This can be validated by following steps:

    Once the changes is done w.r.t  the pins either you may have switches to change the configuration In my case we had to solder the corresponding resistors to make it work for spi0Slave it depends on hardware

    Once this is done connect your board to CCS and debug the code to check the BOOTCFG REGISTER This reflects the boot mode that you have selected CHECK THE Value 0X7000001 THAT IS THE BOOT ROM ADDRESS in the any of below register if present

    This is to validate that your hardware configuration is working fine and boot loader is proper

    STEP 2:

    IMPLEMENTATION OF SWS

    void sws_sync(unsigned short int value)
    {
       int i;
       for(i=0;i<value;i++)                                  //value represents the no of times the sws command to be transmitted--->0x5853
         {
          sleep(100);                                        ///5msec  MAKING IT AS SPI FALLING EDGE
          spi_2_send_init();                                 //Configuring the spi in Falling edge for transmitting data 
          sws_send_synchronisaton_spi2(0x5853);
          spi_2_recv_init();                                   //Configuring the spi in RISING for transmitting data 
          sleep(100);                                           ///5msec
          sws_value = sws_recv_synchronisaton_spi2(0x5853);   //Dummy read for getting the response  
          send_str("SWS:");
          send_char(' ');
          send_int(sws_value);
          send_char(' ');
          sleep(100);                                        ///5msec
         }  
          for(i=0;i<1;i++)     
         {
          sleep(100);
          spi_2_send_init();                                 //Configuring the Spi in falling edge for transmitting mandatory to do this after sws 
          sws_send_synchronisaton_spi2(0x5853);
         } 
    }

    This is important step where you have to send the data to boot loader as described in boot pdf .

    The logic is that while sending the data 0x5853 make sure the clock of spi is in falling edge  and while you receive the data by just writing the dummy data the spi clock should be in rising edge


    If the response from the Boot loader is 0X5253 Then you have to proceed to perform PING SYNC .If not kindly check and achieve SWS

    STEP 3:

    IMPLEMENTATION OF PING_DEVICE

    To data to be sent to boot loader  make sure the spi clock is in falling edge and send the command 0x590b and 5853 Note:while receiving in case  the data from PING DEVICE spi clock is in falling egde and do a dummy read to receive the ping opcode .Note:send the PING OPCODE ATLEAST TWICE  before performing the read and then read the data

    void opcode_sync()
    { 
      int k;
      sleep(100);             //5msec
      for(i=0;i<1;i++)
      {
          sleep(100);                                 //5msec
          spi_2_send_init();                        // Configuring the spi in Falling edge for transmitting data 
          for(j=0;j<2;j++)                          // Transmitting of pingopcode sync 0x590b and 0x5853   
          { 
          sws_send_synchronisaton_spi2(0x590b);
          sleep(10000);                                 //5msec
          sws_send_synchronisaton_spi2(0x5853);
          sleep(10000);                                   //5msec      
          }
          sws_value = sws_recv_synchronisaton_spi2(0xffff);         ///dummy read for receiving the data for opcode sync
          send_str("opcode:");
          send_char(' ');
          send_int(sws_value);
          send_char(' ');
          sleep(100);      
          sws_value = sws_recv_synchronisaton_spi2(0xffff);         ///dummy read for receiving the data for opcode sync         
          send_str("opcode:");
          send_char(' ');
          send_int(sws_value);
          send_char(' ');
          sleep(50);  
        } 
    }

    STEP 4

    IMPLEMENTATION OF DUMMY READ AND WRITE VALUES  AFTER PING DEVICE

    Send data as 0x000A This represents the no of bytes you are sending  and send the data and receive back Note:spi clock is in falling egde

    void send_receive_dummy_check(unsigned short int count ,unsigned short int data)
    {
         int k;
         data=0x000a;
         spi_2_send_init();
         for(i=0;i<count;i++)
         {
          sleep(100000);
          sws_send_synchronisaton_spi2(data);
          sleep(100000);
          sws_send_synchronisaton_spi2(0x0000);
          sleep(100);
          for(k=0;k<2;k++)
            {
              sws_value = sws_recv_synchronisaton_spi2(0xFFFF);
              send_str("SYNC:");
              send_char(' ');
              send_int(sws_value);
              send_char(' ');
              sleep(100);
              }
         
          if(i == 0)
          {
              data=0x0001;
          }
          else
          {
              data=data+0x0001;
          }
         }
    }

     

    Once you receive all the bytes that is transferred 

    Important step is to reset the spi in falling edge and do an Send 0x5853:It used to provide 00000 if i missed this set up

    STEP5:ONce you are able to achieve the final thing is to write your binary

     Make sure you have the proper binary tested .In my case my binary just toggles the leds 

    Try to open the bin file in HEX FILE and analyse the values present this consists of the opcodes like MAGIC CODE FUNC_EXEC SECT_LOAD

    EXAMPLE OF HEX BINARY IS

    unsigned char buffer_size[8836]={0X54,0X49,0X50,0X41,0X0d,0X59,0X53,0X58,0X0,0X0,0X2,0X0,0X2,0X2,0X1,0X9
    ,0Xb8,0X2,0X5,0X0,0X7,0X59,0X53,0X58,0X4,0X0,0X2,0X0,0X88,0X41,0Xc1,0X1
    ,0X5,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0d,0X59,0X53,0X58,0X2,0X0,0X4,0X0
    ,0X21,0Xc4,0X1,0X0,0Xc8,0X29,0X91,0X0e,0X5,0X0,0X8,0X78,0X10,0X4,0X0,0X0
    ,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0,0X3,0X0,0X0,0X0,0X0d,0X59,0X53,0X58
    ,0X6,0X0,0X1,0X0,0X3,0X0,0X1,0X0,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0
    ,0X3,0X0,0X2,0X0,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0,0X3,0X0,0X3,0X0
    ,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0,0X3,0X0,0X4,0X0,0X0d,0X59,0X53,0X58
    ,0X6,0X0,0X1,0X0,0X3,0X0,0X5,0X0,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0
    ,0X3,0X0,0X6,0X0,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0,0X3,0X0,0X7,0X0
    ,0X0d,0X59,0X53,0X58,0X6,0X0,0X1,0X0,0X3,0X0,0X8,0X0,0X0d,0X59,0X53,0X58

    Once this is done Try sending the hex values to the spi and spi clock is in falling edge.
    The trick lies here to initially test I have made bin file of 9 kb and converted to hex format and passing these hex value (i.eBinary) to the spi 

    I keep sending the Values to the spi ,but while i encounter a opcode i read back weather i get back the opcode if i get back the opcode back then i itereate over the next values of data Else make sure i get the sync of opcode (EX : If I send a opcode in hex file is 0X590D  0x5853  i receives the values 0X590B 0X5253 tHIS RESPONSE IS IMPORTANT IF YOU DONT GET THE OPCODE THAT YOU SEND IT STATES THAT ITS STILL IN PROCESSING AND DONT VER DUMP DATA BLINDLY

    MAKE SURE YOU SEND THE DATA AFTER SENDING THE OPCODE AND RECIEVING THE ACK AND THEN DUMP THE DATA

    IF THESE STEPS ARE DONE THE BOOTLAODER WILL EXECUTE THE LAST OPCODE JUMP AND CALL AND EXECUTES MY APPLICATION

     

    void localb2uint(unsigned char *buf) ///unsigned char buf[]
    {
       
        unsigned  short int *value_pointer;
        static int counter =0;
        int i,k;
        unsigned int  val;
        static int count;
        ///spi_2_send_init();       
        for(k=0 ; k<=8836 ;k+=4)  ////8646   8782 8844
         {        
          value1=0x0000;
          value2=0x0000;
          value3=0x0000;
          counter++;
          value1=(int)*buf++;
          value2=(int)*buf++;
          
          value3=( value1 + (value2 << 8));
          value4=(int)*buf++;
          value5=(int)*buf++;
          
          value6=( value4 + (value5 << 8));
          
          sleep(1000);
          
          switch(value3)
         {
             case  MAGIC_CODE : 
             send_char(' ');
             send_str("********************MAGIC_CODE********************");
             break;
             
             case DISABLE_CRC :
             send_char(' ');
             send_str("********************DISABLE_CRC********************");
             send_char(' ');          
             break;
             
             case SECT_LOAD:
             send_char(' ');
             send_str("********************SECT_LOAD********************");
             send_str("\n\r");        
             break;
             
             case JUMP_CLOSE:
             send_char(' ');  
             send_str("*******************JUMP_CLOSE**********************");
             send_str("\n\r");
             send_char(' ');
             send_int(value1);
             send_char(' ');
             send_int(value2);
             send_char(' '); 
             send_char(' ');
             send_int(k);  
             break;
             
             case SEQ_READ:
             send_char(' ');
             send_str("********************SEQ_READ***********************");
             send_str("\n\r");
             send_char(' ');
             break;
             
             case FUNCTION_EXEC:         
             send_char(' ');  
             send_str("********************FUNCTION_EXEC******************");
             send_str("\n\r");
             send_char(' ');
             send_int(value1);
             send_char(' ');
             send_int(value2);
             send_char(' ');        
             break;
             
             case BOOT_TABLE :
             send_char(' ');
             send_str("********************BOOT_TABLE********************");
             send_str("\n\r");
             send_char(' ');
             send_int(value1);
             send_char(' ');
             send_int(value2);
             send_char(' ');
             break;
             case ENABLE_CRC :
             send_char(' ');
             send_str("********************ENABLE_CRC********************");
             send_str("\n\r");
             send_char(' ');
             break;
             case PING_DEVICE :
             send_char(' ');
             send_str("******************** PING_DEVICE********************");
             send_str("\n\r");
             send_char(' ');
             break;
            
        }
         
          if(value3==  MAGIC_CODE || value3 == SECT_LOAD || value3 == SECT_LOAD||
             value3 == JUMP_CLOSE || value3 == SEQ_READ || value3 == FUNCTION_EXEC||  
             value3== BOOT_TABLE || value3 == ENABLE_CRC || value3 ==  PING_DEVICE )
          {
          sleep(1000);
          sr_sync_code(value3,value6,1);
          }
          else
          {
          sleep(1000);
          //sws_send_data(value3,value6);
          }
          
          if(counter == 1000)
          {
             send_char(' ');
             send_str("****************BYTES WRITTEN***********************");
             send_str("\n\r");
             send_char(' ');
             send_int(k);
             send_char(' ');
             counter=0;
          }
         }       
         send_str("DONE"); 
         send_char(' ');
         send_int(k);
         spi_2_recv_init();  
    } 

    int sr_sync_code(unsigned short int value1, unsigned short int value2,int flag)
    {
                    unsigned short int sws_value_one,sws_value_two;
    		int value = 0;
    		
    		//while(flag == 1)
    		//{
                    send_str("SYNC:");
                    send_int(value1);
    		send_char(' ');
                    send_int(value2);
    		send_char(' ');
         		sws_send_synchronisaton_spi2(value1);
    		sleep(10000);
    		sws_send_synchronisaton_spi2(value2);
    		sleep(10000);
    		sws_value_one = sws_recv_synchronisaton_spi2(0xFFFF);
    		sleep(100);
    		sws_value_two = sws_recv_synchronisaton_spi2(0xFFFF);
                    send_int(sws_value_one);
    		send_char(' ');		
    		send_int(sws_value_two);
    		send_char(' ');
    		/* 
    		if(sws_value_one == value1 && sws_value_two == 0x5253 )
    		{
    		flag=0;
    		send_int(sws_value_one);
    		send_char(' ');		
    		send_int(sws_value_two);
    		send_char(' ');
    		sleep(100);
    		}
                    }*/
                    return value;
    }
    int sws_send_data(unsigned short int value1, unsigned short int value2)
    {
            sws_send_synchronisaton_spi2(value1);
    	sleep(100);
    	sws_send_synchronisaton_spi2(value2);
            return 0;
    }
    
    int sws_send_synchronisaton_spi2(unsigned short cmd_data)
    {
      int val;
      static int count;
      int i;
      unsigned short data = 0; 
      SPI2PC3 &= 0xFFEF;                   // CS Pin is made LOW    
      SPI2DAT1 = cmd_data;                 // This is just a dummy read. No affect on this
      sleep(100);                           //5 msec
      SPI2PC3 |= 0x0010;                   // CS Pin is made HIGH*/
      return count;
    }
    
    int sws_recv_synchronisaton_spi2(unsigned short cmd_data)
    {
      int val;
      static int count;
      int i;     
      unsigned int data = 0;
      SPI2PC3 &= 0xFFEF;                   // CS Pin is made LOW  
      sleep(100);
      SPI2CTRL3_bit.RXINTFLAG |= 0x1; 
      SPI2DAT1 = cmd_data;                     // This is just a dummy read. No affect on this
      while(!(SPI2CTRL3_bit.RXINTFLAG & 0x1));
      data = SPI2BUF;
      sleep(100);
      SPI2PC3 |= 0x0010;                       // CS Pin is made HIGH  
      return data;
    }

    HOPE THIS REFERENCE HELPS TO IMPLEMENT SLAVE BOOTING!!!!!

    Thanks Titusrathinaraj for resonponding

     

  • Thank you so much for the post and update.