SW checksums and S-Records when uploading code to targets

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

SW checksums and S-Records when uploading code to targets

5,913件の閲覧回数
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
 
 
ラベル(1)
タグ(1)
0 件の賞賛
9 返答(返信)

1,456件の閲覧回数
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 件の賞賛

1,456件の閲覧回数
peg
Senior Contributor IV
Hmmm.....
 
You would have to loose EXACTLY a whole line, quite unlikely.
Checksum the checksums????
 
0 件の賞賛

1,456件の閲覧回数
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 件の賞賛

1,456件の閲覧回数
AndersJ
Contributor IV
Sorry, some people never learn, do they?
HCS12 and CW3.1
Anders
0 件の賞賛

1,456件の閲覧回数
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 件の賞賛

1,456件の閲覧回数
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 件の賞賛

1,456件の閲覧回数
AndersJ
Contributor IV
How do you generate binaries?
For a banked memory application?
 
Anders
 
0 件の賞賛

1,456件の閲覧回数
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 件の賞賛

1,456件の閲覧回数
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 件の賞賛