Difference between revisions of "NXP LPC2xxx valid user code"

From SEGGER Wiki
Jump to: navigation, search
 
(12 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
= Calculation =
 
= Calculation =
   
The interrupt vector at 0x0000_0014 should contain the Two's complement of the sum of the interrupt vectors before.
+
The interrupt vector at 0x0000_0014 should contain the Two's complement of the sum of the other interrupt vectors.
   
== Example ==
+
== Example Calculation ==
  +
Example content of interrupt vectors:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
Line 23: Line 24:
 
|-
 
|-
 
| 0x0000_0010 || 0xEAFFFFFE
 
| 0x0000_0010 || 0xEAFFFFFE
  +
|-
  +
| 0x0000_0014 || 0x94000006
 
|-
 
|-
 
| 0x0000_0018 || 0xEAFFFFFE
 
| 0x0000_0018 || 0xEAFFFFFE
Line 29: Line 32:
 
|}
 
|}
   
Sum = 0x6BFFFFFA // sum of all interrupt vectors (with unsigned wrap)
+
Sum (32 bit unsigned integer) of all interrupt vectors (despite 0x0000_0014):
  +
  +
Sum = 0x6BFFFFFA
  +
  +
Checksum (32 bit unsigned integer) at 0x0000_0014 (two's complement of sum):
   
Checksum = ~(Sum) + 1 // checksum at 0x0000_0014 (two's complement of sum)
+
Checksum = ~(Sum) + 1 = 0x94000006
   
 
= Troubleshooting =
 
= Troubleshooting =
Line 40: Line 47:
 
[[File:jflash_error_checksum_missing.PNG]]
 
[[File:jflash_error_checksum_missing.PNG]]
   
If you do not want that the pop-up will show up, make sure that the checksum is correctly calculated in your data-file (see (1) Calculation).
+
If you do not want that the pop-up will show up, make sure that the checksum is correctly calculated in your data-file (see Calculation).

Latest revision as of 14:57, 9 September 2019

Some MCUs (e.g. LPC2xxx family) designed by NXP Semiconductors expect a checksum of the interrupt vectors to validate the user code. If the checksum matches the user code will be executed as expected, otherwise the code will not be executed.

Calculation

The interrupt vector at 0x0000_0014 should contain the Two's complement of the sum of the other interrupt vectors.

Example Calculation

Example content of interrupt vectors:

Address Value
0x0000_0000 0xEA000006
0x0000_0004 0xEAFFFFFE
0x0000_0008 0xEAFFFFFE
0x0000_000C 0xEAFFFFFE
0x0000_0010 0xEAFFFFFE
0x0000_0014 0x94000006
0x0000_0018 0xEAFFFFFE
0x0000_001C 0xEAFFFFFE

Sum (32 bit unsigned integer) of all interrupt vectors (despite 0x0000_0014):

Sum = 0x6BFFFFFA

Checksum (32 bit unsigned integer) at 0x0000_0014 (two's complement of sum):

Checksum = ~(Sum) + 1 = 0x94000006 

Troubleshooting

J-Flash will display a pop-up if the checksum is not valid and will offer to calculate the correct checksum for the user code:


jflash error checksum missing.PNG

If you do not want that the pop-up will show up, make sure that the checksum is correctly calculated in your data-file (see Calculation).