diffexpand extract merge NSZ partition read remove shift shrink write Download
nshex - diff
The diff command creates a differential HEX image using two other images. The most common usage is to create a differential update file for your bootloader.
This command requires two images. The Reference image represent an image that may have been programmed on the device already. The Source image represents a new image, which you want to be programmed on the device.
nshex scans the Source image and compares it to the Reference image. Every part of the Source image which is present in the Reference image and has the same contents as the corresponding part in the Reference image gets removed. What remained of the Source image after all removals is stored as the Target image.
target = diff(reference,source,units)
|reference||The Reference image.|
|source||The Source image.|
|units||Optional. Comarison units. May be one of the following:
diff_update = diff(version_3,version_4,page)
This command compares the version_4 HEX image to version_3 HEX image and removes all the pages which are the same. diff_update will consists of all the pages which are present in the version_4 image, but are either missing in the version_3 HEX file, or the page from version_4 is different from the page contained in version_3.
# update.txt - create differential update
#read the reference version HEX file
old = read(%1.hex)
#read the new version HEX file
new = read(%2.hex)
new = extract(new,code)
#create and save the update
old = expand(old,page)
new = expand(new,page)
update = diff(old,new,page)
This example shows an entire nshex command file which can be used to prepare a differential (incremental) update for a bootloader. It first reads two hex images from the hex files. The names of the files will be supplied in the command line. It also uses the extract command to make sure that the file doesn't contain configuration bits or any other unwanted memory. This is done because the bootloader can only write code memory.
Then both files get expanded to whole pages. The bootloader will erase pages, and we want to make sure it doesn't erase something important. The expand is used for this purpose.
Finally, the diff command is used to produce the differential update and save it. The resulting HEX file makes the bootloader job really easy - the HEX file contains only whole pages and the pages are sorted.
This command file could be used like this:
nshex -s update.txt -d dsPIC33EP256MU814 fwv3 fwv4
This would read the fwv4.hex and fwv3.hex files, produce the differential update and save it as fwv3_to_fwv4.hex file.
© 2007-2023 Northern Software Inc. All Rights Reserved.