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.

[TMS470_414]how to calculate the checksum of a function from obj file or .out file

Guru 65750 points

Hello Champs

We have a very old codes which is using TMS470_414 tool chain. This codes is download via 3rd Part JTAG to internal SRAM. So The codes do verify the key function to make sure that it is good after downloading.

My question is: how can I know the value of the key function since we may need modify the key function for other usage. I know the data value of the function is either at obj or final .out file. But how to retrieve so that I can manually calculate the checksum.

Below is the pseudo codes

static void program_data_flash(void)

{

 Code section

}

#pragma FUNC_EXT_CALLED(program_data_flash_end);
static void program_data_flash_end(void){}

#pragma TASK (main)

void main(void)

{

// Check that the program_data_flash() is valid and run it if it is
    checksum = 0;
    src_ptr  = (Uint8*)&program_data_flash;

    while (src_ptr < (Uint8*)program_data_flash_end)
    {
        checksum += *src_ptr++;
    }

    if (checksum == PROGRAM_DATA_FLASH)

   {
        program_data_flash();
    }
    else
    {
        //*((Uint32*)0x19808) = checksum;
        failed();
    }

}

Regards

Yihe

  • My guess is that you have a customer that has a very old design and they want to do a code update. It looks like they had a custom tool (not from TI) that computed a checksum of the code and embedded it in the object file that was downloaded. I suggest that they should look again to see if they can find the original custom tools they used.

    If they fail, they will need to recreate that tool. They need to identify the form of object code used to download. (Something that old could be COFF, but it may be ELF.) I would suggest they convert the code to a readable format (Intel hex, Tektronics hex or Motorola S) using hex470. Then write a program to calculate the checksum. Finally, look at the link command file used to create the object code. It should suggest where to put the computed checksum value and then rebuild the .out file.

  • Hello

    Thank you for the reply. I may not describe it clearly, we have already converted the .out file to the intel hex file. But the problem is that how to get the beginning address of the program_data_flash() and program_data_flash_end() so that we can calculate the checksum of the function from the hex file.

    The .map file does not have the address for these functions since they are static. I assumed that they are under .bss section. 

    Regards

    Yihe

  • Try running ofd470.exe on the .out file and then search the output for those symbols. 

    TMS470 Object File Display v4.4.10.126
    Tools Copyright (c) 1996-2016 Texas Instruments Incorporated

    Usage: ofd470 [-options] filename

    Use 'ofd470 -h <option>' for more information on a particular option. Use
    'ofd470 -h <text>' to search options for information regarding <text>.

    Option arguments surrounded by [] declare they are optional. Option arguments
    separated by commas specify that the option's argument must be chosen from
    those arguments listed.

    General Options:
    --dwarf_display=attribute
    Display settings; use --dwarf_display=help for details
    --dynamic_info Output dynamic linking information
    -g Append DWARF information to file information.
    -h Display help
    -o=file Output object file information to <file>.
    --obj_display=attribute
    Display settings; use --obj_display=help for details
    -v Prints verbose text output.
    -x Output information in XML form.
    --xml_indent=# Number of spaces to indent nested XML tags

  • Did you check the map of the boot loader code or the map of the application being loaded? Those symbols will be in the bootloader. Does the key function that is being modified fit entirely in RAM before being programmed in flash? If it does, you may not need the RAM buffer start and end address. The simple checksum will not change when the data is padded with zeros. Just compute the checksum of the code to be loaded. As long as the code to be loaded is equal to or smaller than the size of the RAM buffer and the remaining RAM locations are zero, the checksum will be the same.

  • Hi

    Thank you. I obj dump the .out file. here are the details related to the key functions.

    The starting address of program_data_flash is 0x1983C

    The starting address of program_data_flash_end is 0x198B4.

    So the data between 0x1983C and 0x198b3 are the codes for the program_data_flash. 

    Am I right?

    <25> "$program_data_flash" :

    UNDEFINED EXTERNAL SYMBOL, Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x0.

    <26> "_program_data_flash" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x1983c.

    <27> "DW$L$_program_data_flash$2$B" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x19850.

    <28> "L3" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x19850.

    <29> "DW$L$_program_data_flash$2$E" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x19860.

    <30> "DW$L$_program_data_flash$4$B" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x19878.

    <31> "L4" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x19878.

    <32> "DW$L$_program_data_flash$5$B" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x19884.

    <33> "DW$L$_program_data_flash$4$E" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x19884.

    <34> "DW$L$_program_data_flash$6$B" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x19888.

    <35> "L5" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x19888.

    <36> "DW$L$_program_data_flash$5$E" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x19888.

    <37> "DW$L$_program_data_flash$7$B" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x19894.

    <38> "DW$L$_program_data_flash$6$E" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x19894.

    <39> "DW$L$_program_data_flash$8$B" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x198a0.

    <40> "DW$L$_program_data_flash$7$E" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x198a0.

    <41> "DW$L$_program_data_flash$9$B" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x198a4.

    <42> "L6" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x198a4.

    <43> "DW$L$_program_data_flash$8$E" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x198a4.

    <44> "DW$L$_program_data_flash$9$E" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x198b0.

    <45> "$program_data_flash_end" :
    UNDEFINED EXTERNAL SYMBOL, Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x0.

    <46> "_program_data_flash_end" :
    Defined in section ".text", Type = 0x4, Class = C_LABEL
    Has 0 aux entries, its value is 0x198b4.

    Regards

    Yihe

  • Yes, I think you are correct. That would be 120 bytes.