Method to add Code validation bytes in User executable output file

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Method to add Code validation bytes in User executable output file

1,708 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ramana on Sun Aug 31 22:12:29 MST 2014
Dear all,
   I have a requirement regarding code validations.
   I am using Keil uVision v4.7. Is there any method/exe to generate and place code validation bytes(CRC/Checksum or any)in output executable file(.axf or .hex). Validation bytes should be stored in some memory location of Flash,so that at power-on I'll calculate the checksum of entire flash and compare with the validation bytes in memory location.
   Presently I've written a DOS script to generate checksum of code in a hex files, and places validation byte into hexfile. But this method is not suitable when I download the code from debugger (since it uses axf file to download code).
   Can u provide any solution for my problem...
   Thank You in advance....
Labels (1)
0 Kudos
Reply
5 Replies

1,661 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by arw on Tue Oct 07 05:22:12 MST 2014
Hello Ramana,

Many NXP microcontrollers contain on-chip EEPROM.  You might also consider to use EEPROM to store the checksum (or even store an inversion of the checksum as safety copy).

-arw
0 Kudos
Reply

1,661 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ramana on Sun Sep 07 20:59:36 MST 2014
Dear Dude,
  Thank you so much for your kind suggestion. I think it is one of the simplest method. But if flash sector containing Code validation bytes is failed, there is a chance to read Validation bytes as 0xFF. Then application may recalculate the checksum will write the validation bytes to flash. This is not acceptable.
  I think better way is to add validation bytes before generating .axf/.hex file and downloading into flash.

Best Regards,
Ramana
0 Kudos
Reply

1,661 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheDude on Sun Sep 07 12:17:27 MST 2014
Dear Ramana,

I am sorry, I have misunderstood your problem. I think the best solution for you would be to delete the whole flash before programming via debugger. By this you can check within your debugging session, if the place, where you store the checksum is filled with 0xFF-Bytes. If this is the case, then you can calculate the checksum within the MCU and then store it with IAP in this flash-region. When you make a reset within the same debugging session, then you can check if your checksum algorithm is working properly.

Best Regards,
The Dude.
0 Kudos
Reply

1,661 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ramana on Fri Sep 05 21:32:28 MST 2014
Dear Dude,
  Thank u for your reply.
  My requirement is about Code validations in deployment, means no debugger is connected. There is a chance to corrupt flash contents. If user code proceeded further without validating flash contents there is a chance to misbehaviour of the system. It may cause severe problem in fail safe systems.
0 Kudos
Reply

1,661 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheDude on Thu Sep 04 04:00:33 MST 2014
Dear Ramana,

as far as I know the debugger already does a validation during the upload of the code.

Best Regards,
The Dude.

P.S. you can check if a debugger is attached:


if((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == CoreDebug_DHCSR_C_DEBUGEN_Msk) {
/* Debugger is attached*/
}
0 Kudos
Reply