SW checksums and S-Records when uploading code to targets

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

SW checksums and S-Records when uploading code to targets

6,896 Views
AndersJ
Contributor IV
Hi,
 
Working with a bootloader I started thinking about checksumming an entire application, to ensure the full program is downloaded into the the target via the bootloader.
 
Question 1:
Is there a way to automatically generate, and/or add a checksum to the firmware so a check can be made that the S-Record file is intact before committing to erase and reprogram the target.
 
Follow up:
Every line of an S-Record has a checksum, which is fine.
But, how do you make sure ALL lines of the S-Record file are in the file?
It is an editable file, and a line may have been lost?
 
Thanks for any and all comments,
Anders J
 
 
Labels (1)
Tags (1)
0 Kudos
Reply
9 Replies

2,439 Views
sjmelnikoff
Contributor III

AndersJ wrote:
...
Is there a way to automatically generate, and/or add a checksum to the firmware so a check can be made that the S-Record file is intact before committing to erase and reprogram the target.
...
Every line of an S-Record has a checksum, which is fine.
But, how do you make sure ALL lines of the S-Record file are in the file?
It is an editable file, and a line may have been lost?

You could do it like this:
 
  1. Use the 'FILL' command in the linker file (for HCS12; may be different for ColdFire), to ensure that the S-Record file always contains the same amount of data, regardless of the size of your code.
  2. Write a utility to process the S-Record file. Because the whole (flash) memory space is always covered, you always know the order in which the S-Records will appear, which is of particular relevance if you're using an HCS12 with banked memory.
  3. Compute a checksum over the whole memory space, and insert it into the code.
  4. Given that the S-Record format is quite inefficient, you might want to convert to a simple binary format, perhaps with a header at the start, and a checksum at the end, perhaps with encryption as well, if desired.

Steve.

0 Kudos
Reply

2,439 Views
peg
Senior Contributor IV
Hmmm.....
 
You would have to loose EXACTLY a whole line, quite unlikely.
Checksum the checksums????
 
0 Kudos
Reply

2,439 Views
CrasyCat
Specialist III
Hello
This depends on the processor you are targeting and on the version of CodeWarrior you are using.
 
- Which CPU are you targeting (HC08, HC12, Coldfire, ..)
- Which version of CodeWarrior are you using?
  To retrieve that info:
    - Start CodeWarrior
    - Select Help -> About Freescale CodeWarrior
    - Click on "Install Products"
    - CodeWarrior version used is displayed on top in the Installed Products dialog.
 
CrasyCat
0 Kudos
Reply

2,439 Views
AndersJ
Contributor IV
Sorry, some people never learn, do they?
HCS12 and CW3.1
Anders
0 Kudos
Reply

2,439 Views
CrasyCat
Specialist III
Hello
 
CodeWarrior for HCS12 includes a checksum computation feature.
Check in "{}Install}\help\pdf\Manual_SmartLinker.pdf", chapter "Linking Issues" section "Checksum Computation".
 
There are also sample project using Checksum computation in directory
    {Install}\(CodeWarrior_Examples)\HC12\Checksums
 
Please note that if you have banked code in your application, you cannot compute checksum over page boundary. You need to evaluate checksum of each page separately.
 
I hope this helps.
 
CrasyCat
0 Kudos
Reply

2,439 Views
GonzaloVictorio
Contributor I
I've done MainApp checksumming with the products I've worked on. We created an application that calculates the checksums and inserts it into the "update" file. We also use that for joining the bootloader and mainapp applications.
 
I wouldn't mess doing checksums with S19 files... is a lot easier getting checksums and reprogram a product using raw binary files. Actually I don't generate S19 files after linking... but binaries.
0 Kudos
Reply

2,439 Views
AndersJ
Contributor IV
How do you generate binaries?
For a banked memory application?
 
Anders
 
0 Kudos
Reply

2,439 Views
CrasyCat
Specialist III
Hello
 
Just my 10 cents on that topic.
I would not recommend using binary files for HCS12 banked application.
 
A binary file does not include any address information. 
And keep in mind address space for HCS12 is not linear.
You cannot map that in a raw binary file.
 
CrasyCat
0 Kudos
Reply

2,439 Views
GonzaloVictorio
Contributor I
For generating binaries I basically modified the .bbl file of the project:
 
OPENFILE "%ABS_FILE%.bin"
format=binary
busWidth=1
origin=0x7c00
len=0x6600
undefByte=0xff
SENDBYTE 1 "%ABS_FILE%"
CLOSE
 
You can have more than one bbl file; for instance I have one for the Bootloader targets and one for the MainApp targets... your target will use the one that is selected as part of the target (using the Files tab).
 
I compile the code using the -Ms option and have quite a few segments defined in the .prm file for all the memory areas that I use for boot and mainapp.
 
Hope this helps!
 
btw: I use CW v5.1 for HC08
0 Kudos
Reply