This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cortex-M3 valid user code

This is quoted from datasheet:
"The reserved Cortex-M3 exception vector location 7 (offset 0x 001C in the vector table)
should contain the 2’s complement of the check-sum of table entries 0 through 6. This
causes the checksum of the first 8 table entries to be 0. The boot loader code checksums
the first 8 locations in sector 0 of the flash. If the result is 0, then execution control is
transferred to the user code."

how am I supposed to calculate the checksum of 7 entries, the following is the first 7 entries of my code:
68020010
69010000
71010000
73010000
75010000
77010000
79010000

E6F4FFEF (flash magic calculates this checksum!!!)

HOW????????????????????????????????????????????????

Parents
  • The math and description are simple enough,

    #include <stdio.h>
    
    int main(int argc, char **argv)
    {
            unsigned long vecs[]= {
                    0x10000268, 0x00000169, 0x00000171, 0x00000173,
                    0x00000175, 0x00000177, 0x00000179 };
      int i;
      unsigned long sum;
    
            sum = 0;
    
            for(i=0; i<7; i++)
                    sum += vecs[i];
    
            printf("%08X\n", -sum); // expect 0xEFFFF4E6
    
      return(1);
    }
    

Reply
  • The math and description are simple enough,

    #include <stdio.h>
    
    int main(int argc, char **argv)
    {
            unsigned long vecs[]= {
                    0x10000268, 0x00000169, 0x00000171, 0x00000173,
                    0x00000175, 0x00000177, 0x00000179 };
      int i;
      unsigned long sum;
    
            sum = 0;
    
            for(i=0; i<7; i++)
                    sum += vecs[i];
    
            printf("%08X\n", -sum); // expect 0xEFFFF4E6
    
      return(1);
    }
    

Children