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.

comparing two binary image files

Hello,

My application uploads a binary image file and writes it to FLASH.

I am trying to devise a way of determining if the image file is one program or another program. Is there a way of storing a variable name in both programs and reading a memory location to check which program the image file represents? I thought about appending a value at the end of the file, similar to appending a CRC, but I thought there might be an easier solution.

-Chuck

  • Chuck,

    It depends on whether you want to compare the images on a PC or in the MCU itself. In the MCU, you could create a global constant or initialized variable and check its value in software. On a PC, you could do a byte for byte comparison with a reference file, or append a value, or compute an actual checksum (and probably more). Can you elaborate on the purpose for checking the image file?

    Thanks,

  • Adam,

    I am uploading an image file that can be one of two possible types of software. One type is an upgrade to the software doing the uploading, and the other type is the main application. I want to be able to tell the difference between the two image files and then take appropriate action within the application that is uploading the image.

    I figured out how to do this by appending a value to the file. I already do this with a CRC, but I thought there might be a better way, such as you suggested with a variable.

    Can you give me an example of how you would check an initialized variable that is stored inside the image file?

    Thank you,

    Chuck

  • Chuck,

    In your MCU software, you could set up your linker command file and variable declaration to put a variable at a certain memory address. The upload program then writes a value to that address. It's not that different from appending a value to the file, I guess, although it might make the software cleaner.

    Similarly, you could upload a function to a specific address and call it after the data transfer completes. The function could be something like:

    #define MAIN_APPLICATION_UPGRADE 1
    #define LOADER_UPGRADE 2

    uint16_t GetDataType()
    {
      return MAIN_APPLICATION_UPGRADE;
    }

    If you don't want to mess around with linker files, you can use pointers to do the same thing.

    Please let me know if you'd like further explanation for any of this.