Partager via


Adding Support for Download Progress Indication

To add support for download progress indication, you need to implement the OEMShowProgress function. The OEMShowProgress function is called on a per-.bin record basis and is provided the record number that was just downloaded. You can implement this function to compute the number of bytes downloaded by tracking it in the OEMReadData routine. The computed value should not increment consistently because record sizes can differ. The OEMShowProgress function can then display the download progress to the user through some visual indication such as a LED display.

To implement the OEMShowProgress function

  1. Edit the file Main.c.

  2. Add the code necessary to fully implement the OEMShowProgress function.

    The following code example shows the implementation of the OEMShowProgress function for the hardware platform used in this boot loader example.

    void OEMShowProgress(DWORD dwPacketNum)
    {
        static BYTE PrevPercentComplete = -1;
        BYTE PercentComplete;
    
        // g_dwBytesRead and g_dwTotalBytes are global variables.
        // g_dwBytesRead is updated during a data packet read.
        // g_dwTotalBytes is determined from the size of the download image
        // (which is obtained from the .bin file header for example).
    
        PercentComplete = ((g_dwBytesRead * 100) / g_dwTotalBytes);
    
        // Update the display only when the percent complete changes.
        if (PercentComplete != PrevPercentComplete)
        {
            //
            // Write PercentComplete to board LEDs here.
            //
    
            PrevPercentComplete = PercentComplete;
        }
    
        return;
    }
    

See Also

How to Develop a Boot Loader

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.