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.

SFH Header data read

Other Parts Discussed in Thread: OMAPL138

Hi,

I am trying to write a UBL code for OMAPL138 custom board. For that i need SFH code to flash the application. 

while debugging the Sfh code i found that its reading some information about the app img like magic no, start address,byte count,load address ect... its getting through the UART.

the code for the same is below :


error = UART_recvHexData( hUartInfo, 4, (Uint32 *) &(ackHeader->magicNum) );

error |= UART_recvHexData( hUartInfo, 4, (Uint32 *) &(ackHeader->startAddr) );

error |= UART_recvHexData( hUartInfo, 4, (Uint32 *) &(ackHeader->byteCnt) );

error |= UART_recvHexData( hUartInfo, 4, (Uint32 *) &(ackHeader->loadAddr) );

error |= UART_recvHexData( hUartInfo, 4, (Uint32 *) &(ackHeader->flashAddr) );

from the forum i found that these info are added by the Sfh

http://e2e.ti.com/support/dsp/omap_applications_processors/f/42/t/72080.aspx

is it correct...?  If so when these info are added..?

or is it reading from the Bin file ...?.

 in the bin file of the Application i found the magic no which is located at the first position and the remaining data are unknown .

Thank you.

 

  • Hi Tinu,

    yes, you are right. The header is placed by the serial flasher only. It is not reading from the bin file.

    You can download the source of serial flasher utility and with reference to those number of header bytes, you can write the UBL code to read the same header in the same format from the flash memory. 

    Download link is http://processors.wiki.ti.com/index.php/Serial_Boot_and_Flash_Loading_Utility_for_OMAP-L138#Obtaining_the_software

     

    Regards,

    Shankari

     

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.
    --------------------------------------------------------------------------------------------------------

  • Hi Sankari ,

    Thanks for your replay . My understanding is while flashing, the flashing utility (here the SFH ) is responsible for making the Header. can you explain how it is creating the header . or how the SFH get the information like byte count, load address ect. since its a independent program from the application right..? for my requirement i need to write these header.

    Thank you.   

  • Hi Tinu,

    The structure of the header is given below.

    struct ImageHeader
      {
        public UInt32 magicNum;     
        public UInt32 startAddr;
        public UInt32 loadAddr;
        public UInt32 byteCnt;
     public UInt32 flashAddr;
      }  

    Please go through the source code of SFH in detail.

    In sfh.cs, TransmitUBLandAPP() function, it flashes the UBL and the app.

    private static Boolean TransmitUBLandAPP()
        {         
          Byte[] imageData;
          ImageHeader ackHeader = new ImageHeader();
    
          try
          {   
            // First send the UBL image that will be written to flash\
            Console.WriteLine("Sending the UBL image");
            imageData = FileIO.GetFileData(cmdParams.UBLFileName);
            ackHeader.magicNum = (UInt32)cmdParams.UBLMagicFlag;
            ackHeader.startAddr = cmdParams.UBLStartAddr;
            ackHeader.byteCnt = (UInt32) imageData.Length;
            ackHeader.loadAddr = 0x0020;    // Not used here, but this is what RBL assumes
            
            // Actually transmit the data
            if (!TransmitImage(imageData, ackHeader))
            {
              return false;
            }
            // ^^^DONE\0 that indicates that UBL flashing is complete
            if (!SerialIO.waitForSequence("   DONE\0", "BOOTUBL\0", MySP, true))
              return false;
            
            // Now Send the application image that will be written to flash
            Console.WriteLine("Sending the Application image");
            imageData = FileIO.GetFileData(cmdParams.APPFileName);
            ackHeader.magicNum = ((UInt32)MagicFlags.UBL_MAGIC_BINARY_BOOT);
            ackHeader.startAddr = cmdParams.APPStartAddr;
            ackHeader.byteCnt = (UInt32) imageData.Length;
            ackHeader.loadAddr = cmdParams.APPLoadAddr;
            
            if (!TransmitImage(imageData, ackHeader))
            {
              return false;
            }
            // ^^^DONE\0 that indicates that application flashing is complete
            if (!SerialIO.waitForSequence("   DONE\0", "BOOTUBL\0", MySP, true))
              return false;
              
            return true;
          }
          catch (ObjectDisposedException e)
          {
            Console.WriteLine(e.StackTrace);
            throw e;
          }
        }

    In sfh.cs, please refer TransmitAPP() function which flashes the application without UBL.
    For more information on "cmdParams", refer Bc.cs file of sfh Source code.

     

    Regards,

    Shankari

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.
    --------------------------------------------------------------------------------------------------------

  • Thank you Shankari for your help.