Cortex-M3 valid user code

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Cortex-M3 valid user code

1,387 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by reza_elc87 on Tue Jun 30 01:55:12 MST 2015
Dear all,
Hello!

I have developed a C# program that can send a .hex file to the flash memory of LPC1768 using ISP. But the program does not work well. I know the problem is that it cannot verify a valid user code, because the checksum at location 7 of the vector table is incorrect.
this is the first 8 entries of my vector table:

:10000000       68020010 69010000 71010000 73010000       26
:10001000       75010000 77010000 79010000 [color=#f06]00000000[/color]       78

I know instead of those red zeros I need to put the two's complement of the checksum. The only problrm is that I do not know how to calculate the checksum and its two's complement.
Flash magic calculates it and gives:
E6F4FFEF

BUT HOW???
标签 (1)
0 项奖励
回复
3 回复数

1,264 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Wed Jul 01 01:37:31 MST 2015
The 8 32-bit values should sum to 0.  To make that happen you need to put the negation of the sum of the other values at position 7.

Note that here twos complement just means negation.  In C there is the unary - operator for that.
0 项奖励
回复

1,264 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Tue Jun 30 04:03:14 MST 2015

Quote: reza_elc87
The only problrm is that I do not know how to calculate the checksum and its two's complement.



... then use a software to add the checksum  :O

http://www.lpcware.com/content/faq/lpcxpresso/image-checksums
0 项奖励
回复

1,264 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Tue Jun 30 03:48:01 MST 2015
unsigned long *ptr, cks, idx;

   cks = 0;                   // clear checksum
   for (idx =7; idx--; )   // addup 1st 7 32-bit word values (unsigned) ignore carry/overflow
      cks += *ptr++;      // ptr must be initialised to point to the first vector (beginning of image

  cks = (~cks)+1;       // calc twos complement (ones complement plus one)

  *ptr = cks;               // update the checksum in the eighth slot

// all hunky-dory now ... write image


I won't have anything to do with managed code (convert the "C" above if you must).
If you could not work that out for your self, you need to read programming books (No put down, simple truth)


Cheers, Mike
0 项奖励
回复